Nathan Chancellor 2bc6262c61 ACPI: CPPC: Replace cppc_attr with kobj_attribute
All of the CPPC sysfs show functions are called via indirect call in
kobj_attr_show(), where they should be of type

ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, char *buf);

because that is the type of the ->show() member in
'struct kobj_attribute' but they are actually of type

ssize_t (*show)(struct kobject *kobj, struct attribute *attr, char *buf);

because of the ->show() member in 'struct cppc_attr', resulting in a
Control Flow Integrity violation [1].

$ cat /sys/devices/system/cpu/cpu0/acpi_cppc/highest_perf
3400

$ dmesg | grep "CFI failure"
[  175.970559] CFI failure (target: show_highest_perf+0x0/0x8):

As far as I can tell, the only difference between 'struct cppc_attr'
and 'struct kobj_attribute' aside from the type of the attr parameter
is the type of the count parameter in the ->store() member (ssize_t vs.
size_t), which does not actually matter because all of these nodes are
read-only.

Eliminate 'struct cppc_attr' in favor of 'struct kobj_attribute' to fix
the violation.

[1]: https://lore.kernel.org/r/20210401233216.2540591-1-samitolvanen@google.com/

Fixes: 158c998ea44b ("ACPI / CPPC: add sysfs support to compute delivered performance")
Link: https://github.com/ClangBuiltLinux/linux/issues/1343
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-04-08 19:58:12 +02:00
..
2020-11-10 18:52:51 +01:00
2020-10-14 11:42:04 -07:00
2021-02-04 19:45:45 +01:00
2019-06-23 09:23:33 +02:00
2020-10-15 10:46:16 -07:00
2021-01-22 16:17:19 +01:00
2021-02-20 21:50:59 -08:00
2021-01-22 16:17:19 +01:00
2020-11-09 19:08:06 +01:00
2020-11-09 19:25:20 +01:00
2021-02-25 18:57:40 +01:00
2021-02-25 18:57:40 +01:00
2019-11-13 11:12:08 +01:00
2021-02-10 19:09:43 +01:00
2020-11-09 19:08:06 +01:00
2021-02-15 17:04:53 +01:00
2020-12-15 16:39:06 -08:00
2020-11-09 19:08:06 +01:00
2020-11-09 19:08:06 +01:00
2021-02-15 17:04:53 +01:00
2020-07-09 14:09:28 +02:00
2021-02-21 14:10:36 -08:00
2020-11-09 19:08:06 +01:00