Commit dd4c89b
authored
Fix potential integer overflow in hash container create/resize (#1811)
The sized constructors, reserve(), and rehash() methods of
absl::{flat,node}_hash_{set,map} did not impose an upper bound on
their size argument. As a result, it was possible for a caller to pass
a very large size that would cause an integer overflow when computing
the size of the container's backing store. Subsequent accesses to the
container might then access out-of-bounds memory.
The fix is in two parts:
1) Update max_size() to return the maximum number of items that can be
stored in the container
2) Validate the size arguments to the constructors, reserve(), and
rehash() methods, and abort the program when the argument is invalid
We've looked at uses of these containers in Google codebases like
Chrome, and determined this vulnerability is likely to be difficult to
exploit. This is primarily because container sizes are rarely
attacker-controlled.
The bug was discovered by Dmitry Vyukov <[email protected]>.1 parent 4447c75 commit dd4c89b
File tree
4 files changed
+27
-3
lines changed- absl
- base
- container/internal
4 files changed
+27
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1208 | 1208 | | |
1209 | 1209 | | |
1210 | 1210 | | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
1211 | 1214 | | |
1212 | 1215 | | |
1213 | 1216 | | |
| |||
1500 | 1503 | | |
1501 | 1504 | | |
1502 | 1505 | | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
1503 | 1512 | | |
1504 | 1513 | | |
1505 | 1514 | | |
| |||
2614 | 2623 | | |
2615 | 2624 | | |
2616 | 2625 | | |
| 2626 | + | |
| 2627 | + | |
2617 | 2628 | | |
2618 | 2629 | | |
2619 | 2630 | | |
| |||
2871 | 2882 | | |
2872 | 2883 | | |
2873 | 2884 | | |
2874 | | - | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
2875 | 2888 | | |
2876 | 2889 | | |
2877 | 2890 | | |
| |||
3260 | 3273 | | |
3261 | 3274 | | |
3262 | 3275 | | |
| 3276 | + | |
| 3277 | + | |
3263 | 3278 | | |
3264 | 3279 | | |
3265 | 3280 | | |
| |||
3272 | 3287 | | |
3273 | 3288 | | |
3274 | 3289 | | |
| 3290 | + | |
3275 | 3291 | | |
3276 | 3292 | | |
3277 | 3293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3594 | 3594 | | |
3595 | 3595 | | |
3596 | 3596 | | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
3597 | 3605 | | |
3598 | 3606 | | |
3599 | 3607 | | |
| |||
0 commit comments