1
0
Fork 0
alistair23-linux/fs/nfsd
Trond Myklebust 0300cda500 nfsd: Don't add locks to closed or closing open stateids
[ Upstream commit a451b12311 ]

In NFSv4, the lock stateids are tied to the lockowner, and the open stateid,
so that the action of closing the file also results in either an automatic
loss of the locks, or an error of the form NFS4ERR_LOCKS_HELD.

In practice this means we must not add new locks to the open stateid
after the close process has been invoked. In fact doing so, can result
in the following panic:

 kernel BUG at lib/list_debug.c:51!
 invalid opcode: 0000 [#1] SMP NOPTI
 CPU: 2 PID: 1085 Comm: nfsd Not tainted 5.6.0-rc3+ #2
 Hardware name: VMware, Inc. VMware7,1/440BX Desktop Reference Platform, BIOS VMW71.00V.14410784.B64.1908150010 08/15/2019
 RIP: 0010:__list_del_entry_valid.cold+0x31/0x55
 Code: 1a 3d 9b e8 74 10 c2 ff 0f 0b 48 c7 c7 f0 1a 3d 9b e8 66 10 c2 ff 0f 0b 48 89 f2 48 89 fe 48 c7 c7 b0 1a 3d 9b e8 52 10 c2 ff <0f> 0b 48 89 fe 4c 89 c2 48 c7 c7 78 1a 3d 9b e8 3e 10 c2 ff 0f 0b
 RSP: 0018:ffffb296c1d47d90 EFLAGS: 00010246
 RAX: 0000000000000054 RBX: ffff8ba032456ec8 RCX: 0000000000000000
 RDX: 0000000000000000 RSI: ffff8ba039e99cc8 RDI: ffff8ba039e99cc8
 RBP: ffff8ba032456e60 R08: 0000000000000781 R09: 0000000000000003
 R10: 0000000000000000 R11: 0000000000000001 R12: ffff8ba009a4abe0
 R13: ffff8ba032456e8c R14: 0000000000000000 R15: ffff8ba00adb01d8
 FS:  0000000000000000(0000) GS:ffff8ba039e80000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 00007fb213f0b008 CR3: 00000001347de006 CR4: 00000000003606e0
 Call Trace:
  release_lock_stateid+0x2b/0x80 [nfsd]
  nfsd4_free_stateid+0x1e9/0x210 [nfsd]
  nfsd4_proc_compound+0x414/0x700 [nfsd]
  ? nfs4svc_decode_compoundargs+0x407/0x4c0 [nfsd]
  nfsd_dispatch+0xc1/0x200 [nfsd]
  svc_process_common+0x476/0x6f0 [sunrpc]
  ? svc_sock_secure_port+0x12/0x30 [sunrpc]
  ? svc_recv+0x313/0x9c0 [sunrpc]
  ? nfsd_svc+0x2d0/0x2d0 [nfsd]
  svc_process+0xd4/0x110 [sunrpc]
  nfsd+0xe3/0x140 [nfsd]
  kthread+0xf9/0x130
  ? nfsd_destroy+0x50/0x50 [nfsd]
  ? kthread_park+0x90/0x90
  ret_from_fork+0x1f/0x40

The fix is to ensure that lock creation tests for whether or not the
open stateid is unhashed, and to fail if that is the case.

Fixes: 659aefb68e ("nfsd: Ensure we don't recognise lock stateids after freeing them")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-01 13:17:43 +02:00
..
Kconfig nfsd: depend on CRYPTO_MD5 for legacy client tracking 2020-01-26 10:01:01 +01:00
Makefile nfsd: add a new struct file caching facility to nfsd 2019-08-19 11:00:39 -04:00
acl.h nfsd: eliminate an unnecessary acl size limit 2019-08-28 21:13:45 -04:00
auth.c nfsd: auth: Fix gid sorting when rootsquash enabled 2018-01-22 20:13:07 -08:00
auth.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blocklayout.c nfsd: convert fi_deleg_file and ls_file fields to nfsd_file 2019-08-19 11:09:09 -04:00
blocklayoutxdr.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blocklayoutxdr.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cache.h nfsd4: make drc_slab global, not per-net 2020-06-24 17:50:37 +02:00
current_stateid.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
export.c nfsd: nfsd_file cache entries should be per net namespace 2019-09-10 09:23:41 -04:00
export.h knfsd: Allow lockless lookups of the exports 2018-10-29 16:58:04 -04:00
fault_inject.c nfsd: no need to check return value of debugfs_create functions 2019-07-03 16:57:17 +02:00
filecache.c nfsd: Fix a soft lockup race in nfsd_file_mark_find_or_create() 2020-10-01 13:17:28 +02:00
filecache.h nfsd: nfsd_file cache entries should be per net namespace 2019-09-10 09:23:41 -04:00
flexfilelayout.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
flexfilelayoutxdr.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
flexfilelayoutxdr.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
idmap.h nfsd: Remove duplicate define of IDMAP_NAMESZ/IDMAP_TYPE_xx 2015-07-20 14:58:46 -04:00
lockd.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
netns.h nfsd4: make drc_slab global, not per-net 2020-06-24 17:50:37 +02:00
nfs2acl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfs3acl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfs3proc.c nfsd: fix nfs read eof detection 2019-09-23 16:24:08 -04:00
nfs3xdr.c nfsd: Support the server resetting the boot verifier 2019-09-10 09:23:41 -04:00
nfs4acl.c nfsd: check permissions when setting ACLs 2016-06-24 12:11:52 -04:00
nfs4callback.c nfsd: Fix svc_xprt refcnt leak when setup callback client failed 2020-06-24 17:50:17 +02:00
nfs4idmap.c nfsd: Fix misuse of strlcpy 2019-07-08 23:16:11 -04:00
nfs4layouts.c nfsd: fix delay timer on 32-bit architectures 2020-02-11 04:35:46 -08:00
nfs4proc.c NFSD fixing possible null pointer derefering in copy offload 2020-01-17 19:49:02 +01:00
nfs4recover.c nfsd: Fix cld_net->cn_tfm initialization 2020-01-17 19:48:47 +01:00
nfs4state.c nfsd: Don't add locks to closed or closing open stateids 2020-10-01 13:17:43 +02:00
nfs4xdr.c nfsd: Fix NFSv4 READ on RDMA when using readv 2020-08-11 15:33:42 +02:00
nfscache.c nfsd: safer handling of corrupted c_type 2020-06-24 17:50:38 +02:00
nfsctl.c nfsd: fix nfsdfs inode reference count leak 2020-07-09 09:37:53 +02:00
nfsd.h nfsd4: fix nfsdfs reference count loop 2020-07-09 09:37:53 +02:00
nfsfh.c nfsd: use true and false for boolean values 2018-08-09 16:11:21 -04:00
nfsfh.h This request is late, apologies. 2018-02-08 15:18:32 -08:00
nfsproc.c nfsd: fix nfs read eof detection 2019-09-23 16:24:08 -04:00
nfssvc.c nfsd: restore NFSv3 ACL support 2019-12-13 08:42:52 +01:00
nfsxdr.c nfsd: knfsd must use the container user namespace 2019-04-24 09:46:35 -04:00
pnfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
state.h nfsd: fix jiffies/time_t mixup in LRU list 2020-02-11 04:35:47 -08:00
stats.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stats.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.c nfsd: move include of state.h from trace.c to trace.h 2015-10-23 15:57:29 -04:00
trace.h nfsd: Fix a perf warning 2020-10-01 13:17:31 +02:00
vfs.c nfsd: apply umask on fs without ACL support 2020-07-09 09:37:55 +02:00
vfs.h nfsd: Ensure CLONE persists data and metadata changes to the target file 2019-12-13 08:42:51 +01:00
xdr.h NFSD: Clean up legacy NFS SYMLINK argument XDR decoders 2018-04-03 15:08:16 -04:00
xdr3.h nfsd: fix nfs read eof detection 2019-09-23 16:24:08 -04:00
xdr4.h nfsd: hook up nfs4_preprocess_stateid_op to the nfsd_file cache 2019-08-19 11:09:09 -04:00
xdr4cb.h NFSD CB_OFFLOAD xdr 2018-09-25 20:34:54 -04:00