From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] Smack: harmless underflow in smk_set_cipso()
Date: Tue, 03 Nov 2015 22:15:39 +0000 [thread overview]
Message-ID: <20151103221539.GC19280@mwanda> (raw)
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>
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;
next reply other threads:[~2015-11-03 22:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 22:15 Dan Carpenter [this message]
2015-12-03 22:23 ` [patch] Smack: harmless underflow in smk_set_cipso() Casey Schaufler
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=20151103221539.GC19280@mwanda \
--to=dan.carpenter@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox