FROMLIST: exec: Restore EACCES of S_ISDIR execve()
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.
Link: https://lore.kernel.org/lkml/20200813151305.6191993b@why
Link: https://lore.kernel.org/r/20200813231723.2725102-2-keescook@chromium.org
Fixes: 633fb6ac39 ("exec: move S_ISREG() check earlier")
Reported-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Idb68cdfc90be5928691ac68dda8c98726af20c9e
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
af494fd94b
commit
901e02c2ec
+3
-1
@@ -2933,8 +2933,10 @@ static int may_open(const struct path *path, int acc_mode, int flag)
|
||||
case S_IFLNK:
|
||||
return -ELOOP;
|
||||
case S_IFDIR:
|
||||
if (acc_mode & (MAY_WRITE | MAY_EXEC))
|
||||
if (acc_mode & MAY_WRITE)
|
||||
return -EISDIR;
|
||||
if (acc_mode & MAY_EXEC)
|
||||
return -EACCES;
|
||||
break;
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
|
||||
Reference in New Issue
Block a user