diff options
| author | Nathan Chancellor <[email protected]> | 2022-05-13 07:51:36 +0000 |
|---|---|---|
| committer | Jani Nikula <[email protected]> | 2022-05-19 09:10:57 +0000 |
| commit | 58606220a2f1407a7516c547f09a1ba7b4350a73 (patch) | |
| tree | 385af8cde5a6a5771a92ad1c1cb04180a8d56ddd /fs/ext4/fast_commit.c | |
| parent | drm/i915: Fix 'mixing different enum types' warnings in intel_display_power.c (diff) | |
| download | kernel-58606220a2f1407a7516c547f09a1ba7b4350a73.tar.gz kernel-58606220a2f1407a7516c547f09a1ba7b4350a73.zip | |
drm/i915: Fix CFI violation with show_dynamic_id()
When an attribute group is created with sysfs_create_group(), the
->sysfs_ops() callback is set to kobj_sysfs_ops, which sets the ->show()
callback to kobj_attr_show(). kobj_attr_show() uses container_of() to
get the ->show() callback from the attribute it was passed, meaning the
->show() callback needs to be the same type as the ->show() callback in
'struct kobj_attribute'.
However, show_dynamic_id() has the type of the ->show() callback in
'struct device_attribute', which causes a CFI violation when opening the
'id' sysfs node under drm/card0/metrics. This happens to work because
the layout of 'struct kobj_attribute' and 'struct device_attribute' are
the same, so the container_of() cast happens to allow the ->show()
callback to still work.
Change the type of show_dynamic_id() to match the ->show() callback in
'struct kobj_attributes' and update the type of sysfs_metric_id to
match, which resolves the CFI violation.
Fixes: f89823c21224 ("drm/i915/perf: Implement I915_PERF_ADD/REMOVE_CONFIG interface")
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Reviewed-by: Sami Tolvanen <[email protected]>
Signed-off-by: Tvrtko Ursulin <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit 18fb42db05a0b93ab5dd5eab5315e50eaa3ca620)
Signed-off-by: Jani Nikula <[email protected]>
Diffstat (limited to 'fs/ext4/fast_commit.c')
0 files changed, 0 insertions, 0 deletions
