From: Roman Kubiak Date: Mon, 10 Aug 2015 14:54:25 +0000 (+0200) Subject: BACKPORT: Kernel threads excluded from smack checks X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=783ce03474b2b0663c1e39595a48ea29fa74d9aa;p=platform%2Fkernel%2Flinux-stable.git BACKPORT: Kernel threads excluded from smack checks Adds an ignore case for kernel tasks, so that they can access all resources. Since kernel worker threads are spawned with floor label, they are severely restricted by Smack policy. It is not an issue without onlycap, as these processes also run with root, so CAP_MAC_OVERRIDE kicks in. But with onlycap turned on, there is no way to change the label for these processes. Signed-off-by: Roman Kubiak Acked-by: Casey Schaufler (cherry-picked from upstream 41a2d5751616e38d1e293e3cb35a6e2bc7a03473) --- diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c index 2f7ff308c6a8..9d86b243334d 100644 --- a/security/smack/smack_access.c +++ b/security/smack/smack_access.c @@ -640,6 +640,12 @@ int smack_privileged(int cap) struct smack_known *skp = smk_of_current(); struct smack_onlycap *sop; + /* + * All kernel tasks are privileged + */ + if (unlikely(current->flags & PF_KTHREAD)) + return 1; + if (!capable(cap)) return 0;