Skip to content

Commit 3eab830

Browse files
committed
uselib: remove use of __FMODE_EXEC
Jann Horn points out that uselib() really shouldn't trigger the new FMODE_EXEC logic introduced by commit 4759ff7 ("exec: __FMODE_EXEC instead of in_execve for LSMs"). In fact, it shouldn't even have ever triggered the old pre-existing logic for __FMODE_EXEC (like the NFS code that makes executables not need read permissions). Unlike a real execve(), that can work even with files that are purely executable by the user (not readable), uselib() has that MAY_READ requirement becasue it's really just a convenience wrapper around mmap() for legacy shared libraries. The whole FMODE_EXEC bit was originally introduced by commit b500531 ("[PATCH] Introduce FMODE_EXEC file flag"), primarily to give ETXTBUSY error returns for distributed filesystems. It has since grown a few other warts (like that NFS thing), but there really isn't any reason to use it for uselib(), and now that we are trying to use it to replace the horrid 'tsk->in_execve' flag, it's actively wrong. Of course, as Jann Horn also points out, nobody should be enabling CONFIG_USELIB in the first place in this day and age, but that's a different discussion entirely. Reported-by: Jann Horn <[email protected]> Fixes: 4759ff7 ("exec: __FMODE_EXEC instead of in_execve for LSMs") Cc: Kees Cook <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 443b349 commit 3eab830

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
128128
struct filename *tmp = getname(library);
129129
int error = PTR_ERR(tmp);
130130
static const struct open_flags uselib_flags = {
131-
.open_flag = O_LARGEFILE | O_RDONLY | __FMODE_EXEC,
131+
.open_flag = O_LARGEFILE | O_RDONLY,
132132
.acc_mode = MAY_READ | MAY_EXEC,
133133
.intent = LOOKUP_OPEN,
134134
.lookup_flags = LOOKUP_FOLLOW,

0 commit comments

Comments
 (0)