* [PATCH net] net: Clear old fragment checksum value in napi_get_frags
@ 2025-02-21 16:14 Mohammad Heib
2025-02-24 22:34 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Mohammad Heib @ 2025-02-21 16:14 UTC (permalink / raw)
To: netdev; +Cc: Mohammad Heib
In certain cases, napi_get_frags() returns an skb that points to an old
received fragment, This skb may have its skb->ip_summed, csum, and other
fields set from previous fragment handling.
Some network drivers set skb->ip_summed to either CHECKSUM_COMPLETE or
CHECKSUM_UNNECESSARY when getting skb from napi_get_frags(), while
others only set skb->ip_summed when RX checksum offload is enabled on
the device, and do not set any value for skb->ip_summed when hardware
checksum offload is disabled, assuming that the skb->ip_summed
initiated to zero by napi_get_frags.
This inconsistency sometimes leads to checksum validation issues in the
upper layers of the network stack.
To resolve this, this patch clears the skb->ip_summed value for each skb
returned by napi_get_frags(), ensuring that the caller is responsible
for setting the correct checksum status. This eliminates potential
checksum validation issues caused by improper handling of
skb->ip_summed.
Fixes: 76620aafd66f ("gro: New frags interface to avoid copying shinfo")
Signed-off-by: Mohammad Heib <mheib@redhat.com>
---
net/core/gro.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/gro.c b/net/core/gro.c
index 78b320b63174..e98007d8f26f 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -675,6 +675,8 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
napi->skb = skb;
skb_mark_napi_id(skb, napi);
}
+ } else {
+ skb->ip_summed = CHECKSUM_NONE;
}
return skb;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: Clear old fragment checksum value in napi_get_frags
2025-02-21 16:14 [PATCH net] net: Clear old fragment checksum value in napi_get_frags Mohammad Heib
@ 2025-02-24 22:34 ` Jakub Kicinski
2025-02-25 11:50 ` Mohammad Heib
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2025-02-24 22:34 UTC (permalink / raw)
To: Mohammad Heib; +Cc: netdev
On Fri, 21 Feb 2025 18:14:05 +0200 Mohammad Heib wrote:
> In certain cases, napi_get_frags() returns an skb that points to an old
> received fragment, This skb may have its skb->ip_summed, csum, and other
> fields set from previous fragment handling.
>
> Some network drivers set skb->ip_summed to either CHECKSUM_COMPLETE or
> CHECKSUM_UNNECESSARY when getting skb from napi_get_frags(), while
> others only set skb->ip_summed when RX checksum offload is enabled on
> the device, and do not set any value for skb->ip_summed when hardware
> checksum offload is disabled, assuming that the skb->ip_summed
> initiated to zero by napi_get_frags.
>
> This inconsistency sometimes leads to checksum validation issues in the
> upper layers of the network stack.
>
> To resolve this, this patch clears the skb->ip_summed value for each skb
> returned by napi_get_frags(), ensuring that the caller is responsible
> for setting the correct checksum status. This eliminates potential
> checksum validation issues caused by improper handling of
> skb->ip_summed.
Could you give an example of a driver where this may happen?
Otherwise the commit message reads too hypothetical.
> Fixes: 76620aafd66f ("gro: New frags interface to avoid copying shinfo")
> Signed-off-by: Mohammad Heib <mheib@redhat.com>
> ---
> net/core/gro.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/core/gro.c b/net/core/gro.c
> index 78b320b63174..e98007d8f26f 100644
> --- a/net/core/gro.c
> +++ b/net/core/gro.c
> @@ -675,6 +675,8 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
> napi->skb = skb;
> skb_mark_napi_id(skb, napi);
> }
> + } else {
> + skb->ip_summed = CHECKSUM_NONE;
> }
> return skb;
> }
I think this belongs in napi_reuse_skb(), doesn't it ?
Please make sure you CC maintainers on v2, especially Eric.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: Clear old fragment checksum value in napi_get_frags
2025-02-24 22:34 ` Jakub Kicinski
@ 2025-02-25 11:50 ` Mohammad Heib
0 siblings, 0 replies; 3+ messages in thread
From: Mohammad Heib @ 2025-02-25 11:50 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev
On Mon, Feb 24, 2025 at 02:34:30PM -0800, Jakub Kicinski wrote:
> On Fri, 21 Feb 2025 18:14:05 +0200 Mohammad Heib wrote:
> > In certain cases, napi_get_frags() returns an skb that points to an old
> > received fragment, This skb may have its skb->ip_summed, csum, and other
> > fields set from previous fragment handling.
> >
> > Some network drivers set skb->ip_summed to either CHECKSUM_COMPLETE or
> > CHECKSUM_UNNECESSARY when getting skb from napi_get_frags(), while
> > others only set skb->ip_summed when RX checksum offload is enabled on
> > the device, and do not set any value for skb->ip_summed when hardware
> > checksum offload is disabled, assuming that the skb->ip_summed
> > initiated to zero by napi_get_frags.
> >
> > This inconsistency sometimes leads to checksum validation issues in the
> > upper layers of the network stack.
> >
> > To resolve this, this patch clears the skb->ip_summed value for each skb
> > returned by napi_get_frags(), ensuring that the caller is responsible
> > for setting the correct checksum status. This eliminates potential
> > checksum validation issues caused by improper handling of
> > skb->ip_summed.
>
> Could you give an example of a driver where this may happen?
> Otherwise the commit message reads too hypothetical.
>
Hi Jakub,
Thank you so much for your review.
all the comments were addressed in v3.
Thanks,
> > Fixes: 76620aafd66f ("gro: New frags interface to avoid copying shinfo")
> > Signed-off-by: Mohammad Heib <mheib@redhat.com>
> > ---
> > net/core/gro.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/net/core/gro.c b/net/core/gro.c
> > index 78b320b63174..e98007d8f26f 100644
> > --- a/net/core/gro.c
> > +++ b/net/core/gro.c
> > @@ -675,6 +675,8 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)
> > napi->skb = skb;
> > skb_mark_napi_id(skb, napi);
> > }
> > + } else {
> > + skb->ip_summed = CHECKSUM_NONE;
> > }
> > return skb;
> > }
>
> I think this belongs in napi_reuse_skb(), doesn't it ?
>
> Please make sure you CC maintainers on v2, especially Eric.
> --
> pw-bot: cr
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-25 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 16:14 [PATCH net] net: Clear old fragment checksum value in napi_get_frags Mohammad Heib
2025-02-24 22:34 ` Jakub Kicinski
2025-02-25 11:50 ` Mohammad Heib
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).