mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-06 01:05:11 +00:00
123 lines
4.7 KiB
Diff
123 lines
4.7 KiB
Diff
![]() |
Pass struct vfsmount to the inode_rename LSM hook
|
||
|
|
||
|
Signed-off-by: Tony Jones <tonyj@suse.de>
|
||
|
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
|
||
|
|
||
|
Index: linux-2.6.19/fs/namei.c
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/fs/namei.c
|
||
|
+++ linux-2.6.19/fs/namei.c
|
||
|
@@ -2402,7 +2402,8 @@ static int vfs_rename_dir(struct inode *
|
||
|
return error;
|
||
|
}
|
||
|
|
||
|
- error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry);
|
||
|
+ error = security_inode_rename(old_dir, old_mnt, old_dentry, new_dir,
|
||
|
+ new_mnt, new_dentry);
|
||
|
if (error)
|
||
|
return error;
|
||
|
|
||
|
@@ -2436,7 +2437,8 @@ static int vfs_rename_other(struct inode
|
||
|
struct inode *target;
|
||
|
int error;
|
||
|
|
||
|
- error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry);
|
||
|
+ error = security_inode_rename(old_dir, old_mnt, old_dentry, new_dir,
|
||
|
+ new_mnt, new_dentry);
|
||
|
if (error)
|
||
|
return error;
|
||
|
|
||
|
Index: linux-2.6.19/include/linux/security.h
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/include/linux/security.h
|
||
|
+++ linux-2.6.19/include/linux/security.h
|
||
|
@@ -335,8 +335,10 @@ struct request_sock;
|
||
|
* @inode_rename:
|
||
|
* Check for permission to rename a file or directory.
|
||
|
* @old_dir contains the inode structure for parent of the old link.
|
||
|
+ * @old_mnt is the vfsmount where @old_dentry was looked up (may be NULL)
|
||
|
* @old_dentry contains the dentry structure of the old link.
|
||
|
* @new_dir contains the inode structure for parent of the new link.
|
||
|
+ * @new_mnt is the vfsmount for @new_dentry (may be NULL)
|
||
|
* @new_dentry contains the dentry structure of the new link.
|
||
|
* Return 0 if permission is granted.
|
||
|
* @inode_readlink:
|
||
|
@@ -1237,8 +1239,10 @@ struct security_operations {
|
||
|
struct dentry *dentry);
|
||
|
int (*inode_mknod) (struct inode *dir, struct vfsmount *mnt,
|
||
|
struct dentry *dentry, int mode, dev_t dev);
|
||
|
- int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
|
||
|
- struct inode *new_dir, struct dentry *new_dentry);
|
||
|
+ int (*inode_rename) (struct inode *old_dir, struct vfsmount *old_mnt,
|
||
|
+ struct dentry *old_dentry, struct inode *new_dir,
|
||
|
+ struct vfsmount *new_mnt,
|
||
|
+ struct dentry *new_dentry);
|
||
|
int (*inode_readlink) (struct vfsmount *mnt, struct dentry *dentry);
|
||
|
int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
|
||
|
int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
|
||
|
@@ -1704,15 +1708,17 @@ static inline int security_inode_mknod (
|
||
|
}
|
||
|
|
||
|
static inline int security_inode_rename (struct inode *old_dir,
|
||
|
+ struct vfsmount *old_mnt,
|
||
|
struct dentry *old_dentry,
|
||
|
struct inode *new_dir,
|
||
|
+ struct vfsmount *new_mnt,
|
||
|
struct dentry *new_dentry)
|
||
|
{
|
||
|
if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
|
||
|
(new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
|
||
|
return 0;
|
||
|
- return security_ops->inode_rename (old_dir, old_dentry,
|
||
|
- new_dir, new_dentry);
|
||
|
+ return security_ops->inode_rename (old_dir, old_mnt, old_dentry,
|
||
|
+ new_dir, new_mnt, new_dentry);
|
||
|
}
|
||
|
|
||
|
static inline int security_inode_readlink (struct vfsmount *mnt,
|
||
|
@@ -2427,8 +2433,10 @@ static inline int security_inode_mknod (
|
||
|
}
|
||
|
|
||
|
static inline int security_inode_rename (struct inode *old_dir,
|
||
|
+ struct vfsmount *old_mnt,
|
||
|
struct dentry *old_dentry,
|
||
|
struct inode *new_dir,
|
||
|
+ struct vfsmount *new_mnt,
|
||
|
struct dentry *new_dentry)
|
||
|
{
|
||
|
return 0;
|
||
|
Index: linux-2.6.19/security/dummy.c
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/security/dummy.c
|
||
|
+++ linux-2.6.19/security/dummy.c
|
||
|
@@ -309,8 +309,10 @@ static int dummy_inode_mknod (struct ino
|
||
|
}
|
||
|
|
||
|
static int dummy_inode_rename (struct inode *old_inode,
|
||
|
+ struct vfsmount *old_mnt,
|
||
|
struct dentry *old_dentry,
|
||
|
struct inode *new_inode,
|
||
|
+ struct vfsmount *new_mnt,
|
||
|
struct dentry *new_dentry)
|
||
|
{
|
||
|
return 0;
|
||
|
Index: linux-2.6.19/security/selinux/hooks.c
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/security/selinux/hooks.c
|
||
|
+++ linux-2.6.19/security/selinux/hooks.c
|
||
|
@@ -2190,8 +2190,12 @@ static int selinux_inode_mknod(struct in
|
||
|
return may_create(dir, dentry, inode_mode_to_security_class(mode));
|
||
|
}
|
||
|
|
||
|
-static int selinux_inode_rename(struct inode *old_inode, struct dentry *old_dentry,
|
||
|
- struct inode *new_inode, struct dentry *new_dentry)
|
||
|
+static int selinux_inode_rename(struct inode *old_inode,
|
||
|
+ struct vfsmount *old_mnt,
|
||
|
+ struct dentry *old_dentry,
|
||
|
+ struct inode *new_inode,
|
||
|
+ struct vfsmount *new_mnt,
|
||
|
+ struct dentry *new_dentry)
|
||
|
{
|
||
|
return may_rename(old_inode, old_dentry, new_inode, new_dentry);
|
||
|
}
|