mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 00:04:15 +08:00
NFSv4: Fix problems with close in the presence of a delegation
In the presence of delegations, we can no longer assume that the
state->n_rdwr, state->n_rdonly, state->n_wronly reflect the open
stateid share mode, and so we need to calculate the initial value
for calldata->arg.fmode using the state->flags.
Reported-by: James Drews <drews@engr.wisc.edu>
Fixes: 88069f77e1
(NFSv41: Fix a potential state leakage when...)
Cc: stable@vger.kernel.org # 2.6.33+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
parent
52addcf9d6
commit
aee7af356e
@ -2601,6 +2601,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
|
|||||||
struct nfs4_closedata *calldata = data;
|
struct nfs4_closedata *calldata = data;
|
||||||
struct nfs4_state *state = calldata->state;
|
struct nfs4_state *state = calldata->state;
|
||||||
struct inode *inode = calldata->inode;
|
struct inode *inode = calldata->inode;
|
||||||
|
bool is_rdonly, is_wronly, is_rdwr;
|
||||||
int call_close = 0;
|
int call_close = 0;
|
||||||
|
|
||||||
dprintk("%s: begin!\n", __func__);
|
dprintk("%s: begin!\n", __func__);
|
||||||
@ -2608,18 +2609,24 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
|
|||||||
goto out_wait;
|
goto out_wait;
|
||||||
|
|
||||||
task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
|
task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
|
||||||
calldata->arg.fmode = FMODE_READ|FMODE_WRITE;
|
|
||||||
spin_lock(&state->owner->so_lock);
|
spin_lock(&state->owner->so_lock);
|
||||||
|
is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
|
||||||
|
is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
|
||||||
|
is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
|
||||||
|
/* Calculate the current open share mode */
|
||||||
|
calldata->arg.fmode = 0;
|
||||||
|
if (is_rdonly || is_rdwr)
|
||||||
|
calldata->arg.fmode |= FMODE_READ;
|
||||||
|
if (is_wronly || is_rdwr)
|
||||||
|
calldata->arg.fmode |= FMODE_WRITE;
|
||||||
/* Calculate the change in open mode */
|
/* Calculate the change in open mode */
|
||||||
if (state->n_rdwr == 0) {
|
if (state->n_rdwr == 0) {
|
||||||
if (state->n_rdonly == 0) {
|
if (state->n_rdonly == 0) {
|
||||||
call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags);
|
call_close |= is_rdonly || is_rdwr;
|
||||||
call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
|
|
||||||
calldata->arg.fmode &= ~FMODE_READ;
|
calldata->arg.fmode &= ~FMODE_READ;
|
||||||
}
|
}
|
||||||
if (state->n_wronly == 0) {
|
if (state->n_wronly == 0) {
|
||||||
call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags);
|
call_close |= is_wronly || is_rdwr;
|
||||||
call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
|
|
||||||
calldata->arg.fmode &= ~FMODE_WRITE;
|
calldata->arg.fmode &= ~FMODE_WRITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user