linux: Fix __closefrom_fallback iterates until max int (BZ#28993)
commit053fe273434056f551ed8f81daf750db9dab5931
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 23 Mar 2022 20:40:01 +0000 (23 17:40 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 5 Apr 2022 11:08:19 +0000 (5 08:08 -0300)
treeaa523a541ce952fc531e0200eb61e1a918390be0
parent3ee318c9233ce77dee099f2830e8e29a0c572ca7
linux: Fix __closefrom_fallback iterates until max int (BZ#28993)

The __closefrom_fallback tries to get a available file descriptor
if the initial open ("/proc/self/fd/", ...) fails.  It assumes the
failure would be only if procfs is not mount (ENOENT), however if
the the proc file is not accessible (due some other kernel filtering
such apparmor) it will iterate over a potentially large file set
issuing close calls.

It should only try the close fallback if open returns EMFILE,
ENFILE, or ENOMEM.

Checked on x86_64-linux-gnu.
sysdeps/unix/sysv/linux/closefrom_fallback.c