Open kees opened 4 years ago
And for size_t
calculations, we now have size_mul()
, size_add()
, and size_sub()
(introduced in Linux v5.18).
And for
size_t
calculations, we now havesize_mul()
,size_add()
, andsize_sub()
(introduced in Linux v5.18).
This is about to get fun (even more so). :p
Having code be aware of arithmetic overflow so it can handle it gracefully is much better than either introducing security flaws from using overflow results or compiler instrumentation that kills the thread on unexpected overflow. As such, open-coded arithmetic should be replaced with the respective overflow checking routines:
check_mul_overflow()
check_div_overflow()
check_add_overflow()
check_sub_overflow()
check_shl_overflow()
(these helpers were introduced in Linux v4.18)
See also issue #83