diff options
author | Weston Andros Adamson <dros@netapp.com> | 2013-01-03 16:42:29 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-11 09:18:38 -0800 |
commit | 5865afd9e73a8981f38344ddcb42d9f2049c1469 (patch) | |
tree | 84355ebc044380c52ac5815a3a2fd656ff084295 /fs/nfs/dir.c | |
parent | e13ddf6bbcfe7ea1f83b9a7a9f698ef461cdff82 (diff) |
NFS: Fix access to suid/sgid executables
commit f8d9a897d4384b77f13781ea813156568f68b83e upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index a1aa28254be..c99f07ea416 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2148,12 +2148,16 @@ static int nfs_open_permission_mask(int openflags) { int mask = 0; - if ((openflags & O_ACCMODE) != O_WRONLY) - mask |= MAY_READ; - if ((openflags & O_ACCMODE) != O_RDONLY) - mask |= MAY_WRITE; - if (openflags & __FMODE_EXEC) - mask |= MAY_EXEC; + if (openflags & __FMODE_EXEC) { + /* ONLY check exec rights */ + mask = MAY_EXEC; + } else { + if ((openflags & O_ACCMODE) != O_WRONLY) + mask |= MAY_READ; + if ((openflags & O_ACCMODE) != O_RDONLY) + mask |= MAY_WRITE; + } + return mask; } |