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: <fea564b7-8c6f-fa61-48e5-76eaaf9cbe91@iogearbox.net>
Date:   Fri, 11 Dec 2020 01:15:05 +0100
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Hangbin Liu <liuhangbin@...il.com>, bpf@...r.kernel.org
Cc:     netdev@...r.kernel.org, Jesper Dangaard Brouer <brouer@...hat.com>,
        John Fastabend <john.fastabend@...il.com>,
        Yonghong Song <yhs@...com>,
        Toke Høiland-Jørgensen <toke@...hat.com>
Subject: Re: [PATCHv4 bpf-next] samples/bpf: add xdp program on egress for
 xdp_redirect_map

On 12/8/20 1:01 PM, Hangbin Liu wrote:
[...]
>   
> +static int get_mac_addr(unsigned int ifindex_out, void *mac_addr)
> +{
> +	struct ifreq ifr;
> +	char ifname[IF_NAMESIZE];
> +	int fd = socket(AF_INET, SOCK_DGRAM, 0);
> +
> +	if (fd < 0)
> +		return -1;
> +
> +	if (!if_indextoname(ifindex_out, ifname))
> +		return -1;
> +
> +	strcpy(ifr.ifr_name, ifname);
> +
> +	if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0)
> +		return -1;
> +
> +	memcpy(mac_addr, ifr.ifr_hwaddr.sa_data, 6 * sizeof(char));
> +	close(fd);

Given we do bother to close the socket fd here, we should also close it in above
error cases..

> +	return 0;
> +}
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ