mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
132 lines
4.8 KiB
Diff
132 lines
4.8 KiB
Diff
From: Tony Jones <tonyj@suse.de>
|
|
Subject: Pass struct vfsmount to the inode_unlink LSM hook
|
|
|
|
This is needed for computing pathnames in the AppArmor LSM.
|
|
|
|
Signed-off-by: Tony Jones <tonyj@suse.de>
|
|
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
|
|
Signed-off-by: John Johansen <jjohansen@suse.de>
|
|
|
|
---
|
|
fs/namei.c | 2 +-
|
|
include/linux/security.h | 10 +++++++---
|
|
security/capability.c | 3 ++-
|
|
security/security.c | 5 +++--
|
|
security/selinux/hooks.c | 5 +++--
|
|
security/smack/smack_lsm.c | 4 +++-
|
|
6 files changed, 19 insertions(+), 10 deletions(-)
|
|
|
|
--- a/fs/namei.c
|
|
+++ b/fs/namei.c
|
|
@@ -2233,7 +2233,7 @@ int vfs_unlink(struct inode *dir, struct
|
|
if (d_mountpoint(dentry))
|
|
error = -EBUSY;
|
|
else {
|
|
- error = security_inode_unlink(dir, dentry);
|
|
+ error = security_inode_unlink(dir, dentry, mnt);
|
|
if (!error)
|
|
error = dir->i_op->unlink(dir, dentry);
|
|
}
|
|
--- a/include/linux/security.h
|
|
+++ b/include/linux/security.h
|
|
@@ -352,6 +352,7 @@ static inline void security_free_mnt_opt
|
|
* Check the permission to remove a hard link to a file.
|
|
* @dir contains the inode structure of parent directory of the file.
|
|
* @dentry contains the dentry structure for file to be unlinked.
|
|
+ * @mnt is the vfsmount corresponding to @dentry (may be NULL).
|
|
* Return 0 if permission is granted.
|
|
* @inode_symlink:
|
|
* Check the permission to create a symbolic link to a file.
|
|
@@ -1368,7 +1369,8 @@ struct security_operations {
|
|
int (*inode_link) (struct dentry *old_dentry, struct vfsmount *old_mnt,
|
|
struct inode *dir, struct dentry *new_dentry,
|
|
struct vfsmount *new_mnt);
|
|
- int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
|
|
+ int (*inode_unlink) (struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt);
|
|
int (*inode_symlink) (struct inode *dir, struct dentry *dentry,
|
|
struct vfsmount *mnt, const char *old_name);
|
|
int (*inode_mkdir) (struct inode *dir, struct dentry *dentry,
|
|
@@ -1640,7 +1642,8 @@ int security_inode_create(struct inode *
|
|
int security_inode_link(struct dentry *old_dentry, struct vfsmount *old_mnt,
|
|
struct inode *dir, struct dentry *new_dentry,
|
|
struct vfsmount *new_mnt);
|
|
-int security_inode_unlink(struct inode *dir, struct dentry *dentry);
|
|
+int security_inode_unlink(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt);
|
|
int security_inode_symlink(struct inode *dir, struct dentry *dentry,
|
|
struct vfsmount *mnt, const char *old_name);
|
|
int security_inode_mkdir(struct inode *dir, struct dentry *dentry,
|
|
@@ -2003,7 +2006,8 @@ static inline int security_inode_link(st
|
|
}
|
|
|
|
static inline int security_inode_unlink(struct inode *dir,
|
|
- struct dentry *dentry)
|
|
+ struct dentry *dentry,
|
|
+ struct vfsmount *mnt)
|
|
{
|
|
return 0;
|
|
}
|
|
--- a/security/capability.c
|
|
+++ b/security/capability.c
|
|
@@ -167,7 +167,8 @@ static int cap_inode_link(struct dentry
|
|
return 0;
|
|
}
|
|
|
|
-static int cap_inode_unlink(struct inode *inode, struct dentry *dentry)
|
|
+static int cap_inode_unlink(struct inode *inode, struct dentry *dentry,
|
|
+ struct vfsmount *mnt)
|
|
{
|
|
return 0;
|
|
}
|
|
--- a/security/security.c
|
|
+++ b/security/security.c
|
|
@@ -376,11 +376,12 @@ int security_inode_link(struct dentry *o
|
|
new_dentry, new_mnt);
|
|
}
|
|
|
|
-int security_inode_unlink(struct inode *dir, struct dentry *dentry)
|
|
+int security_inode_unlink(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt)
|
|
{
|
|
if (unlikely(IS_PRIVATE(dentry->d_inode)))
|
|
return 0;
|
|
- return security_ops->inode_unlink(dir, dentry);
|
|
+ return security_ops->inode_unlink(dir, dentry, mnt);
|
|
}
|
|
|
|
int security_inode_symlink(struct inode *dir, struct dentry *dentry,
|
|
--- a/security/selinux/hooks.c
|
|
+++ b/security/selinux/hooks.c
|
|
@@ -2587,11 +2587,12 @@ static int selinux_inode_link(struct den
|
|
return may_link(dir, old_dentry, MAY_LINK);
|
|
}
|
|
|
|
-static int selinux_inode_unlink(struct inode *dir, struct dentry *dentry)
|
|
+static int selinux_inode_unlink(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt)
|
|
{
|
|
int rc;
|
|
|
|
- rc = secondary_ops->inode_unlink(dir, dentry);
|
|
+ rc = secondary_ops->inode_unlink(dir, dentry, mnt);
|
|
if (rc)
|
|
return rc;
|
|
return may_link(dir, dentry, MAY_UNLINK);
|
|
--- a/security/smack/smack_lsm.c
|
|
+++ b/security/smack/smack_lsm.c
|
|
@@ -454,11 +454,13 @@ static int smack_inode_link(struct dentr
|
|
* smack_inode_unlink - Smack check on inode deletion
|
|
* @dir: containing directory object
|
|
* @dentry: file to unlink
|
|
+ * @mnt: vfsmount of file to unlink
|
|
*
|
|
* Returns 0 if current can write the containing directory
|
|
* and the object, error code otherwise
|
|
*/
|
|
-static int smack_inode_unlink(struct inode *dir, struct dentry *dentry)
|
|
+static int smack_inode_unlink(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt)
|
|
{
|
|
struct inode *ip = dentry->d_inode;
|
|
int rc;
|