linux/fs/nfsd
Jeff Layton dff1399f8a nfsd: close potential race between delegation break and laundromat
Bruce says:

    There's also a preexisting expire_client/laundromat vs break race:

    - expire_client/laundromat adds a delegation to its local
      reaplist using the same dl_recall_lru field that a delegation
      uses to track its position on the recall lru and drops the
      state lock.

    - a concurrent break_lease adds the delegation to the lru.

    - expire/client/laundromat then walks it reaplist and sees the
      lru head as just another delegation on the list....

Fix this race by checking the dl_time under the state_lock. If we find
that it's not 0, then we know that it has already been queued to the LRU
list and that we shouldn't queue it again.

In the case of destroy_client, we must also ensure that we don't hit
similar races by ensuring that we don't move any delegations to the
reaplist with a dl_time of 0. Just bump the dl_time by one before we
drop the state_lock. We're destroying the delegations anyway, so a 1s
difference there won't matter.

The fault injection code also requires a bit of surgery here:

First, in the case of nfsd_forget_client_delegations, we must prevent
the same sort of race vs. the delegation break callback. For that, we
just increment the dl_time to ensure that a delegation callback can't
race in while we're working on it.

We can't do that for nfsd_recall_client_delegations, as we need to have
it actually queue the delegation, and that won't happen if we increment
the dl_time. The state lock is held over that function, so we don't need
to worry about these sorts of races there.

There is one other potential bug nfsd_recall_client_delegations though.
Entries on the victims list are not dequeued before calling
nfsd_break_one_deleg. That's a potential list corruptor, so ensure that
we do that there.

Reported-by: "J. Bruce Fields" <bfields@fieldses.org>
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2014-07-10 13:40:51 -04:00
..
acl.h nfsd4: remove nfs4_acl_new 2014-07-08 17:14:27 -04:00
auth.c NFSD: Cleanup unused variable in nfsd_setuser() 2014-05-30 17:32:21 -04:00
auth.h nfsd: Remove nfsd_luid, nfsd_lgid, nfsd_ruid and nfsd_rgid 2013-02-13 06:15:51 -08:00
cache.h nfsd: get rid of unused function definition 2014-01-02 17:53:23 -05:00
current_stateid.h nfsd41: use current stateid by value 2012-02-15 11:20:45 -05:00
export.c NFSD: Using exp_get for export getting 2014-06-23 11:31:36 -04:00
export.h NFSD: Using exp_get for export getting 2014-06-23 11:31:36 -04:00
fault_inject.c nfsd: properly handle embedded newlines in fault_injection input 2014-06-23 11:31:38 -04:00
idmap.h nfsd4: use xdr_reserve_space in attribute encoding 2014-05-28 14:52:34 -04:00
Kconfig nfsd: fix Kconfig syntax 2013-10-26 15:37:26 -04:00
lockd.c nfsd: Remove deprecated nfsctl system call and related code. 2011-07-15 18:58:42 -04:00
Makefile NFSD: Added fault injection 2011-11-07 21:10:47 -05:00
netns.h nfsd: NFSv4 lock-owners are not associated to a specific file 2014-07-09 20:54:58 -04:00
nfs2acl.c nfsd: Remove assignments inside conditions 2014-05-22 15:52:23 -04:00
nfs3acl.c nfsd: Remove assignments inside conditions 2014-05-22 15:52:23 -04:00
nfs3proc.c NFSD: Remove iattr parameter from nfsd_symlink() 2014-07-08 17:14:31 -04:00
nfs3xdr.c NFSD: Using min/max/min_t/max_t for calculate 2014-06-23 11:31:36 -04:00
nfs4acl.c nfsd4: remove nfs4_acl_new 2014-07-08 17:14:27 -04:00
nfs4callback.c nfsd: set timeparms.to_maxval in setup_callback_client 2014-04-18 14:34:31 +02:00
nfs4idmap.c nfsd4: use xdr_reserve_space in attribute encoding 2014-05-28 14:52:34 -04:00
nfs4proc.c nfsd: Convert nfs4_check_open_reclaim() to work with lookup_clientid() 2014-07-09 20:55:07 -04:00
nfs4recover.c nfsd: switch to %p[dD] 2013-10-24 23:34:51 -04:00
nfs4state.c nfsd: close potential race between delegation break and laundromat 2014-07-10 13:40:51 -04:00
nfs4xdr.c NFSD: Fix memory leak in encoding denied lock 2014-07-09 20:55:08 -04:00
nfscache.c nfsd: clean up sparse endianness warnings in nfscache.c 2014-06-23 11:31:37 -04:00
nfsctl.c nfsd: add a new /proc/fs/nfsd/max_connections file 2014-07-08 17:14:32 -04:00
nfsd.h NFSD: Get rid of empty function nfs4_state_init 2014-05-08 14:59:52 -04:00
nfsfh.c nfsd: add appropriate __force directives to filehandle generation code 2014-06-23 11:31:37 -04:00
nfsfh.h nfsd: add appropriate __force directives to filehandle generation code 2014-06-23 11:31:37 -04:00
nfsproc.c nfsd: add a nfserrno mapping for -E2BIG to nfserr_fbig 2014-07-09 20:55:03 -04:00
nfssvc.c nfsd: add a new /proc/fs/nfsd/max_connections file 2014-07-08 17:14:32 -04:00
nfsxdr.c NFSD: Using min/max/min_t/max_t for calculate 2014-06-23 11:31:36 -04:00
state.h nfsd: Convert nfs4_check_open_reclaim() to work with lookup_clientid() 2014-07-09 20:55:07 -04:00
stats.c nfsd: move <linux/nfsd/stats.h> to fs/nfsd 2014-05-06 17:54:55 -04:00
stats.h nfsd: move <linux/nfsd/stats.h> to fs/nfsd 2014-05-06 17:54:55 -04:00
vfs.c nfsd: properly convert return from commit_metadata to __be32 2014-07-09 20:55:02 -04:00
vfs.h NFSD: Remove iattr parameter from nfsd_symlink() 2014-07-08 17:14:31 -04:00
xdr.h nfsd: handle vfs_getattr errors in acl protocol 2013-02-26 02:46:09 -05:00
xdr3.h nfsd: fix encode_entryplus_baggage stack usage 2014-01-23 13:50:27 -05:00
xdr4.h nfsd: Allow struct nfsd4_compound_state to cache the nfs4_client 2014-07-09 20:55:04 -04:00
xdr4cb.h nfsd4: check backchannel attributes on create_session 2013-04-09 16:53:56 -04:00