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: <82d0bfd2-2b49-47cd-b91e-b5e749682537@davidwei.uk>
Date: Fri, 16 Feb 2024 19:53:06 -0700
From: David Wei <dw@...idwei.uk>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Jiri Pirko <jiri@...nulli.us>, Sabrina Dubroca <sd@...asysnail.net>,
 netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
 Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next v11 1/3] netdevsim: allow two netdevsim ports to
 be connected

On 2024-02-16 18:46, Jakub Kicinski wrote:
> On Thu, 15 Feb 2024 11:43:23 -0800 David Wei wrote:
>> +	ns_a = get_net_ns_by_fd(netnsfd_a);
>> +	if (IS_ERR(ns_a)) {
>> +		pr_err("Could not find netns with fd: %d\n", netnsfd_a);
>> +		return -EINVAL;
>> +	}
>> +
>> +	ns_b = get_net_ns_by_fd(netnsfd_b);
>> +	if (IS_ERR(ns_b)) {
>> +		pr_err("Could not find netns with fd: %d\n", netnsfd_b);
>> +		return -EINVAL;
>> +	}
>> +
>> +	err = -EINVAL;
>> +	rtnl_lock();
>> +	dev_a = __dev_get_by_index(ns_a, ifidx_a);
>> +	if (!dev_a) {
>> +		pr_err("Could not find device with ifindex %u in netnsfd %d\n", ifidx_a, netnsfd_a);
>> +		goto out_put_netns_a;
>> +	}
>> +
>> +	if (!netdev_is_nsim(dev_a)) {
>> +		pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_a, netnsfd_a);
>> +		goto out_put_netns_a;
>> +	}
>> +
>> +	dev_b = __dev_get_by_index(ns_b, ifidx_b);
>> +	if (!dev_b) {
>> +		pr_err("Could not find device with ifindex %u in netnsfd %d\n", ifidx_b, netnsfd_b);
>> +		goto out_put_netns_b;
>> +	}
>> +
>> +	if (!netdev_is_nsim(dev_b)) {
>> +		pr_err("Device with ifindex %u in netnsfd %d is not a netdevsim\n", ifidx_b, netnsfd_b);
>> +		goto out_put_netns_b;
>> +	}
>> +
>> +	if (dev_a == dev_b) {
>> +		pr_err("Cannot link a netdevsim to itself\n");
>> +		goto out_put_netns_b;
> 
> You need to fix the gotos here :( You're leaking the references 
> to the namespaces on error paths :(

Sorry about that, should check every time I move code around. :(

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ