Commit bd86c69d authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Chuck Lever

NFSD: unregister shrinker when nfsd_init_net() fails

syzbot is reporting UAF read at register_shrinker_prepared() [1], for
commit 7746b32f ("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: default avatarsyzbot <syzbot+ff796f04613b4c84ad89@syzkaller.appspotmail.com>
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: 7746b32f ("NFSD: add shrinker to reap courtesy clients on low memory condition")
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 243a5263
...@@ -1458,12 +1458,14 @@ static __net_init int nfsd_init_net(struct net *net) ...@@ -1458,12 +1458,14 @@ static __net_init int nfsd_init_net(struct net *net)
goto out_drc_error; goto out_drc_error;
retval = nfsd_reply_cache_init(nn); retval = nfsd_reply_cache_init(nn);
if (retval) if (retval)
goto out_drc_error; goto out_cache_error;
get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key)); get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key));
seqlock_init(&nn->writeverf_lock); seqlock_init(&nn->writeverf_lock);
return 0; return 0;
out_cache_error:
nfsd4_leases_net_shutdown(nn);
out_drc_error: out_drc_error:
nfsd_idmap_shutdown(net); nfsd_idmap_shutdown(net);
out_idmap_error: out_idmap_error:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment