aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-12-16 06:27:40 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:47 -0500
commitb65a9cfc2c38eebc33533280b8ad5841caee8b6e (patch)
treed6e5b713615cc5e65c900162ab09235ae4847909 /fs/namei.c
parent0552f879d45cecc35d8e372a591fc5ed863bca58 (diff)
Untangling ima mess, part 2: deal with counters
* do ima_get_count() in __dentry_open() * stop doing that in followups * move ima_path_check() to right after nameidata_to_filp() * don't bump counters on it Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 0f0fcccab19f..c530e5d32f12 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1461,14 +1461,7 @@ int may_open(struct path *path, int acc_mode, int flag)
1461 /* 1461 /*
1462 * Ensure there are no outstanding leases on the file. 1462 * Ensure there are no outstanding leases on the file.
1463 */ 1463 */
1464 error = break_lease(inode, flag); 1464 return break_lease(inode, flag);
1465 if (error)
1466 return error;
1467
1468 return ima_path_check(path, acc_mode ?
1469 acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) :
1470 ACC_MODE(flag) & (MAY_READ | MAY_WRITE),
1471 IMA_COUNT_UPDATE);
1472} 1465}
1473 1466
1474static int handle_truncate(struct path *path) 1467static int handle_truncate(struct path *path)
@@ -1688,13 +1681,17 @@ do_last:
1688 goto exit; 1681 goto exit;
1689 } 1682 }
1690 filp = nameidata_to_filp(&nd, open_flag); 1683 filp = nameidata_to_filp(&nd, open_flag);
1691 if (IS_ERR(filp))
1692 ima_counts_put(&nd.path,
1693 acc_mode & (MAY_READ | MAY_WRITE |
1694 MAY_EXEC));
1695 mnt_drop_write(nd.path.mnt); 1684 mnt_drop_write(nd.path.mnt);
1696 if (nd.root.mnt) 1685 if (nd.root.mnt)
1697 path_put(&nd.root); 1686 path_put(&nd.root);
1687 if (!IS_ERR(filp)) {
1688 error = ima_path_check(&filp->f_path, filp->f_mode &
1689 (MAY_READ | MAY_WRITE | MAY_EXEC), 0);
1690 if (error) {
1691 fput(filp);
1692 filp = ERR_PTR(error);
1693 }
1694 }
1698 return filp; 1695 return filp;
1699 } 1696 }
1700 1697
@@ -1748,27 +1745,24 @@ ok:
1748 goto exit; 1745 goto exit;
1749 } 1746 }
1750 filp = nameidata_to_filp(&nd, open_flag); 1747 filp = nameidata_to_filp(&nd, open_flag);
1751 if (IS_ERR(filp)) { 1748 if (!IS_ERR(filp)) {
1752 ima_counts_put(&nd.path, 1749 error = ima_path_check(&filp->f_path, filp->f_mode &
1753 acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC)); 1750 (MAY_READ | MAY_WRITE | MAY_EXEC), 0);
1754 if (will_truncate)
1755 mnt_drop_write(nd.path.mnt);
1756 if (nd.root.mnt)
1757 path_put(&nd.root);
1758 return filp;
1759 }
1760
1761 if (acc_mode & MAY_WRITE)
1762 vfs_dq_init(nd.path.dentry->d_inode);
1763
1764 if (will_truncate) {
1765 error = handle_truncate(&nd.path);
1766 if (error) { 1751 if (error) {
1767 mnt_drop_write(nd.path.mnt);
1768 fput(filp); 1752 fput(filp);
1769 if (nd.root.mnt) 1753 filp = ERR_PTR(error);
1770 path_put(&nd.root); 1754 }
1771 return ERR_PTR(error); 1755 }
1756 if (!IS_ERR(filp)) {
1757 if (acc_mode & MAY_WRITE)
1758 vfs_dq_init(nd.path.dentry->d_inode);
1759
1760 if (will_truncate) {
1761 error = handle_truncate(&nd.path);
1762 if (error) {
1763 fput(filp);
1764 filp = ERR_PTR(error);
1765 }
1772 } 1766 }
1773 } 1767 }
1774 /* 1768 /*