From patchwork Mon Oct 24 11:28:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp442331wru; Mon, 24 Oct 2022 06:07:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CYjd+EObAuTiaShKyMo9NvViD2F/LBoBZrzIkoB0SkIBwAUbdGH+ZHtVChiGZdk8aAccN X-Received: by 2002:a17:902:c407:b0:17f:8bec:e7f4 with SMTP id k7-20020a170902c40700b0017f8bece7f4mr33351645plk.156.1666616839978; Mon, 24 Oct 2022 06:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616839; cv=none; d=google.com; s=arc-20160816; b=jOBDO2TrTqe7zRmO0VC4mUjH8bbTWK6kfxaT3nJ33YebPCyO5+naZn/c8QBKd4OxBZ 2mkatiqD6msgLuH9+xr7ArPXNtWOuWIeBxihC1aBKhLEPDpnLzMhhOkbJ3JcdRb5rHYs jPNi41HM28301wdSI+lLzGzipLdNeSkwGyVyXSoS09UX2gZM6ShRJXaRcMyMyOkRt/Mu OPY1IPfLsz08dgAXtL6l3LeA/WhKCKVe/rTKO8yCiNHdIJRnRUdYaK5wIA+EG5LfqZIM yN8q0tCls3CDS4YUlYCA9AqYWYnxKbdptiB/6l3LbzJ0jjr/c2hybLyNWoy0jR/He9sM JFIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3NeK362u9SYuxz8x7Mlvkg676U58gTI3svCgQqoY9YY=; b=X9jVkZXI2YMEfZ3CuortDplf/6V7KnSE8YK0qZ5BkrPHl8JfzqQC8XxM74Or113EEk aGe51hyQIYVdmUvqSVJSilKSvBZplxMuP+iEv3mwPQpDvw86uwoeyQ8pV8QbOniRl8F+ Oc7cSzHv6ix2tAPhwyRXDNKOyopuJsMTb1mAw1/gbb2ppDuEqPWr0Gwu40DyZtvQTLqL 4KgxbjbMgJzn9BUT/57j1Cfj4rbOLuPEBck5Q/fVIbjqzKNIJAK6+gVWy4A/aoOoxBBo 8iqb2ZLGQD0yR8s/ZVt1iogrAwESRZTSUM0pu5tyGcFFLJpHFJhWc4p6kVcw4qQFb5pa 2bIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J87SWjvD; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jf17-20020a170903269100b00174c5fdc8d2si2203754plb.307.2022.10.24.06.07.03; Mon, 24 Oct 2022 06:07:19 -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=@linuxfoundation.org header.s=korg header.b=J87SWjvD; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235417AbiJXNG2 (ORCPT + 99 others); Mon, 24 Oct 2022 09:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235383AbiJXNEl (ORCPT ); Mon, 24 Oct 2022 09:04:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DBA45282F; Mon, 24 Oct 2022 05:20:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C925461017; Mon, 24 Oct 2022 12:20:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBDB3C433D6; Mon, 24 Oct 2022 12:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614011; bh=kaSLeQO+QPkHMeHmXJ59FjLAZu2CjkLZn8B3+ZzYINA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J87SWjvDQETYh6LHZnA/smt1L3UPptjDC/4brVnHGEPn+f1WOWMW8ymp/9076ZG8K kUVSbNIHQw6+/FZb7Y7fOpNq4fMkZGkZdJ/iGG8tVM7N8/ObUu28DUxT4c0wEkKXTG YtQAWnxW4bPQ69EMhr2UGnwsgpXMw75gy/cFfDPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 5.10 099/390] nfsd: Fix a memory leak in an error handling path Date: Mon, 24 Oct 2022 13:28:16 +0200 Message-Id: <20221024113026.874772555@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747574419285054948?= X-GMAIL-MSGID: =?utf-8?q?1747574419285054948?= From: Christophe JAILLET [ Upstream commit fd1ef88049de09bc70d60b549992524cfc0e66ff ] If this memdup_user() call fails, the memory allocated in a previous call a few lines above should be freed. Otherwise it leaks. Fixes: 6ee95d1c8991 ("nfsd: add support for upcall version 2") Signed-off-by: Christophe JAILLET Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4recover.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index f9b730c43192..83c4e6883953 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -815,8 +815,10 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, princhash.data = memdup_user( &ci->cc_princhash.cp_data, princhashlen); - if (IS_ERR_OR_NULL(princhash.data)) + if (IS_ERR_OR_NULL(princhash.data)) { + kfree(name.data); return -EFAULT; + } princhash.len = princhashlen; } else princhash.len = 0;