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/ocfs2/xattr.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/ocfs2/xattr.c')
-rw-r--r-- | fs/ocfs2/xattr.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 67cd43914641..6bb602486c6b 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -7185,7 +7185,8 @@ out: | |||
7185 | * must not hold any lock expect i_mutex. | 7185 | * must not hold any lock expect i_mutex. |
7186 | */ | 7186 | */ |
7187 | int ocfs2_init_security_and_acl(struct inode *dir, | 7187 | int ocfs2_init_security_and_acl(struct inode *dir, |
7188 | struct inode *inode) | 7188 | struct inode *inode, |
7189 | const struct qstr *qstr) | ||
7189 | { | 7190 | { |
7190 | int ret = 0; | 7191 | int ret = 0; |
7191 | struct buffer_head *dir_bh = NULL; | 7192 | struct buffer_head *dir_bh = NULL; |
@@ -7193,7 +7194,7 @@ int ocfs2_init_security_and_acl(struct inode *dir, | |||
7193 | .enable = 1, | 7194 | .enable = 1, |
7194 | }; | 7195 | }; |
7195 | 7196 | ||
7196 | ret = ocfs2_init_security_get(inode, dir, &si); | 7197 | ret = ocfs2_init_security_get(inode, dir, qstr, &si); |
7197 | if (!ret) { | 7198 | if (!ret) { |
7198 | ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, | 7199 | ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, |
7199 | si.name, si.value, si.value_len, | 7200 | si.name, si.value, si.value_len, |
@@ -7261,13 +7262,14 @@ static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name, | |||
7261 | 7262 | ||
7262 | int ocfs2_init_security_get(struct inode *inode, | 7263 | int ocfs2_init_security_get(struct inode *inode, |
7263 | struct inode *dir, | 7264 | struct inode *dir, |
7265 | const struct qstr *qstr, | ||
7264 | struct ocfs2_security_xattr_info *si) | 7266 | struct ocfs2_security_xattr_info *si) |
7265 | { | 7267 | { |
7266 | /* check whether ocfs2 support feature xattr */ | 7268 | /* check whether ocfs2 support feature xattr */ |
7267 | if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) | 7269 | if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) |
7268 | return -EOPNOTSUPP; | 7270 | return -EOPNOTSUPP; |
7269 | return security_inode_init_security(inode, dir, &si->name, &si->value, | 7271 | return security_inode_init_security(inode, dir, qstr, &si->name, |
7270 | &si->value_len); | 7272 | &si->value, &si->value_len); |
7271 | } | 7273 | } |
7272 | 7274 | ||
7273 | int ocfs2_init_security_set(handle_t *handle, | 7275 | int ocfs2_init_security_set(handle_t *handle, |