mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
210 lines
8.4 KiB
Diff
210 lines
8.4 KiB
Diff
From: Tony Jones <tonyj@suse.de>
|
|
Subject: Pass struct vfsmount to the inode_setxattr 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/xattr.c | 4 ++--
|
|
include/linux/security.h | 35 +++++++++++++++++++++--------------
|
|
security/commoncap.c | 4 ++--
|
|
security/dummy.c | 9 ++++++---
|
|
security/security.c | 14 ++++++++------
|
|
security/selinux/hooks.c | 8 ++++++--
|
|
6 files changed, 45 insertions(+), 29 deletions(-)
|
|
|
|
--- a/fs/xattr.c
|
|
+++ b/fs/xattr.c
|
|
@@ -79,7 +79,7 @@ vfs_setxattr(struct dentry *dentry, stru
|
|
return error;
|
|
|
|
mutex_lock(&inode->i_mutex);
|
|
- error = security_inode_setxattr(dentry, name, value, size, flags);
|
|
+ error = security_inode_setxattr(dentry, mnt, name, value, size, flags);
|
|
if (error)
|
|
goto out;
|
|
error = -EOPNOTSUPP;
|
|
@@ -87,7 +87,7 @@ vfs_setxattr(struct dentry *dentry, stru
|
|
error = inode->i_op->setxattr(dentry, name, value, size, flags);
|
|
if (!error) {
|
|
fsnotify_xattr(dentry);
|
|
- security_inode_post_setxattr(dentry, name, value,
|
|
+ security_inode_post_setxattr(dentry, mnt, name, value,
|
|
size, flags);
|
|
}
|
|
} else if (!strncmp(name, XATTR_SECURITY_PREFIX,
|
|
--- a/include/linux/security.h
|
|
+++ b/include/linux/security.h
|
|
@@ -56,7 +56,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 dentry *dentry, struct vfsmount *mnt, char *name, void *value, size_t size, int flags);
|
|
extern int cap_inode_removexattr(struct dentry *dentry, char *name);
|
|
extern int cap_inode_need_killpriv(struct dentry *dentry);
|
|
extern int cap_inode_killpriv(struct dentry *dentry);
|
|
@@ -398,11 +398,11 @@ struct request_sock;
|
|
* inode.
|
|
* @inode_setxattr:
|
|
* Check permission before setting the extended attributes
|
|
- * @value identified by @name for @dentry.
|
|
+ * @value identified by @name for @dentry and @mnt.
|
|
* Return 0 if permission is granted.
|
|
* @inode_post_setxattr:
|
|
* Update inode security field after successful setxattr operation.
|
|
- * @value identified by @name for @dentry.
|
|
+ * @value identified by @name for @dentry and @mnt.
|
|
* @inode_getxattr:
|
|
* Check permission before obtaining the extended attributes
|
|
* identified by @name for @dentry.
|
|
@@ -1285,9 +1285,11 @@ 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);
|
|
- void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
|
|
+ int (*inode_setxattr) (struct dentry *dentry, struct vfsmount *mnt,
|
|
+ char *name, void *value, size_t size, int flags);
|
|
+ void (*inode_post_setxattr) (struct dentry *dentry,
|
|
+ struct vfsmount *mnt,
|
|
+ char *name, void *value,
|
|
size_t size, int flags);
|
|
int (*inode_getxattr) (struct dentry *dentry, char *name);
|
|
int (*inode_listxattr) (struct dentry *dentry);
|
|
@@ -1547,10 +1549,11 @@ int security_inode_setattr(struct dentry
|
|
struct iattr *attr);
|
|
int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
|
|
void security_inode_delete(struct inode *inode);
|
|
-int security_inode_setxattr(struct dentry *dentry, char *name,
|
|
- void *value, size_t size, int flags);
|
|
-void security_inode_post_setxattr(struct dentry *dentry, char *name,
|
|
- void *value, size_t size, int flags);
|
|
+int security_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ char *name, void *value, size_t size, int flags);
|
|
+void security_inode_post_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ char *name, void *value, size_t size,
|
|
+ int flags);
|
|
int security_inode_getxattr(struct dentry *dentry, char *name);
|
|
int security_inode_listxattr(struct dentry *dentry);
|
|
int security_inode_removexattr(struct dentry *dentry, char *name);
|
|
@@ -1937,14 +1940,18 @@ 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 dentry *dentry,
|
|
+ struct vfsmount *mnt, char *name,
|
|
void *value, size_t size, int flags)
|
|
{
|
|
- return cap_inode_setxattr(dentry, name, value, size, flags);
|
|
+ return cap_inode_setxattr(dentry, mnt, name, value, size, flags);
|
|
}
|
|
|
|
-static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
|
|
- void *value, size_t size, int flags)
|
|
+static inline void security_inode_post_setxattr (struct dentry *dentry,
|
|
+ struct vfsmount *mnt,
|
|
+ char *name,
|
|
+ void *value, size_t size,
|
|
+ int flags)
|
|
{ }
|
|
|
|
static inline int security_inode_getxattr (struct dentry *dentry, char *name)
|
|
--- a/security/commoncap.c
|
|
+++ b/security/commoncap.c
|
|
@@ -368,8 +368,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 dentry *dentry, struct vfsmount *mnt, char *name,
|
|
+ void *value, size_t size, int flags)
|
|
{
|
|
if (!strcmp(name, XATTR_NAME_CAPS)) {
|
|
if (!capable(CAP_SETFCAP))
|
|
--- a/security/dummy.c
|
|
+++ b/security/dummy.c
|
|
@@ -347,8 +347,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 dentry *dentry, struct vfsmount *mnt,
|
|
+ char *name, void *value, size_t size,
|
|
+ int flags)
|
|
{
|
|
if (!strncmp(name, XATTR_SECURITY_PREFIX,
|
|
sizeof(XATTR_SECURITY_PREFIX) - 1) &&
|
|
@@ -357,7 +358,9 @@ static int dummy_inode_setxattr (struct
|
|
return 0;
|
|
}
|
|
|
|
-static void dummy_inode_post_setxattr (struct dentry *dentry, char *name, void *value,
|
|
+static void dummy_inode_post_setxattr (struct dentry *dentry,
|
|
+ struct vfsmount *mnt,
|
|
+ char *name, void *value,
|
|
size_t size, int flags)
|
|
{
|
|
}
|
|
--- a/security/security.c
|
|
+++ b/security/security.c
|
|
@@ -440,20 +440,22 @@ void security_inode_delete(struct inode
|
|
security_ops->inode_delete(inode);
|
|
}
|
|
|
|
-int security_inode_setxattr(struct dentry *dentry, char *name,
|
|
- void *value, size_t size, int flags)
|
|
+int security_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ 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(dentry, mnt, name, value, size,
|
|
+ flags);
|
|
}
|
|
|
|
-void security_inode_post_setxattr(struct dentry *dentry, char *name,
|
|
- void *value, size_t size, int flags)
|
|
+void security_inode_post_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ char *name, void *value, size_t size,
|
|
+ int flags)
|
|
{
|
|
if (unlikely(IS_PRIVATE(dentry->d_inode)))
|
|
return;
|
|
- security_ops->inode_post_setxattr(dentry, name, value, size, flags);
|
|
+ security_ops->inode_post_setxattr(dentry, mnt, name, value, size, flags);
|
|
}
|
|
|
|
int security_inode_getxattr(struct dentry *dentry, char *name)
|
|
--- a/security/selinux/hooks.c
|
|
+++ b/security/selinux/hooks.c
|
|
@@ -2332,7 +2332,9 @@ static int selinux_inode_setotherxattr(s
|
|
return dentry_has_perm(current, NULL, dentry, FILE__SETATTR);
|
|
}
|
|
|
|
-static int selinux_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags)
|
|
+static int selinux_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ char *name, void *value, size_t size,
|
|
+ int flags)
|
|
{
|
|
struct task_security_struct *tsec = current->security;
|
|
struct inode *inode = dentry->d_inode;
|
|
@@ -2381,7 +2383,9 @@ static int selinux_inode_setxattr(struct
|
|
&ad);
|
|
}
|
|
|
|
-static void selinux_inode_post_setxattr(struct dentry *dentry, char *name,
|
|
+static void selinux_inode_post_setxattr(struct dentry *dentry,
|
|
+ struct vfsmount *mnt,
|
|
+ char *name,
|
|
void *value, size_t size, int flags)
|
|
{
|
|
struct inode *inode = dentry->d_inode;
|