Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932496AbbG1Ogf (ORCPT ); Tue, 28 Jul 2015 10:36:35 -0400 Received: from smtp103.biz.mail.bf1.yahoo.com ([98.139.221.62]:38106 "EHLO smtp103.biz.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696AbbG1Ogd (ORCPT ); Tue, 28 Jul 2015 10:36:33 -0400 X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: wwHf20sVM1lx9W4yyxztFSUbpcd_48HanZ70EMeA7AK3sYP U97TQ4CxvfaxqjkV2Fg0NdkqGYFsOeKaoAZITArMb7Xss3FAgF8zy1ImKFwz wuaZPSX1ES5l.9PW640E9GEQU1oYTRLMHC9IpQ3MaQH2hPl8dFApVs6zT8VB m7MU_IBMBt3.g39VmAUUEjSCEvY5DZUXSaGRt1VDejwnL1_cYDzItPHthNFY LwEJHiIoS60nNZLIKb_Jg4wZNd7bvPKzaVhKCreWDhK_vue43aA0Ow9dlW7V hZp7eS265Wytrh47phdtHTjtBV.FPdeckjWgxfeUaaYMTVreb6BkE_6RxYvp UGF_RrrWFByfP89M3wHJbhELK8GRu5rhQtJf7P2bKuC5C6AWgwK4FZeeUFvY klPgs05DEMgv8FEiGif5tVqAx119EelSt5SohivXBLzBkLCImxdvMuHgtMXj gxDtLQRBnxRnEXW.NvJAgreP7jkGqLl1f8IHl3LiDufYw9yP8TukwdEJ36sw GK2W0kNW8EMHvtNdMi02uldib2fv3WcMfoA-- X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Subject: Re: [PATCH] Smack: replace capable() with ns_capable() To: Sungbae Yoo , "'Lukasz Pawelczyk'" References: <1437737174-29451-1-git-send-email-sungbae.yoo@samsung.com> <1437738032.2190.2.camel@samsung.com> <000001d0c80b$55bdec50$0139c4f0$@samsung.com> Cc: "'James Morris'" , "'Serge E. Hallyn'" , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Casey Schaufler From: Casey Schaufler Message-ID: <55B7936E.2080007@schaufler-ca.com> Date: Tue, 28 Jul 2015 07:36:30 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <000001d0c80b$55bdec50$0139c4f0$@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2623 Lines: 75 On 7/26/2015 6:27 PM, Sungbae Yoo wrote: > So, Do you agree to allow the process to change its own labels? No. This requires CAP_MAC_ADMIN. Smack is mandatory access control. Being in a namespace (as they are implemented today) is not sufficient. > > Now, init process(eg. systemd) can't be running in user namespace properly > because it can't be assign smack label to service. > > If you agree, I'll upload another patch limited to this. > > > -----Original Message----- > From: Lukasz Pawelczyk [mailto:l.pawelczyk@samsung.com] > Sent: Friday, July 24, 2015 8:41 PM > To: Sungbae Yoo; Casey Schaufler > Cc: James Morris; Serge E. Hallyn; linux-security-module@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH] Smack: replace capable() with ns_capable() > > On piÄ…, 2015-07-24 at 20:26 +0900, Sungbae Yoo wrote: >> If current task has capabilities, Smack operations (eg. Changing own >> smack >> label) should be available even inside of namespace. >> >> Signed-off-by: Sungbae Yoo >> >> diff --git a/security/smack/smack_access.c >> b/security/smack/smack_access.c index 00f6b38..f6b2c35 100644 >> --- a/security/smack/smack_access.c >> +++ b/security/smack/smack_access.c >> @@ -639,7 +639,7 @@ int smack_privileged(int cap) >> struct smack_known *skp = smk_of_current(); >> struct smack_onlycap *sop; >> >> - if (!capable(cap)) >> + if (!ns_capable(current_user_ns(), cap)) >> return 0; > It's not that easy. > > With this change Smack becomes completely insecure. You can change rules as an unprivileged user without any problems now. > What you want is Smack namespace that was made to remedy exactly this issue (e.g. changing own labels inside a namespace). > >> >> rcu_read_lock(); >> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c >> index a143328..7fdc3dd 100644 >> --- a/security/smack/smack_lsm.c >> +++ b/security/smack/smack_lsm.c >> @@ -403,7 +403,8 @@ static int smk_ptrace_rule_check(struct >> task_struct *tracer, >> rc = 0; >> else if (smack_ptrace_rule == >> SMACK_PTRACE_DRACONIAN) >> rc = -EACCES; >> - else if (capable(CAP_SYS_PTRACE)) >> + else if (ns_capable(__task_cred(tracer)->user_ns, >> + CAP_SYS_PTRACE)) >> rc = 0; >> else >> rc = -EACCES; > -- > Lukasz Pawelczyk > Samsung R&D Institute Poland > Samsung Electronics > > > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/