Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752451AbbG0IwV (ORCPT ); Mon, 27 Jul 2015 04:52:21 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:37473 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbbG0IwT (ORCPT ); Mon, 27 Jul 2015 04:52:19 -0400 MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 X-AuditID: cbfec7f4-f79c56d0000012ee-32-55b5f140811f Content-transfer-encoding: 8BIT Message-id: <1437987136.3303.2.camel@samsung.com> Subject: Re: [PATCH] Smack: replace capable() with ns_capable() From: Lukasz Pawelczyk To: Sungbae Yoo , "'Casey Schaufler'" Cc: "'James Morris'" , "'Serge E. Hallyn'" , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 27 Jul 2015 10:52:16 +0200 In-reply-to: <000001d0c80b$55bdec50$0139c4f0$@samsung.com> References: <1437737174-29451-1-git-send-email-sungbae.yoo@samsung.com> <1437738032.2190.2.camel@samsung.com> <000001d0c80b$55bdec50$0139c4f0$@samsung.com> X-Mailer: Evolution 3.16.4 (3.16.4-2.fc22) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t/xy7oOH7eGGjxdYWNxb9svNou+x0EW l3fNYbP40POIzeL8hXPsFg+bfzI6sHlc2x3p8fHpLRaPvi2rGD2O7l/E5vF5k1wAaxSXTUpq TmZZapG+XQJXxoz5n5kLPopVHHj2g72BcZpQFyMnh4SAicTUyRfZIGwxiQv31gPZXBxCAksZ Je7+e8wCkuAVEJT4MfkekM3BwSwgL3HkUjZImFlAXWLSvEXMEPWfGSVa7+6EqjeUuPYVYqiw gL3E6pU3mUBsNgEDie8X9jKD2CIC4RK3dx9lhxg0n1FizmU1EJtFQFVi6duHrCA2p4CVxNt7 yxghFgDV7N+0gQnkCAkBLYm2N1kTGAVmITlvFsJ5s5Cct4CReRWjaGppckFxUnquoV5xYm5x aV66XnJ+7iZGSFB/2cG4+JjVIUYBDkYlHt4LKltDhVgTy4orcw8xSnAwK4nwPo4CCvGmJFZW pRblxxeV5qQWH2KU5mBREuedu+t9iJBAemJJanZqakFqEUyWiYNTqoHR63K58/wqtsI35iy7 vpp93i5dLSOvMXHrXtVnb5exbnM1VVBh+DR7Yen5bS+zfNu2TRSJXB+g9tH81gOnFy1nr6k2 bYtbOfd9U7vMiScuOc1+eaV/r+i5/ZSapu3c9+WkSuXmmL1yHS6vgsQzpDREVyvMZLgldbmm yyvzse1frvNbLy5uDulWYinOSDTUYi4qTgQAmQ2izWYCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3085 Lines: 94 On pon, 2015-07-27 at 10:27 +0900, Sungbae Yoo wrote: > So, Do you agree to allow the process to change its own labels? Yes, by using a proper method as I mentioned below (e.g. Smack namespace posted to this list). > 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. This won't help. Limiting this to init process will still allow every process outside of a namespace to change its own label, still insecure. > -----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 > -security-module" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- 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/