Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp798026imm; Fri, 1 Jun 2018 09:42:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJr4Lr6mxk2tcuF0wYRMImw5i/SR1K67GPe7xQhyoAondLX3ds8TwqVbMT3FIhkLZi1vgcv X-Received: by 2002:a62:c809:: with SMTP id z9-v6mr11443159pff.5.1527871342149; Fri, 01 Jun 2018 09:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527871342; cv=none; d=google.com; s=arc-20160816; b=MKk7tlqwvP6kYE8Sy9vIsjA9qHiAMkMUe0udYeKEfpxgl8GbLrZj38Z545E7ScfvzN xuTy2+P8vlBTt0e3lZMMVFclxD3/T+0k3Z4q4S5OFOm9SYRU6RVDiYREOQjHV7jBZwqR +rs9HoHw7QxbA3rrFJX83TrkzInzTQ2k+4iUisskQ9aNcZYTQvBy8//VjEdRVVn3/9na Wx3CSvyS8vcZN9zISrbhMTCf6J8ij9jJHisXWPjlo6HZgzj4Xez6K5SZYBwlh1BTy2q3 zQ7wQjZK5vUVclIhbTRD68+X7NAj0TzYoQ4ALa9MMh1iu6KVJprJxeP9DnAHECOkJznS q4ow== 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=Zb6kwIHCbm3r/iQ/uu1RJHEDVBWcyhP7S7MtgNGc7J4=; b=Ghdg6XM2yH8nn7bhCuJQPXfIbwNT5kxEeCvlQweBopSYnP9fQGLkK2YcHqJnhZ32Sg 6jl21HKwzauhwwR8uIstpz/pfPBRXvB1MBcrl1ImiSwM75w33015YXC2cJN861cVWnEa d6cU/7J4faZlC2SBKEmltF/8MoT2z8Z61cRHjuqlgjPD4CY/Dc0VhHadtT/3oEv6cVW7 ijKcXtHzynncenVwotYvQa3CSk07a8iBc38HT0eTEby5kgbB1wxUF6JdOh378JJ0Z87U QIEzx2MUsNmfKBN0kdxCSdzUfTZy4v+b266vBekEc55yMpGYTyHNjBJwe60O1S0k4zgB p9jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=JY4Txr6G; 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 a35-v6si40772722pli.85.2018.06.01.09.42.07; Fri, 01 Jun 2018 09:42:22 -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=JY4Txr6G; 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 S1752704AbeFAQlq (ORCPT + 99 others); Fri, 1 Jun 2018 12:41:46 -0400 Received: from sonic306-26.consmr.mail.gq1.yahoo.com ([98.137.68.89]:37796 "EHLO sonic306-26.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752486AbeFAQlm (ORCPT ); Fri, 1 Jun 2018 12:41:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1527871302; bh=Zb6kwIHCbm3r/iQ/uu1RJHEDVBWcyhP7S7MtgNGc7J4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=JY4Txr6GP9+csrUU+VgBMZgQbGO7ePPELz2bQ1UjEoXX6lBDA4ogvb2jSUuS2VpK89CCGL3FxprGJkoFAPKmhH1Wf5f51g1DEn4i91igdyxr1HhTaVR4DqRN/n+eur6ge30/2IIPCmPetzp5VpSP+DXsvhRfaek1V4OOb2H0GmB6CrQDyq4LcANAuA6tTKFg9mhWeckuQWOaY7Bg32XrvhEE/Lkf/aNvmze16HpNBaO8wn00xoWa/PSqM+MqgKbymHqqzZrwM9L1hhbnXESVzeUmHmo+bArISc9FeVIwpJC+8cNJ7QYgPE8j3jNTQrSc5YumLdvhJxKOTP5bG5Bxpg== X-YMail-OSG: bYfU9rcVM1nUASJSbLG2p49jd8q6CMyEZR2TjtIOPLNs46zpYSe0Tji7INLUXIO 8Cx1KyIjBHMys2cUYvjd7jTmpRAFj_5LDKcZ8N2_zRIs0DHmpbwmNLlVnUInDMIz60Lhwxxb2zRz f_ZY8FRkk385TuCpoRKZ_ydUQxOBN_6cvmgyjae6W7NyJ87s8CrcvVoQmHYlW4SsGlFXoYxYJis3 6m66e8QYPbO59QUd6scVqJMP_29NG0g_9OkqfuBw.p8LDL7aPQLJANDOEY1r3wBYvXn8rClGnPFS Ac6d8mBeYm0VYY54h3zKuUbLF1AioVqEHY5.tjpRQnGyCH4TyjlslcxtkM4ZYH5bI6IncTSnV6Xu PLzXcgN49vj2cbcQSscV7tbgdlIhUNb9ZhTVDo33sBo23HiYxJ43wcYZqaXyG1hVyB9v9Zv5zD1s TJx.uAkpJejuOPBeT6aUgJNEvam9HIQ1pD_E1hPAb4d6pobJD5Jgw7ae1Q2b3bmDkCq.Nk8iXaFh kQjkHPtUYGeSjwSc1gu9MXyC5kBTiuGruYNHSufOcdG10CbE8fbCrziEuzcfGSk5zDBhHeaszdNy zX497IvinYfTav4.Q3ukeTmaJizcnMnd_1CkYeAUoVtOYnK_d.PCvKBTwTY2JL1mh7g6pDxR82BX ivl_9TJ8pE9Qzeq1m1Un44Edp_8S1QqH.iRhnKLNN7Zs- Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.gq1.yahoo.com with HTTP; Fri, 1 Jun 2018 16:41:42 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.105]) ([67.169.65.224]) by smtp410.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID c916732037d30163713d847ae71db74a; Fri, 01 Jun 2018 16:41:41 +0000 (UTC) Subject: Re: [PATCH 1/1] Fix memory leak in kernfs_security_xattr_set and kernfs_security_xattr_set To: chandan.vn@samsung.com, "linux-security-module@vger.kernel.org" Cc: Tejun Heo , "gregkh@linuxfoundation.org" , "bfields@fieldses.org" , "jlayton@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-nfs@vger.kernel.org" , CPGS , Sireesha Talluri , Chris Wright , Casey Schaufler 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> From: Casey Schaufler Message-ID: <5b0b157a-0e8c-d8f5-901e-836d545a8e4c@schaufler-ca.com> Date: Fri, 1 Jun 2018 09:41:39 -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: <20180601162913epcms5p7737f5b4376d8865af1eae119aa866550@epcms5p7> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 9:29 AM, CHANDAN VN wrote: >>>  I agree that the fix can be done simply by using "false" for  >>>  smack_inode_getsecurity(), but what happens with kernfs_node_setsecdata() >>>  and smack_inode_notifysecctx(). kernfs_node_setsecdata() is probably ignorable >>>  but smack_inode_notifysecctx() is sending the "ctx" to smack_inode_setsecurity() >>>  and since "ctx" would be NULL because we used "false", smack_inode_setsecurity() >>>  becomes dummy. >   >> Thank you for pointing this out. You're right, there's more >> at issue here than changing the alloc flag will fix. I think >> that calling smack_inode_getsecurity() from smack_inode_getsecctx() >> is making the code more complicated than it needs to be. I will >> have a patch shortly. > If you think the patch would take time or is complicated, I suggest that the kfree() fix should go > to fix the leaks for now. Heavens no! The patch is very simple. I'm building a kernel with it now, and should have it tested and posted within a few hours. The implementation of smack_inode_getsecctx() that's there is understandable, but wrong. There's a much better way to do the job.