1. 04 Sep, 2019 1 commit
  2. 30 Aug, 2019 19 commits
    • Arnd Bergmann's avatar
      Merge branch 'limits' of https://github.com/deepa-hub/vfs into y2038 · 9d14545b
      Arnd Bergmann authored
      The series is an update and a more complete version of the
      previously posted series at
      https://lore.kernel.org/linux-fsdevel/20180122020426.2988-1-deepa.kernel@gmail.com/
      
      Thanks to Arnd Bergmann for doing a few preliminary reviews.
      They helped me fix a few issues I had overlooked.
      
      The limits (sometimes granularity also) for the filesystems updated here are according to the
      following table:
      
      File system   Time type                      Start year Expiration year Granularity
      cramfs        fixed                          0          0
      romfs         fixed                          0          0
      pstore        ascii seconds (27 digit ascii) S64_MIN    S64_MAX         1
      coda          INT64                          S64_MIN    S64_MAX         1
      omfs          64-bit milliseconds            0          U64_MAX/ 1000   NSEC_PER_MSEC
      befs          unsigned 48-bit seconds        0          0xffffffffffff  alloc_super
      bfs           unsigned 32-bit seconds        0          U32_MAX         alloc_super
      efs           unsigned 32-bit seconds        0          U32_MAX         alloc_super
      ext2          signed 32-bit seconds          S32_MIN    S32_MAX         alloc_super
      ext3          signed 32-bit seconds          S32_MIN    S32_MAX         alloc_super
      ext4 (old)    signed 32-bit seconds          S32_MIN    S32_MAX         alloc_super
      ext4 (extra)  34-bit seconds, 30-bit ns      S32_MIN    0x37fffffff     1
      freevxfs      u32 secs/usecs                 0          U32_MAX         alloc_super
      jffs2         unsigned 32-bit seconds        0          U32_MAX         alloc_super
      jfs           unsigned 32-bit seconds/ns     0          U32_MAX         1
      minix         unsigned 32-bit seconds        0          U32_MAX         alloc_super
      qnx4          unsigned 32-bit seconds        0          U32_MAX         alloc_super
      qnx6          unsigned 32-bit seconds        0          U32_MAX         alloc_super
      reiserfs      unsigned 32-bit seconds        0          U32_MAX         alloc_super
      squashfs      unsigned 32-bit seconds        0          U32_MAX         alloc_super
      ufs1          signed 32-bit seconds          S32_MIN    S32_MAX         NSEC_PER_SEC
      ufs2          signed 64-bit seconds/u32 ns   S64_MIN    S64_MAX         1
      xfs           signed 32-bit seconds/ns       S32_MIN    S32_MAX         1
      ceph          unsigned 32-bit second/ns      0          U32_MAX         1000
      sysv          unsigned 32-bit seconds        0          U32_MAX         alloc_super
      affs          u32 day, min, ticks            1978       u32_max days    NSEC_PER_SEC
      nfsv2         unsigned 32-bit seconds/ns     0          U32_MAX         1
      nfsv3         unsigned 32-bit seconds/ns     0          U32_MAX         1000
      nfsv4         u64 seconds/u32 ns             S64_MIN    S64_MAX         1000
      isofs         u8 year since 1900 (fixable)   1900       2155            alloc_super
      hpfs          unsigned 32-bit seconds        1970       2106            alloc_super
      fat           7-bit years, 2s resolution     1980       2107
      cifs (smb)    7-bit years                    1980       2107
      cifs (modern) 64-bit 100ns since 1601        1601       30828
      9p (9P2000)   unsigned 32-bit seconds        1970       2106
      9p (9P2000.L) signed 64-bit seconds, ns      1970       S64_MAX
      
      Granularity column filled in by the alloc_super() in the above table indicates that
      the granularity is NSEC_PER_SEC.
      Note that anything not mentioned above still has the default limits
      S64_MIN..S64_MAX.
      
      The patches in the series are as structured below:
      1. Add vfs support to maintain the limits per filesystem.
      2. Add a new timestamp_truncate() api for clamping timestamps
         according to the filesystem limits.
      3. Add a warning for mount syscall to indicate the impending
         expiry of timestamps.
      4. Modify utimes to clamp the timestamps.
      5. Fill in limits for filesystems.
      
      A test for checking file system timestamp limits has been posted
      at https://www.spinics.net/lists/fstests/msg12262.html
      
      Changes since v8:
      * Dropped orangefs patch because of ongoing discussion
      * Dropped adfs patch because a conflict with Russell's ADFS series
      Changes since v7:
      * Dropped fat modifications from timespec_truncate patch
      * Leverage timestamp_truncate function in utimes
      * Added a fix for pstore ramoops timestamps
      * Added ext4 warning for inodes without room for extended timestamps.
      * Made mount warning more human readable
      Changes since v6:
      * No change in mount behavior because of expiry of timestamps.
      * Included limits for more filesystems.
      Changes since v5:
      * Dropped y2038-specific changes
      Changes since v4:
      * Added documentation for boot param
      Changes since v3:
      * Remove redundant initializations in libfs.c
      * Change early_param to __setup similar to other root mount options.
      * Fix documentation warning
      Changes since v2:
      * Introduce early boot param override for checks.
      * Drop afs patch for timestamp limits.
      Changes since v1:
      * return EROFS on mount errors
      * fix mtime copy/paste error in utimes
      
      * 'limits' of https://github.com/deepa-hub/vfs:
        isofs: Initialize filesystem timestamp ranges
        pstore: fs superblock limits
        fs: omfs: Initialize filesystem timestamp ranges
        fs: hpfs: Initialize filesystem timestamp ranges
        fs: ceph: Initialize filesystem timestamp ranges
        fs: sysv: Initialize filesystem timestamp ranges
        fs: affs: Initialize filesystem timestamp ranges
        fs: fat: Initialize filesystem timestamp ranges
        fs: cifs: Initialize filesystem timestamp ranges
        fs: nfs: Initialize filesystem timestamp ranges
        ext4: Initialize timestamps limits
        9p: Fill min and max timestamps in sb
        fs: Fill in max and min timestamps in superblock
        utimes: Clamp the timestamps before update
        mount: Add mount warning for impending timestamp expiry
        timestamp_truncate: Replace users of timespec64_trunc
        vfs: Add timestamp_truncate() api
        vfs: Add file timestamp range support
      
      Link: https://lore.kernel.org/lkml/20190730014924.2193-1-deepa.kernel@gmail.com/
      Link: https://lore.kernel.org/lkml/20190830154744.4868-1-deepa.kernel@gmail.com/Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      9d14545b
    • Deepa Dinamani's avatar
      isofs: Initialize filesystem timestamp ranges · 5ad32b3a
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      Reference: http://www.ecma-international.org/publications/standards/Ecma-119.htmSigned-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      5ad32b3a
    • Deepa Dinamani's avatar
      pstore: fs superblock limits · 83b8a3fb
      Deepa Dinamani authored
      Leaving granularity at 1ns because it is dependent on the specific
      attached backing pstore module. ramoops has microsecond resolution.
      
      Fix the readback of ramoops fractional timestamp microseconds,
      which has incorrectly been reporting the value as nanoseconds.
      
      Fixes: 3f8f80f0 ("pstore/ram: Read and write to the 'compressed' flag of pstore").
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: anton@enomsg.org
      Cc: ccross@android.com
      Cc: keescook@chromium.org
      Cc: tony.luck@intel.com
      83b8a3fb
    • Deepa Dinamani's avatar
      fs: omfs: Initialize filesystem timestamp ranges · 8833293d
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarBob Copeland <me@bobcopeland.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: me@bobcopeland.com
      Cc: linux-karma-devel@lists.sourceforge.net
      8833293d
    • Deepa Dinamani's avatar
      fs: hpfs: Initialize filesystem timestamp ranges · cdd62b5b
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      Also change the local_to_gmt() to use time64_t instead
      of time32_t.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: mikulas@artax.karlin.mff.cuni.cz
      cdd62b5b
    • Deepa Dinamani's avatar
      fs: ceph: Initialize filesystem timestamp ranges · 028ca4db
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      According to the disscussion in
      https://patchwork.kernel.org/patch/8308691/ we agreed to use
      unsigned 32 bit timestamps on ceph.
      Update the limits accordingly.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: zyan@redhat.com
      Cc: sage@redhat.com
      Cc: idryomov@gmail.com
      Cc: ceph-devel@vger.kernel.org
      028ca4db
    • Deepa Dinamani's avatar
      fs: sysv: Initialize filesystem timestamp ranges · 452c2779
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: hch@infradead.org
      452c2779
    • Deepa Dinamani's avatar
      fs: affs: Initialize filesystem timestamp ranges · 487b25bc
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      Also fix timestamp calculation to avoid overflow
      while converting from days to seconds.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarDavid Sterba <dsterba@suse.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: dsterba@suse.com
      487b25bc
    • Deepa Dinamani's avatar
      fs: fat: Initialize filesystem timestamp ranges · c0da64f6
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      Some FAT variants indicate that the years after 2099 are not supported.
      Since commit 7decd1cb ("fat: Fix and cleanup timestamp conversion")
      we support the full range of years that can be represented, up to 2107.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: hirofumi@mail.parknet.co.jp
      c0da64f6
    • Deepa Dinamani's avatar
      fs: cifs: Initialize filesystem timestamp ranges · cb7a69e6
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      Also fixed cnvrtDosUnixTm calculations to avoid int overflow
      while computing maximum date.
      
      References:
      
      http://cifs.com/
      
      https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2bSigned-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: sfrench@samba.org
      Cc: linux-cifs@vger.kernel.org
      cb7a69e6
    • Deepa Dinamani's avatar
      fs: nfs: Initialize filesystem timestamp ranges · 1fcb79c1
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      The time formats for various verious is detailed in the
      RFCs as below:
      
      https://tools.ietf.org/html/rfc7862(time metadata)
      https://tools.ietf.org/html/rfc7530:
      
      nfstime4
      
         struct nfstime4 {
                 int64_t         seconds;
                 uint32_t        nseconds;
         };
      
      https://tools.ietf.org/html/rfc1094
      
                struct timeval {
                    unsigned int seconds;
                    unsigned int useconds;
                };
      
      https://tools.ietf.org/html/rfc1813
      
      struct nfstime3 {
               uint32   seconds;
               uint32   nseconds;
            };
      
      Use the limits as per the RFC.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: trond.myklebust@hammerspace.com
      Cc: anna.schumaker@netapp.com
      Cc: linux-nfs@vger.kernel.org
      1fcb79c1
    • Deepa Dinamani's avatar
      ext4: Initialize timestamps limits · 4881c497
      Deepa Dinamani authored
      ext4 has different overflow limits for max filesystem
      timestamps based on the extra bytes available.
      
      The timestamp limits are calculated according to the
      encoding table in
      a4dad1aei(ext4: Fix handling of extended tv_sec):
      
      * extra  msb of                         adjust for signed
      * epoch  32-bit                         32-bit tv_sec to
      * bits   time    decoded 64-bit tv_sec  64-bit tv_sec      valid time range
      * 0 0    1    -0x80000000..-0x00000001  0x000000000   1901-12-13..1969-12-31
      * 0 0    0    0x000000000..0x07fffffff  0x000000000   1970-01-01..2038-01-19
      * 0 1    1    0x080000000..0x0ffffffff  0x100000000   2038-01-19..2106-02-07
      * 0 1    0    0x100000000..0x17fffffff  0x100000000   2106-02-07..2174-02-25
      * 1 0    1    0x180000000..0x1ffffffff  0x200000000   2174-02-25..2242-03-16
      * 1 0    0    0x200000000..0x27fffffff  0x200000000   2242-03-16..2310-04-04
      * 1 1    1    0x280000000..0x2ffffffff  0x300000000   2310-04-04..2378-04-22
      * 1 1    0    0x300000000..0x37fffffff  0x300000000   2378-04-22..2446-05-10
      
      Note that the time limits are not correct for deletion times.
      
      Added a warn when an inode cannot be extended to incorporate an
      extended timestamp.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: tytso@mit.edu
      Cc: adilger.kernel@dilger.ca
      Cc: linux-ext4@vger.kernel.org
      4881c497
    • Deepa Dinamani's avatar
      9p: Fill min and max timestamps in sb · d5c6e2d5
      Deepa Dinamani authored
      struct p9_wstat and struct p9_stat_dotl indicate that the
      wire transport uses u32 and u64 fields for timestamps.
      Fill in the appropriate limits to avoid inconsistencies in
      the vfs cached inode times when timestamps are outside the
      permitted range.
      
      Note that the upper bound for V9FS_PROTO_2000L is retained as S64_MAX.
      This is because that is the upper bound supported by vfs.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: ericvh@gmail.com
      Cc: lucho@ionkov.net
      Cc: asmadeus@codewreck.org
      Cc: v9fs-developer@lists.sourceforge.net
      d5c6e2d5
    • Deepa Dinamani's avatar
      fs: Fill in max and min timestamps in superblock · 22b13969
      Deepa Dinamani authored
      Fill in the appropriate limits to avoid inconsistencies
      in the vfs cached inode times when timestamps are
      outside the permitted range.
      
      Even though some filesystems are read-only, fill in the
      timestamps to reflect the on-disk representation.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Acked-By: default avatarTigran Aivazian <aivazian.tigran@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: aivazian.tigran@gmail.com
      Cc: al@alarsen.net
      Cc: coda@cs.cmu.edu
      Cc: darrick.wong@oracle.com
      Cc: dushistov@mail.ru
      Cc: dwmw2@infradead.org
      Cc: hch@infradead.org
      Cc: jack@suse.com
      Cc: jaharkes@cs.cmu.edu
      Cc: luisbg@kernel.org
      Cc: nico@fluxnic.net
      Cc: phillip@squashfs.org.uk
      Cc: richard@nod.at
      Cc: salah.triki@gmail.com
      Cc: shaggy@kernel.org
      Cc: linux-xfs@vger.kernel.org
      Cc: codalist@coda.cs.cmu.edu
      Cc: linux-ext4@vger.kernel.org
      Cc: linux-mtd@lists.infradead.org
      Cc: jfs-discussion@lists.sourceforge.net
      Cc: reiserfs-devel@vger.kernel.org
      22b13969
    • Deepa Dinamani's avatar
      utimes: Clamp the timestamps before update · 42e729b9
      Deepa Dinamani authored
      POSIX is ambiguous on the behavior of timestamps for
      futimens, utimensat and utimes. Whether to return an
      error or silently clamp a timestamp beyond the range
      supported by the underlying filesystems is not clear.
      
      POSIX.1 section for futimens, utimensat and utimes says:
      (http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html)
      
      The file's relevant timestamp shall be set to the greatest
      value supported by the file system that is not greater
      than the specified time.
      
      If the tv_nsec field of a timespec structure has the special
      value UTIME_NOW, the file's relevant timestamp shall be set
      to the greatest value supported by the file system that is
      not greater than the current time.
      
      [EINVAL]
          A new file timestamp would be a value whose tv_sec
          component is not a value supported by the file system.
      
      The patch chooses to clamp the timestamps according to the
      filesystem timestamp ranges and does not return an error.
      This is in line with the behavior of utime syscall also
      since the POSIX page(http://pubs.opengroup.org/onlinepubs/009695399/functions/utime.html)
      for utime does not mention returning an error or clamping like above.
      
      Same for utimes http://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.htmlSigned-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      42e729b9
    • Deepa Dinamani's avatar
      mount: Add mount warning for impending timestamp expiry · f8b92ba6
      Deepa Dinamani authored
      The warning reuses the uptime max of 30 years used by
      settimeofday().
      
      Note that the warning is only emitted for writable filesystem mounts
      through the mount syscall. Automounts do not have the same warning.
      
      Print out the warning in human readable format using the struct tm.
      After discussion with Arnd Bergmann, we chose to print only the year number.
      The raw s_time_max is also displayed, and the user can easily decode
      it e.g. "date -u -d @$((0x7fffffff))". We did not want to consolidate
      struct rtc_tm and struct tm just to print the date using a format specifier
      as part of this series.
      Given that the rtc_tm is not compiled on all architectures, this is not a
      trivial patch. This can be added in the future.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      f8b92ba6
    • Deepa Dinamani's avatar
      timestamp_truncate: Replace users of timespec64_trunc · 3818c190
      Deepa Dinamani authored
      Update the inode timestamp updates to use timestamp_truncate()
      instead of timespec64_trunc().
      
      The change was mostly generated by the following coccinelle
      script.
      
      virtual context
      virtual patch
      
      @r1 depends on patch forall@
      struct inode *inode;
      identifier i_xtime =~ "^i_[acm]time$";
      expression e;
      @@
      
      inode->i_xtime =
      - timespec64_trunc(
      + timestamp_truncate(
      ...,
      - e);
      + inode);
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Cc: adrian.hunter@intel.com
      Cc: dedekind1@gmail.com
      Cc: gregkh@linuxfoundation.org
      Cc: hch@lst.de
      Cc: jaegeuk@kernel.org
      Cc: jlbec@evilplan.org
      Cc: richard@nod.at
      Cc: tj@kernel.org
      Cc: yuchao0@huawei.com
      Cc: linux-f2fs-devel@lists.sourceforge.net
      Cc: linux-ntfs-dev@lists.sourceforge.net
      Cc: linux-mtd@lists.infradead.org
      3818c190
    • Deepa Dinamani's avatar
      vfs: Add timestamp_truncate() api · 50e17c00
      Deepa Dinamani authored
      timespec_trunc() function is used to truncate a
      filesystem timestamp to the right granularity.
      But, the function does not clamp tv_sec part of the
      timestamps according to the filesystem timestamp limits.
      
      The replacement api: timestamp_truncate() also alters the
      signature of the function to accommodate filesystem
      timestamp clamping according to flesystem limits.
      
      Note that the tv_nsec part is set to 0 if tv_sec is not within
      the range supported for the filesystem.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      50e17c00
    • Deepa Dinamani's avatar
      vfs: Add file timestamp range support · 188d20bc
      Deepa Dinamani authored
      Add fields to the superblock to track the min and max
      timestamps supported by filesystems.
      
      Initially, when a superblock is allocated, initialize
      it to the max and min values the fields can hold.
      Individual filesystems override these to match their
      actual limits.
      
      Pseudo filesystems are assumed to always support the
      min and max allowable values for the fields.
      Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      188d20bc
  3. 25 Aug, 2019 20 commits