All of lore.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] Smack: harmless underflow in smk_set_cipso()
Date: Thu, 03 Dec 2015 22:23:22 +0000	[thread overview]
Message-ID: <5660C0DA.90503@schaufler-ca.com> (raw)
In-Reply-To: <20151103221539.GC19280@mwanda>

On 11/3/2015 2:15 PM, Dan Carpenter wrote:
> This causes a static checker warning because "maplevel" is set by the
> user and we cap the upper bound but not the lower bound.  It seems
> harmless to me and it's root only but we may as well make the static
> checker happy.
>
> Also checkpatch complains that we should use kstrtouint() instead of
> sscanf here.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

This no longer parses cipso specifications correctly.
I haven't investigated why. It looks as if it should
work. Does kstrtouint() allow for leading whitespace?
If not, that's the problem.
  

>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index 94bd9e4..ebb1241 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -862,7 +862,7 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
>   	struct smack_known *skp;
>   	struct netlbl_lsm_secattr ncats;
>   	char mapcatset[SMK_CIPSOLEN];
> -	int maplevel;
> +	unsigned int maplevel;
>   	unsigned int cat;
>   	int catlen;
>   	ssize_t rc = -EINVAL;
> @@ -912,8 +912,8 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
>   	else
>   		rule += strlen(skp->smk_known) + 1;
>   
> -	ret = sscanf(rule, "%d", &maplevel);
> -	if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
> +	ret = kstrtouint(rule, 10, &maplevel);
> +	if (ret || maplevel > SMACK_CIPSO_MAXLEVEL)
>   		goto out;
>   
>   	rule += SMK_DIGITLEN;
>


  reply	other threads:[~2015-12-03 22:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 22:15 [patch] Smack: harmless underflow in smk_set_cipso() Dan Carpenter
2015-12-03 22:23 ` Casey Schaufler [this message]
2015-12-04 12:53 ` Dan Carpenter

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=5660C0DA.90503@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=kernel-janitors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.