Hi Kees, I love your patch! Yet something to improve: [auto build test ERROR on kees/for-next/hardening] [also build test ERROR on next-20220927] [cannot apply to drm-tip/drm-tip drm-intel/for-linux-next drm-misc/drm-misc-next linus/master v6.0-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Kees-Cook/overflow-Introduce-overflows_type-and-castable_to_type/20220927-094847 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening config: x86_64-rhel-8.3-func compiler: gcc-11 (Debian 11.3.0-5) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/ffc9129a19eb65b2d20780558b0c1af24d66434a git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Kees-Cook/overflow-Introduce-overflows_type-and-castable_to_type/20220927-094847 git checkout ffc9129a19eb65b2d20780558b0c1af24d66434a # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/i915/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All errors (new ones prefixed by >>): In file included from drivers/gpu/drm/i915/i915_utils.h:29, from drivers/gpu/drm/i915/i915_user_extensions.c:14: drivers/gpu/drm/i915/i915_user_extensions.c: In function 'i915_user_extensions': >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:27: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:132:23: note: in expansion of macro 'type_max' 132 | (x) > type_max(typeof(T)) ? 1 : 0 \ | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:53: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:132:23: note: in expansion of macro 'type_max' 132 | (x) > type_max(typeof(T)) ? 1 : 0 \ | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:27: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:134:34: note: in expansion of macro 'type_max' 134 | (x) < 0 || (x) > type_max(typeof(T)) ? 1 : 0 \ | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:53: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:134:34: note: in expansion of macro 'type_max' 134 | (x) < 0 || (x) > type_max(typeof(T)) ? 1 : 0 \ | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:27: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:35:30: note: in expansion of macro 'type_max' 35 | #define type_min(T) ((T)((T)-type_max(T)-(T)1)) | ^~~~~~~~ include/linux/overflow.h:135:25: note: in expansion of macro 'type_min' 135 | : (x) < type_min(typeof(T)) || \ | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:53: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:35:30: note: in expansion of macro 'type_max' 35 | #define type_min(T) ((T)((T)-type_max(T)-(T)1)) | ^~~~~~~~ include/linux/overflow.h:135:25: note: in expansion of macro 'type_min' 135 | : (x) < type_min(typeof(T)) || \ | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:27: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:136:25: note: in expansion of macro 'type_max' 136 | (x) > type_max(typeof(T)) ? 1 : 0) | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> include/linux/overflow.h:33:40: error: invalid operands to binary << (have 'struct i915_user_extension *' and 'long unsigned int') 33 | #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) | ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int include/linux/overflow.h:34:53: note: in expansion of macro '__type_half_max' 34 | #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) | ^~~~~~~~~~~~~~~ include/linux/overflow.h:136:25: note: in expansion of macro 'type_max' 136 | (x) > type_max(typeof(T)) ? 1 : 0) | ^~~~~~~~ include/linux/overflow.h:159:31: note: in expansion of macro '__overflows_type_constexpr' 159 | __overflows_type_constexpr(n, T), \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/i915_user_extensions.c:54:21: note: in expansion of macro 'overflows_type' 54 | overflows_type(next, ext)) | ^~~~~~~~~~~~~~ >> drivers/gpu/drm/i915/i915_user_extensions.c:54:21: error: argument 2 in call to function '__builtin_add_overflow' does not have integral type vim +33 include/linux/overflow.h f0907827a8a915 Rasmus Villemoes 2018-05-08 8 f0907827a8a915 Rasmus Villemoes 2018-05-08 9 /* 4eb6bd55cfb22f Nick Desaulniers 2021-09-10 10 * We need to compute the minimum and maximum values representable in a given 4eb6bd55cfb22f Nick Desaulniers 2021-09-10 11 * type. These macros may also be useful elsewhere. It would seem more obvious 4eb6bd55cfb22f Nick Desaulniers 2021-09-10 12 * to do something like: f0907827a8a915 Rasmus Villemoes 2018-05-08 13 * f0907827a8a915 Rasmus Villemoes 2018-05-08 14 * #define type_min(T) (T)(is_signed_type(T) ? (T)1 << (8*sizeof(T)-1) : 0) f0907827a8a915 Rasmus Villemoes 2018-05-08 15 * #define type_max(T) (T)(is_signed_type(T) ? ((T)1 << (8*sizeof(T)-1)) - 1 : ~(T)0) f0907827a8a915 Rasmus Villemoes 2018-05-08 16 * f0907827a8a915 Rasmus Villemoes 2018-05-08 17 * Unfortunately, the middle expressions, strictly speaking, have f0907827a8a915 Rasmus Villemoes 2018-05-08 18 * undefined behaviour, and at least some versions of gcc warn about f0907827a8a915 Rasmus Villemoes 2018-05-08 19 * the type_max expression (but not if -fsanitize=undefined is in f0907827a8a915 Rasmus Villemoes 2018-05-08 20 * effect; in that case, the warning is deferred to runtime...). f0907827a8a915 Rasmus Villemoes 2018-05-08 21 * f0907827a8a915 Rasmus Villemoes 2018-05-08 22 * The slightly excessive casting in type_min is to make sure the f0907827a8a915 Rasmus Villemoes 2018-05-08 23 * macros also produce sensible values for the exotic type _Bool. [The f0907827a8a915 Rasmus Villemoes 2018-05-08 24 * overflow checkers only almost work for _Bool, but that's f0907827a8a915 Rasmus Villemoes 2018-05-08 25 * a-feature-not-a-bug, since people shouldn't be doing arithmetic on f0907827a8a915 Rasmus Villemoes 2018-05-08 26 * _Bools. Besides, the gcc builtins don't allow _Bool* as third f0907827a8a915 Rasmus Villemoes 2018-05-08 27 * argument.] f0907827a8a915 Rasmus Villemoes 2018-05-08 28 * f0907827a8a915 Rasmus Villemoes 2018-05-08 29 * Idea stolen from f0907827a8a915 Rasmus Villemoes 2018-05-08 30 * https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html - f0907827a8a915 Rasmus Villemoes 2018-05-08 31 * credit to Christian Biere. f0907827a8a915 Rasmus Villemoes 2018-05-08 32 */ f0907827a8a915 Rasmus Villemoes 2018-05-08 @33 #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type))) f0907827a8a915 Rasmus Villemoes 2018-05-08 34 #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T))) f0907827a8a915 Rasmus Villemoes 2018-05-08 35 #define type_min(T) ((T)((T)-type_max(T)-(T)1)) f0907827a8a915 Rasmus Villemoes 2018-05-08 36 -- 0-DAY CI Kernel Test Service https://01.org/lkp