From patchwork Mon Oct 24 11:29:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp434800wru; Mon, 24 Oct 2022 05:53:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/VfRNQ4kasbyAJ1Uc3osSE7o6l7tyaIsVdVvpUVsS+QiRgpdBcNAq8C1FVdtRhv0UvjlS X-Received: by 2002:a17:906:5d04:b0:722:f46c:b891 with SMTP id g4-20020a1709065d0400b00722f46cb891mr27199765ejt.4.1666615969935; Mon, 24 Oct 2022 05:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615969; cv=none; d=google.com; s=arc-20160816; b=0cDrHrbDtjuUiU9Izo2ZhQYapGkBLg6vVRv4vMjLzPPiV4BvNBfTigEz9NH1eXuTfy dEGcgDBP7IBkdDlNpB+Jd9WGhb3UGh4W1SHqNjdqvSF8WVKe8q8QIANAhoXrMhUy6YlY aIkAw0Bv1F9RWNFyrAd9DbpUV7IlaeMH8Th6EAq+Rrvy4VIvrlqlID4H20bz/j9h1/fe NRZDe4GKrdBCwfCmvdaP1N+TA90f8TIlvj6LE58d63O6ZHceOim18VTd51HO+qGe4O42 4OalSlvbFcJyoymczkY/7HEgA8KLWR+ii0O9+KGFkmqoT3ls+HfghgrDb3vy/FR6t9Bi HS5Q== 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=V7mOAfbKi8Oqp9UbcnpPxdve997h5q3HBoWYuX4ZO3M=; b=hv0pmd1/Np0s1WcJlwgPTh+MldhTnrXhgXa/CsvJX5u1ktVNigZA4gCVYPEHrL3DTl V7lyqXSTA3lBwqGH39xXyJD9HMR/3ONdP+UpCr/fCJzZwH7qPRxsEzv8MfHqFH71p/kP 0n1nQRHsWk+ONR9X79HVPJCp5ievVdYIzWenrP2kxLZVUcbWq7mf0HiYpHzPxyh1pwGp jzAzDUFKctJNzy1BcqbjBvgRMno6mlrGqAcOOEgUT52QL0JZdM5WNWWwM7nG0fc+jZld CRv8rjbtYlddwW0z3qV/K+005m4EEo3JdxzPxNNRXqybOdbVluf2C7mQzJuSnt67taJK yr+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lQvg/zAq"; 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 t8-20020a056402524800b00461f0d84ee1si674544edd.228.2022.10.24.05.52.25; Mon, 24 Oct 2022 05:52:49 -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="lQvg/zAq"; 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 S234192AbiJXMt6 (ORCPT + 99 others); Mon, 24 Oct 2022 08:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234574AbiJXMpI (ORCPT ); Mon, 24 Oct 2022 08:45:08 -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 2504A18B3F; Mon, 24 Oct 2022 05:09:38 -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 8E32061280; Mon, 24 Oct 2022 12:08:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A026BC433D6; Mon, 24 Oct 2022 12:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613319; bh=f5/ry2w4/EIE/Rvgacwxb1aOJVW3QyhE+7Q0rNa4NA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQvg/zAqOna8+ABd2AeW/3rjf6CsKXJpHtPVUypMK87vd4WD7wlxwEH071NNOFCco JvuLP5sdDdF/C84R1nXuLlfiBTHj0L5tyxd7LyaLcNDoYzm3IbiBEZNkg67505CKoh cuYcfyAERM6QeuMgFLfTJmMIFpNk1+V2JGTRPmOo= 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.4 062/255] nfsd: Fix a memory leak in an error handling path Date: Mon, 24 Oct 2022 13:29:32 +0200 Message-Id: <20221024113004.576442802@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573507422467794?= X-GMAIL-MSGID: =?utf-8?q?1747573507422467794?= 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 7d408957ed62..14463e107918 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -825,8 +825,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;