Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp111620imm; Mon, 4 Jun 2018 14:02:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLSSGyFBEq/WjqG3nqiSAXlJeiu2/cYbpkRpLNhOk4b1rjF93aVm2en+M2QD9KhIHfz1qrF X-Received: by 2002:a63:ad08:: with SMTP id g8-v6mr18147413pgf.74.1528146163467; Mon, 04 Jun 2018 14:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528146163; cv=none; d=google.com; s=arc-20160816; b=Ifn7J7kD0yAWOL2jv6wz7AjweYtZ/hSTh5rhrcWt4vXVvCWODrnhzx1/YG0y9jj/cI 1ezbhEeSnVXjoBFqSk3vxaBkEobkmzqaE0euUEmaX6aQmyykXt2u6r/VWLUG7/Fn3uC0 39KfwZSxDOJYHfnqgrYhfEjhAohg++LC38Rgfi4u9p6lyQnAnOpSwJ22cZfjdg8Anlr4 uyUxSo9IQ0XdbMgWQxOFsOKHsZ1HBcQPfd9rRLA5eZdD2hMtdeFPEt92dDlcWzQgTYgK 7nsMgEkFE27BV6d/XJXDw3ZdhwmOS8h2Vg139DorizuktST5Ijc2e2hsARu8O7IjK00j KyuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=W/UQeHq5EplKfKDfSHZ+eguxIM6YOZYLeZdT9WdH28Q=; b=hg/A9sY426XUPaXC7XU+xAUNStniVe0o6KEEvXBf1eHsx3BcoIeXjpNm7x007aQucn 5XUE3LG2eFM7DIoh+AIzP+CM99G7AzRQb3xpocj71wGysFqtQmc95cEoIov3rNRo+llu vKVf32vpLQ//pvktt3V6RhPM5LhWM7/9q66H3Ln3bxc9NWsqi0uH/yowsYddH1UKbzMb uAbw6KOJ1YoGSsavnoXolQ/SWBZg8QuKibAoLmlyNET+jIvonq0Xq99QgqY6lJZUD/Xp TB8fw09KS6AueeRvnaGyEHUwp5F1FjHBq/UXo/SraVTPy5OyRT2qLceJ9jJGZKVOuWPS hAXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=G4ADRGC3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7-v6si10903915pgt.220.2018.06.04.14.02.06; Mon, 04 Jun 2018 14:02:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=G4ADRGC3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309AbeFDVBi (ORCPT + 99 others); Mon, 4 Jun 2018 17:01:38 -0400 Received: from sonic301-28.consmr.mail.gq1.yahoo.com ([98.137.64.154]:35896 "EHLO sonic301-28.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbeFDVBg (ORCPT ); Mon, 4 Jun 2018 17:01:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1528146096; bh=W/UQeHq5EplKfKDfSHZ+eguxIM6YOZYLeZdT9WdH28Q=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=G4ADRGC3QYjkEv78NFHCSZeu0xysyI0MId3gcIuqJtnTK+3KrDM2IVV8iItSbq8TV+5ES0AvGc9aE1NlP4d2uMyXmgEnGgUxCsm2Dt4F5neX5q+ANSW0AxPu5wg++6JhCsRAJLHUdwWTmX+spLaCI0dv1v2aca/FO7itLg3ImIXKnJfmmFFMAQiIMYb8Guf/pfPVNTXIkGVRz5uACASe20XJzTcvivQ0bexqtn6+pKDbeizyXae2LgV/a4M5rBb3dCk9z9HG2XefkXpfDrd1Gg19f8MgYgVB3vSb+CvHno0+PgDn89pHvgqMwLR0JG8H2EPOoCC+bhwilTH1src6gw== X-YMail-OSG: lh1JmTQVM1kI0CsVmsC4Z6oOb2ERfyB2UdELI3TnVmDIRxw9Kw4r2kDyuBpvwUV HAUj4gt3HvWxNPOpWRdwb.Vv0.sU5kC1CawVgc5siLs4iDtL.pWFT03_NPEVE5zRzhphGDHaKxsY EGWbHguCWdp5KtiBUprzfVonk7ZPdz2bffChrdJ7hTXPZtKkzXiTbY9eU2d7.GgrYfIVXBMl24b3 301INb0nCvm0o4HOiY.PovzMGSP5TzlrbOy8NnC_dZnnIqfL45n6x7PxIfhDqiZKOXUAfdacLTgs rrgPyU1dHaPPMpEIeGdzQ6J0A7rNKFrXQ62J9jYAG.2sdnkMR379TUaDVtHlHB.ddcJtXqEkn6.s S81DuBeDc3mo03Pkhjc4YbV3pKY2ILHNuKxHJscL_53pD6ujs26zu3XZTq1IPGGoAiupDmgbN2DR jM5ydmjKnARoFtQzOJKy1_lXRpnicoDNsxkIu8E5B0NGlv3D0FNsi2VSEn8ZBJgiITa5YseETBa7 AsX9HHBP.bD2yBfaRqvcq_bjYzpUFyE10JyQtxmG4i2dUttq0tLz2Xv8EPaZ6bn1G4QHDQVjdUWU xyi_1CyX.P0D3IchtRg3.J7YbMPdH5T6fYTtRbIRNiskPP1qaeDObV5Y9qcUiZtFHDneAAjImUHm J9_1ovRpLGI3Rgi1IAfT_zM4PS9ayT_WgUkQFAnvymRVfNNBlhczH1hLyKim37G4g Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.gq1.yahoo.com with HTTP; Mon, 4 Jun 2018 21:01:36 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp430.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID a976c6635acd49ca38ec0681446d5734; Mon, 04 Jun 2018 21:01:35 +0000 (UTC) Subject: Re: [PATCH] Smack: Fix memory leak in smack_inode_getsecctx To: "linux-security-module@vger.kernel.org" , Tejun Heo Cc: chandan.vn@samsung.com, "gregkh@linuxfoundation.org" , "bfields@fieldses.org" , "jlayton@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-nfs@vger.kernel.org" , CPGS , Sireesha Talluri , Chris Wright References: <02d9878e-65bf-5de8-9658-cf0f692f358c@schaufler-ca.com> <1ced6bce-92cc-7e0c-fab4-0aaa3d03b82f@schaufler-ca.com> <1527758911-18610-1-git-send-email-chandan.vn@samsung.com> <20180531153943.GR1351649@devbig577.frc2.facebook.com> <4f00f9ae-3302-83b9-c083-d21ade380eb2@schaufler-ca.com> <20180531161107.GV1351649@devbig577.frc2.facebook.com> <20180601085609epcms5p5fefac0156a4816e9e48751211ab595ee@epcms5p5> <20180601162913epcms5p7737f5b4376d8865af1eae119aa866550@epcms5p7> <5b0b157a-0e8c-d8f5-901e-836d545a8e4c@schaufler-ca.com> From: Casey Schaufler Message-ID: Date: Mon, 4 Jun 2018 14:01:34 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/1/2018 10:45 AM, Casey Schaufler wrote: > Fix memory leak in smack_inode_getsecctx > > The implementation of smack_inode_getsecctx() made > incorrect assumptions about how Smack presents a security > context. Smack does not need to allocate memory to support > security contexts, so "releasing" a Smack context is a no-op. > The code made an unnecessary copy and returned that as a > context, which was never freed. The revised implementation > returns the context correctly. > > Signed-off-by: Casey Schaufler Tejun, does this pass your tests? > --- > security/smack/smack_lsm.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c > index 0b414836bebd..5e3beae334a8 100644 > --- a/security/smack/smack_lsm.c > +++ b/security/smack/smack_lsm.c > @@ -1545,9 +1545,9 @@ static int smack_inode_listsecurity(struct inode *inode, char *buffer, > */ > static void smack_inode_getsecid(struct inode *inode, u32 *secid) > { > - struct inode_smack *isp = inode->i_security; > + struct smack_known *skp = smk_of_inode(inode); > > - *secid = isp->smk_inode->smk_secid; > + *secid = skp->smk_secid; > } > > /* > @@ -4538,12 +4538,10 @@ static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) > > static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen) > { > - int len = 0; > - len = smack_inode_getsecurity(inode, XATTR_SMACK_SUFFIX, ctx, true); > + struct smack_known *skp = smk_of_inode(inode); > > - if (len < 0) > - return len; > - *ctxlen = len; > + *ctx = skp->smk_known; > + *ctxlen = strlen(skp->smk_known); > return 0; > } > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-security-module" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >