path: root/block/blk-mq-sched.c
diff options
authorSami Tolvanen <>2021-04-08 11:28:34 -0700
committerKees Cook <>2021-04-08 16:04:22 -0700
commit4f0f586bf0c898233d8f316f471a21db2abd522d (patch)
tree3b3ec78051f5a5d2b96f834347355b1b306026ea /block/blk-mq-sched.c
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 'block/blk-mq-sched.c')
1 files changed, 2 insertions, 1 deletions
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index e1e997af89a0..3ebd6f10f728 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -75,7 +75,8 @@ void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx)
blk_mq_run_hw_queue(hctx, true);
-static int sched_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
+static int sched_rq_cmp(void *priv, const struct list_head *a,
+ const struct list_head *b)
struct request *rqa = container_of(a, struct request, queuelist);
struct request *rqb = container_of(b, struct request, queuelist);