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 9AB8617B404; Wed, 3 Jul 2024 11:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720005974; cv=none; b=jG0FnfPZiwO68sQcy2q0gRXrbTmE2eFMU5pSe1v4ySpBLPIF/I75JwTjxPuciSoc2W6wo/WzPyhifgoWaG3JpIhIv1y17O+lVsEmZ+IT7fWAjMI9MENZ8J8qvFrCQCUJ9V33Jj6bKam4PSgwgCUp26SoBp8Zy09G8xA+SFWjgII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720005974; c=relaxed/simple; bh=W4qNDTKHAOF140uf3BpTYvmDc9PV5KOlzkln9Tmbu0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pGTrSZ71Bf6coMmioW0VKfyfsEhlkTVahuWGOmV7k/Gv/jw5ib6i2Y3tDlWWrrBxKD6Bii6+t9fuqPAV8JryxoeM4EX1G3GEpJqjWRTCbMiIGSul4KIfEKdEoI3OaY33PneCWrzEMt8Ja/Uh7N82YAvkBEV/UcE0aAXyJCBD79g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DBhI8tpY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DBhI8tpY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20A75C2BD10; Wed, 3 Jul 2024 11:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720005974; bh=W4qNDTKHAOF140uf3BpTYvmDc9PV5KOlzkln9Tmbu0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBhI8tpY5LLBQw6YWth66K3r5LaYPS0oF3WkbDq5F7pTvuCuM8R0HCRTJc5udWi0I TmRnai3PZ8GxOxCKECSyARxT2ZVrFMiOB9sgxKaMqvR3k1+shGaD4tdVnzKV/4SYkE 0en1R7p7GIgVoPhEVhHDDPvkxpcKVUQAgvHWaUsQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shailend Chand , Ziwei Xiao , Harshitha Ramamurthy , Praveen Kaligineedi , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 259/356] gve: Clear napi->skb before dev_kfree_skb_any() Date: Wed, 3 Jul 2024 12:39:55 +0200 Message-ID: <20240703102922.915220386@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240703102913.093882413@linuxfoundation.org> References: <20240703102913.093882413@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev 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: Ziwei Xiao [ Upstream commit 6f4d93b78ade0a4c2cafd587f7b429ce95abb02e ] gve_rx_free_skb incorrectly leaves napi->skb referencing an skb after it is freed with dev_kfree_skb_any(). This can result in a subsequent call to napi_get_frags returning a dangling pointer. Fix this by clearing napi->skb before the skb is freed. Fixes: 9b8dd5e5ea48 ("gve: DQO: Add RX path") Cc: stable@vger.kernel.org Reported-by: Shailend Chand Signed-off-by: Ziwei Xiao Reviewed-by: Harshitha Ramamurthy Reviewed-by: Shailend Chand Reviewed-by: Praveen Kaligineedi Link: https://lore.kernel.org/r/20240612001654.923887-1-ziweixiao@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_rx_dqo.c b/drivers/net/ethernet/google/gve/gve_rx_dqo.c index 630f42a3037b0..8756f9cbd631e 100644 --- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c +++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c @@ -465,11 +465,13 @@ static void gve_rx_skb_hash(struct sk_buff *skb, skb_set_hash(skb, le32_to_cpu(compl_desc->hash), hash_type); } -static void gve_rx_free_skb(struct gve_rx_ring *rx) +static void gve_rx_free_skb(struct napi_struct *napi, struct gve_rx_ring *rx) { if (!rx->ctx.skb_head) return; + if (rx->ctx.skb_head == napi->skb) + napi->skb = NULL; dev_kfree_skb_any(rx->ctx.skb_head); rx->ctx.skb_head = NULL; rx->ctx.skb_tail = NULL; @@ -690,7 +692,7 @@ int gve_rx_poll_dqo(struct gve_notify_block *block, int budget) err = gve_rx_dqo(napi, rx, compl_desc, rx->q_num); if (err < 0) { - gve_rx_free_skb(rx); + gve_rx_free_skb(napi, rx); u64_stats_update_begin(&rx->statss); if (err == -ENOMEM) rx->rx_skb_alloc_fail++; @@ -733,7 +735,7 @@ int gve_rx_poll_dqo(struct gve_notify_block *block, int budget) /* gve_rx_complete_skb() will consume skb if successful */ if (gve_rx_complete_skb(rx, napi, compl_desc, feat) != 0) { - gve_rx_free_skb(rx); + gve_rx_free_skb(napi, rx); u64_stats_update_begin(&rx->statss); rx->rx_desc_err_dropped_pkt++; u64_stats_update_end(&rx->statss); -- 2.43.0