s390,alpha: switch to 64-bit ino_t
authorHeiko Carstens <hca@linux.ibm.com>
Wed, 10 Feb 2021 20:51:02 +0000 (21:51 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Sat, 13 Feb 2021 16:17:53 +0000 (17:17 +0100)
s390 and alpha are the only 64 bit architectures with a 32-bit ino_t.
Since this is quite unusual this causes bugs from time to time.

See e.g. commit ebce3eb2f7ef ("ceph: fix inode number handling on
arches with 32-bit ino_t") for an example.

This (obviously) also prevents s390 and alpha to use 64-bit ino_t for
tmpfs. See commit b85a7a8bb573 ("tmpfs: disallow CONFIG_TMPFS_INODE64
on s390").

Therefore switch both s390 and alpha to 64-bit ino_t. This should only
have an effect on the ustat system call. To prevent ABI breakage
define struct ustat compatible to the old layout and change
sys_ustat() accordingly.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/Kconfig
arch/alpha/Kconfig
arch/s390/Kconfig
fs/statfs.c
include/linux/types.h

index 24862d1..383c98e 100644 (file)
@@ -327,6 +327,10 @@ config ARCH_32BIT_OFF_T
          still support 32-bit off_t. This option is enabled for all such
          architectures explicitly.
 
+# Selected by 64 bit architectures which have a 32 bit f_tinode in struct ustat
+config ARCH_32BIT_USTAT_F_TINODE
+       bool
+
 config HAVE_ASM_MODVERSIONS
        bool
        help
index 1f51437..96ce656 100644 (file)
@@ -2,6 +2,7 @@
 config ALPHA
        bool
        default y
+       select ARCH_32BIT_USTAT_F_TINODE
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select ARCH_MIGHT_HAVE_PC_SERIO
        select ARCH_NO_PREEMPT
index 5de9f40..b68e695 100644 (file)
@@ -58,6 +58,7 @@ config S390
        # Note: keep this list sorted alphabetically
        #
        imply IMA_SECURE_AND_OR_TRUSTED_BOOT
+       select ARCH_32BIT_USTAT_F_TINODE
        select ARCH_BINFMT_ELF_STATE
        select ARCH_HAS_DEBUG_VM_PGTABLE
        select ARCH_HAS_DEBUG_WX
index 68cb077..0ba34c1 100644 (file)
@@ -255,7 +255,10 @@ SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
 
        memset(&tmp,0,sizeof(struct ustat));
        tmp.f_tfree = sbuf.f_bfree;
-       tmp.f_tinode = sbuf.f_ffree;
+       if (IS_ENABLED(CONFIG_ARCH_32BIT_USTAT_F_TINODE))
+               tmp.f_tinode = min_t(u64, sbuf.f_ffree, UINT_MAX);
+       else
+               tmp.f_tinode = sbuf.f_ffree;
 
        return copy_to_user(ubuf, &tmp, sizeof(struct ustat)) ? -EFAULT : 0;
 }
index a147977..ac825ad 100644 (file)
@@ -14,7 +14,7 @@ typedef u32 __kernel_dev_t;
 
 typedef __kernel_fd_set                fd_set;
 typedef __kernel_dev_t         dev_t;
-typedef __kernel_ino_t         ino_t;
+typedef __kernel_ulong_t       ino_t;
 typedef __kernel_mode_t                mode_t;
 typedef unsigned short         umode_t;
 typedef u32                    nlink_t;
@@ -189,7 +189,11 @@ struct hlist_node {
 
 struct ustat {
        __kernel_daddr_t        f_tfree;
-       __kernel_ino_t          f_tinode;
+#ifdef CONFIG_ARCH_32BIT_USTAT_F_TINODE
+       unsigned int            f_tinode;
+#else
+       unsigned long           f_tinode;
+#endif
        char                    f_fname[6];
        char                    f_fpack[6];
 };