From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965659AbbJ2WvA (ORCPT ); Thu, 29 Oct 2015 18:51:00 -0400 Received: from smtp107.biz.mail.bf1.yahoo.com ([98.139.244.55]:32386 "EHLO smtp107.biz.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758200AbbJ2Wu5 (ORCPT ); Thu, 29 Oct 2015 18:50:57 -0400 X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: h70KiZAVM1lpxylY4HO166sX6T13SulShmedjTyY3O3X1d5 Davl42dSWY33ziN8QjiwR1rIvG27vsmz8nzewC71mF8K2QN1WGUA7a6gj1Mh weYU5BCsiNDKJU2piUnKosiuFfBCxwAMC3.3f2HNpxogf_NTa4AEtOVvlTbi fpXbCZUHjU3laLb4ZxQHZ2xT_FeoWBZSEte3ieXVN9TCjfmSjXlUKRzww0sf kcDXhpM5jgjNkgleu5vf4qniuK4V3Ygs8ysD3Al7Vvzgq4Qqvt8td_v9bIXS kTUvgfDuAxXB2Z5I6fEcZ7f5gLhbIzyfy.ZOuW9oijAVZCfuiu8DKGk3HQbr T8ZdICFPixakkvwROL8ZOSWVyOhcfBW7iMZVP6Uin127LHVvVJXiUcELLTR7 khloNm1m8.5OGG_fT.LaSNr7MsexKhwTq9okO7KpGyzZJfQkObCgpIaG32s6 u3PjH55NLPAlbhcb7Nc.zPYp3yblM.O3ZajxP4vz_t7KtVTlrj6zSBhw0TQS WE6k- X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Subject: Re: [PATCH v4 06/11] smack: don't use implicit star to display smackfs/syslog To: Lukasz Pawelczyk , "David S. Miller" , "Eric W. Biederman" , "Serge E. Hallyn" , Al Viro , Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Calvin Owens , David Howells , Eric Dumazet , Eric Paris , Greg Kroah-Hartman , James Morris , Jann Horn , Jiri Slaby , Joe Perches , John Johansen , Jonathan Corbet , Kees Cook , Mauro Carvalho Chehab , NeilBrown , Paul Moore , Serge Hallyn , Stephen Smalley , Tejun Heo , Tetsuo Handa , containers@lists.linuxfoundation.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov References: <1444826525-9758-1-git-send-email-l.pawelczyk@samsung.com> <1444826525-9758-7-git-send-email-l.pawelczyk@samsung.com> Cc: Lukasz Pawelczyk From: Casey Schaufler Message-ID: <5632A2CB.1000702@schaufler-ca.com> Date: Thu, 29 Oct 2015 15:50:51 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1444826525-9758-7-git-send-email-l.pawelczyk@samsung.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/14/2015 5:42 AM, Lukasz Pawelczyk wrote: > Smackfs/syslog is analogous to onlycap and unconfined. When not filled > they don't do anything. In such cases onlycap and unconfined displayed > nothing when read, but syslog unconditionally displayed star. This > doesn't work well with namespaces where the star could have been > unmapped. Besides the meaning of this star was different then a star > that could be written to this file. This was misleading. > > This also brings syslog read/write functions on par with onlycap and > unconfined where it is possible to reset the value to NULL as should be > possible according to comment in smackfs.c describing smack_syslog_label > variable. > > Before that the initial state was to allow (smack_syslog_label was > NULL), but after writing star to it the current had to be labeled star > as well to have an access, even thought reading the smackfs/syslog > returned the same result in both cases. > > Signed-off-by: Lukasz Pawelczyk > Acked-by: Serge Hallyn Acked-by: Casey Schaufler > --- > security/smack/smackfs.c | 42 +++++++++++++++++++++++++++--------------- > 1 file changed, 27 insertions(+), 15 deletions(-) > > diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c > index ce8d503..05e09ee2 100644 > --- a/security/smack/smackfs.c > +++ b/security/smack/smackfs.c > @@ -2634,23 +2634,20 @@ static const struct file_operations smk_change_rule_ops = { > static ssize_t smk_read_syslog(struct file *filp, char __user *buf, > size_t cn, loff_t *ppos) > { > - struct smack_known *skp; > + char *smack = ""; > ssize_t rc = -EINVAL; > int asize; > > if (*ppos != 0) > return 0; > > - if (smack_syslog_label == NULL) > - skp = &smack_known_star; > - else > - skp = smack_syslog_label; > + if (smack_syslog_label != NULL) > + smack = smack_syslog_label->smk_known; > > - asize = strlen(skp->smk_known) + 1; > + asize = strlen(smack) + 1; > > if (cn >= asize) > - rc = simple_read_from_buffer(buf, cn, ppos, skp->smk_known, > - asize); > + rc = simple_read_from_buffer(buf, cn, ppos, smack, asize); > > return rc; > } > @@ -2678,16 +2675,31 @@ static ssize_t smk_write_syslog(struct file *file, const char __user *buf, > if (data == NULL) > return -ENOMEM; > > - if (copy_from_user(data, buf, count) != 0) > + if (copy_from_user(data, buf, count) != 0) { > rc = -EFAULT; > - else { > - skp = smk_import_entry(data, count); > - if (IS_ERR(skp)) > - rc = PTR_ERR(skp); > - else > - smack_syslog_label = skp; > + goto freeout; > } > > + /* > + * Clear the smack_syslog_label on invalid label errors. This means > + * that we can pass a null string to unset the syslog value. > + * > + * Importing will also reject a label beginning with '-', > + * so "-syslog" will also work. > + * > + * But do so only on invalid label, not on system errors. > + */ > + skp = smk_import_entry(data, count); > + if (PTR_ERR(skp) == -EINVAL) > + skp = NULL; > + else if (IS_ERR(skp)) { > + rc = PTR_ERR(skp); > + goto freeout; > + } > + > + smack_syslog_label = skp; > + > +freeout: > kfree(data); > return rc; > }