]> git.baikalelectronics.ru Git - kernel.git/commit
nfsd: fix incorrect umasks
authorJ. Bruce Fields <bfields@redhat.com>
Wed, 21 Mar 2018 21:19:02 +0000 (17:19 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 3 Apr 2018 20:27:08 +0000 (16:27 -0400)
commit4f294097c9a792dd408f37ead744b43fc608bca8
tree8beb5344209c3ae8ec1f00ebe0da66bc31e64f49
parentcf890862d5580692ea17bb34fc2033a9d4e816e3
nfsd: fix incorrect umasks

We're neglecting to clear the umask after it's set, which can cause a
later unrelated rpc to (incorrectly) use the same umask if it happens to
be processed by the same thread.

There's a more subtle problem here too:

An NFSv4 compound request is decoded all in one pass before any
operations are executed.

Currently we're setting current->fs->umask at the time we decode the
compound.  In theory a single compound could contain multiple creates
each setting a umask.  In that case we'd end up using whichever umask
was passed in the *last* operation as the umask for all the creates,
whether that was correct or not.

So, we should just be saving the umask at decode time and waiting to set
it until we actually process the corresponding operation.

In practice it's unlikely any client would do multiple creates in a
single compound.  And even if it did they'd likely be from the same
process (hence carry the same umask).  So this is a little academic, but
we should get it right anyway.

Fixes: 6e683c1514ee (nfsd: add support for the umask attribute)
Cc: stable@vger.kernel.org
Reported-by: Lucash Stach <l.stach@pengutronix.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4xdr.c
fs/nfsd/xdr4.h