diff options
author | Kees Cook <[email protected]> | 2024-01-18 16:05:52 -0800 |
---|---|---|
committer | Kees Cook <[email protected]> | 2024-02-29 13:38:01 -0800 |
commit | d70de8054c58d7bd9a4654c9f4797d29fa46d545 (patch) | |
tree | bcc66c9026a9407845dca2827111bf619c092626 /net/lapb/lapb_timer.c | |
parent | 3e19086fb5a9079611de426e8cb2f4503e28757e (diff) |
overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()
Provide helpers that will perform wrapping addition, subtraction, or
multiplication without tripping the arithmetic wrap-around sanitizers. The
first argument is the type under which the wrap-around should happen
with. In other words, these two calls will get very different results:
wrapping_mul(int, 50, 50) == 2500
wrapping_mul(u8, 50, 50) == 196
Add to the selftests to validate behavior and lack of side-effects.
Reviewed-by: Gustavo A. R. Silva <[email protected]>
Reviewed-by: Marco Elver <[email protected]>
Acked-by: Mark Rutland <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'net/lapb/lapb_timer.c')
0 files changed, 0 insertions, 0 deletions