aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2023-10-24 19:05:41 -0700
committerTony Luck <tony.luck@intel.com>2023-10-24 19:05:41 -0700
commitf230628f5aeb00987d640c3240be9582fc8e6000 (patch)
tree60e0f0921caade7b2cd9b65f8bb6378d7670dcbc
parent17b57df4684ac939e6db67b715b322e47c3c0961 (diff)
downloadras-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.c4
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], ':');