aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-12-19 10:10:39 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-22 12:27:34 -0500
commit482928d59db668b8d82a48717f78986d8cea72e9 (patch)
tree6985c64474172ddfb67c737bc4a49e588c49d055 /fs/namei.c
parent628ff7c1d8d8466a5ad8078bd0206a130f8b8a51 (diff)
Fix f_flags/f_mode in case of lookup_instantiate_filp() from open(pathname, 3)
Just set f_flags when shoving struct file into nameidata; don't postpone that until __dentry_open(). do_filp_open() has correct value; lookup_instantiate_filp() doesn't - we lose the difference between O_RDWR and 3 by that point. We still set .intent.open.flags, so no fs code needs to be changed. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c
index dad4b80257db..d517f73aa36b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1640,6 +1640,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
1640 if (filp == NULL) 1640 if (filp == NULL)
1641 return ERR_PTR(-ENFILE); 1641 return ERR_PTR(-ENFILE);
1642 nd.intent.open.file = filp; 1642 nd.intent.open.file = filp;
1643 filp->f_flags = open_flag;
1643 nd.intent.open.flags = flag; 1644 nd.intent.open.flags = flag;
1644 nd.intent.open.create_mode = 0; 1645 nd.intent.open.create_mode = 0;
1645 error = do_path_lookup(dfd, pathname, 1646 error = do_path_lookup(dfd, pathname,
@@ -1685,6 +1686,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
1685 if (filp == NULL) 1686 if (filp == NULL)
1686 goto exit_parent; 1687 goto exit_parent;
1687 nd.intent.open.file = filp; 1688 nd.intent.open.file = filp;
1689 filp->f_flags = open_flag;
1688 nd.intent.open.flags = flag; 1690 nd.intent.open.flags = flag;
1689 nd.intent.open.create_mode = mode; 1691 nd.intent.open.create_mode = mode;
1690 dir = nd.path.dentry; 1692 dir = nd.path.dentry;
@@ -1725,7 +1727,7 @@ do_last:
1725 mnt_drop_write(nd.path.mnt); 1727 mnt_drop_write(nd.path.mnt);
1726 goto exit; 1728 goto exit;
1727 } 1729 }
1728 filp = nameidata_to_filp(&nd, open_flag); 1730 filp = nameidata_to_filp(&nd);
1729 mnt_drop_write(nd.path.mnt); 1731 mnt_drop_write(nd.path.mnt);
1730 if (nd.root.mnt) 1732 if (nd.root.mnt)
1731 path_put(&nd.root); 1733 path_put(&nd.root);
@@ -1789,7 +1791,7 @@ ok:
1789 mnt_drop_write(nd.path.mnt); 1791 mnt_drop_write(nd.path.mnt);
1790 goto exit; 1792 goto exit;
1791 } 1793 }
1792 filp = nameidata_to_filp(&nd, open_flag); 1794 filp = nameidata_to_filp(&nd);
1793 if (!IS_ERR(filp)) { 1795 if (!IS_ERR(filp)) {
1794 error = ima_path_check(&filp->f_path, filp->f_mode & 1796 error = ima_path_check(&filp->f_path, filp->f_mode &
1795 (MAY_READ | MAY_WRITE | MAY_EXEC)); 1797 (MAY_READ | MAY_WRITE | MAY_EXEC));