linux/fs/nfsd
J. Bruce Fields 9a307403d3 nfsd4: fix null dereference on replay
if we receive a compound such that:

	- the sessionid, slot, and sequence number in the SEQUENCE op
	  match a cached succesful reply with N ops, and
	- the Nth operation of the compound is a PUTFH, PUTPUBFH,
	  PUTROOTFH, or RESTOREFH,

then nfsd4_sequence will return 0 and set cstate->status to
nfserr_replay_cache.  The current filehandle will not be set.  This will
cause us to call check_nfsd_access with first argument NULL.

To nfsd4_compound it looks like we just succesfully executed an
operation that set a filehandle, but the current filehandle is not set.

Fix this by moving the nfserr_replay_cache earlier.  There was never any
reason to have it after the encode_op label, since the only case where
he hit that is when opdesc->op_func sets it.

Note that there are two ways we could hit this case:

	- a client is resending a previously sent compound that ended
	  with one of the four PUTFH-like operations, or
	- a client is sending a *new* compound that (incorrectly) shares
	  sessionid, slot, and sequence number with a previously sent
	  compound, and the length of the previously sent compound
	  happens to match the position of a PUTFH-like operation in the
	  new compound.

The second is obviously incorrect client behavior.  The first is also
very strange--the only purpose of a PUTFH-like operation is to set the
current filehandle to be used by the following operation, so there's no
point in having it as the last in a compound.

So it's likely this requires a buggy or malicious client to reproduce.

Reported-by: Scott Mayhew <smayhew@redhat.com>
Cc: stable@kernel.vger.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2017-05-23 14:20:58 -04:00
..
acl.h
auth.c
auth.h
blocklayout.c scsi: introduce a result field in struct scsi_request 2017-04-20 12:16:10 -06:00
blocklayoutxdr.c
blocklayoutxdr.h
cache.h
current_stateid.h
export.c
export.h
fault_inject.c
flexfilelayout.c
flexfilelayoutxdr.c
flexfilelayoutxdr.h
idmap.h
Kconfig
lockd.c
Makefile
netns.h
nfs2acl.c
nfs3acl.c
nfs3proc.c
nfs3xdr.c nfsd: Revert "nfsd: check for oversized NFSv2/v3 arguments" 2017-05-16 16:16:30 -04:00
nfs4acl.c
nfs4callback.c
nfs4idmap.c
nfs4layouts.c
nfs4proc.c nfsd4: fix null dereference on replay 2017-05-23 14:20:58 -04:00
nfs4recover.c
nfs4state.c nfsd4: remove pointless strdup_if_nonnull 2017-04-25 17:25:54 -04:00
nfs4xdr.c nfsd: Fix up the "supattr_exclcreat" attributes 2017-05-10 14:30:10 -04:00
nfscache.c lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
nfsctl.c fs: constify tree_descr arrays passed to simple_fill_super() 2017-04-26 23:54:06 -04:00
nfsd.h
nfsfh.c
nfsfh.h
nfsproc.c nfsd: map the ENOKEY to nfserr_perm for avoiding warning 2017-03-10 16:54:55 -05:00
nfssvc.c nfsd: check for oversized NFSv2/v3 arguments 2017-04-25 16:34:37 -04:00
nfsxdr.c nfsd: Revert "nfsd: check for oversized NFSv2/v3 arguments" 2017-05-16 16:16:30 -04:00
pnfs.h
state.h
stats.c
stats.h
trace.c
trace.h
vfs.c Another RDMA update from Chuck Lever, and a bunch of miscellaneous 2017-05-10 13:29:23 -07:00
vfs.h statx: Add a system call to make enhanced file info available 2017-03-02 20:51:15 -05:00
xdr3.h
xdr4.h
xdr4cb.h
xdr.h