Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1924463rdb; Sun, 24 Dec 2023 07:51:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKVKgA6n+RJVkpA68iALsp900I1CHMAGgwIwtjmd7UogIfIaNVb9sOG0CUo0R63mRTXiac X-Received: by 2002:a05:620a:5582:b0:781:1185:d9b4 with SMTP id vq2-20020a05620a558200b007811185d9b4mr5811818qkn.27.1703433113840; Sun, 24 Dec 2023 07:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703433113; cv=none; d=google.com; s=arc-20160816; b=K00eZ8nZChmkDjHy4hOOkwNyGcv/P+VVXNJBhfWCqRreQs1miMwqrId0lWoxZSiyPO Sw9OW0mJt+XiFHTP93+YtfVv1W1GpxX/H2lp0J7IDztZB1Do2rqt+kxa0vX7TPxouT3v AIUZawD8PTF+9KKzY08kFK/RyTNj6pnKu4dMbGummuo4lI3md19FHILYS0YKjuGSDOv2 V4bnTjERJJplKHxPx/30ATxPOUR+aOhp3kS63R50HMNWWpSzJDVmkDK0SpnnxLv0+z9m ganmKmRD+NQjqs3CUJltfmX4WrI8gf8tquu26TbkZiqYOP9/10G7A+FaVi8uh9oBT7Sh aiIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=S64yTUhmrEtRSJEwSIHYNg0cRCkHCahSRGvOUVhqqgI=; fh=pSDwFNWo5eFhWplobM9Q5SeQsOzAfF67ext7vt1lI3Q=; b=W4wR0ss3SMivD75bkztN8B7wGdiyK2WmNghk7G7GcQ7g5cEF9QdZVrYCYDrzuMS2JR LLBasK3dwyqxLOGy4WZStSbMWqaoH20iNJ8I8dWbdjucK2X8cB+6A4cUvyTY2SspKRH6 yuOGNc9qbH4TS2wzvDGtuy9I0e0D5jwcq/MHbqs1hTXfNHWzSOWPeK6HENHdCR9q6jrF t4ZkWfjoc93stUmjB+EQRyQ+EctCtKZqkUn40U1/ncWK+OI+tFkjgcCqGqyyRxWqF/ax 91TQYjiPML4xPazSNK0AJIhgFdk0wWBU2JubtI20T6eZRu+sbsFHxyxFI7HkB7eHCwT2 +7fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dUVI7Mfz; spf=pass (google.com: domain of linux-kernel+bounces-10755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p21-20020a05620a22f500b0077bc48f0627si8322528qki.735.2023.12.24.07.51.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 07:51:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dUVI7Mfz; spf=pass (google.com: domain of linux-kernel+bounces-10755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 966C21C2140D for ; Sun, 24 Dec 2023 15:51:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BA0B79E5; Sun, 24 Dec 2023 15:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dUVI7Mfz" X-Original-To: linux-kernel@vger.kernel.org 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 7C0FBC8D2; Sun, 24 Dec 2023 15:51:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7B78C433C8; Sun, 24 Dec 2023 15:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703433102; bh=a8AVVMA9i8/vIRkHwBif/ih1iJwLQCXmGBNA6/LCdO0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dUVI7Mfz84DXVBs41CT4Trzet+epNbKLETOcL/fBrzxi7aOSIlalfRJbkfqvP+qwu 8QTyN21Ignp0QH0w/zyiZ9G1T2udtO/2Xgx00nTHN/dyVUdwjaibalj11WtL5q7b2a +csyz8RZzr6qfK/xRRs+lC3rnRcIsT0fD3SyorF31VUXrLk8wJJ8P5xugCms1TOeIt x7teiy/vpJf3QO1uBYs2HagMrAtCXWFU/QeDeIhmqkR+GF4X4G3lBcW3TvEi/yEypT nGA8e8lQRsaMDzUfklZ+OLsv84k7F1xHr15QIFg7e6flOCkXfYTO6bM21VycgThXXJ vL49EvioitnSA== Date: Sun, 24 Dec 2023 15:51:38 +0000 From: Simon Horman To: Zhipeng Lu Cc: Edward Cree , Martin Habets , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] [v2] sfc: fix a double-free bug in efx_probe_filters Message-ID: <20231224155138.GA228041@kernel.org> References: <20231222154952.3531636-1-alexious@zju.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231222154952.3531636-1-alexious@zju.edu.cn> On Fri, Dec 22, 2023 at 11:49:52PM +0800, Zhipeng Lu wrote: > 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. > --- Everything below the line above (---) will be omitted from the commit message when the patch is applied. > Changelog: > > v2: Correct the call-chain description in commit message and change > patch subject. > > Fixes: a9dc3d5612ce ("sfc_ef100: RX filter table management and related gubbins") > Signed-off-by: Zhipeng Lu > Reviewed-by: Simon Horman > Reviewed-by: Edward Cree Hi Zhipeng Lu, I think that your Signed-off-by should go last when you post a patch. And the Changelog should go below the (first set of) scissors (---). > --- > drivers/net/ethernet/sfc/rx_common.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) With the above in mind, I think you want something like: 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 --- Changelog: v2: Correct the call-chain description in commit message and change patch subject. --- drivers/net/ethernet/sfc/rx_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- pw-bot: changes-requested