Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Johannes Berg
Thu, 15 Oct 2026 12:47
Re: [PATCH net-next v2 2/7] um: vector: honor virtio net hdr conversion failures
Author: Johannes Berg
Date: Thu, 15 Oct 2026 12:47
Date: Thu, 15 Oct 2026 12:47
40 lines
7892 bytes
7892 bytes
On Thu, 2026-10-15 at 08:41 -0400, Michael S. Tsirkin wrote: > virtio_net_hdr_to_skb() refuses packets whose checksum metadata > it cannot make sense of, but the vector raw transport ignored > its return value: rejected packets went on into the stack with > their metadata unvalidated. > > Propagate the failure. > > Assisted-by: LLM > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > arch/um/drivers/vector_transports.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/um/drivers/vector_transports.c b/arch/um/drivers/vector_transports.c > index e1fb2a76fdff..8b7548458663 100644 > --- a/arch/um/drivers/vector_transports.c > +++ b/arch/um/drivers/vector_transports.c > @@ -210,7 +210,9 @@ static int raw_verify_header( > return 1; > > skb_set_network_header(skb, ETH_HLEN); > - virtio_net_hdr_to_skb(skb, vheader, virtio_legacy_is_little_endian()); > + if (virtio_net_hdr_to_skb(skb, vheader, > + virtio_legacy_is_little_endian()) < 0) > + return -1; > return 0; > Seems it'd be simpler to just return virtio_net_hdr_to_skb(...); As far as I can tell, the function only returns -EINVAL or 0 (never a positive value), and the caller only cares about negative (error) or positive (no checksum needed), so that'd be equivalent? johannes
Re: [PATCH net-next v2 2/7] um: vector: honor virtio net hdr conversion failures
Author: Johannes Berg
Date: Thu, 15 Oct 2026 12:55
Date: Thu, 15 Oct 2026 12:55
53 lines
8639 bytes
8639 bytes
On Thu, 2026-10-15 at 08:52 -0400, Michael S. Tsirkin wrote: > On Thu, Oct 15, 2026 at 02:47:01PM +0200, Johannes Berg wrote: > > On Thu, 2026-10-15 at 08:41 -0400, Michael S. Tsirkin wrote: > > > virtio_net_hdr_to_skb() refuses packets whose checksum metadata > > > it cannot make sense of, but the vector raw transport ignored > > > its return value: rejected packets went on into the stack with > > > their metadata unvalidated. > > > > > > Propagate the failure. > > > > > > Assisted-by: LLM > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > > --- > > > arch/um/drivers/vector_transports.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/arch/um/drivers/vector_transports.c b/arch/um/drivers/vector_transports.c > > > index e1fb2a76fdff..8b7548458663 100644 > > > --- a/arch/um/drivers/vector_transports.c > > > +++ b/arch/um/drivers/vector_transports.c > > > @@ -210,7 +210,9 @@ static int raw_verify_header( > > > return 1; > > > > > > skb_set_network_header(skb, ETH_HLEN); > > > - virtio_net_hdr_to_skb(skb, vheader, virtio_legacy_is_little_endian()); > > > + if (virtio_net_hdr_to_skb(skb, vheader, > > > + virtio_legacy_is_little_endian()) < 0) > > > + return -1; > > > return 0; > > > > > > > Seems it'd be simpler to just > > > > return virtio_net_hdr_to_skb(...); > > > > As far as I can tell, the function only returns -EINVAL or 0 (never a > > positive value), and the caller only cares about negative (error) or > > positive (no checksum needed), so that'd be equivalent? > > > > johannes > > if raw_verify_header can safely return any errno - i did not want to > audit it. You already used an LLM and still didn't want to? ;-) I checked briefly (by hand) and it seems fine, it's assigned to the function pointer, which only has two callers on the _kern.c side. johannes
Re: [PATCH net-next v2 2/7] um: vector: honor virtio net hdr conversion failures
Author: Johannes Berg
Date: Fri, 16 Oct 2026 09:44
Date: Fri, 16 Oct 2026 09:44
72 lines
9478 bytes
9478 bytes
On Fri, 2026-10-16 at 05:43 -0400, Michael S. Tsirkin wrote:
>
> > > > > - virtio_net_hdr_to_skb(skb, vheader, virtio_legacy_is_little_endian());
> > > > > + if (virtio_net_hdr_to_skb(skb, vheader,
> > > > > + virtio_legacy_is_little_endian()) < 0)
> > > > > + return -1;
> > > > > return 0;
> > > > >
> > > >
> > > > Seems it'd be simpler to just
> > > >
> > > > return virtio_net_hdr_to_skb(...);
> > > >
> > > > As far as I can tell, the function only returns -EINVAL or 0 (never a
> > > > positive value), and the caller only cares about negative (error) or
> > > > positive (no checksum needed), so that'd be equivalent?
> > > >
> > > > johannes
> > >
> > > if raw_verify_header can safely return any errno - i did not want to
> > > audit it.
> >
> > You already used an LLM and still didn't want to? ;-)
> >
> > I checked briefly (by hand) and it seems fine, it's assigned to the
> > function pointer, which only has two callers on the _kern.c side.
> >
> > johannes
>
>
> header_check = vp->verify_header(
> mmsg_vector->msg_hdr.msg_iov->iov_base,
> skb,
> vp
> );
> if (header_check < 0) {
> /* Overlay header failed to verify - discard.
> * We can actually keep this skb and reuse it,
> * but that will make the prep logic too
> * complex.
> */
> dev_kfree_skb_irq(skb);
> vp->estats.rx_encaps_errors++;
> (*skbuff_vector) = NULL;
> mmsg_vector++;
> skbuff_vector++;
> continue;
> }
> if (header_check > 0) {
> vp->estats.rx_csum_offload_good++;
> skb->ip_summed = CHECKSUM_UNNECESSARY;
> }
>
>
>
> so any negative is fine, but if we return 1 then it will force to CHECKSUM_UNNECESSARY
> which I am not sure is what was intended?
>
Right, but virtio_net_hdr_to_skb() cannot return 1, only 0 on success
and -ERROR on failure?
johannes
Re: [PATCH net-next v2 2/7] um: vector: honor virtio net hdr conversion failures
Author: Johannes Berg
Date: Fri, 16 Oct 2026 09:49
Date: Fri, 16 Oct 2026 09:49
14 lines
7417 bytes
7417 bytes
On Fri, 2026-10-16 at 05:47 -0400, Michael S. Tsirkin wrote: > > > > > Right, but virtio_net_hdr_to_skb() cannot return 1, only 0 on success > > and -ERROR on failure? > > After this patchset, it can, to signal slow path software checksum. > I'm changing callers first so that changing the function itself > does not break bisect. I should mention this in the commit log. Oh, OK, that I clearly missed, but also was only CC'ed on patches 2 and 3 :) johannes
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads