From: Trond Myklebust Date: Wed, 4 Apr 2012 17:51:33 +0000 (-0700) Subject: NFSv4: Don't use open stateids that have the wrong open mode X-Git-Tag: next-20120411~58^2~2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5ec0ed6cd88c65464092533787706d9ecfb85320;p=karo-tx-linux.git NFSv4: Don't use open stateids that have the wrong open mode If the client is doing an operation that needs a particular open mode, then nfs4_select_rw_stateid() should only copy the open stateid if the latter has the correct open mode. Otherwise we should just use the zero stateid. Reported-by: Miklos Szeredi Signed-off-by: Trond Myklebust --- diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 0f43414eb25a..71dcfd4e30f3 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -932,6 +932,13 @@ void nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state, { if (nfs4_copy_delegation_stateid(dst, state->inode, fmode)) return; + + fmode &= FMODE_READ|FMODE_WRITE; + if ((state->state & fmode) != fmode) { + nfs4_stateid_copy(dst, &zero_stateid); + return; + } + if (nfs4_copy_lock_stateid(dst, state, fl_owner, fl_pid)) return; nfs4_copy_open_stateid(dst, state);