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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z0YQYKgUyLt8w4va@lore-desk>
Date: Tue, 26 Nov 2024 19:16:00 +0100
From: Lorenzo Bianconi <lorenzo.bianconi@...hat.com>
To: Til Kaiser <mail@...54.de>
Cc: nbd@....name, sean.wang@...iatek.com, Mark-MC.Lee@...iatek.com,
	lorenzo@...nel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net] mediathek: mtk_eth_soc: fix netdev inside
 xdp_rxq_info

> Currently, the network device isn't set inside the xdp_rxq_info
> of the mtk_rx_ring, which means that an XDP program attached to
> the Mediathek ethernet driver cannot retrieve the index of the
> interface that received the package since it's always 0 inside
> the xdp_md struct.
> 
> This patch sets the network device pointer inside the
> xdp_rxq_info struct, which is later used to initialize
> the xdp_buff struct via xdp_init_buff.
> 
> This was tested using the following eBPF/XDP program attached
> to a network interface of the mtk_eth_soc driver. As said before,
> ingress_ifindex always had a value of zero. After applying the
> patch, ingress_ifindex holds the correct interface index.
> 
> 	#include <linux/bpf.h>
> 	#include <bpf/bpf_helpers.h>
> 
> 	SEC("pass")
> 	int pass_func(struct xdp_md *xdp) {
>     		bpf_printk("ingress_ifindex: %u",
> 			xdp->ingress_ifindex);
> 
> 		return XDP_PASS;
> 	}
> 
> 	char _license[] SEC("license") = "GPL";
> 
> Signed-off-by: Til Kaiser <mail@...54.de>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 53485142938c..9c6d4477e536 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -2069,6 +2069,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
>  
>  		netdev = eth->netdev[mac];
>  		ppe_idx = eth->mac[mac]->ppe_idx;
> +		ring->xdp_q.dev = netdev;

I guess you can set it just before running xdp_init_buff(), but the change is fine.

Regards,
Lorenzo

>  
>  		if (unlikely(test_bit(MTK_RESETTING, &eth->state)))
>  			goto release_desc;
> -- 
> 2.47.1
> 
> 

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ