KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
83 stars 5 forks source link

Replace open-coded arithmetic with check_mul_overflow(), check_dev_overflow(), check_add_overflow(), check_sub_overflow(), check_shl_overflow() #92

Open kees opened 4 years ago

kees commented 4 years ago

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:

(these helpers were introduced in Linux v4.18)

See also issue #83

kees commented 2 years ago

And for size_t calculations, we now have size_mul(), size_add(), and size_sub() (introduced in Linux v5.18).

GustavoARSilva commented 2 years ago

And for size_t calculations, we now have size_mul(), size_add(), and size_sub() (introduced in Linux v5.18).

This is about to get fun (even more so). :p