Linux Container Development
 help / color / mirror / Atom feed
From: Casey Schaufler <casey-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
To: Lukasz Pawelczyk
	<l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	"Eric W. Biederman"
	<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
	"Serge E. Hallyn" <serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org>,
	Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	Alexey Dobriyan
	<adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Calvin Owens <calvinowens-b10kYP2dOMg@public.gmane.org>,
	David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Eric Dumazet <edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Eric Paris <eparis-FjpueFixGhCM4zKIHC2jIg@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	James Morris
	<james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Jann Horn <jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org>,
	Jiri Slaby <jslaby-IBi9RG/b67k@public.gmane.org>,
	Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>,
	John Johansen
	<john.johansen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
	Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Mauro Carvalho Chehab
	<mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>,
	NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>,
	Paul Moore <paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org>Serge
Cc: Lukasz Pawelczyk <havner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH v4 06/11] smack: don't use implicit star to display smackfs/syslog
Date: Thu, 29 Oct 2015 15:50:51 -0700	[thread overview]
Message-ID: <5632A2CB.1000702@schaufler-ca.com> (raw)
In-Reply-To: <1444826525-9758-7-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.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 <l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> Acked-by: Serge Hallyn <serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

Acked-by: Casey Schaufler <casey-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>


> ---
>  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;
>  }

  parent reply	other threads:[~2015-10-29 22:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 12:41 [PATCH v4 00/11] Smack namespace Lukasz Pawelczyk
     [not found] ` <1444826525-9758-1-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-14 12:41   ` [PATCH v4 01/11] user_ns: 3 new LSM hooks for user namespace operations Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-2-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:49       ` Casey Schaufler
2015-10-14 12:41   ` [PATCH v4 02/11] lsm: /proc/$PID/attr/label_map file and getprocattr_seq hook Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-3-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:49       ` Casey Schaufler
2015-10-14 12:41   ` [PATCH v4 03/11] lsm: add file opener's cred to a setprocattr arguments Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-4-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:49       ` Casey Schaufler
2015-11-10  4:16       ` Al Viro
     [not found]     ` <20151110041625.GA19875@ZenIV.linux.org.uk>
     [not found]       ` <20151110041625.GA19875-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2015-11-10 10:15         ` Lukasz Pawelczyk
2015-10-14 12:41   ` [PATCH v4 04/11] lsm: inode_pre_setxattr hook Lukasz Pawelczyk
2015-10-14 12:41   ` [PATCH v4 05/11] smack: extend capability functions and fix 2 checks Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-6-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:50       ` Casey Schaufler
2015-10-14 12:42   ` [PATCH v4 06/11] smack: don't use implicit star to display smackfs/syslog Lukasz Pawelczyk
2015-10-14 12:42   ` [PATCH v4 07/11] smack: abstraction layer for 2 common Smack operations Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-8-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:51       ` Casey Schaufler
2015-10-14 12:42   ` [PATCH v4 08/11] smack: misc cleanups in preparation for a namespace patch Lukasz Pawelczyk
2015-10-14 12:42   ` [PATCH v4 09/11] smack: namespace groundwork Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-10-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:51       ` Casey Schaufler
2015-10-14 12:42   ` [PATCH v4 10/11] smack: namespace implementation Lukasz Pawelczyk
2015-10-14 12:42   ` [PATCH v4 11/11] smack: documentation for the Smack namespace Lukasz Pawelczyk
     [not found]     ` <1444826525-9758-12-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:52       ` Casey Schaufler
2015-11-09 15:40   ` [PATCH v4 00/11] " Lukasz Pawelczyk
     [not found] ` <1444826525-9758-5-git-send-email-l.pawelczyk@samsung.com>
     [not found]   ` <1444826525-9758-5-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:50     ` [PATCH v4 04/11] lsm: inode_pre_setxattr hook Casey Schaufler
2015-11-05  5:16     ` John Johansen
     [not found] ` <1444826525-9758-7-git-send-email-l.pawelczyk@samsung.com>
     [not found]   ` <1444826525-9758-7-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:50     ` Casey Schaufler [this message]
     [not found] ` <1444826525-9758-9-git-send-email-l.pawelczyk@samsung.com>
     [not found]   ` <1444826525-9758-9-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:51     ` [PATCH v4 08/11] smack: misc cleanups in preparation for a namespace patch Casey Schaufler
     [not found] ` <1444826525-9758-11-git-send-email-l.pawelczyk@samsung.com>
     [not found]   ` <1444826525-9758-11-git-send-email-l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-10-29 22:52     ` [PATCH v4 10/11] smack: namespace implementation Casey Schaufler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5632A2CB.1000702@schaufler-ca.com \
    --to=casey-isgtlc1asvqwg2llvl+j4a@public.gmane.org \
    --cc=adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=calvinowens-b10kYP2dOMg@public.gmane.org \
    --cc=corbet-T1hC0tSOHrs@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
    --cc=edumazet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=eparis-FjpueFixGhCM4zKIHC2jIg@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=havner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=james.l.morris-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org \
    --cc=joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org \
    --cc=john.johansen-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
    --cc=jslaby-IBi9RG/b67k@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=l.pawelczyk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org \
    --cc=neilb-l3A5Bk7waGM@public.gmane.org \
    --cc=paul-r2n+y4ga6xFZroRs9YW3xA@public.gmane.org \
    --cc=serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org \
    --cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox