mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-07 01:41:00 +01:00
107 lines
4 KiB
Diff
107 lines
4 KiB
Diff
From: Tony Jones <tonyj@suse.de>
|
|
Subject: Pass struct vfsmount to the inode_create 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/namei.c | 2 +-
|
|
include/linux/security.h | 9 ++++++---
|
|
security/capability.c | 2 +-
|
|
security/security.c | 5 +++--
|
|
security/selinux/hooks.c | 3 ++-
|
|
5 files changed, 13 insertions(+), 8 deletions(-)
|
|
|
|
--- a/fs/namei.c
|
|
+++ b/fs/namei.c
|
|
@@ -1512,7 +1512,7 @@ int vfs_create(struct inode *dir, struct
|
|
return -EACCES; /* shouldn't it be ENOSYS? */
|
|
mode &= S_IALLUGO;
|
|
mode |= S_IFREG;
|
|
- error = security_inode_create(dir, dentry, mode);
|
|
+ error = security_inode_create(dir, dentry, nd ? nd->path.mnt : NULL, mode);
|
|
if (error)
|
|
return error;
|
|
DQUOT_INIT(dir);
|
|
--- a/include/linux/security.h
|
|
+++ b/include/linux/security.h
|
|
@@ -337,6 +337,7 @@ static inline void security_free_mnt_opt
|
|
* Check permission to create a regular file.
|
|
* @dir contains inode structure of the parent of the new file.
|
|
* @dentry contains the dentry structure for the file to be created.
|
|
+ * @mnt is the vfsmount corresponding to @dentry (may be NULL).
|
|
* @mode contains the file mode of the file to be created.
|
|
* Return 0 if permission is granted.
|
|
* @inode_link:
|
|
@@ -1354,8 +1355,8 @@ struct security_operations {
|
|
void (*inode_free_security) (struct inode *inode);
|
|
int (*inode_init_security) (struct inode *inode, struct inode *dir,
|
|
char **name, void **value, size_t *len);
|
|
- int (*inode_create) (struct inode *dir,
|
|
- struct dentry *dentry, int mode);
|
|
+ int (*inode_create) (struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt, int mode);
|
|
int (*inode_link) (struct dentry *old_dentry,
|
|
struct inode *dir, struct dentry *new_dentry);
|
|
int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
|
|
@@ -1622,7 +1623,8 @@ int security_inode_alloc(struct inode *i
|
|
void security_inode_free(struct inode *inode);
|
|
int security_inode_init_security(struct inode *inode, struct inode *dir,
|
|
char **name, void **value, size_t *len);
|
|
-int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
|
|
+int security_inode_create(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt, int mode);
|
|
int security_inode_link(struct dentry *old_dentry, struct inode *dir,
|
|
struct dentry *new_dentry);
|
|
int security_inode_unlink(struct inode *dir, struct dentry *dentry);
|
|
@@ -1968,6 +1970,7 @@ static inline int security_inode_init_se
|
|
|
|
static inline int security_inode_create(struct inode *dir,
|
|
struct dentry *dentry,
|
|
+ struct vfsmount *mnt,
|
|
int mode)
|
|
{
|
|
return 0;
|
|
--- a/security/capability.c
|
|
+++ b/security/capability.c
|
|
@@ -155,7 +155,7 @@ static int cap_inode_init_security(struc
|
|
}
|
|
|
|
static int cap_inode_create(struct inode *inode, struct dentry *dentry,
|
|
- int mask)
|
|
+ struct vfsmount *mnt, int mask)
|
|
{
|
|
return 0;
|
|
}
|
|
--- a/security/security.c
|
|
+++ b/security/security.c
|
|
@@ -358,11 +358,12 @@ int security_inode_init_security(struct
|
|
}
|
|
EXPORT_SYMBOL(security_inode_init_security);
|
|
|
|
-int security_inode_create(struct inode *dir, struct dentry *dentry, int mode)
|
|
+int security_inode_create(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt, int mode)
|
|
{
|
|
if (unlikely(IS_PRIVATE(dir)))
|
|
return 0;
|
|
- return security_ops->inode_create(dir, dentry, mode);
|
|
+ return security_ops->inode_create(dir, dentry, mnt, mode);
|
|
}
|
|
|
|
int security_inode_link(struct dentry *old_dentry, struct inode *dir,
|
|
--- a/security/selinux/hooks.c
|
|
+++ b/security/selinux/hooks.c
|
|
@@ -2566,7 +2566,8 @@ static int selinux_inode_init_security(s
|
|
return 0;
|
|
}
|
|
|
|
-static int selinux_inode_create(struct inode *dir, struct dentry *dentry, int mask)
|
|
+static int selinux_inode_create(struct inode *dir, struct dentry *dentry,
|
|
+ struct vfsmount *mnt, int mask)
|
|
{
|
|
return may_create(dir, dentry, SECCLASS_FILE);
|
|
}
|