diff options
author | CoprDistGit <infra@openeuler.org> | 2024-08-03 06:28:41 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2024-08-03 06:28:41 +0000 |
commit | d20db0561a6a36f914fde030512503b114ef9a0c (patch) | |
tree | d4e5e3494d95c269a1cee6195f11bf3201bcadbf /linux-Fix-__closefrom_fallback-iterates-until-max-in.patch | |
parent | 016343d99b1b269d7246ef1e143d4b54914433d4 (diff) |
automatic import of glibcopeneuler22.03_LTS_SP4openeuler22.03_LTS_SP3openeuler20.03
Diffstat (limited to 'linux-Fix-__closefrom_fallback-iterates-until-max-in.patch')
-rw-r--r-- | linux-Fix-__closefrom_fallback-iterates-until-max-in.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/linux-Fix-__closefrom_fallback-iterates-until-max-in.patch b/linux-Fix-__closefrom_fallback-iterates-until-max-in.patch new file mode 100644 index 0000000..1b46598 --- /dev/null +++ b/linux-Fix-__closefrom_fallback-iterates-until-max-in.patch @@ -0,0 +1,58 @@ +From 053fe273434056f551ed8f81daf750db9dab5931 Mon Sep 17 00:00:00 2001 +From: Adhemerval Zanella <adhemerval.zanella@linaro.org> +Date: Wed, 23 Mar 2022 17:40:01 -0300 +Subject: [PATCH] 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 | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/sysdeps/unix/sysv/linux/closefrom_fallback.c b/sysdeps/unix/sysv/linux/closefrom_fallback.c +index 60101aa..a9dd0c4 100644 +--- a/sysdeps/unix/sysv/linux/closefrom_fallback.c ++++ b/sysdeps/unix/sysv/linux/closefrom_fallback.c +@@ -30,16 +30,16 @@ + _Bool + __closefrom_fallback (int from, _Bool dirfd_fallback) + { +- bool ret = false; +- + int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY, + 0); + if (dirfd == -1) + { +- /* The closefrom should work even when process can't open new files. */ +- if (errno == ENOENT || !dirfd_fallback) +- goto err; ++ /* Return if procfs can not be opened for some reason. */ ++ if ((errno != EMFILE && errno != ENFILE && errno != ENOMEM) ++ || !dirfd_fallback) ++ return false; + ++ /* The closefrom should work even when process can't open new files. */ + for (int i = from; i < INT_MAX; i++) + { + int r = __close_nocancel (i); +@@ -54,6 +54,7 @@ __closefrom_fallback (int from, _Bool dirfd_fallback) + } + + char buffer[1024]; ++ bool ret = false; + while (true) + { + ssize_t ret = __getdents64 (dirfd, buffer, sizeof (buffer)); +-- +1.8.3.1 + |