]> git.karo-electronics.de Git - karo-tx-linux.git/commit
svcrpc: fix double-free on shutdown of nfsd after changing pool mode
authorJ. Bruce Fields <bfields@redhat.com>
Fri, 23 Dec 2011 01:22:49 +0000 (18:22 -0700)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 Feb 2012 14:38:28 +0000 (15:38 +0100)
commitb57fdc838c5af0c587e36b03050ea4c98344b8ac
treea18d7271f9fa16e0c294096e90daf6ad2b788e79
parent2e9633af99b28c996ec0d1b53b7503a4dade6d8e
svcrpc: fix double-free on shutdown of nfsd after changing pool mode

commit 61c8504c428edcebf23b97775a129c5b393a302b upstream.

The pool_to and to_pool fields of the global svc_pool_map are freed on
shutdown, but are initialized in nfsd startup only in the
SVC_POOL_PERCPU and SVC_POOL_PERNODE cases.

They *are* initialized to zero on kernel startup.  So as long as you use
only SVC_POOL_GLOBAL (the default), this will never be a problem.

You're also OK if you only ever use SVC_POOL_PERCPU or SVC_POOL_PERNODE.

However, the following sequence events leads to a double-free:

1. set SVC_POOL_PERCPU or SVC_POOL_PERNODE
2. start nfsd: both fields are initialized.
3. shutdown nfsd: both fields are freed.
4. set SVC_POOL_GLOBAL
5. start nfsd: the fields are left untouched.
6. shutdown nfsd: now we try to free them again.

Step 4 is actually unnecessary, since (for some bizarre reason), nfsd
automatically resets the pool mode to SVC_POOL_GLOBAL on shutdown.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/sunrpc/svc.c