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] [day] [month] [year] [list]
Message-ID: <e261cce8-bd41-4f7b-b035-2480fe0e36c5@orange.com>
Date: Tue, 17 Sep 2024 21:04:30 +0200
From: Alexandre Ferrieux <alexandre.ferrieux@...il.com>
To: nicolas.dichtel@...nd.com, Stephen Hemminger <stephen@...workplumber.org>
Cc: David Ahern <dsahern@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH iproute2] iplink: fix fd leak when playing with netns

On 17/09/2024 17:17, Nicolas Dichtel wrote:
> Le 17/09/2024 à 17:11, Stephen Hemminger a écrit :
>> On Tue, 17 Sep 2024 08:51:58 +0200
>> Nicolas Dichtel <nicolas.dichtel@...nd.com> wrote:
>> 
>>> The command 'ip link set foo netns mynetns' opens a file descriptor to fill
>>> the netlink attribute IFLA_NET_NS_FD. This file descriptor is never closed.
>>> When batch mode is used, the number of file descriptor may grow greatly and
>>> reach the maximum file descriptor number that can be opened.
>>>
>>> This fd can be closed only after the netlink answer. Let's pass a new
>>> argument to iplink_parse() to remember this fd and close it.
>>>
>>> Fixes: 0dc34c7713bb ("iproute2: Add processless network namespace support")
>>> Reported-by: Alexandre Ferrieux <alexandre.ferrieux@...nge.com>
>>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@...nd.com>
>>> Tested-by: Alexandre Ferrieux <alexandre.ferrieux@...nge.com>
>>> ---
>> 
>> Maybe netns_fd should be a global variable rather than having to pass
>> to change all the unrelated function calls.
> I hesitated with this option. I don't have any strong opinion on this.
> 
> Note that two variables are needed, because the link_util->parse_opt may call
> again iplink_parse().
> 
> Another note that I forgot to mention: I didn't fix devlink which has the same
> problem. I was waiting for the conclusion of this fix first.

Another option would be to append "cleanup tasks" (a function pointer and a
single arg) to a global linked list; and call the chain at the end of the
execution of each single batch command. This allows for as many fds as are
needed, and other cleanups as well.

My $.02 ;)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ