From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3280F1846; Sat, 13 Jan 2024 10:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1fUR9E2P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98D3DC433C7; Sat, 13 Jan 2024 10:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705140082; bh=s5V6z+FNnHic6nCzJ0cU68M9uWRHcMd/THX2G3S0O3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1fUR9E2Py8tCuVGn6U24sFHWi72jANJ91bKrKT+sMDYU9yEtG8guQlXPOwinPBYye PS5/PuDJO38jyn5bE3/tg4w+D7LOkyqsEQrdkg1hWHlTSchwx36UVho7I3tCwnNYM6 c+AgPeEwh46eHa3DwVLRy40cWq1qdH3vU3QmERcU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Simon Horman , Edward Cree , Zhipeng Lu , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 23/59] sfc: fix a double-free bug in efx_probe_filters Date: Sat, 13 Jan 2024 10:49:54 +0100 Message-ID: <20240113094210.021820384@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240113094209.301672391@linuxfoundation.org> References: <20240113094209.301672391@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhipeng Lu [ Upstream commit d5a306aedba34e640b11d7026dbbafb78ee3a5f6 ] In efx_probe_filters, the channel->rps_flow_id is freed in a efx_for_each_channel marco when success equals to 0. However, after the following call chain: ef100_net_open |-> efx_probe_filters |-> ef100_net_stop |-> efx_remove_filters The channel->rps_flow_id is freed again in the efx_for_each_channel of efx_remove_filters, triggering a double-free bug. Fixes: a9dc3d5612ce ("sfc_ef100: RX filter table management and related gubbins") Reviewed-by: Simon Horman Reviewed-by: Edward Cree Signed-off-by: Zhipeng Lu Link: https://lore.kernel.org/r/20231225112915.3544581-1-alexious@zju.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/sfc/rx_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c index a804c754cd7d0..0f2d6efdbba1c 100644 --- a/drivers/net/ethernet/sfc/rx_common.c +++ b/drivers/net/ethernet/sfc/rx_common.c @@ -837,8 +837,10 @@ int efx_probe_filters(struct efx_nic *efx) } if (!success) { - efx_for_each_channel(channel, efx) + efx_for_each_channel(channel, efx) { kfree(channel->rps_flow_id); + channel->rps_flow_id = NULL; + } efx->type->filter_table_remove(efx); rc = -ENOMEM; goto out_unlock; -- 2.43.0