Skip to content

Commit bd86c69

Browse files
Tetsuo Handachucklever
authored andcommitted
NFSD: unregister shrinker when nfsd_init_net() fails
syzbot is reporting UAF read at register_shrinker_prepared() [1], for commit 7746b32 ("NFSD: add shrinker to reap courtesy clients on low memory condition") missed that nfsd4_leases_net_shutdown() from nfsd_exit_net() is called only when nfsd_init_net() succeeded. If nfsd_init_net() fails due to nfsd_reply_cache_init() failure, register_shrinker() from nfsd4_init_leases_net() has to be undone before nfsd_init_net() returns. Link: https://syzkaller.appspot.com/bug?extid=ff796f04613b4c84ad89 [1] Reported-by: syzbot <syzbot+ff796f04613b4c84ad89@syzkaller.appspotmail.com> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Fixes: 7746b32 ("NFSD: add shrinker to reap courtesy clients on low memory condition") Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 243a526 commit bd86c69

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/nfsd/nfsctl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,12 +1458,14 @@ static __net_init int nfsd_init_net(struct net *net)
14581458
goto out_drc_error;
14591459
retval = nfsd_reply_cache_init(nn);
14601460
if (retval)
1461-
goto out_drc_error;
1461+
goto out_cache_error;
14621462
get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key));
14631463
seqlock_init(&nn->writeverf_lock);
14641464

14651465
return 0;
14661466

1467+
out_cache_error:
1468+
nfsd4_leases_net_shutdown(nn);
14671469
out_drc_error:
14681470
nfsd_idmap_shutdown(net);
14691471
out_idmap_error:

0 commit comments

Comments
 (0)