aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@netapp.com>2013-01-03 16:42:29 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-01-03 17:06:27 -0500
commitf8d9a897d4384b77f13781ea813156568f68b83e (patch)
treec34e5e5b5da7a6c46d1d12b7408ef5312a55e8ca /fs/nfs/nfs4proc.c
parentd1c3ed669a2d452cacfb48c2d171a1f364dae2ed (diff)
NFS: Fix access to suid/sgid executables
nfs_open_permission_mask() should only check MAY_EXEC for files that are opened with __FMODE_EXEC. Also fix NFSv4 access-in-open path in a similar way -- openflags must be used because fmode will not always have FMODE_EXEC set. This patch fixes https://bugzilla.kernel.org/show_bug.cgi?id=49101 Signed-off-by: Weston Andros Adamson <dros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 5d864fb36578..cf747ef86650 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1626,7 +1626,8 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
1626 1626
1627static int nfs4_opendata_access(struct rpc_cred *cred, 1627static int nfs4_opendata_access(struct rpc_cred *cred,
1628 struct nfs4_opendata *opendata, 1628 struct nfs4_opendata *opendata,
1629 struct nfs4_state *state, fmode_t fmode) 1629 struct nfs4_state *state, fmode_t fmode,
1630 int openflags)
1630{ 1631{
1631 struct nfs_access_entry cache; 1632 struct nfs_access_entry cache;
1632 u32 mask; 1633 u32 mask;
@@ -1638,11 +1639,14 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
1638 1639
1639 mask = 0; 1640 mask = 0;
1640 /* don't check MAY_WRITE - a newly created file may not have 1641 /* don't check MAY_WRITE - a newly created file may not have
1641 * write mode bits, but POSIX allows the creating process to write */ 1642 * write mode bits, but POSIX allows the creating process to write.
1642 if (fmode & FMODE_READ) 1643 * use openflags to check for exec, because fmode won't
1643 mask |= MAY_READ; 1644 * always have FMODE_EXEC set when file open for exec. */
1644 if (fmode & FMODE_EXEC) 1645 if (openflags & __FMODE_EXEC) {
1645 mask |= MAY_EXEC; 1646 /* ONLY check for exec rights */
1647 mask = MAY_EXEC;
1648 } else if (fmode & FMODE_READ)
1649 mask = MAY_READ;
1646 1650
1647 cache.cred = cred; 1651 cache.cred = cred;
1648 cache.jiffies = jiffies; 1652 cache.jiffies = jiffies;
@@ -1896,7 +1900,7 @@ static int _nfs4_do_open(struct inode *dir,
1896 if (server->caps & NFS_CAP_POSIX_LOCK) 1900 if (server->caps & NFS_CAP_POSIX_LOCK)
1897 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); 1901 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
1898 1902
1899 status = nfs4_opendata_access(cred, opendata, state, fmode); 1903 status = nfs4_opendata_access(cred, opendata, state, fmode, flags);
1900 if (status != 0) 1904 if (status != 0)
1901 goto err_opendata_put; 1905 goto err_opendata_put;
1902 1906