Skip to content

Commit fc4177b

Browse files
keestorvalds
authored andcommitted
exec: restore EACCES of S_ISDIR execve()
Patch series "Fix S_ISDIR execve() errno". Fix an errno change for execve() of directories, noticed by Marc Zyngier. Along with the fix, include a regression test to avoid seeing this return in the future. This patch (of 2): The return code for attempting to execute a directory has always been EACCES. Adjust the S_ISDIR exec test to reflect the old errno instead of the general EISDIR for other kinds of "open" attempts on directories. Fixes: 633fb6a ("exec: move S_ISREG() check earlier") Reported-by: Marc Zyngier <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Link: https://lore.kernel.org/lkml/20200813151305.6191993b@why Signed-off-by: Linus Torvalds <[email protected]>
1 parent b1a3e75 commit fc4177b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/namei.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2849,8 +2849,10 @@ static int may_open(const struct path *path, int acc_mode, int flag)
28492849
case S_IFLNK:
28502850
return -ELOOP;
28512851
case S_IFDIR:
2852-
if (acc_mode & (MAY_WRITE | MAY_EXEC))
2852+
if (acc_mode & MAY_WRITE)
28532853
return -EISDIR;
2854+
if (acc_mode & MAY_EXEC)
2855+
return -EACCES;
28542856
break;
28552857
case S_IFBLK:
28562858
case S_IFCHR:

0 commit comments

Comments
 (0)