OSDN Git Service

NFSD: fix seqid in copy stateid
authorOlga Kornievskaia <olga.kornievskaia@gmail.com>
Wed, 4 Dec 2019 20:13:53 +0000 (15:13 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 9 Dec 2019 16:44:07 +0000 (11:44 -0500)
commit3f9544ca62bc13cf1c145d1deae7bf3270730e0a
tree32e3462c44a1c777cfb3be50a71ec355016e7046
parent10db651210b2c618eb90a7fea4d6c5132bba7982
NFSD: fix seqid in copy stateid

s_stid->si_generation is a u32, copy->stateid.seqid is a __be32, so we
should be byte-swapping here if necessary.

This effectively undoes the byte-swap performed when reading
s_stid->s_generation in nfsd4_decode_copy().  Without this second swap,
the stateid we sent to the source in READ could be different from the
one the client provided us in the COPY.  We didn't spot this in testing
since our implementation always uses a 0 in the seqid field.  But other
implementations might not do that.

You'd think we should just skip the byte-swapping entirely, but the
s_stid field can be used for either our own stateids (in the
intra-server case) or foreign stateids (in the inter-server case), and
the former are interpreted by us and need byte-swapping.

Reported-by: kbuild test robot <lkp@intel.com>
Fixes: d5e54eeb0e3d ("NFSD add nfs4 inter ssc to nfsd4_copy")
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4proc.c