apparmor/kernel-patches/2.6.25/sys_fchdir-nameidata.diff
2008-04-19 17:49:10 +00:00

40 lines
1,015 B
Diff

From: Andreas Gruenbacher <agruen@suse.de>
Subject: Switch to vfs_permission() in sys_fchdir()
Switch from file_permission() to vfs_permission() in sys_fchdir(): this
avoids calling permission() with a NULL nameidata here.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: John Johansen <jjohansen@suse.de>
---
fs/open.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--- a/fs/open.c
+++ b/fs/open.c
@@ -500,8 +500,8 @@ out:
asmlinkage long sys_fchdir(unsigned int fd)
{
+ struct nameidata nd = { .flags = 0 };
struct file *file;
- struct inode *inode;
int error;
error = -EBADF;
@@ -509,12 +509,11 @@ asmlinkage long sys_fchdir(unsigned int
if (!file)
goto out;
- inode = file->f_path.dentry->d_inode;
-
error = -ENOTDIR;
- if (!S_ISDIR(inode->i_mode))
+ if (!S_ISDIR(file->f_path.dentry->d_inode->i_mode))
goto out_putf;
+ nd.path = file->f_path;
error = file_permission(file, MAY_EXEC);
if (!error)
set_fs_pwd(current->fs, &file->f_path);