Commit 02921914170e3b7fea1cd82dac9713685d2de5e2

Authored by J. Bruce Fields
1 parent 21fb4016bd

nfsd4: fix openmode checking on IO using lock stateid

It is legal to perform a write using the lock stateid that was
originally associated with a read lock, or with a file that was
originally opened for read, but has since been upgraded.

So, when checking the openmode, check the mode associated with the
open stateid from which the lock was derived.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

... ... @@ -2779,6 +2779,9 @@
2779 2779 {
2780 2780 __be32 status = nfserr_openmode;
2781 2781  
  2782 + /* For lock stateid's, we test the parent open, not the lock: */
  2783 + if (stp->st_openstp)
  2784 + stp = stp->st_openstp;
2782 2785 if ((flags & WR_STATE) && (!access_permit_write(stp->st_access_bmap)))
2783 2786 goto out;
2784 2787 if ((flags & RD_STATE) && (!access_permit_read(stp->st_access_bmap)))
... ... @@ -3466,7 +3469,6 @@
3466 3469 stp->st_stateid.si_fileid = fp->fi_id;
3467 3470 stp->st_stateid.si_generation = 0;
3468 3471 stp->st_vfs_file = open_stp->st_vfs_file; /* FIXME refcount?? */
3469   - stp->st_access_bmap = open_stp->st_access_bmap;
3470 3472 stp->st_deny_bmap = open_stp->st_deny_bmap;
3471 3473 stp->st_openstp = open_stp;
3472 3474