]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFSv4: Don't use open stateids that have the wrong open mode
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 4 Apr 2012 17:51:33 +0000 (10:51 -0700)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 5 Apr 2012 16:46:59 +0000 (09:46 -0700)
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 <miklos@szeredi.hu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/nfs4state.c

index 0f43414eb25a141be336c34bef78cc126cd9039f..71dcfd4e30f3888832a36eb7eaa41b29b5175436 100644 (file)
@@ -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);