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]
Message-ID: <Y2ABb+G+ykcUd413@lunn.ch>
Date:   Mon, 31 Oct 2022 18:10:07 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Shenwei Wang <shenwei.wang@....com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jesper Dangaard Brouer <hawk@...nel.org>,
        John Fastabend <john.fastabend@...il.com>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        imx@...ts.linux.dev, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v2 1/1] net: fec: add initial XDP support

> +static int fec_enet_bpf(struct net_device *dev, struct netdev_bpf *bpf)
> +{
> +	struct fec_enet_private *fep = netdev_priv(dev);
> +	bool is_run = netif_running(dev);
> +	struct bpf_prog *old_prog;
> +	unsigned int dsize;
> +	int i;
> +
> +	switch (bpf->command) {
> +	case XDP_SETUP_PROG:
> +		if (is_run) {
> +			napi_disable(&fep->napi);
> +			netif_tx_disable(dev);
> +		}
> +
> +		old_prog = xchg(&fep->xdp_prog, bpf->prog);
> +
> +		/* Update RX ring size */
> +		dsize = fep->bufdesc_ex ? sizeof(struct bufdesc_ex) :
> +			sizeof(struct bufdesc);
> +		for (i = 0; i < fep->num_rx_queues; i++) {
> +			struct fec_enet_priv_rx_q *rxq = fep->rx_queue[i];
> +			struct bufdesc *cbd_base;
> +			unsigned int size;
> +
> +			cbd_base = rxq->bd.base;
> +			if (bpf->prog)
> +				rxq->bd.ring_size = XDP_RX_RING_SIZE;
> +			else
> +				rxq->bd.ring_size = RX_RING_SIZE;
> +			size = dsize * rxq->bd.ring_size;
> +			cbd_base = (struct bufdesc *)(((void *)cbd_base) + size);
> +			rxq->bd.last = (struct bufdesc *)(((void *)cbd_base) - dsize);

This does not look safe. netif_tx_disable(dev) will stop new
transmissions, but the hardware can be busy receiving, DMAing frames,
using the descriptors, etc. Modifying rxq->bd.last in particular seems
risky. I think you need to disable the receiver, wait for it to
indicate it really has stopped, and only then make these
modifications.

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ