aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2019-04-12 16:37:30 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-16 12:20:52 -0400
commitbad60fa8b12d52b410f2339e58bd639555a9ff68 (patch)
treef999559bd3de0bac7816f82380ac1f204743cee5 /fs
parent9ed25c04cbf9af346ff7c88b87113a44ff65fba5 (diff)
downloadlinux-yocto-bad60fa8b12d52b410f2339e58bd639555a9ff68.tar.gz
linux-yocto-bad60fa8b12d52b410f2339e58bd639555a9ff68.tar.bz2
linux-yocto-bad60fa8b12d52b410f2339e58bd639555a9ff68.zip
nfsd: allow fh_want_write to be called twice
commit 0b8f62625dc309651d0efcb6a6247c933acd8b45 upstream. A fuzzer recently triggered lockdep warnings about potential sb_writers deadlocks caused by fh_want_write(). Looks like we aren't careful to pair each fh_want_write() with an fh_drop_write(). It's not normally a problem since fh_put() will call fh_drop_write() for us. And was OK for NFSv3 where we'd do one operation that might call fh_want_write(), and then put the filehandle. But an NFSv4 protocol fuzzer can do weird things like call unlink twice in a compound, and then we get into trouble. I'm a little worried about this approach of just leaving everything to fh_put(). But I think there are probably a lot of fh_want_write()/fh_drop_write() imbalances so for now I think we need it to be more forgiving. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/vfs.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index a7e107309f76..db351247892d 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -120,8 +120,11 @@ void nfsd_put_raparams(struct file *file, struct raparms *ra);
static inline int fh_want_write(struct svc_fh *fh)
{
- int ret = mnt_want_write(fh->fh_export->ex_path.mnt);
+ int ret;
+ if (fh->fh_want_write)
+ return 0;
+ ret = mnt_want_write(fh->fh_export->ex_path.mnt);
if (!ret)
fh->fh_want_write = true;
return ret;