diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2016-07-13 10:44:50 -0400 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2016-08-08 20:43:59 -0400 |
commit | 19472b69d639d58415866bf127d5f9005038c105 (patch) | |
tree | de7f757f15275283bc3153bb368cb305d8081993 | |
parent | 121ab822ef21914adac2fa3730efeeb8fd762473 (diff) |
selinux: Implementation for inode_copy_up_xattr() hook
When a file is copied up in overlay, we have already created file on
upper/ with right label and there is no need to copy up selinux
label/xattr from lower file to upper file. In fact in case of context
mount, we don't want to copy up label as newly created file got its label
from context= option.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r-- | security/selinux/hooks.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 40597ed00ba9..a2d510895ff3 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -3313,6 +3313,21 @@ static int selinux_inode_copy_up(struct dentry *src, struct cred **new) | |||
3313 | return 0; | 3313 | return 0; |
3314 | } | 3314 | } |
3315 | 3315 | ||
3316 | static int selinux_inode_copy_up_xattr(const char *name) | ||
3317 | { | ||
3318 | /* The copy_up hook above sets the initial context on an inode, but we | ||
3319 | * don't then want to overwrite it by blindly copying all the lower | ||
3320 | * xattrs up. Instead, we have to filter out SELinux-related xattrs. | ||
3321 | */ | ||
3322 | if (strcmp(name, XATTR_NAME_SELINUX) == 0) | ||
3323 | return 1; /* Discard */ | ||
3324 | /* | ||
3325 | * Any other attribute apart from SELINUX is not claimed, supported | ||
3326 | * by selinux. | ||
3327 | */ | ||
3328 | return -EOPNOTSUPP; | ||
3329 | } | ||
3330 | |||
3316 | /* file security operations */ | 3331 | /* file security operations */ |
3317 | 3332 | ||
3318 | static int selinux_revalidate_file_permission(struct file *file, int mask) | 3333 | static int selinux_revalidate_file_permission(struct file *file, int mask) |
@@ -6109,6 +6124,7 @@ static struct security_hook_list selinux_hooks[] = { | |||
6109 | LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity), | 6124 | LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity), |
6110 | LSM_HOOK_INIT(inode_getsecid, selinux_inode_getsecid), | 6125 | LSM_HOOK_INIT(inode_getsecid, selinux_inode_getsecid), |
6111 | LSM_HOOK_INIT(inode_copy_up, selinux_inode_copy_up), | 6126 | LSM_HOOK_INIT(inode_copy_up, selinux_inode_copy_up), |
6127 | LSM_HOOK_INIT(inode_copy_up_xattr, selinux_inode_copy_up_xattr), | ||
6112 | 6128 | ||
6113 | LSM_HOOK_INIT(file_permission, selinux_file_permission), | 6129 | LSM_HOOK_INIT(file_permission, selinux_file_permission), |
6114 | LSM_HOOK_INIT(file_alloc_security, selinux_file_alloc_security), | 6130 | LSM_HOOK_INIT(file_alloc_security, selinux_file_alloc_security), |