Bug 28850 - linux: __get_nprocs_sched reads uninitialized memory from the stack
Summary: linux: __get_nprocs_sched reads uninitialized memory from the stack
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.36
Assignee: Dmitry V. Levin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-01 21:46 UTC by Gleb Fotengauer-Malinovskiy
Modified: 2022-02-03 12:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2022-02-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Fotengauer-Malinovskiy 2022-02-01 21:46:05 UTC
$ cat f.c
#include <stdio.h>
extern int __get_nprocs_sched (void);

int main() {
        printf("%d\n", __get_nprocs_sched());
}
$ gcc -static f.c -o f
$ ./f
828
$ ./f
794
$ nproc
8

sched_getaffinity(2) writes first N bits of cpu_bits array, but the rest of it is left uninitialized.