[AppArmor 01/41] Pass struct vfsmount to the inode_create LSM hook

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: jjohansen
Date: Thursday, April 12, 2007 - 2:08 am

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/dummy.c         |    2 +-
 security/selinux/hooks.c |    3 ++-
 4 files changed, 10 insertions(+), 6 deletions(-)

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1503,7 +1503,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->mnt : NULL, mode);
 	if (error)
 		return error;
 	DQUOT_INIT(dir);
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -283,6 +283,7 @@ struct request_sock;
  *	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:
@@ -1204,8 +1205,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);
@@ -1611,11 +1612,12 @@ static inline int security_inode_init_se
 	
 static inline 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);
 }
 
 static inline int security_inode_link (struct dentry *old_dentry,
@@ -2338,6 +2340,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/dummy.c
+++ b/security/dummy.c
@@ -265,7 +265,7 @@ static int dummy_inode_init_security (st
 }
 
 static int dummy_inode_create (struct inode *inode, struct dentry *dentry,
-			       int mask)
+			       struct vfsmount *mnt, int mask)
 {
 	return 0;
 }
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2178,7 +2178,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);
 }

-- 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[AppArmor 01/41] Pass struct vfsmount to the inode_create ..., jjohansen, (Thu Apr 12, 2:08 am)
Re: [AppArmor 01/41] Pass struct vfsmount to the inode_cre ..., Christoph Hellwig, (Thu Apr 12, 3:06 am)
[nameidata 1/2] Don't pass NULL nameidata to vfs_create, Andreas Gruenbacher, (Mon Apr 16, 9:11 am)
Re: [nameidata 1/2] Don't pass NULL nameidata to vfs_create, Christoph Hellwig, (Mon Apr 16, 9:21 am)
[nameidata 2/2] Pass no useless nameidata to the create, l ..., Andreas Gruenbacher, (Mon Apr 16, 9:29 am)
Re: [nameidata 2/2] Pass no useless nameidata to the creat ..., Christoph Hellwig, (Mon Apr 16, 9:39 am)
Re: [nameidata 1/2] Don't pass NULL nameidata to vfs_create, Andreas Gruenbacher, (Mon Apr 16, 9:40 am)
Re: [nameidata 2/2] Pass no useless nameidata to the creat ..., Andreas Gruenbacher, (Mon Apr 16, 9:44 am)
Re: [nameidata 1/2] Don't pass NULL nameidata to vfs_create, Christoph Hellwig, (Mon Apr 16, 9:45 am)
Re: [nameidata 1/2] Don't pass NULL nameidata to vfs_create, Andreas Gruenbacher, (Tue Apr 17, 5:09 am)
Re: [nameidata 1/2] Don't pass NULL nameidata to vfs_create, Andreas Gruenbacher, (Fri May 11, 8:59 am)
Re: [AppArmor 01/41] Pass struct vfsmount to the inode_cre ..., Andreas Gruenbacher, (Wed May 23, 12:06 pm)
Re: [AppArmor 01/41] Pass struct vfsmount to the inode_cre ..., Andreas Gruenbacher, (Thu May 24, 2:16 am)