diff options
author | jooseong lee <jooseong.lee@samsung.com> | 2016-07-20 10:07:11 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2016-12-14 13:52:16 +0900 |
commit | 212e412eb38cd52631f6b6bec92f66306466a654 (patch) | |
tree | cec27abef42ba0acd86ab45de5fbb8fad9c25430 /security | |
parent | 07ba11f76ccb764ae094eeb113ac2834bf0ad289 (diff) |
Smack: Assign smack_known_web label for kernel thread's socket in the sk_alloc_security hook
Creating struct sock by sk_alloc function in various kernel subsystems
like bluetooth dosen't call smack_socket_post_create(). In such case,
received sock label is the floor('_') label and makes access deny.
Refers to:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7412301b76bd53ee53b860f611fc3b5b1c2245b5
Change-Id: I614c5f0e6d59be5ca6b49f0581edfef79fc334cf
Signed-off-by: jooseong lee <jooseong.lee@samsung.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/smack/smack_lsm.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index d53fd8acae74..ea5694d92ee2 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -2343,8 +2343,16 @@ static int smack_sk_alloc_security(struct sock *sk, int family, gfp_t gfp_flags) if (ssp == NULL) return -ENOMEM; - ssp->smk_in = skp; - ssp->smk_out = skp; + /* + * Sockets created by kernel threads receive web label. + */ + if (unlikely(current->flags & PF_KTHREAD)) { + ssp->smk_in = &smack_known_web; + ssp->smk_out = &smack_known_web; + } else { + ssp->smk_in = skp; + ssp->smk_out = skp; + } ssp->smk_packet = NULL; sk->sk_security = ssp; |