mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 00:34:10 +08:00
4f0f586bf0
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 <ndesaulniers@google.com> Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kees Cook <keescook@chromium.org> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20210408182843.1754385-10-samitolvanen@google.com
15 lines
374 B
C
15 lines
374 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_LIST_SORT_H
|
|
#define _LINUX_LIST_SORT_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
struct list_head;
|
|
|
|
typedef int __attribute__((nonnull(2,3))) (*list_cmp_func_t)(void *,
|
|
const struct list_head *, const struct list_head *);
|
|
|
|
__attribute__((nonnull(2,3)))
|
|
void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp);
|
|
#endif
|