Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2865788rwb; Mon, 15 Aug 2022 12:55:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lSXBw8JP6/TB4XqDaq/RDBNB2PScKic1N+/JsNaZcD6f8RG24nP8nTI2WrqW8jGZwCZPW X-Received: by 2002:a17:907:7623:b0:730:c378:b82e with SMTP id jy3-20020a170907762300b00730c378b82emr11040553ejc.372.1660593311583; Mon, 15 Aug 2022 12:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593311; cv=none; d=google.com; s=arc-20160816; b=gXC8kI8df68GKnPFgWhoSQzNJhwvn2mzIVuttEdYeFYVks2B8UpUxzkLC7dVGp8IVk ATaWBLERCblVRwaZGomZVRreycj8PXZW1r2IsGZBRDnmV2qnHI70UbYZChDl4mV6jCmr uKwEg5GRgObAk0Ql0ljFfXKkUzqwJU988vfptKvFI1kQv0K8tuLfeLJd1rtMKDjoA0jU H25Ues66N0wS6Rqq6yeQAzusDtg+naJnaOeko+DrRYPfF4oXBB4f28FlT00Af/EzcTrC fmV5TXRZZrfEZCxowyoq8h5vh84IhfWl9lDT+/jfKx6jx4zpvFL7nMJTuHMxROdgUPv5 2aXA== 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=uaQjkwR5Bfs4f87VMZ4I8trbruJUWQy4lTfbZi3aBuQ=; b=vQ8xs0fPlGlD/1uAG/J88MUDiTSopXzyc7t2NjEjzP4ylrwgzs6MoJu97fmjSV8WJQ TslyivABoNtm5zYrzo8eonBP6+EIGnGvNndDVenJZK3ymgCH1ejnaqHqIvkA6jmIzN+J jLmPdKzDBBDC72Nc8Ru5c+px434UqUHGV/y1Jqpo5MpLOVA657zGGO5jXCsMuxaMmzub A0Hwa1MXJT8BOx5THdEDGy3PV8LHx1TVynZtOrq8CQUVnJQknMQKost6Bj1RWq6p+VG2 ijB1RnKWurVWmjwpVdllijhOgd4f8WTC17IxYeQpBcF6VSLGRALRmM2WI5jmnD3wR9JK pjVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ai/7EuNT"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a056402348800b0043e18c7dee7si8842482edc.634.2022.08.15.12.54.46; Mon, 15 Aug 2022 12:55:11 -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="Ai/7EuNT"; 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 S241224AbiHOSWd (ORCPT + 99 others); Mon, 15 Aug 2022 14:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241079AbiHOSWE (ORCPT ); Mon, 15 Aug 2022 14:22:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C052A42A; Mon, 15 Aug 2022 11:17:11 -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 ADCD3B81077; Mon, 15 Aug 2022 18:17:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06C61C433C1; Mon, 15 Aug 2022 18:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587427; bh=7cyjgV5neVvXvAMFqPTigQYH2UGTWOf11a0mfS7prpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ai/7EuNTfVcx3ugiD+eXmzUncAnQstWqS+ryLUKNmB1uB9xSkjE8RAif/jgi5tc8j 21T75j8sFqtmuedbFJzv/PXcg6VEE+VJJ+fixyfNikw6ZrvjWYddwIaBl+Wx/og7se db3ncj0C1UfHU5K1wAomgTnW/0Um9xYIEW6K0YDo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namjae Jeon , Hyunchul Lee , Steve French , zdi-disclosures@trendmicro.com Subject: [PATCH 5.15 082/779] ksmbd: fix memory leak in smb2_handle_negotiate Date: Mon, 15 Aug 2022 19:55:26 +0200 Message-Id: <20220815180340.793635570@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 From: Namjae Jeon commit aa7253c2393f6dcd6a1468b0792f6da76edad917 upstream. The allocated memory didn't free under an error path in smb2_handle_negotiate(). Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Cc: stable@vger.kernel.org Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17815 Signed-off-by: Namjae Jeon Reviewed-by: Hyunchul Lee Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/ksmbd/smb2pdu.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -1146,12 +1146,16 @@ int smb2_handle_negotiate(struct ksmbd_w status); rsp->hdr.Status = status; rc = -EINVAL; + kfree(conn->preauth_info); + conn->preauth_info = NULL; goto err_out; } rc = init_smb3_11_server(conn); if (rc < 0) { rsp->hdr.Status = STATUS_INVALID_PARAMETER; + kfree(conn->preauth_info); + conn->preauth_info = NULL; goto err_out; }