lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 7 Feb 2024 10:54:35 +0800
From: Liang Chen <liangchen.linux@...il.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: Jesper Dangaard Brouer <hawk@...nel.org>, mst@...hat.com, jasowang@...hat.com, 
	xuanzhuo@...ux.alibaba.com, hengqi@...ux.alibaba.com, davem@...emloft.net, 
	edumazet@...gle.com, kuba@...nel.org, netdev@...r.kernel.org, 
	virtualization@...ts.linux.dev, linux-kernel@...r.kernel.org, 
	bpf@...r.kernel.org, john.fastabend@...il.com, daniel@...earbox.net, 
	ast@...nel.org
Subject: Re: [PATCH net-next v5] virtio_net: Support RX hash XDP hint

On Tue, Feb 6, 2024 at 6:44 PM Paolo Abeni <pabeni@...hat.com> wrote:
>
> On Sat, 2024-02-03 at 10:56 +0800, Liang Chen wrote:
> > On Sat, Feb 3, 2024 at 12:20 AM Jesper Dangaard Brouer <hawk@...nel.org> wrote:
> > > On 02/02/2024 13.11, Liang Chen wrote:
> [...]
> > > > @@ -1033,6 +1039,16 @@ static void put_xdp_frags(struct xdp_buff *xdp)
> > > >       }
> > > >   }
> > > >
> > > > +static void virtnet_xdp_save_rx_hash(struct virtnet_xdp_buff *virtnet_xdp,
> > > > +                                  struct net_device *dev,
> > > > +                                  struct virtio_net_hdr_v1_hash *hdr_hash)
> > > > +{
> > > > +     if (dev->features & NETIF_F_RXHASH) {
> > > > +             virtnet_xdp->hash_value = hdr_hash->hash_value;
> > > > +             virtnet_xdp->hash_report = hdr_hash->hash_report;
> > > > +     }
> > > > +}
> > > > +
> > >
> > > Would it be possible to store a pointer to hdr_hash in virtnet_xdp_buff,
> > > with the purpose of delaying extracting this, until and only if XDP
> > > bpf_prog calls the kfunc?
> > >
> >
> > That seems to be the way v1 works,
> > https://lore.kernel.org/all/20240122102256.261374-1-liangchen.linux@gmail.com/
> > . But it was pointed out that the inline header may be overwritten by
> > the xdp prog, so the hash is copied out to maintain its integrity.
>
> Why? isn't XDP supposed to get write access only to the pkt
> contents/buffer?
>

Normally, an XDP program accesses only the packet data. However,
there's also an XDP RX Metadata area, referenced by the data_meta
pointer. This pointer can be adjusted with bpf_xdp_adjust_meta to
point somewhere ahead of the data buffer, thereby granting the XDP
program access to the virtio header located immediately before the
packet data.

Thanks,
Liang

> if the XDP program can really change the virtio_net_hdr, that looks
> potentially dangerous/bug prone regardless of this patch.
>
> Thanks,
>
> Paolo
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ