diff options
author | Eric Paris <eparis@redhat.com> | 2011-02-01 11:05:39 -0500 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2011-02-01 11:12:29 -0500 |
commit | 2a7dba391e5628ad665ce84ef9a6648da541ebab (patch) | |
tree | ba0722bd74d2c883dbda7ff721850bab411cac04 /fs/btrfs/inode.c | |
parent | 821404434f3324bf23f545050ff64055a149766e (diff) |
fs/vfs/security: pass last path component to LSM on inode creation
SELinux would like to implement a new labeling behavior of newly created
inodes. We currently label new inodes based on the parent and the creating
process. This new behavior would also take into account the name of the
new object when deciding the new label. This is not the (supposed) full path,
just the last component of the path.
This is very useful because creating /etc/shadow is different than creating
/etc/passwd but the kernel hooks are unable to differentiate these
operations. We currently require that userspace realize it is doing some
difficult operation like that and than userspace jumps through SELinux hoops
to get things set up correctly. This patch does not implement new
behavior, that is obviously contained in a seperate SELinux patch, but it
does pass the needed name down to the correct LSM hook. If no such name
exists it is fine to pass NULL.
Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a0ff46a47895..49c04bec6a9d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -90,13 +90,14 @@ static noinline int cow_file_range(struct inode *inode, | |||
90 | unsigned long *nr_written, int unlock); | 90 | unsigned long *nr_written, int unlock); |
91 | 91 | ||
92 | static int btrfs_init_inode_security(struct btrfs_trans_handle *trans, | 92 | static int btrfs_init_inode_security(struct btrfs_trans_handle *trans, |
93 | struct inode *inode, struct inode *dir) | 93 | struct inode *inode, struct inode *dir, |
94 | const struct qstr *qstr) | ||
94 | { | 95 | { |
95 | int err; | 96 | int err; |
96 | 97 | ||
97 | err = btrfs_init_acl(trans, inode, dir); | 98 | err = btrfs_init_acl(trans, inode, dir); |
98 | if (!err) | 99 | if (!err) |
99 | err = btrfs_xattr_security_init(trans, inode, dir); | 100 | err = btrfs_xattr_security_init(trans, inode, dir, qstr); |
100 | return err; | 101 | return err; |
101 | } | 102 | } |
102 | 103 | ||
@@ -4675,7 +4676,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4675 | if (IS_ERR(inode)) | 4676 | if (IS_ERR(inode)) |
4676 | goto out_unlock; | 4677 | goto out_unlock; |
4677 | 4678 | ||
4678 | err = btrfs_init_inode_security(trans, inode, dir); | 4679 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
4679 | if (err) { | 4680 | if (err) { |
4680 | drop_inode = 1; | 4681 | drop_inode = 1; |
4681 | goto out_unlock; | 4682 | goto out_unlock; |
@@ -4736,7 +4737,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4736 | if (IS_ERR(inode)) | 4737 | if (IS_ERR(inode)) |
4737 | goto out_unlock; | 4738 | goto out_unlock; |
4738 | 4739 | ||
4739 | err = btrfs_init_inode_security(trans, inode, dir); | 4740 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
4740 | if (err) { | 4741 | if (err) { |
4741 | drop_inode = 1; | 4742 | drop_inode = 1; |
4742 | goto out_unlock; | 4743 | goto out_unlock; |
@@ -4864,7 +4865,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
4864 | 4865 | ||
4865 | drop_on_err = 1; | 4866 | drop_on_err = 1; |
4866 | 4867 | ||
4867 | err = btrfs_init_inode_security(trans, inode, dir); | 4868 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
4868 | if (err) | 4869 | if (err) |
4869 | goto out_fail; | 4870 | goto out_fail; |
4870 | 4871 | ||
@@ -6946,7 +6947,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
6946 | if (IS_ERR(inode)) | 6947 | if (IS_ERR(inode)) |
6947 | goto out_unlock; | 6948 | goto out_unlock; |
6948 | 6949 | ||
6949 | err = btrfs_init_inode_security(trans, inode, dir); | 6950 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
6950 | if (err) { | 6951 | if (err) { |
6951 | drop_inode = 1; | 6952 | drop_inode = 1; |
6952 | goto out_unlock; | 6953 | goto out_unlock; |