diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/dir.c | 16 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 18 |
2 files changed, 21 insertions, 13 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 32e6c53520e2..1b2d7eb93796 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -2153,12 +2153,16 @@ static int nfs_open_permission_mask(int openflags) | |||
2153 | { | 2153 | { |
2154 | int mask = 0; | 2154 | int mask = 0; |
2155 | 2155 | ||
2156 | if ((openflags & O_ACCMODE) != O_WRONLY) | 2156 | if (openflags & __FMODE_EXEC) { |
2157 | mask |= MAY_READ; | 2157 | /* ONLY check exec rights */ |
2158 | if ((openflags & O_ACCMODE) != O_RDONLY) | 2158 | mask = MAY_EXEC; |
2159 | mask |= MAY_WRITE; | 2159 | } else { |
2160 | if (openflags & __FMODE_EXEC) | 2160 | if ((openflags & O_ACCMODE) != O_WRONLY) |
2161 | mask |= MAY_EXEC; | 2161 | mask |= MAY_READ; |
2162 | if ((openflags & O_ACCMODE) != O_RDONLY) | ||
2163 | mask |= MAY_WRITE; | ||
2164 | } | ||
2165 | |||
2162 | return mask; | 2166 | return mask; |
2163 | } | 2167 | } |
2164 | 2168 | ||
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 | ||
1627 | static int nfs4_opendata_access(struct rpc_cred *cred, | 1627 | static 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 | ||