Skip to content

overflow: Allow mixed type arguments in overflow macros

Eliav Farber linux-hardening linux-sparse lkml stable 3 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 1 replyIn review
  2. v24 patches 3 repliesSuperseded
  3. v14 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- Fixed SHA1 of commits mentioned in cover letter

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4overflow: Correct check_shl_overflow() commentinclude/linux/overflow.h+1 -10 replies
2/4compiler.h: drop fallback overflow checkersinclude/linux/compiler-clang.h include/linux/compiler-gcc.h include/linux/overflow.h +2 more+6 -2930 replies
3/4overflow: Allow mixed type argumentsinclude/linux/overflow.h+41 -310 replies
4/4tracing: Define the is_signed_type() macro onceinclude/linux/compiler.h include/linux/overflow.h include/linux/trace_events.h+6 -31 reply

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchKees CookNathan ChancellorAndrzej HajdaGwan-gyeong Mun
1/4
2/4A-b R-b
3/4R-b R-b T-b
4/4A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v3 thread

Cover letter [PATCH v3 0/4 5.10.y] overflow: Allow mixed type arguments in overflow macros

This series backports four commits to bring include/linux/overflow.h in line with v5.15.193:
- 4578be130a64 ("overflow: Correct check_shl_overflow() comment")
- 4eb6bd55cfb2 ("compiler.h: drop fallback overflow checkers")
- 53f2cd86a81c ("overflow: Allow mixed type arguments")
- ed6e37e30826 ("tracing: Define the is_signed_type() macro once")

The motivation is to fix build failures such as:

drivers/net/ethernet/intel/e1000e/ethtool.c: In function ‘e1000_set_eeprom’:
./include/linux/overflow.h:71:15: error: comparison of distinct pointer types lacks a cast [-Werror]
71 | (void) (&__a == __d); \
| ^~
drivers/net/ethernet/intel/e1000e/ethtool.c:582:6: note: in expansion of macro ‘check_add_overflow’
582 | if (check_add_overflow(eeprom->offset, eeprom->len, &total_len) ||

      |      ^~~~~~~~~~~~~~~~~~

This regression was triggered by commit ce8829d3d44b ("e1000e: fix heap overflow in e1000_set_eeprom").

check_add_overflow() requires the first two operands and the result pointer to be of identical type. On 64-bit builds, using size_t for the result conflicted with the u32 fields eeprom->offset and eeprom->len, resulting in type check failures.

Bart Van Assche (1):
tracing: Define the is_signed_type() macro once

Kees Cook (1):
overflow: Allow mixed type arguments

Keith Busch (1):
overflow: Correct check_shl_overflow() comment

Nick Desaulniers (1):
compiler.h: drop fallback overflow checkers

 include/linux/compiler-clang.h     |  13 --
 include/linux/compiler-gcc.h       |   4 -
 include/linux/compiler.h           |   6 +
 include/linux/overflow.h           | 209 ++++++-----------------------
 include/linux/trace_events.h       |   2 -
 tools/include/linux/compiler-gcc.h |   4 -
 tools/include/linux/overflow.h     | 140 +------------------
 7 files changed, 52 insertions(+), 326 deletions(-)

---
Changes in v3:
- Fixed SHA1 of commits mentioned in cover letter

Changes in v2:
- Added missing sign-off in all patches

Signature · 1 line
2.47.3