]> git.baikalelectronics.ru Git - kernel.git/commit
ACPI: CPPC: Replace cppc_attr with kobj_attribute
authorNathan Chancellor <nathan@kernel.org>
Wed, 7 Apr 2021 21:30:48 +0000 (14:30 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 8 Apr 2021 17:58:12 +0000 (19:58 +0200)
commitb0e3b955d6c6bd30c64f6b01142be7c5f83732da
treeed8f8c9417a2cc2daa999836af0d52ff825c4b2b
parent27e6e50bff92fe161f728d3a4fa77cf6899f9a0e
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: 4e787b1267e8 ("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>
drivers/acpi/cppc_acpi.c