apparmor/kernel-patches/for-mainline/security-link.diff
2007-01-10 06:33:09 +00:00

114 lines
4.5 KiB
Diff

Pass the struct vfsmounts to the inode_link 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
@@ -2279,7 +2279,8 @@ int vfs_link(struct vfsmount *old_mnt, s
if (S_ISDIR(old_dentry->d_inode->i_mode))
return -EPERM;
- error = security_inode_link(old_dentry, dir, new_dentry);
+ error = security_inode_link(old_mnt, old_dentry, 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
@@ -288,8 +288,10 @@ struct request_sock;
* Return 0 if permission is granted.
* @inode_link:
* Check permission before creating a new hard link to a file.
+ * @old_mnt is the vfsmount where @old_dentry was looked up (may be NULL)
* @old_dentry contains the dentry structure for an existing link to the file.
* @dir contains the inode structure of the parent directory of the new link.
+ * @new_mnt is the vfsmount for @new_dentry (may be NULL)
* @new_dentry contains the dentry structure for the new link.
* Return 0 if permission is granted.
* @inode_unlink:
@@ -1220,8 +1222,9 @@ struct security_operations {
char **name, void **value, size_t *len);
int (*inode_create) (struct inode *dir, struct vfsmount *mnt,
struct dentry *dentry, int mode);
- int (*inode_link) (struct dentry *old_dentry,
- struct inode *dir, struct dentry *new_dentry);
+ int (*inode_link) (struct vfsmount *old_mnt, struct dentry *old_dentry,
+ struct inode *dir, struct vfsmount *new_mnt,
+ struct dentry *new_dentry);
int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
int (*inode_symlink) (struct inode *dir, struct vfsmount *mnt,
struct dentry *dentry, const char *old_name);
@@ -1636,13 +1639,16 @@ static inline int security_inode_create
return security_ops->inode_create (dir, mnt, dentry, mode);
}
-static inline int security_inode_link (struct dentry *old_dentry,
+static inline int security_inode_link (struct vfsmount *old_mnt,
+ struct dentry *old_dentry,
struct inode *dir,
+ struct vfsmount *new_mnt,
struct dentry *new_dentry)
{
if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
return 0;
- return security_ops->inode_link (old_dentry, dir, new_dentry);
+ return security_ops->inode_link (old_mnt, old_dentry, dir,
+ new_mnt, new_dentry);
}
static inline int security_inode_unlink (struct inode *dir,
@@ -2367,8 +2373,10 @@ static inline int security_inode_create
return 0;
}
-static inline int security_inode_link (struct dentry *old_dentry,
+static inline int security_inode_link (struct vfsmount *old_mnt,
+ struct dentry *old_dentry,
struct inode *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
@@ -270,7 +270,9 @@ static int dummy_inode_create (struct in
return 0;
}
-static int dummy_inode_link (struct dentry *old_dentry, struct inode *inode,
+static int dummy_inode_link (struct vfsmount *old_mnt,
+ struct dentry *old_dentry, struct inode *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
@@ -2135,11 +2135,15 @@ static int selinux_inode_create(struct i
return may_create(dir, dentry, SECCLASS_FILE);
}
-static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
+static int selinux_inode_link(struct vfsmount *old_mnt,
+ struct dentry *old_dentry, struct inode *dir,
+ struct vfsmount *new_mnt,
+ struct dentry *new_dentry)
{
int rc;
- rc = secondary_ops->inode_link(old_dentry,dir,new_dentry);
+ rc = secondary_ops->inode_link(old_mnt, old_dentry, dir, new_mnt,
+ new_dentry);
if (rc)
return rc;
return may_link(dir, old_dentry, MAY_LINK);