path: root/drivers/md
diff options
authorSami Tolvanen <>2021-04-08 11:28:34 -0700
committerKees Cook <>2021-04-08 16:04:22 -0700
commit4f0f586bf0c898233d8f316f471a21db2abd522d (patch)
tree3b3ec78051f5a5d2b96f834347355b1b306026ea /drivers/md
parent9f5b4009980f369acb80b72235b2d66c3fd6eca6 (diff)
treewide: Change list_sort to use const pointers
list_sort() internally casts the comparison function passed to it to a different type with constant struct list_head pointers, and uses this pointer to call the functions, which trips indirect call Control-Flow Integrity (CFI) checking. Instead of removing the consts, this change defines the list_cmp_func_t type and changes the comparison function types of all list_sort() callers to use const pointers, thus avoiding type mismatches. Suggested-by: Nick Desaulniers <> Signed-off-by: Sami Tolvanen <> Reviewed-by: Nick Desaulniers <> Reviewed-by: Christoph Hellwig <> Reviewed-by: Kees Cook <> Tested-by: Nick Desaulniers <> Tested-by: Nathan Chancellor <> Signed-off-by: Kees Cook <> Link:
Diffstat (limited to 'drivers/md')
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 5d57a5bd171f..841e1c1aa5e6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -953,7 +953,8 @@ static void dispatch_bio_list(struct bio_list *tmp)
-static int cmp_stripe(void *priv, struct list_head *a, struct list_head *b)
+static int cmp_stripe(void *priv, const struct list_head *a,
+ const struct list_head *b)
const struct r5pending_data *da = list_entry(a,
struct r5pending_data, sibling);