Commit 9650f565 authored by Trond Myklebust's avatar Trond Myklebust Committed by Ben Hutchings

NFS: Fix another OPEN_DOWNGRADE bug

commit e547f262 upstream.

Olga Kornievskaia reports that the following test fails to trigger
an OPEN_DOWNGRADE on the wire, and only triggers the final CLOSE.

	fd0 = open(foo, RDRW)   -- should be open on the wire for "both"
	fd1 = open(foo, RDONLY)  -- should be open on the wire for "read"
	close(fd0) -- should trigger an open_downgrade
	read(fd1)
	close(fd1)

The issue is that we're missing a check for whether or not the current
state transitioned from an O_RDWR state as opposed to having transitioned
from a combination of O_RDONLY and O_WRONLY.
Reported-by: default avatarOlga Kornievskaia <aglo@umich.edu>
Fixes: cd9288ff ("NFSv4: Fix another bug in the close/open_downgrade code")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 766b5ed1
...@@ -2620,12 +2620,11 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) ...@@ -2620,12 +2620,11 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
call_close |= is_wronly; call_close |= is_wronly;
else if (is_wronly) else if (is_wronly)
calldata->arg.fmode |= FMODE_WRITE; calldata->arg.fmode |= FMODE_WRITE;
if (calldata->arg.fmode != (FMODE_READ|FMODE_WRITE))
call_close |= is_rdwr;
} else if (is_rdwr) } else if (is_rdwr)
calldata->arg.fmode |= FMODE_READ|FMODE_WRITE; calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;
if (calldata->arg.fmode == 0)
call_close |= is_rdwr;
if (!nfs4_valid_open_stateid(state)) if (!nfs4_valid_open_stateid(state))
call_close = 0; call_close = 0;
spin_unlock(&state->owner->so_lock); spin_unlock(&state->owner->so_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment