Skip to contentSkip to conversation

overflow: improve check_shl_overflow comment

PATCH In review Keith Busch 2 participants 2 messages Apr 1, 2021 Kernel hardening (not covered by other areas)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 overflow: improve check_shl_overflow comment

A 'false' return means the value was safely set, so the comment should say 'true' for when it is not considered safe.

Cc Jason Gunthorpe <[email protected]>
Cc Kees Cook <[email protected]>
---
 include/linux/overflow.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/overflow.h +1 -1
index ef74051d5cfed..0f12345c21fb5 100644
@@ -235,7 +235,7 @@ static inline bool __must_check __must_check_overflow(bool overflow)
  * - 'a << s' sets the sign bit, if any, in '*d'.
  *
  * '*d' will hold the results of the attempted shift, but is not
- * considered "safe for use" if false is returned.
+ * considered "safe for use" if true is returned.
  */
 #define check_shl_overflow(a, s, d) __must_check_overflow(({		\
 	typeof(a) _a = a;						\
Signature · 1 line
2.25.4
#1 lore raw
Quoted 2 lines · Keith Busch

A 'false' return means the value was safely set, so the comment should say 'true' for when it is not considered safe.

Oops, yes; too many inverse negatives. ;) Applied to for-next/overflow, thanks!

[1/1] overflow: Correct check_shl_overflow() comment

      https://git.kernel.org/kees/c/4578be130a64
Signature · 1 line
Kees Cook