mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-06 01:05:11 +00:00
120 lines
5.2 KiB
Diff
120 lines
5.2 KiB
Diff
![]() |
Pass struct vfsmount to the inode_setxattr LSM hook
|
||
|
|
||
|
Signed-off-by: Tony Jones <tonyj@suse.de>
|
||
|
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
|
||
|
|
||
|
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
|
||
|
@@ -49,7 +49,7 @@ extern void cap_capset_set (struct task_
|
||
|
extern int cap_bprm_set_security (struct linux_binprm *bprm);
|
||
|
extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
|
||
|
extern int cap_bprm_secureexec(struct linux_binprm *bprm);
|
||
|
-extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
|
||
|
+extern int cap_inode_setxattr(struct vfsmount *mnt, struct dentry *dentry, char *name, void *value, size_t size, int flags);
|
||
|
extern int cap_inode_removexattr(struct dentry *dentry, char *name);
|
||
|
extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
|
||
|
extern void cap_task_reparent_to_init (struct task_struct *p);
|
||
|
@@ -1250,8 +1250,8 @@ struct security_operations {
|
||
|
struct iattr *attr);
|
||
|
int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
|
||
|
void (*inode_delete) (struct inode *inode);
|
||
|
- int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
|
||
|
- size_t size, int flags);
|
||
|
+ int (*inode_setxattr) (struct vfsmount *mnt, struct dentry *dentry,
|
||
|
+ char *name, void *value, size_t size, int flags);
|
||
|
void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
|
||
|
size_t size, int flags);
|
||
|
int (*inode_getxattr) (struct dentry *dentry, char *name);
|
||
|
@@ -1769,12 +1769,14 @@ static inline void security_inode_delete
|
||
|
security_ops->inode_delete (inode);
|
||
|
}
|
||
|
|
||
|
-static inline int security_inode_setxattr (struct dentry *dentry, char *name,
|
||
|
+static inline int security_inode_setxattr (struct vfsmount *mnt,
|
||
|
+ struct dentry *dentry, char *name,
|
||
|
void *value, size_t size, int flags)
|
||
|
{
|
||
|
if (unlikely (IS_PRIVATE (dentry->d_inode)))
|
||
|
return 0;
|
||
|
- return security_ops->inode_setxattr (dentry, name, value, size, flags);
|
||
|
+ return security_ops->inode_setxattr (mnt, dentry, name, value, size,
|
||
|
+ flags);
|
||
|
}
|
||
|
|
||
|
static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
|
||
|
@@ -2476,10 +2478,11 @@ static inline int security_inode_getattr
|
||
|
static inline void security_inode_delete (struct inode *inode)
|
||
|
{ }
|
||
|
|
||
|
-static inline int security_inode_setxattr (struct dentry *dentry, char *name,
|
||
|
+static inline int security_inode_setxattr (struct vfsmount *mnt,
|
||
|
+ struct dentry *dentry, char *name,
|
||
|
void *value, size_t size, int flags)
|
||
|
{
|
||
|
- return cap_inode_setxattr(dentry, name, value, size, flags);
|
||
|
+ return cap_inode_setxattr(mnt, dentry, name, value, size, flags);
|
||
|
}
|
||
|
|
||
|
static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
|
||
|
Index: linux-2.6.19/security/commoncap.c
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/security/commoncap.c
|
||
|
+++ linux-2.6.19/security/commoncap.c
|
||
|
@@ -191,8 +191,8 @@ int cap_bprm_secureexec (struct linux_bi
|
||
|
current->egid != current->gid);
|
||
|
}
|
||
|
|
||
|
-int cap_inode_setxattr(struct dentry *dentry, char *name, void *value,
|
||
|
- size_t size, int flags)
|
||
|
+int cap_inode_setxattr(struct vfsmount *mnt, struct dentry *dentry, char *name,
|
||
|
+ void *value, size_t size, int flags)
|
||
|
{
|
||
|
if (!strncmp(name, XATTR_SECURITY_PREFIX,
|
||
|
sizeof(XATTR_SECURITY_PREFIX) - 1) &&
|
||
|
Index: linux-2.6.19/security/dummy.c
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/security/dummy.c
|
||
|
+++ linux-2.6.19/security/dummy.c
|
||
|
@@ -350,8 +350,9 @@ static void dummy_inode_delete (struct i
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
-static int dummy_inode_setxattr (struct dentry *dentry, char *name, void *value,
|
||
|
- size_t size, int flags)
|
||
|
+static int dummy_inode_setxattr (struct vfsmount *mnt, struct dentry *dentry,
|
||
|
+ char *name, void *value, size_t size,
|
||
|
+ int flags)
|
||
|
{
|
||
|
if (!strncmp(name, XATTR_SECURITY_PREFIX,
|
||
|
sizeof(XATTR_SECURITY_PREFIX) - 1) &&
|
||
|
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
|
||
|
@@ -2257,7 +2257,9 @@ static int selinux_inode_getattr(struct
|
||
|
return dentry_has_perm(current, mnt, dentry, FILE__GETATTR);
|
||
|
}
|
||
|
|
||
|
-static int selinux_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags)
|
||
|
+static int selinux_inode_setxattr(struct vfsmount *mnt, struct dentry *dentry,
|
||
|
+ char *name, void *value, size_t size,
|
||
|
+ int flags)
|
||
|
{
|
||
|
struct task_security_struct *tsec = current->security;
|
||
|
struct inode *inode = dentry->d_inode;
|
||
|
Index: linux-2.6.19/fs/xattr.c
|
||
|
===================================================================
|
||
|
--- linux-2.6.19.orig/fs/xattr.c
|
||
|
+++ linux-2.6.19/fs/xattr.c
|
||
|
@@ -81,7 +81,7 @@ vfs_setxattr(struct vfsmount *mnt, struc
|
||
|
return error;
|
||
|
|
||
|
mutex_lock(&inode->i_mutex);
|
||
|
- error = security_inode_setxattr(dentry, name, value, size, flags);
|
||
|
+ error = security_inode_setxattr(mnt, dentry, name, value, size, flags);
|
||
|
if (error)
|
||
|
goto out;
|
||
|
error = -EOPNOTSUPP;
|