* [PATCH v8 00/20] vfs: Add support for timestamp limits
@ 2019-08-18 16:57 Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 11/20] fs: cifs: Initialize filesystem timestamp ranges Deepa Dinamani
2019-08-20 11:05 ` [PATCH v8 00/20] vfs: Add support for timestamp limits Jeff Layton
0 siblings, 2 replies; 3+ messages in thread
From: Deepa Dinamani @ 2019-08-18 16:57 UTC (permalink / raw)
To: viro, linux-kernel
Cc: linux-fsdevel, y2038, arnd, adilger.kernel, adrian.hunter,
aivazian.tigran, al, anna.schumaker, anton, asmadeus, ccross,
ceph-devel, coda, codalist, darrick.wong, dedekind1, devel,
dsterba, dushistov, dwmw2, ericvh, gregkh, hch, hch, hirofumi,
hubcap, idryomov, jack, jaegeuk, jaharkes, jfs-discussion, jlbec,
keescook, linux-cifs, linux-ext4, linux-f2fs-devel,
linux-karma-devel, linux-mtd, linux-nfs, linux-ntfs-dev,
linux-xfs, lucho, luisbg, martin, me, mikulas, nico, phillip,
reiserfs-devel, richard, sage, salah.triki, sfrench, shaggy, tj,
tony.luck, trond.myklebust, tytso, v9fs-developer, yuchao0, zyan
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
orangefs u64 seconds 0 U64_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
adfs 40-bit cs since 1900 1900 2248
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 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
Deepa Dinamani (20):
vfs: Add file timestamp range support
vfs: Add timestamp_truncate() api
timestamp_truncate: Replace users of timespec64_trunc
mount: Add mount warning for impending timestamp expiry
utimes: Clamp the timestamps before update
fs: Fill in max and min timestamps in superblock
9p: Fill min and max timestamps in sb
adfs: Fill in max and min timestamps in sb
ext4: Initialize timestamps limits
fs: nfs: Initialize filesystem timestamp ranges
fs: cifs: Initialize filesystem timestamp ranges
fs: fat: Initialize filesystem timestamp ranges
fs: affs: Initialize filesystem timestamp ranges
fs: sysv: Initialize filesystem timestamp ranges
fs: ceph: Initialize filesystem timestamp ranges
fs: orangefs: Initialize filesystem timestamp ranges
fs: hpfs: Initialize filesystem timestamp ranges
fs: omfs: Initialize filesystem timestamp ranges
pstore: fs superblock limits
isofs: Initialize filesystem timestamp ranges
fs/9p/vfs_super.c | 6 +++++-
fs/adfs/adfs.h | 13 +++++++++++++
fs/adfs/inode.c | 8 ++------
fs/adfs/super.c | 2 ++
fs/affs/amigaffs.c | 2 +-
fs/affs/amigaffs.h | 3 +++
fs/affs/inode.c | 4 ++--
fs/affs/super.c | 4 ++++
fs/attr.c | 21 ++++++++++++---------
fs/befs/linuxvfs.c | 2 ++
fs/bfs/inode.c | 2 ++
fs/ceph/super.c | 2 ++
fs/cifs/cifsfs.c | 22 ++++++++++++++++++++++
fs/cifs/netmisc.c | 14 +++++++-------
fs/coda/inode.c | 3 +++
fs/configfs/inode.c | 12 ++++++------
fs/cramfs/inode.c | 2 ++
fs/efs/super.c | 2 ++
fs/ext2/super.c | 2 ++
fs/ext4/ext4.h | 10 +++++++++-
fs/ext4/super.c | 17 +++++++++++++++--
fs/f2fs/file.c | 21 ++++++++++++---------
fs/fat/inode.c | 12 ++++++++++++
fs/freevxfs/vxfs_super.c | 2 ++
fs/hpfs/hpfs_fn.h | 6 ++----
fs/hpfs/super.c | 2 ++
fs/inode.c | 33 ++++++++++++++++++++++++++++++++-
fs/isofs/inode.c | 7 +++++++
fs/jffs2/fs.c | 3 +++
fs/jfs/super.c | 2 ++
fs/kernfs/inode.c | 7 +++----
fs/minix/inode.c | 2 ++
fs/namespace.c | 33 ++++++++++++++++++++++++++++++++-
fs/nfs/super.c | 20 +++++++++++++++++++-
fs/ntfs/inode.c | 21 ++++++++++++---------
fs/omfs/inode.c | 4 ++++
fs/orangefs/super.c | 2 ++
fs/pstore/ram.c | 2 ++
fs/qnx4/inode.c | 2 ++
fs/qnx6/inode.c | 2 ++
fs/reiserfs/super.c | 3 +++
fs/romfs/super.c | 2 ++
fs/squashfs/super.c | 2 ++
fs/super.c | 2 ++
fs/sysv/super.c | 5 ++++-
fs/ubifs/file.c | 21 ++++++++++++---------
fs/ufs/super.c | 7 +++++++
fs/utimes.c | 6 ++----
fs/xfs/xfs_super.c | 2 ++
include/linux/fs.h | 5 +++++
include/linux/time64.h | 2 ++
51 files changed, 315 insertions(+), 78 deletions(-)
--
2.17.1
Cc: adilger.kernel@dilger.ca
Cc: adrian.hunter@intel.com
Cc: aivazian.tigran@gmail.com
Cc: al@alarsen.net
Cc: anna.schumaker@netapp.com
Cc: anton@enomsg.org
Cc: asmadeus@codewreck.org
Cc: ccross@android.com
Cc: ceph-devel@vger.kernel.org
Cc: coda@cs.cmu.edu
Cc: codalist@coda.cs.cmu.edu
Cc: darrick.wong@oracle.com
Cc: dedekind1@gmail.com
Cc: devel@lists.orangefs.org
Cc: dsterba@suse.com
Cc: dushistov@mail.ru
Cc: dwmw2@infradead.org
Cc: ericvh@gmail.com
Cc: gregkh@linuxfoundation.org
Cc: hch@infradead.org
Cc: hch@lst.de
Cc: hirofumi@mail.parknet.co.jp
Cc: hubcap@omnibond.com
Cc: idryomov@gmail.com
Cc: jack@suse.com
Cc: jaegeuk@kernel.org
Cc: jaharkes@cs.cmu.edu
Cc: jfs-discussion@lists.sourceforge.net
Cc: jlbec@evilplan.org
Cc: keescook@chromium.org
Cc: linux-cifs@vger.kernel.org
Cc: linux-ext4@vger.kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Cc: linux-karma-devel@lists.sourceforge.net
Cc: linux-mtd@lists.infradead.org
Cc: linux-nfs@vger.kernel.org
Cc: linux-ntfs-dev@lists.sourceforge.net
Cc: linux-xfs@vger.kernel.org
Cc: lucho@ionkov.net
Cc: luisbg@kernel.org
Cc: martin@omnibond.com
Cc: me@bobcopeland.com
Cc: mikulas@artax.karlin.mff.cuni.cz
Cc: nico@fluxnic.net
Cc: phillip@squashfs.org.uk
Cc: reiserfs-devel@vger.kernel.org
Cc: richard@nod.at
Cc: sage@redhat.com
Cc: salah.triki@gmail.com
Cc: sfrench@samba.org
Cc: shaggy@kernel.org
Cc: tj@kernel.org
Cc: tony.luck@intel.com
Cc: trond.myklebust@hammerspace.com
Cc: tytso@mit.edu
Cc: v9fs-developer@lists.sourceforge.net
Cc: yuchao0@huawei.com
Cc: zyan@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v8 11/20] fs: cifs: Initialize filesystem timestamp ranges
2019-08-18 16:57 [PATCH v8 00/20] vfs: Add support for timestamp limits Deepa Dinamani
@ 2019-08-18 16:58 ` Deepa Dinamani
2019-08-20 11:05 ` [PATCH v8 00/20] vfs: Add support for timestamp limits Jeff Layton
1 sibling, 0 replies; 3+ messages in thread
From: Deepa Dinamani @ 2019-08-18 16:58 UTC (permalink / raw)
To: viro, linux-kernel; +Cc: linux-fsdevel, y2038, arnd, sfrench, linux-cifs
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-4f04b2fd1d2b
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: sfrench@samba.org
Cc: linux-cifs@vger.kernel.org
---
fs/cifs/cifsfs.c | 22 ++++++++++++++++++++++
fs/cifs/netmisc.c | 14 +++++++-------
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 3289b566463f..7a75726442ad 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -56,6 +56,15 @@
#include "dfs_cache.h"
#endif
+/*
+ * DOS dates from 1980/1/1 through 2107/12/31
+ * Protocol specifications indicate the range should be to 119, which
+ * limits maximum year to 2099. But this range has not been checked.
+ */
+#define SMB_DATE_MAX (127<<9 | 12<<5 | 31)
+#define SMB_DATE_MIN (0<<9 | 1<<5 | 1)
+#define SMB_TIME_MAX (23<<11 | 59<<5 | 29)
+
int cifsFYI = 0;
bool traceSMB;
bool enable_oplocks = true;
@@ -142,6 +151,7 @@ cifs_read_super(struct super_block *sb)
struct inode *inode;
struct cifs_sb_info *cifs_sb;
struct cifs_tcon *tcon;
+ struct timespec64 ts;
int rc = 0;
cifs_sb = CIFS_SB(sb);
@@ -161,6 +171,18 @@ cifs_read_super(struct super_block *sb)
/* BB FIXME fix time_gran to be larger for LANMAN sessions */
sb->s_time_gran = 100;
+ if (tcon->unix_ext) {
+ ts = cifs_NTtimeToUnix(0);
+ sb->s_time_min = ts.tv_sec;
+ ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX));
+ sb->s_time_max = ts.tv_sec;
+ } else {
+ ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0);
+ sb->s_time_min = ts.tv_sec;
+ ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX), cpu_to_le16(SMB_TIME_MAX), 0);
+ sb->s_time_max = ts.tv_sec;
+ }
+
sb->s_magic = CIFS_MAGIC_NUMBER;
sb->s_op = &cifs_super_ops;
sb->s_xattr = cifs_xattr_handlers;
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index ed92958e842d..49c17ee18254 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -949,8 +949,8 @@ static const int total_days_of_prev_months[] = {
struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
{
struct timespec64 ts;
- time64_t sec;
- int min, days, month, year;
+ time64_t sec, days;
+ int min, day, month, year;
u16 date = le16_to_cpu(le_date);
u16 time = le16_to_cpu(le_time);
SMB_TIME *st = (SMB_TIME *)&time;
@@ -966,15 +966,15 @@ struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
sec += 60 * 60 * st->Hours;
if (st->Hours > 24)
cifs_dbg(VFS, "illegal hours %d\n", st->Hours);
- days = sd->Day;
+ day = sd->Day;
month = sd->Month;
- if (days < 1 || days > 31 || month < 1 || month > 12) {
- cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, days);
- days = clamp(days, 1, 31);
+ if (day < 1 || day > 31 || month < 1 || month > 12) {
+ cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, day);
+ day = clamp(day, 1, 31);
month = clamp(month, 1, 12);
}
month -= 1;
- days += total_days_of_prev_months[month];
+ days = day + total_days_of_prev_months[month];
days += 3652; /* account for difference in days between 1980 and 1970 */
year = sd->Year;
days += year * 365;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v8 00/20] vfs: Add support for timestamp limits
2019-08-18 16:57 [PATCH v8 00/20] vfs: Add support for timestamp limits Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 11/20] fs: cifs: Initialize filesystem timestamp ranges Deepa Dinamani
@ 2019-08-20 11:05 ` Jeff Layton
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2019-08-20 11:05 UTC (permalink / raw)
To: Deepa Dinamani, viro, linux-kernel
Cc: linux-fsdevel, y2038, arnd, adilger.kernel, adrian.hunter,
aivazian.tigran, al, anna.schumaker, anton, asmadeus, ccross,
ceph-devel, coda, codalist, darrick.wong, dedekind1, devel,
dsterba, dushistov, dwmw2, ericvh, gregkh, hch, hch, hirofumi,
hubcap, idryomov, jack, jaegeuk, jaharkes, jfs-discussion, jlbec,
keescook, linux-cifs, linux-ext4, linux-f2fs-devel,
linux-karma-devel, linux-mtd, linux-nfs, linux-ntfs-dev,
linux-xfs, lucho, luisbg, martin, me, mikulas, nico, phillip,
reiserfs-devel, richard, sage, salah.triki, sfrench, shaggy, tj,
tony.luck, trond.myklebust, tytso, v9fs-developer, yuchao0, zyan
On Sun, 2019-08-18 at 09:57 -0700, Deepa Dinamani wrote:
> 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
> orangefs u64 seconds 0 U64_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
Looks reasonable, overall.
Note that the granularity changed recently for cephfs. See commit
0f7cf80ae96c2a (ceph: initialize superblock s_time_gran to 1).
In any case, you can add my Acked-by
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-20 11:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-18 16:57 [PATCH v8 00/20] vfs: Add support for timestamp limits Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 11/20] fs: cifs: Initialize filesystem timestamp ranges Deepa Dinamani
2019-08-20 11:05 ` [PATCH v8 00/20] vfs: Add support for timestamp limits Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).