Skip to contentSkip to conversation

bug-switch-data-corruption-check-to-__must_check.patch removed from -mm tree

merged [email protected] 1 participant 1 message Feb 27, 2017

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: bug: switch data corruption check to __must_check
has been removed from the -mm tree. Its filename was
bug-switch-data-corruption-check-to-__must_check.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Kees Cook <[email protected]>
Subject: bug: switch data corruption check to __must_check

The CHECK_DATA_CORRUPTION() macro was designed to have callers do something meaningful/protective on failure. However, using "return false" in the macro too strictly limits the design patterns of callers. Instead, let callers handle the logic test directly, but make sure that the result IS checked by forcing __must_check (which appears to not be able to be used directly on macro expressions).

---

 include/linux/bug.h |   12 ++++++-----
 lib/list_debug.c    |   45 ++++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 26 deletions(-)
include/linux/bug.h renamed from include/linux/bug.h~bug-switch-data-corruption-check-to-__must_check +7 -5
diff -puN include/linux/bug.h~bug-switch-data-corruption-check-to-__must_check include/linux/bug.h
@@ -124,18 +124,20 @@ static inline enum bug_trap_type report_
 
 /*
  * Since detected data corruption should stop operation on the affected
- * structures, this returns false if the corruption condition is found.
+ * structures. Return value must be checked and sanely acted on by caller.
  */
+static inline __must_check bool check_data_corruption(bool v) { return v; }
 #define CHECK_DATA_CORRUPTION(condition, fmt, ...)			 \
-	do {								 \
-		if (unlikely(condition)) {				 \
+	check_data_corruption(({					 \
+		bool corruption = unlikely(condition);			 \
+		if (corruption) {					 \
 			if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
 				pr_err(fmt, ##__VA_ARGS__);		 \
 				BUG();					 \
 			} else						 \
 				WARN(1, fmt, ##__VA_ARGS__);		 \
-			return false;					 \
 		}							 \
-	} while (0)
+		corruption;						 \
+	}))
 
 #endif	/* _LINUX_BUG_H */
lib/list_debug.c renamed from lib/list_debug.c~bug-switch-data-corruption-check-to-__must_check +24 -21

57 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are