mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-07 01:41:00 +01:00
218 lines
8.7 KiB
Diff
218 lines
8.7 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 | 41 ++++++++++++++++++++++++++---------------
|
|
security/commoncap.c | 5 +++--
|
|
security/dummy.c | 8 +++++---
|
|
security/security.c | 16 ++++++++++------
|
|
security/selinux/hooks.c | 8 +++++---
|
|
6 files changed, 51 insertions(+), 31 deletions(-)
|
|
|
|
--- a/fs/xattr.c
|
|
+++ b/fs/xattr.c
|
|
@@ -78,7 +78,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;
|
|
@@ -86,7 +86,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
|
|
@@ -53,8 +53,9 @@ extern void cap_capset_set(struct task_s
|
|
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, const char *name,
|
|
- const void *value, size_t size, int flags);
|
|
+extern int cap_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const void *value, size_t size,
|
|
+ int flags);
|
|
extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
|
|
extern int cap_inode_need_killpriv(struct dentry *dentry);
|
|
extern int cap_inode_killpriv(struct dentry *dentry);
|
|
@@ -442,11 +443,11 @@ static inline void security_free_mnt_opt
|
|
* 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.
|
|
@@ -1393,10 +1394,13 @@ 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, const char *name,
|
|
- const void *value, size_t size, int flags);
|
|
- void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
|
|
- const void *value, size_t size, int flags);
|
|
+ int (*inode_setxattr) (struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const void *value, size_t size,
|
|
+ int flags);
|
|
+ void (*inode_post_setxattr) (struct dentry *dentry,
|
|
+ struct vfsmount *mnt,
|
|
+ const char *name, const void *value,
|
|
+ size_t size, int flags);
|
|
int (*inode_getxattr) (struct dentry *dentry, const char *name);
|
|
int (*inode_listxattr) (struct dentry *dentry);
|
|
int (*inode_removexattr) (struct dentry *dentry, const char *name);
|
|
@@ -1672,10 +1676,12 @@ 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, const char *name,
|
|
- const void *value, size_t size, int flags);
|
|
-void security_inode_post_setxattr(struct dentry *dentry, const char *name,
|
|
- const void *value, size_t size, int flags);
|
|
+int security_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const void *value,
|
|
+ size_t size, int flags);
|
|
+void security_inode_post_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const void *value,
|
|
+ size_t size, int flags);
|
|
int security_inode_getxattr(struct dentry *dentry, const char *name);
|
|
int security_inode_listxattr(struct dentry *dentry);
|
|
int security_inode_removexattr(struct dentry *dentry, const char *name);
|
|
@@ -2093,13 +2099,18 @@ static inline void security_inode_delete
|
|
{ }
|
|
|
|
static inline int security_inode_setxattr(struct dentry *dentry,
|
|
- const char *name, const void *value, size_t size, int flags)
|
|
+ struct vfsmount *mnt,
|
|
+ const char *name, const 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,
|
|
- const char *name, const void *value, size_t size, int flags)
|
|
+ struct vfsmount *mnt,
|
|
+ const char *name,
|
|
+ const void *value,
|
|
+ size_t size, int flags)
|
|
{ }
|
|
|
|
static inline int security_inode_getxattr(struct dentry *dentry,
|
|
--- a/security/commoncap.c
|
|
+++ b/security/commoncap.c
|
|
@@ -383,8 +383,9 @@ int cap_bprm_secureexec (struct linux_bi
|
|
current->egid != current->gid);
|
|
}
|
|
|
|
-int cap_inode_setxattr(struct dentry *dentry, const char *name,
|
|
- const void *value, size_t size, int flags)
|
|
+int cap_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const 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
|
|
@@ -374,8 +374,9 @@ static void dummy_inode_delete (struct i
|
|
return;
|
|
}
|
|
|
|
-static int dummy_inode_setxattr (struct dentry *dentry, const char *name,
|
|
- const void *value, size_t size, int flags)
|
|
+static int dummy_inode_setxattr (struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const void *value,
|
|
+ size_t size, int flags)
|
|
{
|
|
if (!strncmp(name, XATTR_SECURITY_PREFIX,
|
|
sizeof(XATTR_SECURITY_PREFIX) - 1) &&
|
|
@@ -384,7 +385,8 @@ static int dummy_inode_setxattr (struct
|
|
return 0;
|
|
}
|
|
|
|
-static void dummy_inode_post_setxattr (struct dentry *dentry, const char *name,
|
|
+static void dummy_inode_post_setxattr (struct dentry *dentry,
|
|
+ struct vfsmount *mnt, const char *name,
|
|
const void *value, size_t size,
|
|
int flags)
|
|
{
|
|
--- a/security/security.c
|
|
+++ b/security/security.c
|
|
@@ -500,20 +500,24 @@ void security_inode_delete(struct inode
|
|
security_ops->inode_delete(inode);
|
|
}
|
|
|
|
-int security_inode_setxattr(struct dentry *dentry, const char *name,
|
|
- const void *value, size_t size, int flags)
|
|
+int security_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const 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, const char *name,
|
|
- const void *value, size_t size, int flags)
|
|
+void security_inode_post_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const 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, const char *name)
|
|
--- a/security/selinux/hooks.c
|
|
+++ b/security/selinux/hooks.c
|
|
@@ -2655,8 +2655,9 @@ static int selinux_inode_setotherxattr(s
|
|
return dentry_has_perm(current, NULL, dentry, FILE__SETATTR);
|
|
}
|
|
|
|
-static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
|
|
- const void *value, size_t size, int flags)
|
|
+static int selinux_inode_setxattr(struct dentry *dentry, struct vfsmount *mnt,
|
|
+ const char *name, const void *value,
|
|
+ size_t size, int flags)
|
|
{
|
|
struct task_security_struct *tsec = current->security;
|
|
struct inode *inode = dentry->d_inode;
|
|
@@ -2705,7 +2706,8 @@ static int selinux_inode_setxattr(struct
|
|
&ad);
|
|
}
|
|
|
|
-static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
|
|
+static void selinux_inode_post_setxattr(struct dentry *dentry,
|
|
+ struct vfsmount *mnt, const char *name,
|
|
const void *value, size_t size,
|
|
int flags)
|
|
{
|