From: sds@tycho.nsa.gov (Stephen Smalley)
To: linux-security-module@vger.kernel.org
Subject: [PATCH] selinux: return -ENOMEM if kzalloc() fails
Date: Fri, 30 Jun 2017 08:48:14 -0400 [thread overview]
Message-ID: <1498826894.16913.1.camel@tycho.nsa.gov> (raw)
In-Reply-To: <20170630075614.ywv3y3tptor5ox7g@mwanda>
On Fri, 2017-06-30 at 10:56 +0300, Dan Carpenter wrote:
> We accidentally return success instead of -ENOMEM on this failure
> path.
>
> Fixes: 409dcf31538a ("selinux: Add a cache for quicker retreival of
> PKey SIDs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
NAK, that's intentional. See the comment just above the code in
question.
>
> diff --git a/security/selinux/ibpkey.c b/security/selinux/ibpkey.c
> index e3614ee5f1c0..36e61f622b5a 100644
> --- a/security/selinux/ibpkey.c
> +++ b/security/selinux/ibpkey.c
> @@ -160,8 +160,10 @@ static int sel_ib_pkey_sid_slow(u64
> subnet_prefix, u16 pkey_num, u32 *sid)
> ? ?* is valid, it just won't be added to the cache.
> ? ?*/
> ? new = kzalloc(sizeof(*new), GFP_ATOMIC);
> - if (!new)
> + if (!new) {
> + ret = -ENOMEM;
> ? goto out;
> + }
> ?
> ? new->psec.subnet_prefix = subnet_prefix;
> ? new->psec.pkey = pkey_num;
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-06-30 12:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 7:56 [PATCH] selinux: return -ENOMEM if kzalloc() fails Dan Carpenter
2017-06-30 12:48 ` Stephen Smalley [this message]
2017-06-30 13:10 ` Tetsuo Handa
2017-06-30 22:30 ` Paul Moore
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=1498826894.16913.1.camel@tycho.nsa.gov \
--to=sds@tycho.nsa.gov \
--cc=linux-security-module@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;
as well as URLs for NNTP newsgroup(s).