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 0511331A8C for ; Fri, 8 Dec 2023 23:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KK36Iq+a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BE0EC433C8; Fri, 8 Dec 2023 23:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702079998; bh=UPg58Wz4ucBYZ9XevepIP3YycirRFgd2o4l6zt7Cie4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KK36Iq+aUSmr22DZbRxU01OqgemLY363GzmXTA1sCeNK846Ngp12J9t7PPwH4d+EA Ayyty3Q+dCNrPFP9uzTTBMFHGVPslApVSlZ3xcGbzDXjtRkrjFoV0FPPQPa6az348T a34naOwCGERAoBfyD7RPDtQb7iarcXQhYN0Mzck85XB6I4HQNzZW8XDuWI8xYJSWFx XiDzaPGlQFX+/HkDKYuJ9+BvmfksLw1y+CA4NqNXP1ABhGfmHvDYfyO9yDQTWhFFvU SH3ZkKGvxF1MGTKcz6D4aecCRhoCKfWD7aHjl/5x/inFrrdmzUtKpsAqi54bs6ccrb zuaRssr5F4Mtw== Date: Fri, 8 Dec 2023 15:59:57 -0800 From: Jakub Kicinski To: Dinghao Liu Cc: Ariel Elior , Manish Chopra , "David S. Miller" , Eric Dumazet , Paolo Abeni , Yuval Mintz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [v2] qed: Fix a potential use-after-free in qed_cxt_tables_alloc Message-ID: <20231208155957.088c372b@kernel.org> In-Reply-To: <20231207093606.17868-1-dinghao.liu@zju.edu.cn> References: <20231207093606.17868-1-dinghao.liu@zju.edu.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 7 Dec 2023 17:36:06 +0800 Dinghao Liu wrote: > v2: -Change the bug type from double-free to use-after-free. > -Move the null check against p_mngr->ilt_shadow to the beginning > of the function qed_ilt_shadow_free(). > -When kcalloc() fails in qed_ilt_shadow_alloc(), just return > because there is nothing to free. This refactoring is not acceptable as part of a fix, sorry. > @@ -933,6 +936,7 @@ static void qed_ilt_shadow_free(struct qed_hwfn *p_hwfn) > p_dma->virt_addr = NULL; > } > kfree(p_mngr->ilt_shadow); > + p_hwfn->p_cxt_mngr->ilt_shadow = NULL; Why do you dereference p_hwfn here? Seems more natural to use: p_mngr->ilt_shadow = NULL; since that's the exact pointer that was passed to free. -- pw-bot: cr