Message ID | 20230616-coresight-dummy-fix-kcfi-warnings-v1-1-c55c64f8f0f5@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | coresight: dummy: Update type of mode parameter in dummy_{sink,source}_enable() | expand |
On Fri, 16 Jun 2023 09:41:30 -0700, Nathan Chancellor wrote: > Clang's kernel Control Flow Integrity (kCFI) is a compiler-based > security mitigation that ensures the target of an indirect function call > matches the expected type of the call and trapping if they do not match > exactly. The warning -Wincompatible-function-pointer-types-strict aims > to catch these issues at compile time, which reveals: > > drivers/hwtracing/coresight/coresight-dummy.c:53:12: error: incompatible function pointer types initializing 'int (*)(struct coresight_device *, struct perf_event *, enum cs_mode)' with an expression of type 'int (struct coresight_device *, struct perf_event *, u32)' (aka 'int (struct coresight_device *, struct perf_event *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] > 53 | .enable = dummy_source_enable, > | ^~~~~~~~~~~~~~~~~~~ > drivers/hwtracing/coresight/coresight-dummy.c:62:12: error: incompatible function pointer types initializing 'int (*)(struct coresight_device *, enum cs_mode, void *)' with an expression of type 'int (struct coresight_device *, u32, void *)' (aka 'int (struct coresight_device *, unsigned int, void *)') [-Werror,-Wincompatible-function-pointer-types-strict] > 62 | .enable = dummy_sink_enable, > | ^~~~~~~~~~~~~~~~~ > 2 errors generated. > > [...] Applied, thanks! [1/1] coresight: dummy: Update type of mode parameter in dummy_{sink,source}_enable() commit: 185891f03f712639c082e08fc9986ff214b5d617 Best regards,
diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c index 42125b7a0f39..8035120b70b3 100644 --- a/drivers/hwtracing/coresight/coresight-dummy.c +++ b/drivers/hwtracing/coresight/coresight-dummy.c @@ -21,7 +21,7 @@ DEFINE_CORESIGHT_DEVLIST(source_devs, "dummy_source"); DEFINE_CORESIGHT_DEVLIST(sink_devs, "dummy_sink"); static int dummy_source_enable(struct coresight_device *csdev, - struct perf_event *event, u32 mode) + struct perf_event *event, enum cs_mode mode) { dev_dbg(csdev->dev.parent, "Dummy source enabled\n"); @@ -34,7 +34,7 @@ static void dummy_source_disable(struct coresight_device *csdev, dev_dbg(csdev->dev.parent, "Dummy source disabled\n"); } -static int dummy_sink_enable(struct coresight_device *csdev, u32 mode, +static int dummy_sink_enable(struct coresight_device *csdev, enum cs_mode mode, void *data) { dev_dbg(csdev->dev.parent, "Dummy sink enabled\n");
Clang's kernel Control Flow Integrity (kCFI) is a compiler-based security mitigation that ensures the target of an indirect function call matches the expected type of the call and trapping if they do not match exactly. The warning -Wincompatible-function-pointer-types-strict aims to catch these issues at compile time, which reveals: drivers/hwtracing/coresight/coresight-dummy.c:53:12: error: incompatible function pointer types initializing 'int (*)(struct coresight_device *, struct perf_event *, enum cs_mode)' with an expression of type 'int (struct coresight_device *, struct perf_event *, u32)' (aka 'int (struct coresight_device *, struct perf_event *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] 53 | .enable = dummy_source_enable, | ^~~~~~~~~~~~~~~~~~~ drivers/hwtracing/coresight/coresight-dummy.c:62:12: error: incompatible function pointer types initializing 'int (*)(struct coresight_device *, enum cs_mode, void *)' with an expression of type 'int (struct coresight_device *, u32, void *)' (aka 'int (struct coresight_device *, unsigned int, void *)') [-Werror,-Wincompatible-function-pointer-types-strict] 62 | .enable = dummy_sink_enable, | ^~~~~~~~~~~~~~~~~ 2 errors generated. Commit 9fa3682869d4 ("coresight: Use enum type for cs_mode wherever possible") updated the type of the mode parameter in the prototype but this driver was not introduced until commit 9d3ba0b6c056 ("Coresight: Add coresight dummy driver") and 'int' is ABI compatible with 'enum cs_mode', so there is no warning from regular -Wincompatible-function-pointer-types. Adjust the type of the mode parameter in the callback implementations in the coresight dummy driver to match the prototype, clearing up the warning and avoiding kCFI failures at runtime. Fixes: 9d3ba0b6c056 ("Coresight: Add coresight dummy driver") Signed-off-by: Nathan Chancellor <nathan@kernel.org> --- drivers/hwtracing/coresight/coresight-dummy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- base-commit: 3b79104f80036231a40ba5d15c3e329985029a0f change-id: 20230616-coresight-dummy-fix-kcfi-warnings-6687abd8d019 Best regards,