From mboxrd@z Thu Jan 1 00:00:00 1970 From: jmorris@namei.org (James Morris) Date: Wed, 4 Oct 2017 17:17:39 +1100 (AEDT) Subject: [PATCH] fix security_release_secctx seems broken In-Reply-To: References: Message-ID: To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org 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 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? I plan to send this to Linus for -rc4 unless anyone has objections. -- James Morris -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751342AbdJDGRt (ORCPT ); Wed, 4 Oct 2017 02:17:49 -0400 Received: from namei.org ([65.99.196.166]:51696 "EHLO namei.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750945AbdJDGRs (ORCPT ); Wed, 4 Oct 2017 02:17:48 -0400 Date: Wed, 4 Oct 2017 17:17:39 +1100 (AEDT) From: James Morris To: Casey Schaufler cc: Konstantin Khlebnikov , linux-kernel , Serge Hallyn , James Morris , LSM List , Stephen Smalley Subject: Re: [PATCH] fix security_release_secctx seems broken In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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? I plan to send this to Linus for -rc4 unless anyone has objections. -- James Morris