linux-stable/drivers/firmware
Nathan Chancellor 0fb0ab7340 qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute
commit fca41af18e upstream.

fw_cfg_showrev() is called by an indirect call in kobj_attr_show(),
which violates clang's CFI checking because fw_cfg_showrev()'s second
parameter is 'struct attribute', whereas the ->show() member of 'struct
kobj_structure' expects the second parameter to be of type 'struct
kobj_attribute'.

$ cat /sys/firmware/qemu_fw_cfg/rev
3

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

Fix this by converting fw_cfg_rev_attr to 'struct kobj_attribute' where
this would have been caught automatically by the incompatible pointer
types compiler warning. Update fw_cfg_showrev() accordingly.

Fixes: 75f3e8e47f ("firmware: introduce sysfs driver for QEMU's fw_cfg device")
Link: https://github.com/ClangBuiltLinux/linux/issues/1299
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20210211194258.4137998-1-nathan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-20 16:17:47 +02:00
..
broadcom
efi efi: cper: fix snprintf() use in cper_dimm_err_location() 2021-06-10 12:43:49 +02:00
google gsmi: Fix bug in append_to_eventlog sysfs handler 2019-12-01 09:13:23 +01:00
meson
tegra firmware: tegra: set drvdata earlier 2017-08-17 13:08:08 +02:00
arm_scpi.c ARM SCPI fixes for v4.14 2017-08-24 15:51:54 +02:00
dcdbas.c firmware/dcdbas: Constify attribute_group structures 2017-08-21 09:43:51 +02:00
dcdbas.h
dell_rbu.c firmware: dell_rbu: Make payload memory uncachable 2019-11-20 18:00:46 +01:00
dmi-id.c
dmi-sysfs.c x86, mpparse, x86/acpi, x86/PCI, x86/dmi, SFI: Use memremap() for RAM mappings 2017-07-18 11:37:58 +02:00
dmi_scan.c firmware: dmi_scan: Fix UUID length safety check 2018-05-30 07:52:22 +02:00
edd.c
iscsi_ibft.c iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND 2019-08-16 10:13:51 +02:00
iscsi_ibft_find.c
Kconfig firmware: qcom-scm: Fix QCOM_SCM configuration 2021-05-22 10:57:30 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
memmap.c
pcdp.c x86, mpparse, x86/acpi, x86/PCI, x86/dmi, SFI: Use memremap() for RAM mappings 2017-07-18 11:37:58 +02:00
pcdp.h
psci.c firmware/psci: Expose SMCCC version through psci_ops 2018-02-16 20:22:56 +01:00
psci_checker.c
qcom_scm-32.c
qcom_scm-64.c firmware: qcom: scm: Ensure 'a0' status code is treated as signed 2019-12-17 20:39:58 +01:00
qcom_scm.c
qcom_scm.h
qemu_fw_cfg.c qemu_fw_cfg: Make fw_cfg_rev_attr a proper kobj_attribute 2021-07-20 16:17:47 +02:00
raspberrypi.c
scpi_pm_domain.c
ti_sci.c firmware: ti_sci: Always request response from firmware 2019-09-19 09:08:08 +02:00
ti_sci.h