32-bit userspace ABI: introduce ARCH_32BIT_OFF_T config option
authorYury Norov <ynorov@caviumnetworks.com>
Wed, 16 May 2018 08:18:49 +0000 (11:18 +0300)
committerArnd Bergmann <arnd@arndb.de>
Tue, 19 Feb 2019 09:10:05 +0000 (10:10 +0100)
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>
23 files changed:
arch/Kconfig
arch/arc/Kconfig
arch/arm/Kconfig
arch/c6x/Kconfig
arch/csky/Kconfig
arch/h8300/Kconfig
arch/hexagon/Kconfig
arch/m68k/Kconfig
arch/microblaze/Kconfig
arch/mips/Kconfig
arch/nds32/Kconfig
arch/nios2/Kconfig
arch/openrisc/Kconfig
arch/parisc/Kconfig
arch/powerpc/Kconfig
arch/riscv/Kconfig
arch/sh/Kconfig
arch/sparc/Kconfig
arch/unicore32/Kconfig
arch/x86/Kconfig
arch/x86/um/Kconfig
arch/xtensa/Kconfig
include/linux/fcntl.h

index 46db715a7f42150085d23f7298408aded6ecd4ac..cd5f443865ecaf4acf75ba301e389f94cb97ddc6 100644 (file)
@@ -276,6 +276,16 @@ config ARCH_THREAD_STACK_ALLOCATOR
 config ARCH_WANTS_DYNAMIC_TASK_STRUCT
        bool
 
+config ARCH_32BIT_OFF_T
+       bool
+       depends on !64BIT
+       help
+         All new 32-bit architectures should have 64-bit off_t type on
+         userspace side which corresponds to the loff_t kernel type. This
+         is the requirement for modern ABIs. Some existing architectures
+         still support 32-bit off_t. This option is enabled for all such
+         architectures explicitly.
+
 config HAVE_REGS_AND_STACK_ACCESS_API
        bool
        help
index 376366a7db81c8c979628d22c37a1028fcc12fed..1cfe4197146fefb0bb48c2aebb384c3d1622f7ed 100644 (file)
@@ -14,6 +14,7 @@ config ARC
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
+       select ARCH_32BIT_OFF_T
        select BUILDTIME_EXTABLE_SORT
        select CLONE_BACKWARDS
        select COMMON_CLK
index 664e918e26249a6dd0a43fa1c80eaf187a040821..8933f7337e56e765ab4077ccd764ed5b3776c117 100644 (file)
@@ -2,6 +2,7 @@
 config ARM
        bool
        default y
+       select ARCH_32BIT_OFF_T
        select ARCH_CLOCKSOURCE_DATA
        select ARCH_DISCARD_MEMBLOCK if !HAVE_ARCH_PFN_VALID && !KEXEC
        select ARCH_HAS_DEBUG_VIRTUAL if MMU
index 456e154674d1570dabb5609a5bb430e188975ab5..e5cd3c5f8399ce1cb055315083db5b2f4873a1fe 100644 (file)
@@ -6,6 +6,7 @@
 
 config C6X
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select CLKDEV_LOOKUP
index 398113c845f56c0d14a3d367af4d515b1586f7ad..6959e0b1e956a049c8acfd691cfe3d95e0c21a00 100644 (file)
@@ -1,5 +1,6 @@
 config CSKY
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_USE_BUILTIN_BSWAP
index 6472a06854703321e1d03c61c6054d41f4955c59..c071da34e0817be181e82ac3d7a9ca7eea85450c 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 config H8300
         def_bool y
+       select ARCH_32BIT_OFF_T
        select GENERIC_ATOMIC64
        select HAVE_UID16
        select VIRT_TO_BUS
index fb2fbfcfc532171192522db4e9541759f04eee09..ac441680dcc06acddcfdf717b1828c2cdc1962d8 100644 (file)
@@ -4,6 +4,7 @@ comment "Linux Kernel Configuration for Hexagon"
 
 config HEXAGON
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_NO_PREEMPT
        select HAVE_OPROFILE
index e173ea2ff3952ef28af8bdb60894837c0621348e..b54206408f91b9693581c9b6a139324a659cf361 100644 (file)
@@ -2,6 +2,7 @@
 config M68K
        bool
        default y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
        select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
        select ARCH_NO_COHERENT_DMA_MMAP if !MMU
index 58aff2653d86efdd6439ffa88b0234a25bf6e56e..a51b965b3b82359f5feb15aaef1529cdbaa0f32a 100644 (file)
@@ -1,5 +1,6 @@
 config MICROBLAZE
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_NO_SWAP
        select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU
        select ARCH_HAS_GCOV_PROFILE_ALL
index 787290781b8c6d52b7b937b222a1d61eec92f97c..d80ccabd3c06796b3501d9bc1a86ec5b104cfdf9 100644 (file)
@@ -2,6 +2,7 @@
 config MIPS
        bool
        default y
+       select ARCH_32BIT_OFF_T if !64BIT
        select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
        select ARCH_CLOCKSOURCE_DATA
        select ARCH_DISCARD_MEMBLOCK
index dda1906bba11c432dc609dc005a5feecd0010ee6..addb7f5f52645c75e83025f075d2878efd186d02 100644 (file)
@@ -5,6 +5,7 @@
 
 config NDS32
         def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_WANT_FRAME_POINTERS if FTRACE
index 532343eebf8901288d95645d13f1128ecfdff6ac..c3e913ef4f0c4cfc1b88bbe616373c96f8bbaccb 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 config NIOS2
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_NO_SWAP
index 09ab59e942ae2366f726fa3dee8b7309a7c5a970..a5e361fbb75a01400681b6238b21a7eea18b9607 100644 (file)
@@ -6,6 +6,7 @@
 
 config OPENRISC
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select OF
        select OF_EARLY_FLATTREE
index 7ca2c3ebad64d8ed6e4c3f5203cdec623bb4fb87..c8e621296092d83751ecdec774fb46aa430c6c04 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 config PARISC
        def_bool y
+       select ARCH_32BIT_OFF_T if !64BIT
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select HAVE_IDE
        select HAVE_OPROFILE
index 2890d36eb53116e9237944db4fd1862e480e262c..375d0dc0dc7d1a3f011c36f7ff8c0c940cf4aff1 100644 (file)
@@ -128,6 +128,7 @@ config PPC
        #
        # Please keep this list sorted alphabetically.
        #
+       select ARCH_32BIT_OFF_T if PPC32
        select ARCH_HAS_DEBUG_VIRTUAL
        select ARCH_HAS_DEVMEM_IS_ALLOWED
        select ARCH_HAS_DMA_SET_COHERENT_MASK
index feeeaa60697caae10cbfa1cbcff6b316440a048b..09fa3a87bf30153366a76cad99f1a29d8a61d8ea 100644 (file)
@@ -11,6 +11,7 @@ config 32BIT
 
 config RISCV
        def_bool y
+       select ARCH_32BIT_OFF_T if !64BIT
        # even on 32-bit, physical (and DMA) addresses are > 32-bits
        select PHYS_ADDR_T_64BIT
        select OF
index a9c36f95744a0ab7d1e4bc76d216124c2f88fe4d..d9a9144dec351292b8c282a01cb8915fc001147c 100644 (file)
@@ -62,6 +62,7 @@ config SUPERH
 
 config SUPERH32
        def_bool "$(ARCH)" = "sh"
+       select ARCH_32BIT_OFF_T
        select HAVE_KPROBES
        select HAVE_KRETPROBES
        select HAVE_IOREMAP_PROT if MMU && !X2TLB
index d5dd652fb8ccf64dde8040e58ec28b3aa42367df..40f8f4f73fe8fea23c31b73d9e4441dbd67fabf1 100644 (file)
@@ -49,6 +49,7 @@ config SPARC
 
 config SPARC32
        def_bool !64BIT
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select GENERIC_ATOMIC64
        select CLZ_TAB
index c3a41bfe161bf05de54910821318b401cb8314f8..a7f1ae58d2110af6a62aaf57dd4dc1bd7f308877 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 config UNICORE32
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_DEVMEM_IS_ALLOWED
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select ARCH_MIGHT_HAVE_PC_SERIO
index 15af091611e29cf2353befbaa260e40dc8664298..7aac274c2849588b9f3cee0258dc8e5e5b782afe 100644 (file)
@@ -47,6 +47,7 @@ config X86
        select ACPI_LEGACY_TABLES_LOOKUP        if ACPI
        select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
        select ANON_INODES
+       select ARCH_32BIT_OFF_T                 if X86_32
        select ARCH_CLOCKSOURCE_DATA
        select ARCH_CLOCKSOURCE_INIT
        select ARCH_DISCARD_MEMBLOCK
index f518b4744ff893282c45ec93746a40ffa7e9eda8..ab14e6f73ca46fa72bbf3f27b56707910d6a10e2 100644 (file)
@@ -17,6 +17,7 @@ config 64BIT
 config X86_32
        def_bool !64BIT
        select HAVE_AOUT
+       select ARCH_32BIT_OFF_T
        select ARCH_WANT_IPC_PARSE_VERSION
        select MODULES_USE_ELF_REL
        select CLONE_BACKWARDS
index 20a0756f27efffbecc3892cc1dee4c1d983483c7..2033b4485cc402d15d0dd5fe159c5ef933f6c8ed 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 config XTENSA
        def_bool y
+       select ARCH_32BIT_OFF_T
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_NO_COHERENT_DMA_MMAP if !MMU
index 27dc7a60693e15bca6b2394381870f5d427c7fd2..d019df946cb24d261effd36d542a75b2ec00e243 100644 (file)
@@ -12,7 +12,7 @@
         O_NOATIME | O_CLOEXEC | O_PATH | __O_TMPFILE)
 
 #ifndef force_o_largefile
-#define force_o_largefile() (BITS_PER_LONG != 32)
+#define force_o_largefile() (!IS_ENABLED(CONFIG_ARCH_32BIT_OFF_T))
 #endif
 
 #if BITS_PER_LONG == 32