Skip to contentSkip to conversation

uselib: add missing MNT_NOEXEC check

PATCH In review Christoph Hellwig 2 participants 3 messages May 17, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uselib: add missing MNT_NOEXEC check

We don't allow loading ELF shared library from noexec points so the same should apply to sys_uselib aswell.

fs/exec.c +2 -0
Index: linux-2.6/fs/exec.c
===================================================================
@@ -133,6 +133,8 @@ asmlinkage long sys_uselib(const char __
 		goto out;
 
 	error = -EINVAL;
+	if (nd.mnt->mnt_flags & MNT_NOEXEC)
+		goto exit;
 	if (!S_ISREG(nd.dentry->d_inode->i_mode))
 		goto exit;
 
#1 lore raw
Quoted 2 lines · Christoph Hellwig

We don't allow loading ELF shared library from noexec points so the same should apply to sys_uselib aswell.

Correct. But...

fs/exec.c asmlinkage long sys_uselib(const char __ · line 137

Quoted 3 lines
        error = -EINVAL;
fs/exec.c +2 -0
+       if (nd.mnt->mnt_flags & MNT_NOEXEC)
+               goto exit;

... the error here should be EACCES. Aside from that you get an ACK from me.

#2 lore raw
Quoted 6 lines · Ulrich Drepper

Review

Quoted 3 lines
       error = -EINVAL;
(quoted diff) +2 -0
+       if (nd.mnt->mnt_flags & MNT_NOEXEC)
+               goto exit;

... the error here should be EACCES. Aside from that you get an ACK from me.

updated patch below:

fs/exec.c +3 -0
Index: linux-2.6/fs/exec.c
===================================================================
@@ -134,6 +134,9 @@ asmlinkage long sys_uselib(const char __
 	if (error)
 		goto out;
 
+	error = -EACCES;
+	if (nd.mnt->mnt_flags & MNT_NOEXEC)
+		goto exit;
 	error = -EINVAL;
 	if (!S_ISREG(nd.dentry->d_inode->i_mode))
 		goto exit;