kernel_samsung_a53x/arch/x86/include/asm
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
..
crypto
e820
fpu
numachip
trace
uv
vdso
xen
acenv.h
acpi.h
agp.h
alternative.h
amd_nb.h
apb_timer.h
apic.h x86/apic: Force native_apic_mem_read() to use the MOV instruction 2024-11-19 11:32:20 +01:00
apicdef.h
apm.h
arch_hweight.h
archrandom.h
asm-offsets.h
asm-prototypes.h x86/bugs: Fix the SRSO mitigation on Zen3/4 2024-11-19 09:23:11 +01:00
asm.h
atomic.h
atomic64_32.h
atomic64_64.h
audit.h
barrier.h
bios_ebda.h
bitops.h
boot.h
bootparam_utils.h
bug.h
bugs.h
cache.h
cacheflush.h
cacheinfo.h
ce4100.h
checksum.h
checksum_32.h
checksum_64.h
clocksource.h
cmdline.h
cmpxchg.h
cmpxchg_32.h
cmpxchg_64.h
compat.h
copy_mc_test.h
cpu.h
cpu_device_id.h x86/cpu: Fix x86_match_cpu() to match just X86_VENDOR_INTEL 2024-11-19 14:19:29 +01:00
cpu_entry_area.h
cpufeature.h x86/cpufeatures: Add CPUID_LNX_5 to track recently added Linux-defined word 2024-11-19 09:23:11 +01:00
cpufeatures.h x86/cpufeatures: Add new word for scattered features 2024-11-19 09:22:44 +01:00
cpuidle_haltpoll.h
cpumask.h
crash.h
current.h
debugreg.h
delay.h
desc.h
desc_defs.h
device.h
disabled-features.h x86/cpufeatures: Add new word for scattered features 2024-11-19 09:22:44 +01:00
div64.h
dma-mapping.h
dma.h
dmi.h
doublefault.h
dwarf2.h
edac.h
efi.h efi/x86: Free EFI memory map only when installing a new one. 2024-11-19 14:19:35 +01:00
elf.h
emergency-restart.h
emulate_prefix.h
entry-common.h
espfix.h
exec.h
extable.h
fb.h
fixmap.h
floppy.h
frame.h
fsgsbase.h
ftrace.h
futex.h
gart.h
GEN-for-each-reg.h
genapic.h
geode.h
hardirq.h
highmem.h
hpet.h
hugetlb.h
hw_breakpoint.h
hw_irq.h
hyperv-tlfs.h
hypervisor.h
i8259.h
ia32.h
ia32_unistd.h
idtentry.h
imr.h
inat.h
inat_types.h
init.h
insn-eval.h
insn.h
inst.h
intel-family.h
intel-mid.h
intel_ds.h
intel_mid_vrtc.h
intel_pconfig.h
intel_pt.h
intel_punit_ipc.h
intel_scu_ipc.h
intel_scu_ipc_legacy.h
intel_telemetry.h
invpcid.h
io.h
io_apic.h
io_bitmap.h
iomap.h
iommu.h
iommu_table.h
iosf_mbi.h
irq.h
irq_remapping.h
irq_stack.h
irq_vectors.h
irq_work.h
irqdomain.h
irqflags.h x86/xen: Drop USERGS_SYSRET64 paravirt call 2024-11-19 12:26:38 +01:00
ist.h
jailhouse_para.h
jump_label.h
kasan.h
kaslr.h
kbdleds.h
Kbuild
kdebug.h
kexec-bzimage64.h
kexec.h
kfence.h
kgdb.h
kmap_types.h
kprobes.h
kvm_host.h
kvm_page_track.h
kvm_para.h
kvm_types.h
kvm_vcpu_regs.h
kvmclock.h
linkage.h
livepatch.h
local.h
mach_timer.h
mach_traps.h
math_emu.h
mc146818rtc.h
mce.h
mem_encrypt.h
memtype.h
microcode.h
microcode_amd.h
microcode_intel.h
misc.h
mmconfig.h
mmu.h
mmu_context.h
mmx.h
mmzone.h
mmzone_32.h
mmzone_64.h
module.h
mpspec.h
mpspec_def.h
mshyperv.h
msi.h
msidef.h
msr-index.h x86/rfds: Mitigate Register File Data Sampling (RFDS) 2024-11-19 09:22:40 +01:00
msr-trace.h
msr.h
mtrr.h
mwait.h
nmi.h
nops.h
nospec-branch.h x86/bugs: Fix the SRSO mitigation on Zen3/4 2024-11-19 09:23:11 +01:00
numa.h
numa_32.h
olpc.h
olpc_ofw.h
orc_lookup.h
orc_types.h
page.h
page_32.h
page_32_types.h
page_64.h
page_64_types.h
page_types.h
paravirt.h x86/xen: Drop USERGS_SYSRET64 paravirt call 2024-11-19 12:26:38 +01:00
paravirt_types.h x86/xen: Drop USERGS_SYSRET64 paravirt call 2024-11-19 12:26:38 +01:00
parport.h
pci-direct.h
pci-functions.h
pci.h
pci_x86.h
percpu.h
perf_event.h
perf_event_p4.h
pgalloc.h
pgtable-2level.h
pgtable-2level_types.h
pgtable-3level.h
pgtable-3level_types.h
pgtable-invert.h
pgtable.h
pgtable_32.h
pgtable_32_areas.h
pgtable_32_types.h
pgtable_64.h
pgtable_64_types.h
pgtable_areas.h
pgtable_types.h
pkeys.h
platform_sst_audio.h
pm-trace.h
posix_types.h
preempt.h
probe_roms.h
processor-cyrix.h
processor-flags.h
processor.h x86/mm: Remove broken vsyscall emulation code from the page fault code 2024-11-19 12:27:13 +01:00
prom.h
proto.h
pti.h
ptrace.h
purgatory.h
pvclock-abi.h
pvclock.h
qrwlock.h
qspinlock.h
qspinlock_paravirt.h
realmode.h
reboot.h
reboot_fixups.h
required-features.h x86/cpufeatures: Add new word for scattered features 2024-11-19 09:22:44 +01:00
resctrl.h
rmwcc.h
seccomp.h
sections.h
segment.h
serial.h
set_memory.h
setup.h x86/head/64: Re-enable stack protection 2024-11-19 09:23:16 +01:00
setup_arch.h
sev-es.h
shmparam.h
sigcontext.h
sigframe.h
sighandling.h
signal.h
simd.h
smap.h
smp.h
sparsemem.h
spec-ctrl.h
special_insns.h
spinlock.h
spinlock_types.h
sta2x11.h
stackprotector.h
stacktrace.h
static_call.h
string.h
string_32.h
string_64.h
suspend.h
suspend_32.h
suspend_64.h
svm.h
swiotlb.h
switch_to.h
sync_bitops.h
sync_core.h
syscall.h x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments() 2024-11-23 23:21:39 +01:00
syscall_wrapper.h
syscalls.h
sysfb.h
text-patching.h
thread_info.h
time.h
timer.h
timex.h
tlb.h
tlbbatch.h
tlbflush.h
topology.h
trace_clock.h
trap_pf.h
trapnr.h
traps.h
tsc.h
uaccess.h
uaccess_32.h
uaccess_64.h
umip.h
unaligned.h
unistd.h
unwind.h
unwind_hints.h
uprobes.h
user.h
user32.h
user_32.h
user_64.h
vdso.h
vermagic.h
vga.h
vgtod.h
virtext.h
vm86.h
vmalloc.h
vmware.h
vmx.h
vmxfeatures.h
vsyscall.h
vvar.h
word-at-a-time.h
x86_init.h
xor.h
xor_32.h
xor_64.h
xor_avx.h