Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1032818imm; Thu, 31 May 2018 13:59:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIC7/f9JiZSuGQK8jlvuYLWzQokX1kPEU2SzOtQYaJwzBWCy/5B1kkr9kTmN4ueqq5n8X1N X-Received: by 2002:a17:902:41:: with SMTP id 59-v6mr8506969pla.345.1527800366583; Thu, 31 May 2018 13:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527800366; cv=none; d=google.com; s=arc-20160816; b=P8p0jMBc498MVEXmYfhKYWd68KgSxUGPsAYdqezsxSipyIisLBf3crOTtButQ89lR8 cEfe/8Ub4VCEeDpTQ4e7aTCjdmVTWNZQn7RCiaIoZ6VkS5PKQA50YHIHkfa2DCE+hUOo Ma+bxJCY5jtG13JqwpCj8q+BIqsQT/CzcnJyBvXa5ay72Fv7U87YXeglCddy6V3naRqg r6TXwVhg7lvl1UN/50q6cAPFlwuPvjxvD334GYVazFie/k1v3N7thOTPFoSaVLzIJZGR PxS44Xjeh5N8BtTZbpxgNj/awa/ppBEDVcdZrcvtP/HFsjqyGYgHsb1HIJjakaG5ece1 3ITg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=Yc5WQRLDLP7jTrOQ89N3KrJOete1j12674f8VDy/8fo=; b=wCIWaPonyZPzkHjgddBVfY6RPJrOT0R/b1jyo2pyJGd9zHByuj3X1Ps+6XCOoFl6dr rin0Hrj362OqS/p9uQ0lmUj8N+CKN2W87KnlnxRunyIhVYejuDIQN/3QdkFXWDpat4Z7 HTItI4bm6cOby3EcIFtaZwofDC5Q6RsdHFzFybwc8ynqzqZuaT/GyYrB1wdqpwq7iy6N ChXC9oidt9XT0jPnCWcQzAiGn4oN6qVj3m+3Uz5iNZ+OxZUYqFPLdW7AXJkHLy/VN/WW zo2k6ROr9uEyG8Uai76Y6bXI5vyZo/hGzFDNDiCzkLOypuuG8QbHU9kk+0g+KpfCszaD yshQ== ARC-Authentication-Results: i=1; mx.google.com; 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 f18-v6si30068810pgt.63.2018.05.31.13.59.11; Thu, 31 May 2018 13:59:26 -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; 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 S1750871AbeEaU51 (ORCPT + 99 others); Thu, 31 May 2018 16:57:27 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:45969 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeEaU5X (ORCPT ); Thu, 31 May 2018 16:57:23 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fOUdN-000595-7j; Thu, 31 May 2018 14:57:21 -0600 Received: from 97-119-124-205.omah.qwest.net ([97.119.124.205] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fOUd7-0005ar-Sd; Thu, 31 May 2018 14:57:21 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Casey Schaufler Cc: CHANDAN VN , gregkh@linuxfoundation.org, tj@kernel.org, bfields@fieldses.org, jlayton@kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, cpgs@samsung.com, sireesha.t@samsung.com References: <1527758911-18610-1-git-send-email-chandan.vn@samsung.com> Date: Thu, 31 May 2018 15:57:00 -0500 In-Reply-To: (Casey Schaufler's message of "Thu, 31 May 2018 08:26:23 -0700") Message-ID: <87po1ba6hv.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fOUd7-0005ar-Sd;;;mid=<87po1ba6hv.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.119.124.205;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/XP0tPEpehqsmwDWlaPGm1Ip3r44VJ/mU= X-SA-Exim-Connect-IP: 97.119.124.205 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: ****** X-Spam-Status: No, score=6.3 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,LotsOfNums_01,TVD_RCVD_IP,T_TM2_M_HEADER_IN_MSG, T_TooManySym_01,XMGappySubj_01,XMNoVowels,XMSolicitRefs_0,XMSubLong,XM_E_VN autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.5 XMGappySubj_01 Very gappy subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 1.2 LotsOfNums_01 BODY: Lots of long strings of numbers * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 2.5 XM_E_VN URI: Link to something.vn * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.1 XMSolicitRefs_0 Weightloss drug * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ******;Casey Schaufler X-Spam-Relay-Country: X-Spam-Timing: total 15041 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 2.6 (0.0%), b_tie_ro: 1.76 (0.0%), parse: 1.25 (0.0%), extract_message_metadata: 21 (0.1%), get_uri_detail_list: 3.0 (0.0%), tests_pri_-1000: 4.6 (0.0%), tests_pri_-950: 1.80 (0.0%), tests_pri_-900: 1.54 (0.0%), tests_pri_-400: 30 (0.2%), check_bayes: 28 (0.2%), b_tokenize: 13 (0.1%), b_tok_get_all: 7 (0.0%), b_comp_prob: 3.3 (0.0%), b_tok_touch_all: 3.1 (0.0%), b_finish: 0.59 (0.0%), tests_pri_0: 188 (1.2%), check_dkim_signature: 0.48 (0.0%), check_dkim_adsp: 2.6 (0.0%), tests_pri_500: 14787 (98.3%), poll_dns_idle: 14769 (98.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/1] Fix memory leak in kernfs_security_xattr_set and kernfs_security_xattr_set X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Casey Schaufler writes: > On 5/31/2018 2:28 AM, CHANDAN VN wrote: >> From: "sireesha.t" >> >> Leak is caused because smack_inode_getsecurity() is allocating memory >> using kstrdup(). Though the security_release_secctx() is called, it >> would not free the allocated memory. Calling security_release_secctx is >> not relevant for this scenario as inode_getsecurity() does not provide a >> "secctx". >> >> Similar fix has been mainlined: >> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=57e7ba04d422c3d41c8426380303ec9b7533ded9 >> >> The fix is to replace the security_release_secctx() with a kfree() >> >> Below is the KMEMLEAK dump: >> unreferenced object 0xffffffc025e11c80 (size 64): >> comm "systemd-tmpfile", pid 2452, jiffies 4294894464 (age 235587.492s) >> hex dump (first 32 bytes): >> 53 79 73 74 65 6d 3a 3a 53 68 61 72 65 64 00 00 System::Shared.. >> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ >> backtrace: >> [] __save_stack_trace+0x28/0x34 >> [] create_object+0x130/0x25c >> [] kmemleak_alloc+0x30/0x5c >> [] __kmalloc_track_caller+0x1cc/0x2a8 >> [] kstrdup+0x3c/0x6c >> [] smack_inode_getsecurity+0xcc/0xec >> [] smack_inode_getsecctx+0x24/0x44 >> [] security_inode_getsecctx+0x50/0x70 >> [] kernfs_security_xattr_set+0x74/0xe0 >> [] __vfs_setxattr+0x74/0x90 >> [] __vfs_setxattr_noperm+0x80/0x1ac >> [] vfs_setxattr+0x84/0xac >> [] setxattr+0x114/0x178 >> [] path_setxattr+0x74/0xb8 >> [] SyS_lsetxattr+0x10/0x1c >> [] __sys_trace_return+0x0/0x4 >> >> Signed-off-by: sireesha.t >> Signed-off-by: CHANDAN VN > > Why not: > > 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); > + int len = smack_inode_getsecurity(inode, XATTR_SMACK_SUFFIX, ctx, false); > The practical difference here is the true vs the false in the call to smack_inode_getsecurity? > if (len < 0) > return len; > Eric