Commit 722c094
bpf: hashtab: fix 32-bit overflow in memory usage calculation
The intermediate product value_size * num_possible_cpus() is evaluated
in 32-bit arithmetic and only then promoted to 64 bits. On systems with
large value_size and many possible CPUs this can overflow and lead to
an underestimated memory usage.
Cast value_size to u64 before multiplying.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 304849a ("bpf: hashtab memory usage")
Cc: [email protected]
Signed-off-by: Alexei Safin <[email protected]>1 parent 03f9e36 commit 722c094
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2216 | 2216 | | |
2217 | 2217 | | |
2218 | 2218 | | |
2219 | | - | |
| 2219 | + | |
2220 | 2220 | | |
2221 | 2221 | | |
2222 | 2222 | | |
| |||
2228 | 2228 | | |
2229 | 2229 | | |
2230 | 2230 | | |
2231 | | - | |
| 2231 | + | |
2232 | 2232 | | |
2233 | 2233 | | |
2234 | 2234 | | |
| |||
0 commit comments