From patchwork Sat Oct 22 07:21:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1091985wrr; Sat, 22 Oct 2022 00:52:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5I9LYYeiFkn0akTrufiTdWUmd3XrRfKAOSBb/Rmvq98mge5j/N0n2aRhTiVP8J/S82XHUu X-Received: by 2002:a05:6a00:181c:b0:563:2c6c:2a7a with SMTP id y28-20020a056a00181c00b005632c6c2a7amr23199876pfa.28.1666425152022; Sat, 22 Oct 2022 00:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425152; cv=none; d=google.com; s=arc-20160816; b=kUIGbN9QEBDzMt7GuOoR5TKHqk4/VspMMCDBDI2z3X4JG1lq3VimSSutJhY6TYPLGa +6xf4hhjvgYXO85fMDOoTKDGmkL0VIzGcrM7U+uILtf6G2Y9qa87K0mSxCDIaVj517yS E6noS0TnwNlpyK/K7/of/ORwaMzMr6Yoyk+JXsYvp8EqiuqkZJmBAiZTSmGHGODVA9eT j0CNvxrFtlAWNHthw0/lsIwPucdS2OfNfTBkvUqhJOwVNRpv8OBxcLkipJr+DGd6FHDk RDLZnaMsCPpAsw8wP4XHKQIURL9Qr72qk758ro/ZODtjKVU/O0+xTM1GO7VHQwPFceBx +Bjw== 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=qfKxD23foxhiHV3sk7NYyRAKNjqABiYk4Q6mGAk34hFv1TZZEvtOS7dLRmifHgPct4 NiLAsH49YICLwSjf71gG3lyMf61IOFvPO7DjtqTE4KIkQ2lPxu64TCLQJk1eHHTubwFF yde+tDyHmmIcBLRNDtHC2h/8T5c5GIbfpJlyJcunvBUxniWIUT+rJ+0sTgUojzUjz9YE RfdtKQbGYK3tTVoryUlrZEupQnfxWX10T6Pm3hw0SGwf5z+Wtg4VgRyQqTgNI0z+8ogc CfEynZ0vR8uQqpyTWrw43D9WkVcXfxJ8GtjhVRvkygAC8tzd9WUna4sL1G8/a6/lAmwh bFjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Aw9Vx7v6; 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 v202-20020a6361d3000000b0046ebaed8e45si4553157pgb.62.2022.10.22.00.52.19; Sat, 22 Oct 2022 00:52:32 -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=Aw9Vx7v6; 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 S231623AbiJVHwD (ORCPT + 99 others); Sat, 22 Oct 2022 03:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231891AbiJVHte (ORCPT ); Sat, 22 Oct 2022 03:49:34 -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 6D24F2ABAAF; Sat, 22 Oct 2022 00:46:03 -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 C6CDB60AC7; Sat, 22 Oct 2022 07:42:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0881C433C1; Sat, 22 Oct 2022 07:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424571; bh=cEznBf9bvTB/4ENmafZ5o4nl4xs2vm5vB0HoS9fBxMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aw9Vx7v6lSeojtgWiboj3lTbGbteCGXfkyIHFunT9gxqjLwP3BT9MozBjmLFUW93J sdBVC3/SxmG171LK7CS6GhdN2+ZJvNs/dGu8F/vdPVyIBsTIC0q7l7Ir5t3qKEGdVa +AnLx36TXczexQizc9WHPUJP1yYSn5ahFT8Yiv7I= 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.19 194/717] nfsd: Fix a memory leak in an error handling path Date: Sat, 22 Oct 2022 09:21:13 +0200 Message-Id: <20221022072449.851687239@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373420193073632?= X-GMAIL-MSGID: =?utf-8?q?1747373420193073632?= 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;