From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: James Morris <jmorris@namei.org>,
Casey Schaufler <casey@schaufler-ca.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Serge Hallyn <serge@hallyn.com>,
James Morris <james.l.morris@oracle.com>,
LSM List <linux-security-module@vger.kernel.org>,
Stephen Smalley <sds@tycho.nsa.gov>
Subject: Re: [PATCH] fix security_release_secctx seems broken
Date: Wed, 4 Oct 2017 12:29:37 +0300 [thread overview]
Message-ID: <ff77bdc9-e642-113d-dbde-f4d0770fff00@yandex-team.ru> (raw)
In-Reply-To: <alpine.LRH.2.21.1710041713160.19339@namei.org>
On 04.10.2017 09:17, James Morris wrote:
> On Tue, 19 Sep 2017, Casey Schaufler wrote:
>
>> Subject: [PATCH] fix security_release_secctx seems broken
>>
>> security_inode_getsecurity() provides the text string value
>> of a security attribute. It does not provide a "secctx".
>> The code in xattr_getsecurity() that calls security_inode_getsecurity()
>> and then calls security_release_secctx() happened to work because
>> SElinux and Smack treat the attribute and the secctx the same way.
>> It fails for cap_inode_getsecurity(), because that module has no
>> secctx that ever needs releasing. It turns out that Smack is the
>> one that's doing things wrong by not allocating memory when instructed
>> to do so by the "alloc" parameter.
>>
>> The fix is simple enough. Change the security_release_secctx() to
>> kfree() because it isn't a secctx being returned by
>> security_inode_getsecurity(). Change Smack to allocate the string when
>> told to do so.
>>
>> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
>
> Looks good to me. I wonder why security_release_secctx was used in the
> first place? (it arrived via commit 42492594)
> > Konstantin: how did you trigger this?
Just "getcap /bin/ping" is enough to tigger leak if file has capabilities.
Selinux shouldn't be loaded because its release_secctx hook call kfree.
But sometimes it takes some time for kmemleak to find leak. Presumably
because stale poiner stays on stack which could be reused nowdays.
>
> I plan to send this to Linus for -rc4 unless anyone has objections.
>
>
next prev parent reply other threads:[~2017-10-04 9:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-16 18:18 [BUG] " Konstantin Khlebnikov
2017-09-18 20:25 ` Casey Schaufler
2017-09-19 2:21 ` Casey Schaufler
2017-09-19 16:39 ` [PATCH] fix " Casey Schaufler
2017-09-20 11:48 ` Konstantin Khlebnikov
2017-10-04 6:17 ` James Morris
2017-10-04 9:29 ` Konstantin Khlebnikov [this message]
2017-10-04 22:10 ` James Morris
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=ff77bdc9-e642-113d-dbde-f4d0770fff00@yandex-team.ru \
--to=khlebnikov@yandex-team.ru \
--cc=casey@schaufler-ca.com \
--cc=james.l.morris@oracle.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=serge@hallyn.com \
/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
all inboxes | Powered by JetHome®