Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8897524rwi; Tue, 25 Oct 2022 12:15:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zGM4ca+WaBqbQcjYS5qybhHoHRIfvjeiTrlhYvKrDHrhiTI3TuvB1o4OrsoDVA6S4TkhU X-Received: by 2002:a17:90a:1c1:b0:20a:e745:bc30 with SMTP id 1-20020a17090a01c100b0020ae745bc30mr84526296pjd.131.1666725335120; Tue, 25 Oct 2022 12:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666725335; cv=none; d=google.com; s=arc-20160816; b=enh0v8hnYOkghC/yo5FDhp+qgyLH+kIxRkVswLtkAfEB0pR5yE9P7P7poDGxDglMyB /us3LfV3ehLUjJsVHlFZuiX1ImP+eefrDM0+I+hgP91Ab4q9WfF+WF4HwdRahVhtPtlR Iq3/VXFVOAaLpOcji4g0iatoF3ZsoXYMA7mCBGwwVecVaP39upwGB3F51c9y7u5DZOqz NzIvgajdm4eS7Q7YTldid5xiKdihVJP3jna7QVVA2eZeCmqNWd8XhoTIhx+8DSGJ4sMa cf7j+2N7rpy/XXTb3YqcN4p1YG+YIXRnxbEYOfJj8UdbqdbNKp3WnjDaolflb8eHMr/8 EPjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wdQpMJv+fAAdPj7JhNoObv56I8k+ulFEDb11lC7AivY=; b=NLoo9eW+HuuJLMOza7kC2/lIoZzHdlIIS2LD56rVrOgfeMs87TZwPZ3/mbSMxvuFVm mmz81rgStxzN+Y4vSGh9uIYoBEcnouuZESdn2JbS1hU50N5/lPZzGb9lp+rFnACqrlUS dVdT4BoW3z6PW8h4s1JKmQaUo4hoJJ45i3kJWjfQNa8F4E0pTHoj3Tc3fEugxqx4AzXN ZmMZWyrKlA+xwLZ/9IhM1l2yEU604pyj9pwA5qSYuGfEu65wQF/6eCNvy4f9F1v35JBV JxAkoDWdTUM7/gcvmOktnYN89Os+94v/kX2axfMacIwPXEjad0F4lW9C0G1JO1UioG4w s26w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lJlZT5zb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id so15-20020a17090b1f8f00b0020d4dffd6e6si4255233pjb.99.2022.10.25.12.15.23; Tue, 25 Oct 2022 12:15:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lJlZT5zb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbiJYTCS (ORCPT + 99 others); Tue, 25 Oct 2022 15:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbiJYTCQ (ORCPT ); Tue, 25 Oct 2022 15:02:16 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90FE32A95B; Tue, 25 Oct 2022 12:02:15 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id y14so15122930ejd.9; Tue, 25 Oct 2022 12:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=wdQpMJv+fAAdPj7JhNoObv56I8k+ulFEDb11lC7AivY=; b=lJlZT5zbsgVFeKCsWmbaL5DSMTf48Ru56giPGXdY/pQohgHr9azEIF3ixhn+tAWh/x pbaOZD2att0kTfKsdsTsl8C7ASExfvIysnxfEkWE1FEyNlSS/fOGJ8oBj4u4jptLgfaO q7rt7ptzzqwkXI+hgKYF1n/wNwKUYygRtFU+CjBdM19VG6l6OWopGfIGo9gDxokz6Oqw BUrWJ6U5FbwDcvIVNRqvvMTjxCiNqF4O/R2GlAoQdy11Zdyl1JlDOEy8a2PKTpxPIgdw fPw6db9HfDJgI6jLVrnWTwMMI+SftXJFg3N2zsQZVPtnbdaQy+RhWAWT4htQIZMRYQbc tLQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wdQpMJv+fAAdPj7JhNoObv56I8k+ulFEDb11lC7AivY=; b=Tja2TpcNVg0wBVrVuxbBIq3ijwsvAI+KZ8nwZMreymljgir2zZObZ42bwZoyeonpV2 5hp7iDp91X1k9cUKD90ovHoisKXNqM+GWqq0/AEAmX5qV0IlrrgWvgmBObB1rJ42JUSB ek1Czjr/YsiTwNIiTtmncoUCMZXzu55toL4CmozfYji/2/S5w1FJjDQVKzVqccUSyrfs Xl+YGNv5djANx7RBTClD26L4Z7+horMecd9oCwgs96tFxRHjX6NEfvIwCichfn8pD61y feQb+lc0O4uVkWPjITqIV3scKuvw0d9QdpYWZux5r6FCGECCP7TSeuJs3Q4kVl5oj9FI UYrQ== X-Gm-Message-State: ACrzQf3SXyZE/Gcveas5J8N8bihRp71D6DrlZqtyC7cCr6Gmio0KaR/H Vn73EKkMT+kwVLEozPYbsg== X-Received: by 2002:a17:906:5a6a:b0:7a6:bad5:8295 with SMTP id my42-20020a1709065a6a00b007a6bad58295mr11961592ejc.647.1666724534017; Tue, 25 Oct 2022 12:02:14 -0700 (PDT) Received: from p183 ([46.53.248.70]) by smtp.gmail.com with ESMTPSA id s5-20020a056402036500b004623028c594sm1031397edw.49.2022.10.25.12.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 12:02:13 -0700 (PDT) Date: Tue, 25 Oct 2022 22:02:11 +0300 From: Alexey Dobriyan To: Li Zetao Cc: viro@zeniv.linux.org.uk, ebiederm@xmission.com, keescook@chromium.org, akpm@linux-foundation.org, yi.zhang@huawei.com, chengzhihao1@huawei.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs/binfmt_elf: Fix memory leak in load_elf_binary() Message-ID: References: <20221024154421.982230-1-lizetao1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221024154421.982230-1-lizetao1@huawei.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 24, 2022 at 11:44:21PM +0800, Li Zetao wrote: > If "interp_elf_ex" fails to allocate memory in load_elf_binary(), > the program will take the "out_free_ph" error handing path, > resulting in "interpreter" file resource is not released. Yes :-( > --- a/fs/binfmt_elf.c > +++ b/fs/binfmt_elf.c > @@ -911,7 +911,7 @@ static int load_elf_binary(struct linux_binprm *bprm) > interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL); > if (!interp_elf_ex) { > retval = -ENOMEM; > - goto out_free_ph; > + goto out_free_file; Reviewed-by: Alexey Dobriyan