From patchwork Mon Oct 24 11:28:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp554057wru; Mon, 24 Oct 2022 09:56:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5mOghX4JtTyYVd0lIXEjm+djm2nqJSAu1s4bpsQmPlJw2adfk/pkbeK+aiP5GCdLj5FgEB X-Received: by 2002:a63:de46:0:b0:46e:c3bd:e47d with SMTP id y6-20020a63de46000000b0046ec3bde47dmr14069441pgi.609.1666630572208; Mon, 24 Oct 2022 09:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666630572; cv=none; d=google.com; s=arc-20160816; b=mGLs9mpnxKnv1gi+RO7LpRipZbmVLtfgqz1xj+fexEWb79LdzYif7QQf0933OZd0Bf y5cnY47CEXLC+imM4CmknTnTiixZch0KIMIh2jVy4U8wM7Kbya46hDLR/qlpgX0pPwGz 1fHxBK3rm5+r+Kzk+fMJsNkwrkvtxetVjVx1hewawvt3JdS7nuDxVNlBZ7yW+qjHnmo8 0wxnSROah25DxNcP8F6pok2OJkkDTvhF8vNJXKDlsvHGGy1VMkzK+U3h0C2uXir2KHLj 6hqNDBmgZPbDgbB+c585pMS2zIAbrwRQ8EUHWRRteEExMxlmatcPmm7jAdcXJO12e3up X8qw== 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=sYCbDu6IqnoFVOJsPSZsMhhxekMSRcJvVSqwENfxYWhzsHFkC7oT4QvMfGXapcPmrm LvBJkujDmY/2UWlfeRpLsAhdlgD1EPPU67R0QWL4F4nnVWNkh8DCzctsEUzbOloY38rR I/rezMfyqvQ9UeviXQgKirBBKeHsE7HW7wODYLChUr397yz6/XVO7dQQRpuwAxpj17K9 PQsIBQZ4fLNe/z95iAphON0R5aVxnXmkfOi/O29Ji2vLZBMYe+cfaiOYx5mlB0Ok1jXS wmeA+RyuUPhMP/PYO30qupeQ5/5MX/ocCF7wNns6rJoF0mfFRP3S+5ZfspgYo1sPmKbg PhoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mT/Zphwb"; 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 n1-20020a634d41000000b0043a20d3388esi35973412pgl.321.2022.10.24.09.55.58; Mon, 24 Oct 2022 09:56:12 -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="mT/Zphwb"; 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 S232077AbiJXQrR (ORCPT + 99 others); Mon, 24 Oct 2022 12:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbiJXQpz (ORCPT ); Mon, 24 Oct 2022 12:45:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C6C319C22B; Mon, 24 Oct 2022 08:31:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1793AB818E6; Mon, 24 Oct 2022 12:39:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BAF6C433C1; Mon, 24 Oct 2022 12:39:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615161; bh=cEznBf9bvTB/4ENmafZ5o4nl4xs2vm5vB0HoS9fBxMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mT/ZphwbxvdN+OHB8ytl2xcL/mb7fWWu7dLj96jMtRtxEDsNZ9P0VJvMVcOD+I0RP hOJjocQopliAh3LnSa3JJF/PCW36iAYjhVZzJusg2pPhqPygFFp8XX1MTyuMoJIw5d sWpcwse/mwUlLmOlvu+bLlSW6YDnGQydCY/gbKto= 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.15 146/530] nfsd: Fix a memory leak in an error handling path Date: Mon, 24 Oct 2022 13:28:10 +0200 Message-Id: <20221024113051.675890096@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747588818881956212?= X-GMAIL-MSGID: =?utf-8?q?1747588818881956212?= 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;