Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1489500
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.4 015/118] nfsd: Close race between nfsd4_release_lockowner and nfsd4_lock |
| Date | 2016-09-22 21:40 +0200 |
| Message-ID | <ski0G-226-7@gated-at.bofh.it> (permalink) |
| References | <skg8x-Rq-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <chuck.lever@oracle.com>
commit 885848186fbc2d1d8fb6d2fdc2156638ae289a46 upstream.
nfsd4_release_lockowner finds a lock owner that has no lock state,
and drops cl_lock. Then release_lockowner picks up cl_lock and
unhashes the lock owner.
During the window where cl_lock is dropped, I don't see anything
preventing a concurrent nfsd4_lock from finding that same lock owner
and adding lock state to it.
Move release_lockowner() into nfsd4_release_lockowner and hang onto
the cl_lock until after the lock owner's state cannot be found
again.
Found by inspection, we don't currently have a reproducer.
Fixes: 2c41beb0e5cf ("nfsd: reduce cl_lock thrashing in ... ")
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/nfsd/nfs4state.c | 40 +++++++++++++++++-----------------------
1 file changed, 17 insertions(+), 23 deletions(-)
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1200,27 +1200,6 @@ free_ol_stateid_reaplist(struct list_hea
}
}
-static void release_lockowner(struct nfs4_lockowner *lo)
-{
- struct nfs4_client *clp = lo->lo_owner.so_client;
- struct nfs4_ol_stateid *stp;
- struct list_head reaplist;
-
- INIT_LIST_HEAD(&reaplist);
-
- spin_lock(&clp->cl_lock);
- unhash_lockowner_locked(lo);
- while (!list_empty(&lo->lo_owner.so_stateids)) {
- stp = list_first_entry(&lo->lo_owner.so_stateids,
- struct nfs4_ol_stateid, st_perstateowner);
- WARN_ON(!unhash_lock_stateid(stp));
- put_ol_stateid_locked(stp, &reaplist);
- }
- spin_unlock(&clp->cl_lock);
- free_ol_stateid_reaplist(&reaplist);
- nfs4_put_stateowner(&lo->lo_owner);
-}
-
static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp,
struct list_head *reaplist)
{
@@ -5952,6 +5931,7 @@ nfsd4_release_lockowner(struct svc_rqst
__be32 status;
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
struct nfs4_client *clp;
+ LIST_HEAD (reaplist);
dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n",
clid->cl_boot, clid->cl_id);
@@ -5982,9 +5962,23 @@ nfsd4_release_lockowner(struct svc_rqst
nfs4_get_stateowner(sop);
break;
}
+ if (!lo) {
+ spin_unlock(&clp->cl_lock);
+ return status;
+ }
+
+ unhash_lockowner_locked(lo);
+ while (!list_empty(&lo->lo_owner.so_stateids)) {
+ stp = list_first_entry(&lo->lo_owner.so_stateids,
+ struct nfs4_ol_stateid,
+ st_perstateowner);
+ WARN_ON(!unhash_lock_stateid(stp));
+ put_ol_stateid_locked(stp, &reaplist);
+ }
spin_unlock(&clp->cl_lock);
- if (lo)
- release_lockowner(lo);
+ free_ol_stateid_reaplist(&reaplist);
+ nfs4_put_stateowner(&lo->lo_owner);
+
return status;
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 055/118] ARM: dts: overo: fix gpmc nand cs0 range Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 025/118] x86/AMD: Apply erratum 665 on machines without a BIOS fix Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 060/118] bus: arm-ccn: Fix XP watchpoint settings bitmask Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 029/118] iio: adc: rockchip_saradc: reset saradc controller before programming it Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 034/118] iio: accel: bmc150: reset chip at init time Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 062/118] dm log writes: move IO accounting earlier to fix error path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 022/118] IB/uverbs: Fix race between uverbs_close and remove_one Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 048/118] cpuset: make sure new tasks conform to the current config of the cpuset Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 021/118] dm flakey: fix reads to be issued if drop_writes configured Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 027/118] iio: accel: kxsd9: Fix raw read return Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 037/118] iio:core: fix IIO_VAL_FRACTIONAL sign handling Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 003/118] clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 056/118] ARM: dts: overo: fix gpmc nand on boards with ethernet Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 066/118] arm64: spinlocks: implement smp_mb__before_spinlock() as smp_mb() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 059/118] bus: arm-ccn: Do not attempt to configure XPs for cycle counter Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 030/118] iio: adc: ti_am335x_adc: Protect FIFO1 from concurrent access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 026/118] kvm-arm: Unmap shadow pagetables properly Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 053/118] ARM: OMAP3: hwmod data: Add sysc information for DSI Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 008/118] tipc: move linearization of buffers to generic code Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 031/118] iio: adc: ti_am335x_adc: Increase timeout value waiting for ADC sample Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:30 +0200
[PATCH 4.4 028/118] iio: proximity: as3935: set up buffer timestamps for non-zero values Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:40 +0200
[PATCH 4.4 012/118] kernfs: dont depend on d_find_any_alias() when generating notifications Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:40 +0200
[PATCH 4.4 015/118] nfsd: Close race between nfsd4_release_lockowner and nfsd4_lock Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-22 21:40 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Holger Hoffstätte <holger@applied-asynchrony.com> - 2016-09-22 22:00 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:20 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Holger Hoffstätte <holger@applied-asynchrony.com> - 2016-09-23 10:50 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 11:30 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Guenter Roeck <linux@roeck-us.net> - 2016-09-23 01:50 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Guenter Roeck <linux@roeck-us.net> - 2016-09-23 05:10 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:10 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:10 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:20 +0200
Re: [PATCH 4.4 000/118] 4.4.22-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 10:20 +0200
csiph-web