android_kernel_samsung_sm8650/drivers/platform/x86
Nathan Chancellor 6341140b04 platform/x86: intel-uncore-freq: Fix types in sysfs callbacks
commit 416de0246f35f43d871a57939671fe814f4455ee upstream.

When booting a kernel with CONFIG_CFI_CLANG, there is a CFI failure when
accessing any of the values under
/sys/devices/system/cpu/intel_uncore_frequency/package_00_die_00:

  $ cat /sys/devices/system/cpu/intel_uncore_frequency/package_00_die_00/max_freq_khz
  fish: Job 1, 'cat /sys/devices/system/cpu/int…' terminated by signal SIGSEGV (Address boundary error)

  $ sudo dmesg &| grep 'CFI failure'
  [  170.953925] CFI failure at kobj_attr_show+0x19/0x30 (target: show_max_freq_khz+0x0/0xc0 [intel_uncore_frequency_common]; expected type: 0xd34078c5

The sysfs callback functions such as show_domain_id() are written as if
they are going to be called by dev_attr_show() but as the above message
shows, they are instead called by kobj_attr_show(). kCFI checks that the
destination of an indirect jump has the exact same type as the prototype
of the function pointer it is called through and fails when they do not.

These callbacks are called through kobj_attr_show() because
uncore_root_kobj was initialized with kobject_create_and_add(), which
means uncore_root_kobj has a ->sysfs_ops of kobj_sysfs_ops from
kobject_create(), which uses kobj_attr_show() as its ->show() value.

The only reason there has not been a more noticeable problem until this
point is that 'struct kobj_attribute' and 'struct device_attribute' have
the same layout, so getting the callback from container_of() works the
same with either value.

Change all the callbacks and their uses to be compatible with
kobj_attr_show() and kobj_attr_store(), which resolves the kCFI failure
and allows the sysfs files to work properly.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1974
Fixes: ae7b2ce578 ("platform/x86/intel/uncore-freq: Use sysfs API to create attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20240104-intel-uncore-freq-kcfi-fix-v1-1-bf1e8939af40@kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[nathan: Fix conflicts due to lack of 9b8dea80e3cb in 6.1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-31 16:17:08 -08:00
..
amd platform/x86/amd/pmf: Fix a missing cleanup path 2023-09-13 09:42:57 +02:00
dell platform/x86: dell-sysman: Fix reference leak 2023-09-13 09:42:54 +02:00
hp platform/x86: hp-wmi:: Mark driver struct with __refdata to prevent section mismatch warning 2023-10-19 23:08:50 +02:00
intel platform/x86: intel-uncore-freq: Fix types in sysfs callbacks 2024-01-31 16:17:08 -08:00
acer-wireless.c
acer-wmi.c platform/x86: acer-wmi: Enable SW_TABLET_MODE on Switch V 10 (SW5-017) 2022-11-15 17:16:40 +01:00
acerhdf.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
adv_swbutton.c
amilo-rfkill.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
apple-gmux.c platform/x86: apple-gmux: Add apple_gmux_detect() helper 2023-02-01 08:34:46 +01:00
asus-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
asus-nb-wmi.c platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi code 2023-12-13 18:39:05 +01:00
asus-tf103c-dock.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
asus-wireless.c
asus-wmi.c platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi code 2023-12-13 18:39:05 +01:00
asus-wmi.h platform/x86: asus-wmi: Change ASUS_WMI_BRN_DOWN code from 0x20 to 0x2e 2023-10-25 12:03:15 +02:00
barco-p50-gpio.c
classmate-laptop.c
compal-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
dual_accel_detect.h
eeepc-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
eeepc-wmi.c platform/x86: asus-wmi: Move acpi_backlight=vendor quirks to ACPI video_detect.c 2022-09-03 12:17:27 +02:00
firmware_attributes_class.c
firmware_attributes_class.h
fujitsu-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
fujitsu-tablet.c
gigabyte-wmi.c platform/x86: gigabyte-wmi: add support for X570S AORUS ELITE 2023-04-26 14:28:37 +02:00
gpd-pocket-fan.c
hdaps.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
huawei-wmi.c platform/x86: huawei-wmi: Silence ambient light sensor 2023-09-13 09:42:22 +02:00
ibm_rtl.c
ideapad-laptop.c platform/x86: ideapad-laptop: Add support for new hotkeys found on ThinkBook 14s Yoga ITL 2023-08-30 16:11:05 +02:00
intel_ips.c
intel_ips.h
intel_scu_ipc.c platform/x86: intel_scu_ipc: Fail IPC send if still busy 2023-10-06 14:56:39 +02:00
intel_scu_ipcutil.c
intel_scu_pcidrv.c platform/x86: intel_scu_pcidrv: Add back PCI ID for Medfield 2023-06-09 10:34:08 +02:00
intel_scu_pltdrv.c
intel_scu_wdt.c
Kconfig platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi code 2023-12-13 18:39:05 +01:00
lenovo-yogabook-wmi.c platform/x86: lenovo-yogabook: Set default keyboard backligh brightness on probe() 2023-07-19 16:21:35 +02:00
lg-laptop.c
Makefile platform/x86: Move existing HP drivers to a new hp subdir 2023-05-24 17:32:42 +01:00
meraki-mx100.c
mlx-platform.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
msi-laptop.c platform/x86: msi-laptop: Fix rfkill out-of-sync on MSI Wind U100 2023-08-03 10:24:01 +02:00
msi-wmi.c
mxm-wmi.c platform/x86: mxm-wmi: fix memleak in mxm_wmi_call_mx[ds|mx]() 2022-12-31 13:32:00 +01:00
nvidia-wmi-ec-backlight.c platform/x86: nvidia-wmi-ec-backlight: Add force module parameter 2023-02-25 11:25:43 +01:00
p2sb.c platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe 2024-01-31 16:17:07 -08:00
panasonic-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
pcengines-apuv2.c
peaq-wmi.c
pmc_atom.c platform/x86: pmc_atom: Amend comment style and grammar 2022-08-25 16:23:52 +02:00
samsung-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
samsung-q10.c
serial-multi-instantiate.c ACPI: scan: Create platform device for CS35L56 2023-08-16 18:27:31 +02:00
simatic-ipc.c platform/x86: simatic-ipc: add another model 2023-02-01 08:34:33 +01:00
sony-laptop.c platform/x86: sony-laptop: Don't turn off 0x153 keyboard backlight during probe 2023-01-18 11:58:18 +01:00
system76_acpi.c
think-lmi.c platform/x86: think-lmi: Fix reference leak 2023-10-19 23:08:50 +02:00
think-lmi.h
thinkpad_acpi.c platform/x86: thinkpad_acpi: fix for incorrect fan reporting on some ThinkPad systems 2024-01-20 11:50:08 +01:00
topstar-laptop.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
toshiba_acpi.c platform/x86: toshiba_acpi: change turn_on_panel_on_resume to static 2022-09-22 15:54:23 +02:00
toshiba_bluetooth.c
toshiba_haps.c
toshiba-wmi.c
touchscreen_dmi.c platform/x86: touchscreen_dmi: Add info for the Positivo C4128B 2023-10-25 12:03:11 +02:00
uv_sysfs.c
winmate-fm07-keys.c platform/x86: use PLATFORM_DEVID_NONE instead of -1 2022-10-03 09:40:04 +02:00
wireless-hotkey.c
wmi-bmof.c
wmi.c platform/x86: wmi: Skip blocks with zero instances 2023-12-13 18:39:06 +01:00
x86-android-tablets.c platform/x86: x86-android-tablets: Add Acer Iconia One 7 B1-750 data 2023-05-24 17:32:34 +01:00
xiaomi-wmi.c
xo1-rfkill.c
xo15-ebook.c