diff options
author | Tony Luck <tony.luck@intel.com> | 2023-10-24 19:05:41 -0700 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2023-10-24 19:05:41 -0700 |
commit | f230628f5aeb00987d640c3240be9582fc8e6000 (patch) | |
tree | 60e0f0921caade7b2cd9b65f8bb6378d7670dcbc | |
parent | 17b57df4684ac939e6db67b715b322e47c3c0961 (diff) | |
download | ras-tools-f230628f5aeb00987d640c3240be9582fc8e6000.tar.gz |
proc_cpuinfo: Add sanity check for number of sockets
A misconfigured system appeared to have a huge number of sockets. The
code here did not handle this gracefully as the bitmask of sockets is
only 64-bits wide, so the extra sockets were not counted.
It doesn't seem worth changiing the code to support more sockets as such
systems do not exist.
Just check, warn, and exit if a socket > 63 is found.
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | proc_cpuinfo.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/proc_cpuinfo.c b/proc_cpuinfo.c index 2b7e638..842cabf 100644 --- a/proc_cpuinfo.c +++ b/proc_cpuinfo.c @@ -48,6 +48,10 @@ void proc_cpuinfo(int *nsockets, int *ncpus, char *model, int *modelnum, int **a (*ncpus)++; p = strchr(&line[10], ':'); s = strtol(p+1, NULL, 10); + if (s > 63) { + fprintf(stderr, "Found socket %d > max supported\n", s); + exit(1); + } sockmask |= 1 << s; } else if (strncmp(line, "processor", 9) == 0) { p = strchr(&line[8], ':'); |