From patchwork Wed Oct 19 08:25:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp213913wrs; Wed, 19 Oct 2022 02:11:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7irKawVk+VhwQHrYYkEhIZqou4+DCwRB1+RLH0uFXWWEvnLpuHV8MS124ZALVDHMkGGKm0 X-Received: by 2002:a17:907:94d1:b0:790:65a:3a18 with SMTP id dn17-20020a17090794d100b00790065a3a18mr5714576ejc.428.1666170685642; Wed, 19 Oct 2022 02:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170685; cv=none; d=google.com; s=arc-20160816; b=LB5PllV6vI8jQ+Fcjmatu5Li0fiCpHLPGaFSP9P4h2ApjJ8g4tK3VXQr8nVmcpP44X q3pHb1Cr6JIzg+r0id8kH8m9Rf16iHX2FDTZaocnVLLmX1tN3/57wSJCw9z0Cua7PxEY MUs7tQ+jhUDAmdKvbeawWGWm9KlSEZ0nTVy4MYN1lGdrkhrVo6vs1NMPH5sfy+XFAjbB c5QXMdjTv7YxPLgxz83IpM9hqaFggi6VEVmB3KGoZ3lMhmw7k2iIBRf1nTZTQRYQ5vpH HjKirtgTpBS1Dpog9UhHtlMjc5tMMxW2tcnRFa2x/TAazsKLLUTP31/dKcWDjpufoaz0 Pxkg== 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=cZofKYENmurOZTvSXKMo94k2spzaldeBtbxYDPdasCE=; b=aQ7V6lzXaeFdYY91nLLyCy5/YWXL7QmpRHXQbfc0vVfyImq/9yNc4KrOH0LqRTExAV eOKPeco9r5kvW8xa9nHqKWdveFJ4zo2f7KSXyLJBBH1QLtmZ/JtcqqWe0jvZuaNqkym8 fjYbh8GCm/7tQqXmZ9YtcSMoeGLrwCVZKZdtNwRz8eyQY9wjntZYlI1DnkbrtitCS8OB /Im2qYfJdUXysYANilq2CIyWT3AAmkB0kHMeqx0O9J+9lHjYm+gxX2J8RJdqTthep86l 4KTEQaZlqM+8JEhfdNDoY3A4rdDAAyfON1bRt2QuKdM92vuWQkx0P+pDA1Yx4DYTVWqS MFtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lXrtZHnK; 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 i19-20020a05640242d300b0045bd55b122fsi17578293edc.57.2022.10.19.02.11.01; Wed, 19 Oct 2022 02:11:25 -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=lXrtZHnK; 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 S232587AbiJSJHg (ORCPT + 99 others); Wed, 19 Oct 2022 05:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232786AbiJSJFH (ORCPT ); Wed, 19 Oct 2022 05:05:07 -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 3B16C9DFAF; Wed, 19 Oct 2022 01:59:14 -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 D234861838; Wed, 19 Oct 2022 08:48:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAFA1C433D6; Wed, 19 Oct 2022 08:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169289; bh=cEznBf9bvTB/4ENmafZ5o4nl4xs2vm5vB0HoS9fBxMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXrtZHnKwr05CjGJekuTytWwLLBIATLhTBvtn/mrJsRVhDQJuxyV96j2ygn1f/eIf 12m7mil4796h4ZBCe3tjG+Ac3FWYmmwqZqiheMcNFVgbs7PUcM20gNUEVpBwyTIYQf IPfdTTJNYYI24rQMBeYASDMLtDdKiU93gCXxV2G8= 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 6.0 221/862] nfsd: Fix a memory leak in an error handling path Date: Wed, 19 Oct 2022 10:25:08 +0200 Message-Id: <20221019083259.801867037@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106592910846430?= X-GMAIL-MSGID: =?utf-8?q?1747106592910846430?= 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 c634483d85d2..8f24485e0f04 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;