Files
linux/drivers/md
Kees Cook 94dc0555b8 overflow.h: Add allocation size calculation helpers
commit 610b15c50e upstream.

In preparation for replacing unchecked overflows for memory allocations,
this creates helpers for the 3 most common calculations:

array_size(a, b): 2-dimensional array
array3_size(a, b, c): 3-dimensional array
struct_size(ptr, member, n): struct followed by n-many trailing members

Each of these return SIZE_MAX on overflow instead of wrapping around.

(Additionally renames a variable named "array_size" to avoid future
collision.)

Co-developed-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-16 08:57:52 +09:00
..
2014-01-14 23:23:03 -05:00
2017-01-31 13:55:27 -08:00
2017-01-31 10:45:54 -08:00
2016-08-07 14:41:02 -06:00
2016-08-07 14:41:02 -06:00
2016-01-20 13:52:20 -08:00
2017-10-21 17:21:35 +02:00
2016-09-21 09:09:44 -07:00
2016-08-07 14:41:02 -06:00
2015-08-13 12:31:57 -06:00