Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

32-bit userspace ABI: introduce ARCH_32BIT_OFF_T config option

All new 32-bit architectures should have 64-bit userspace off_t type, but
existing architectures has 32-bit ones.

To enforce the rule, new config option is added to arch/Kconfig that defaults
ARCH_32BIT_OFF_T to be disabled for new 32-bit architectures. All existing
32-bit architectures enable it explicitly.

New option affects force_o_largefile() behaviour. Namely, if userspace
off_t is 64-bits long, we have no reason to reject user to open big files.

Note that even if architectures has only 64-bit off_t in the kernel
(arc, c6x, h8300, hexagon, nios2, openrisc, and unicore32),
a libc may use 32-bit off_t, and therefore want to limit the file size
to 4GB unless specified differently in the open flags.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Yury Norov <ynorov@marvell.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Yury Norov and committed by
Arnd Bergmann
942fa985 0d0216c0

+32 -1
+10
arch/Kconfig
··· 276 276 config ARCH_WANTS_DYNAMIC_TASK_STRUCT 277 277 bool 278 278 279 + config ARCH_32BIT_OFF_T 280 + bool 281 + depends on !64BIT 282 + help 283 + All new 32-bit architectures should have 64-bit off_t type on 284 + userspace side which corresponds to the loff_t kernel type. This 285 + is the requirement for modern ABIs. Some existing architectures 286 + still support 32-bit off_t. This option is enabled for all such 287 + architectures explicitly. 288 + 279 289 config HAVE_REGS_AND_STACK_ACCESS_API 280 290 bool 281 291 help
+1
arch/arc/Kconfig
··· 14 14 select ARCH_HAS_SYNC_DMA_FOR_CPU 15 15 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 16 16 select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC 17 + select ARCH_32BIT_OFF_T 17 18 select BUILDTIME_EXTABLE_SORT 18 19 select CLONE_BACKWARDS 19 20 select COMMON_CLK
+1
arch/arm/Kconfig
··· 2 2 config ARM 3 3 bool 4 4 default y 5 + select ARCH_32BIT_OFF_T 5 6 select ARCH_CLOCKSOURCE_DATA 6 7 select ARCH_DISCARD_MEMBLOCK if !HAVE_ARCH_PFN_VALID && !KEXEC 7 8 select ARCH_HAS_DEBUG_VIRTUAL if MMU
+1
arch/c6x/Kconfig
··· 6 6 7 7 config C6X 8 8 def_bool y 9 + select ARCH_32BIT_OFF_T 9 10 select ARCH_HAS_SYNC_DMA_FOR_CPU 10 11 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 11 12 select CLKDEV_LOOKUP
+1
arch/csky/Kconfig
··· 1 1 config CSKY 2 2 def_bool y 3 + select ARCH_32BIT_OFF_T 3 4 select ARCH_HAS_SYNC_DMA_FOR_CPU 4 5 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 5 6 select ARCH_USE_BUILTIN_BSWAP
+1
arch/h8300/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 config H8300 3 3 def_bool y 4 + select ARCH_32BIT_OFF_T 4 5 select GENERIC_ATOMIC64 5 6 select HAVE_UID16 6 7 select VIRT_TO_BUS
+1
arch/hexagon/Kconfig
··· 4 4 5 5 config HEXAGON 6 6 def_bool y 7 + select ARCH_32BIT_OFF_T 7 8 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 8 9 select ARCH_NO_PREEMPT 9 10 select HAVE_OPROFILE
+1
arch/m68k/Kconfig
··· 2 2 config M68K 3 3 bool 4 4 default y 5 + select ARCH_32BIT_OFF_T 5 6 select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA 6 7 select ARCH_MIGHT_HAVE_PC_PARPORT if ISA 7 8 select ARCH_NO_COHERENT_DMA_MMAP if !MMU
+1
arch/microblaze/Kconfig
··· 1 1 config MICROBLAZE 2 2 def_bool y 3 + select ARCH_32BIT_OFF_T 3 4 select ARCH_NO_SWAP 4 5 select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU 5 6 select ARCH_HAS_GCOV_PROFILE_ALL
+1
arch/mips/Kconfig
··· 2 2 config MIPS 3 3 bool 4 4 default y 5 + select ARCH_32BIT_OFF_T if !64BIT 5 6 select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT 6 7 select ARCH_CLOCKSOURCE_DATA 7 8 select ARCH_DISCARD_MEMBLOCK
+1
arch/nds32/Kconfig
··· 5 5 6 6 config NDS32 7 7 def_bool y 8 + select ARCH_32BIT_OFF_T 8 9 select ARCH_HAS_SYNC_DMA_FOR_CPU 9 10 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 10 11 select ARCH_WANT_FRAME_POINTERS if FTRACE
+1
arch/nios2/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 config NIOS2 3 3 def_bool y 4 + select ARCH_32BIT_OFF_T 4 5 select ARCH_HAS_SYNC_DMA_FOR_CPU 5 6 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 6 7 select ARCH_NO_SWAP
+1
arch/openrisc/Kconfig
··· 6 6 7 7 config OPENRISC 8 8 def_bool y 9 + select ARCH_32BIT_OFF_T 9 10 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 10 11 select OF 11 12 select OF_EARLY_FLATTREE
+1
arch/parisc/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 config PARISC 3 3 def_bool y 4 + select ARCH_32BIT_OFF_T if !64BIT 4 5 select ARCH_MIGHT_HAVE_PC_PARPORT 5 6 select HAVE_IDE 6 7 select HAVE_OPROFILE
+1
arch/powerpc/Kconfig
··· 128 128 # 129 129 # Please keep this list sorted alphabetically. 130 130 # 131 + select ARCH_32BIT_OFF_T if PPC32 131 132 select ARCH_HAS_DEBUG_VIRTUAL 132 133 select ARCH_HAS_DEVMEM_IS_ALLOWED 133 134 select ARCH_HAS_DMA_SET_COHERENT_MASK
+1
arch/riscv/Kconfig
··· 11 11 12 12 config RISCV 13 13 def_bool y 14 + select ARCH_32BIT_OFF_T if !64BIT 14 15 # even on 32-bit, physical (and DMA) addresses are > 32-bits 15 16 select PHYS_ADDR_T_64BIT 16 17 select OF
+1
arch/sh/Kconfig
··· 62 62 63 63 config SUPERH32 64 64 def_bool "$(ARCH)" = "sh" 65 + select ARCH_32BIT_OFF_T 65 66 select HAVE_KPROBES 66 67 select HAVE_KRETPROBES 67 68 select HAVE_IOREMAP_PROT if MMU && !X2TLB
+1
arch/sparc/Kconfig
··· 49 49 50 50 config SPARC32 51 51 def_bool !64BIT 52 + select ARCH_32BIT_OFF_T 52 53 select ARCH_HAS_SYNC_DMA_FOR_CPU 53 54 select GENERIC_ATOMIC64 54 55 select CLZ_TAB
+1
arch/unicore32/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 config UNICORE32 3 3 def_bool y 4 + select ARCH_32BIT_OFF_T 4 5 select ARCH_HAS_DEVMEM_IS_ALLOWED 5 6 select ARCH_MIGHT_HAVE_PC_PARPORT 6 7 select ARCH_MIGHT_HAVE_PC_SERIO
+1
arch/x86/Kconfig
··· 47 47 select ACPI_LEGACY_TABLES_LOOKUP if ACPI 48 48 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI 49 49 select ANON_INODES 50 + select ARCH_32BIT_OFF_T if X86_32 50 51 select ARCH_CLOCKSOURCE_DATA 51 52 select ARCH_CLOCKSOURCE_INIT 52 53 select ARCH_DISCARD_MEMBLOCK
+1
arch/x86/um/Kconfig
··· 17 17 config X86_32 18 18 def_bool !64BIT 19 19 select HAVE_AOUT 20 + select ARCH_32BIT_OFF_T 20 21 select ARCH_WANT_IPC_PARSE_VERSION 21 22 select MODULES_USE_ELF_REL 22 23 select CLONE_BACKWARDS
+1
arch/xtensa/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 config XTENSA 3 3 def_bool y 4 + select ARCH_32BIT_OFF_T 4 5 select ARCH_HAS_SYNC_DMA_FOR_CPU 5 6 select ARCH_HAS_SYNC_DMA_FOR_DEVICE 6 7 select ARCH_NO_COHERENT_DMA_MMAP if !MMU
+1 -1
include/linux/fcntl.h
··· 12 12 O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE) 13 13 14 14 #ifndef force_o_largefile 15 - #define force_o_largefile() (BITS_PER_LONG != 32) 15 + #define force_o_largefile() (!IS_ENABLED(CONFIG_ARCH_32BIT_OFF_T)) 16 16 #endif 17 17 18 18 #if BITS_PER_LONG == 32