Skip to content

Commit 942fa98

Browse files
norovarndb
authored andcommitted
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>
1 parent 0d0216c commit 942fa98

File tree

23 files changed

+32
-1
lines changed

23 files changed

+32
-1
lines changed

arch/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ config ARCH_THREAD_STACK_ALLOCATOR
276276
config ARCH_WANTS_DYNAMIC_TASK_STRUCT
277277
bool
278278

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+
279289
config HAVE_REGS_AND_STACK_ACCESS_API
280290
bool
281291
help

arch/arc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config ARC
1414
select ARCH_HAS_SYNC_DMA_FOR_CPU
1515
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
1616
select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
17+
select ARCH_32BIT_OFF_T
1718
select BUILDTIME_EXTABLE_SORT
1819
select CLONE_BACKWARDS
1920
select COMMON_CLK

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config ARM
33
bool
44
default y
5+
select ARCH_32BIT_OFF_T
56
select ARCH_CLOCKSOURCE_DATA
67
select ARCH_DISCARD_MEMBLOCK if !HAVE_ARCH_PFN_VALID && !KEXEC
78
select ARCH_HAS_DEBUG_VIRTUAL if MMU

arch/c6x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
config C6X
88
def_bool y
9+
select ARCH_32BIT_OFF_T
910
select ARCH_HAS_SYNC_DMA_FOR_CPU
1011
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
1112
select CLKDEV_LOOKUP

arch/csky/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
config CSKY
22
def_bool y
3+
select ARCH_32BIT_OFF_T
34
select ARCH_HAS_SYNC_DMA_FOR_CPU
45
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
56
select ARCH_USE_BUILTIN_BSWAP

arch/h8300/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
config H8300
33
def_bool y
4+
select ARCH_32BIT_OFF_T
45
select GENERIC_ATOMIC64
56
select HAVE_UID16
67
select VIRT_TO_BUS

arch/hexagon/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ comment "Linux Kernel Configuration for Hexagon"
44

55
config HEXAGON
66
def_bool y
7+
select ARCH_32BIT_OFF_T
78
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
89
select ARCH_NO_PREEMPT
910
select HAVE_OPROFILE

arch/m68k/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config M68K
33
bool
44
default y
5+
select ARCH_32BIT_OFF_T
56
select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
67
select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
78
select ARCH_NO_COHERENT_DMA_MMAP if !MMU

arch/microblaze/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
config MICROBLAZE
22
def_bool y
3+
select ARCH_32BIT_OFF_T
34
select ARCH_NO_SWAP
45
select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU
56
select ARCH_HAS_GCOV_PROFILE_ALL

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config MIPS
33
bool
44
default y
5+
select ARCH_32BIT_OFF_T if !64BIT
56
select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
67
select ARCH_CLOCKSOURCE_DATA
78
select ARCH_DISCARD_MEMBLOCK

arch/nds32/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
config NDS32
77
def_bool y
8+
select ARCH_32BIT_OFF_T
89
select ARCH_HAS_SYNC_DMA_FOR_CPU
910
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
1011
select ARCH_WANT_FRAME_POINTERS if FTRACE

arch/nios2/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
config NIOS2
33
def_bool y
4+
select ARCH_32BIT_OFF_T
45
select ARCH_HAS_SYNC_DMA_FOR_CPU
56
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
67
select ARCH_NO_SWAP

arch/openrisc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
config OPENRISC
88
def_bool y
9+
select ARCH_32BIT_OFF_T
910
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
1011
select OF
1112
select OF_EARLY_FLATTREE

arch/parisc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
config PARISC
33
def_bool y
4+
select ARCH_32BIT_OFF_T if !64BIT
45
select ARCH_MIGHT_HAVE_PC_PARPORT
56
select HAVE_IDE
67
select HAVE_OPROFILE

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ config PPC
128128
#
129129
# Please keep this list sorted alphabetically.
130130
#
131+
select ARCH_32BIT_OFF_T if PPC32
131132
select ARCH_HAS_DEBUG_VIRTUAL
132133
select ARCH_HAS_DEVMEM_IS_ALLOWED
133134
select ARCH_HAS_DMA_SET_COHERENT_MASK

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config 32BIT
1111

1212
config RISCV
1313
def_bool y
14+
select ARCH_32BIT_OFF_T if !64BIT
1415
# even on 32-bit, physical (and DMA) addresses are > 32-bits
1516
select PHYS_ADDR_T_64BIT
1617
select OF

arch/sh/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ config SUPERH
6262

6363
config SUPERH32
6464
def_bool "$(ARCH)" = "sh"
65+
select ARCH_32BIT_OFF_T
6566
select HAVE_KPROBES
6667
select HAVE_KRETPROBES
6768
select HAVE_IOREMAP_PROT if MMU && !X2TLB

arch/sparc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ config SPARC
4949

5050
config SPARC32
5151
def_bool !64BIT
52+
select ARCH_32BIT_OFF_T
5253
select ARCH_HAS_SYNC_DMA_FOR_CPU
5354
select GENERIC_ATOMIC64
5455
select CLZ_TAB

arch/unicore32/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
config UNICORE32
33
def_bool y
4+
select ARCH_32BIT_OFF_T
45
select ARCH_HAS_DEVMEM_IS_ALLOWED
56
select ARCH_MIGHT_HAVE_PC_PARPORT
67
select ARCH_MIGHT_HAVE_PC_SERIO

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ config X86
4747
select ACPI_LEGACY_TABLES_LOOKUP if ACPI
4848
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
4949
select ANON_INODES
50+
select ARCH_32BIT_OFF_T if X86_32
5051
select ARCH_CLOCKSOURCE_DATA
5152
select ARCH_CLOCKSOURCE_INIT
5253
select ARCH_DISCARD_MEMBLOCK

arch/x86/um/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ config 64BIT
1717
config X86_32
1818
def_bool !64BIT
1919
select HAVE_AOUT
20+
select ARCH_32BIT_OFF_T
2021
select ARCH_WANT_IPC_PARSE_VERSION
2122
select MODULES_USE_ELF_REL
2223
select CLONE_BACKWARDS

arch/xtensa/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
config XTENSA
33
def_bool y
4+
select ARCH_32BIT_OFF_T
45
select ARCH_HAS_SYNC_DMA_FOR_CPU
56
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
67
select ARCH_NO_COHERENT_DMA_MMAP if !MMU

include/linux/fcntl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE)
1313

1414
#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))
1616
#endif
1717

1818
#if BITS_PER_LONG == 32

0 commit comments

Comments
 (0)