apparmor/kernel-patches/for-mainline/sys_fchdir-nameidata.diff

41 lines
1,015 B
Diff
Raw Normal View History

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
2007-04-26 17:09:09 +00:00
avoids calling permission() with a NULL nameidata here.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
2007-06-26 22:14:37 +00:00
Signed-off-by: John Johansen <jjohansen@suse.de>
---
2008-07-02 20:24:33 +00:00
fs/open.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--- a/fs/open.c
+++ b/fs/open.c
2008-07-02 20:24:33 +00:00
@@ -512,8 +512,8 @@ out:
asmlinkage long sys_fchdir(unsigned int fd)
{
2008-07-02 20:24:33 +00:00
+ struct nameidata nd = { .flags = 0 };
struct file *file;
- struct inode *inode;
int error;
error = -EBADF;
2008-07-02 20:24:33 +00:00
@@ -521,12 +521,11 @@ asmlinkage long sys_fchdir(unsigned int
if (!file)
goto out;
2008-07-02 20:24:33 +00:00
- inode = file->f_path.dentry->d_inode;
-
error = -ENOTDIR;
- if (!S_ISDIR(inode->i_mode))
2008-07-02 20:24:33 +00:00
+ if (!S_ISDIR(file->f_path.dentry->d_inode->i_mode))
goto out_putf;
2008-07-02 20:24:33 +00:00
+ nd.path = file->f_path;
error = file_permission(file, MAY_EXEC);
if (!error)
2008-07-02 20:24:33 +00:00
set_fs_pwd(current->fs, &file->f_path);