linux/drivers/acpi
Nathan Chancellor 32f5f51a37 ACPI: CPPC: Replace cppc_attr with kobj_attribute
[ Upstream commit 2bc6262c6117dd18106d5aa50d53e945b5d99c51 ]

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: 158c998ea4 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-14 09:44:20 +02:00
..
acpica ACPICA: Fix race in generic_serial_bus (I2C) and GPIO op_region parameter handling 2021-03-11 14:06:49 +01:00
apei
arm64 ACPI: GTDT: Don't corrupt interrupt mappings on watchdow probe failure 2021-05-11 14:04:14 +02:00
dptf
hmat ACPI: HMAT: Fix handling of changes from ACPI 6.2 to ACPI 6.3 2020-11-05 11:43:19 +01:00
nfit ACPI: NFIT: Fix comparison to '-ENXIO' 2020-11-10 12:37:31 +01:00
pmic
x86
Kconfig
Makefile ACPI: Always build evged in 2020-10-17 10:11:22 +02:00
ac.c
acpi_adxl.c
acpi_amba.c
acpi_apd.c
acpi_cmos_rtc.c
acpi_configfs.c ACPI: configfs: add missing check after configfs_register_default_group() 2021-03-04 10:26:40 +01:00
acpi_dbg.c ACPI: debug: don't allow debugging when ACPI is disabled 2020-11-05 11:43:25 +01:00
acpi_extlog.c ACPI / extlog: Check for RDMSR failure 2020-11-05 11:43:24 +01:00
acpi_ipmi.c
acpi_lpat.c
acpi_lpit.c
acpi_lpss.c
acpi_memhotplug.c
acpi_pad.c
acpi_platform.c
acpi_pnp.c ACPI: PNP: compare the string length in the matching_id() 2020-12-30 11:51:32 +01:00
acpi_processor.c
acpi_tad.c
acpi_video.c
acpi_watchdog.c
battery.c
bgrt.c
blacklist.c
bus.c
button.c ACPI: button: Add DMI quirk for Medion Akoya E2228T 2020-11-24 13:29:00 +01:00
cm_sbs.c
container.c
cppc_acpi.c ACPI: CPPC: Replace cppc_attr with kobj_attribute 2021-05-14 09:44:20 +02:00
custom_method.c ACPI: custom_method: fix a possible memory leak 2021-05-11 14:04:01 +02:00
debugfs.c
device_pm.c PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() 2020-12-30 11:51:32 +01:00
device_sysfs.c ACPI: sysfs: Prefer "compatible" modalias 2021-02-03 23:25:56 +01:00
dock.c
ec.c ACPI: EC: PM: Drop ec_no_wakeup check from acpi_ec_dispatch_gpe() 2020-11-05 11:43:25 +01:00
ec_sys.c
event.c
evged.c ACPI: GED: fix -Wformat 2020-11-22 10:14:12 +01:00
fan.c
glue.c
hed.c
internal.h ACPI: scan: Use unique number for instance_no 2021-03-30 14:35:28 +02:00
ioapic.c
irq.c
numa.c ACPI: Add out of bounds and numa_off protections to pxm_to_node() 2020-11-05 11:43:18 +01:00
nvs.c
osi.c
osl.c
pci_irq.c
pci_link.c
pci_mcfg.c
pci_root.c
pci_slot.c
power.c
pptt.c
proc.c
processor_core.c
processor_driver.c
processor_idle.c
processor_pdc.c
processor_perflib.c
processor_thermal.c
processor_throttling.c
property.c ACPI: property: Fix fwnode string properties matching 2021-03-04 10:26:40 +01:00
reboot.c
resource.c Revert "ACPI / resources: Use AE_CTRL_TERMINATE to terminate resources walks" 2020-12-30 11:51:32 +01:00
sbs.c
sbshc.c
sbshc.h
scan.c ACPI: scan: Use unique number for instance_no 2021-03-30 14:35:28 +02:00
sleep.c ACPI: EC: PM: Avoid flushing EC work when EC GPE is inactive 2020-05-27 17:46:10 +02:00
sleep.h
spcr.c
sysfs.c ACPI: sysfs: Fix pm_profile_attr type 2020-06-30 15:37:06 -04:00
tables.c ACPI: tables: x86: Reserve memory occupied by ACPI tables 2021-05-07 10:51:36 +02:00
thermal.c ACPI: thermal: Do not call acpi_thermal_check() directly 2021-02-07 15:35:47 +01:00
utils.c
video_detect.c ACPI: video: Add missing callback back for Sony VPCEH3U1E 2021-03-30 14:35:23 +02:00
wakeup.c