1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-09-05 14:24:06 +03:00

linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]

Pass the actual number of bytes returned by the kernel.

Fixes: 33099d72e4 ("linux: Simplify get_nprocs")
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>

(cherry picked from commit 97ba273b50)
This commit is contained in:
Gleb Fotengauer-Malinovskiy
2022-02-01 22:39:02 +00:00
committed by Dmitry V. Levin
parent d2e4d2a38e
commit a2f1675634
2 changed files with 2 additions and 1 deletions

1
NEWS
View File

@@ -9,6 +9,7 @@ Version 2.35.1
The following bugs are resolved with this release: The following bugs are resolved with this release:
[28850] linux: __get_nprocs_sched reads uninitialized memory from the stack
[28853] libc: tst-spawn6 changes current foreground process group [28853] libc: tst-spawn6 changes current foreground process group
(breaks test isolation) (breaks test isolation)

View File

@@ -44,7 +44,7 @@ __get_nprocs_sched (void)
int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size, int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
cpu_bits); cpu_bits);
if (r > 0) if (r > 0)
return CPU_COUNT_S (cpu_bits_size, (cpu_set_t*) cpu_bits); return CPU_COUNT_S (r, (cpu_set_t*) cpu_bits);
else if (r == -EINVAL) else if (r == -EINVAL)
/* The input buffer is still not enough to store the number of cpus. This /* The input buffer is still not enough to store the number of cpus. This
is an arbitrary values assuming such systems should be rare and there is an arbitrary values assuming such systems should be rare and there