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 D1AD9143C4A; Wed, 19 Jun 2024 13:02:25 +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=1718802145; cv=none; b=aa0MNi3uByzVEwFuV3Dd5HS0tnLIZ+m5+mJRDbGLOi60uqYbisXaiSXky4xCtiGdNJd3x8v4bUGbnx9tMSnG9+YMKZfvGNI1y4tr1QixP23tTdfuaQFAjxCWEfHiUMwXfy5quNrzWd8V20pNT29SlXGxcsass/H0F2SUP7Y/sWI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718802145; c=relaxed/simple; bh=O+gUPzujCZZ8cj+E9fQuIDuV0I6okX+CG+N9NJcnZR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=irj5VzU+xVQLcqLO0lI/DsUSF7jAIMf3D5YM6LDtID2GuCvFaV4Qy5/qt/GwFR14C03wUwCBahLImhDn6jWc5nY2gmrmf3xmxLlsUj5WuDI0VWnkiBrjZw5WIK1dg2+iaEnLnvj4e5JHXSIu9qirsK7EPWLqU3YqWKVlLa02Dqg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gzvG5gR9; 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="gzvG5gR9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54E0EC2BBFC; Wed, 19 Jun 2024 13:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718802145; bh=O+gUPzujCZZ8cj+E9fQuIDuV0I6okX+CG+N9NJcnZR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzvG5gR9UFvvXOkdgfl2mWZjbc8X7URCa4JoVp9lwBPvFc3mz9ZrX10fOLcQyfjKr OSxSM9HC+bPu5QwXKltfFR5mFXy8rCRecUR8zUNtfAYeoY3ydKOBtkJMTc+tM67OkU pngyYtx0leTrOyzGdagRiOe8yisq2zdTTE2Z8cNI= 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 Subject: [PATCH 6.6 098/267] gve: Clear napi->skb before dev_kfree_skb_any() Date: Wed, 19 Jun 2024 14:54:09 +0200 Message-ID: <20240619125610.115079520@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619125606.345939659@linuxfoundation.org> References: <20240619125606.345939659@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ziwei Xiao commit 6f4d93b78ade0a4c2cafd587f7b429ce95abb02e upstream. 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: Greg Kroah-Hartman --- drivers/net/ethernet/google/gve/gve_rx_dqo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c +++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c @@ -506,11 +506,13 @@ static void gve_rx_skb_hash(struct sk_bu 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; @@ -783,7 +785,7 @@ int gve_rx_poll_dqo(struct gve_notify_bl 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++; @@ -826,7 +828,7 @@ int gve_rx_poll_dqo(struct gve_notify_bl /* 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);