kernel_samsung_a53x/arch/x86
Kees Cook 23a2b0d100 x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()
[ Upstream commit d19d638b1e6cf746263ef60b7d0dee0204d8216a ]

Modern (fortified) memcpy() prefers to avoid writing (or reading) beyond
the end of the addressed destination (or source) struct member:

In function ‘fortify_memcpy_chk’,
    inlined from ‘syscall_get_arguments’ at ./arch/x86/include/asm/syscall.h:85:2,
    inlined from ‘populate_seccomp_data’ at kernel/seccomp.c:258:2,
    inlined from ‘__seccomp_filter’ at kernel/seccomp.c:1231:3:
./include/linux/fortify-string.h:580:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
  580 |                         __read_overflow2_field(q_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As already done for x86_64 and compat mode, do not use memcpy() to
extract syscall arguments from struct pt_regs but rather just perform
direct assignments. Binary output differences are negligible, and actually
ends up using less stack space:

-       sub    $0x84,%esp
+       sub    $0x6c,%esp

and less text size:

   text    data     bss     dec     hex filename
  10794     252       0   11046    2b26 gcc-32b/kernel/seccomp.o.stock
  10714     252       0   10966    2ad6 gcc-32b/kernel/seccomp.o.after

Closes: https://lore.kernel.org/lkml/9b69fb14-df89-4677-9c82-056ea9e706f5@gmail.com/
Reported-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Link: https://lore.kernel.org/all/20240708202202.work.477-kees%40kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:21:39 +01:00
..
boot x86/boot: Ignore NMIs during very early boot 2024-11-18 12:13:08 +01:00
configs Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crypto crypto: x86/sha256-avx2 - add missing vzeroupper 2024-11-19 12:26:52 +01:00
entry syscalls: fix compat_sys_io_pgetevents_time64 usage 2024-11-19 14:19:34 +01:00
events perf/x86/intel/pt: Fix sampling synchronization 2024-11-23 23:21:31 +01:00
hyperv Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ia32 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
include x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments() 2024-11-23 23:21:39 +01:00
kernel x86/ibt,ftrace: Search for __fentry__ location 2024-11-23 23:21:16 +01:00
kvm KVM: VMX: Split out the non-virtualization part of vmx_interrupt_blocked() 2024-11-23 23:20:13 +01:00
lib x86/retpoline: Move a NOENDBR annotation to the SRSO dummy return thunk 2024-11-19 14:19:45 +01:00
math-emu Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mm x86/mm: Switch to new Intel CPU model defines 2024-11-23 23:21:29 +01:00
net x86/returnthunk: Allow different return thunks 2024-11-18 22:25:38 +01:00
oprofile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci x86/pci/xen: Fix PCIBIOS_* return code handling 2024-11-23 23:19:56 +01:00
platform x86/platform/iosf_mbi: Convert PCIBIOS_* return codes to errnos 2024-11-23 23:19:56 +01:00
power x86/stackprotector/32: Make the canary into a regular percpu variable 2024-11-19 09:22:37 +01:00
purgatory Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ras Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
realmode Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tools x86/boot: Ignore relocations in .notes sections in walk_relocs() too 2024-11-19 12:26:53 +01:00
um Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
video Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xen xen: use correct end address of kernel for conflict checking 2024-11-23 23:21:22 +01:00
Kbuild Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-11-19 11:32:38 +01:00
Kconfig.assembler Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig.cpu x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 2024-11-18 12:13:31 +01:00
Kconfig.debug x86/kconfig: Select ARCH_WANT_FRAME_POINTERS again when UNWINDER_FRAME_POINTER=y 2024-11-19 12:27:09 +01:00
Makefile x86/stackprotector/32: Make the canary into a regular percpu variable 2024-11-19 09:22:37 +01:00
Makefile.um um: allow not setting extra rpaths in the linux binary 2024-11-18 23:19:35 +01:00
Makefile_32.cpu Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00