linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Deepa Dinamani <deepa.kernel@gmail.com>
To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de
Subject: [PATCH v8 04/20] mount: Add mount warning for impending timestamp expiry
Date: Sun, 18 Aug 2019 09:58:01 -0700	[thread overview]
Message-ID: <20190818165817.32634-5-deepa.kernel@gmail.com> (raw)
In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com>

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: Deepa Dinamani <deepa.kernel@gmail.com>
---
 fs/namespace.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index bfcb4e341257..7fcf289593c5 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2468,6 +2468,26 @@ static void set_mount_attributes(struct mount *mnt, unsigned int mnt_flags)
 	unlock_mount_hash();
 }
 
+static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *mnt)
+{
+	struct super_block *sb = mnt->mnt_sb;
+
+	if (!__mnt_is_readonly(mnt) &&
+	   (ktime_get_real_seconds() + TIME_UPTIME_SEC_MAX > sb->s_time_max)) {
+		char *buf = (char *)__get_free_page(GFP_KERNEL);
+		char *mntpath = buf ? d_path(mountpoint, buf, PAGE_SIZE) : ERR_PTR(-ENOMEM);
+		struct tm tm;
+
+		time64_to_tm(sb->s_time_max, 0, &tm);
+
+		pr_warn("Mounted %s file system at %s supports timestamps until %04ld (0x%llx)\n",
+			sb->s_type->name, mntpath,
+			tm.tm_year+1900, (unsigned long long)sb->s_time_max);
+
+		free_page((unsigned long)buf);
+	}
+}
+
 /*
  * Handle reconfiguration of the mountpoint only without alteration of the
  * superblock it refers to.  This is triggered by specifying MS_REMOUNT|MS_BIND
@@ -2493,6 +2513,9 @@ static int do_reconfigure_mnt(struct path *path, unsigned int mnt_flags)
 	if (ret == 0)
 		set_mount_attributes(mnt, mnt_flags);
 	up_write(&sb->s_umount);
+
+	mnt_warn_timestamp_expiry(path, &mnt->mnt);
+
 	return ret;
 }
 
@@ -2533,6 +2556,9 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags,
 		}
 		up_write(&sb->s_umount);
 	}
+
+	mnt_warn_timestamp_expiry(path, &mnt->mnt);
+
 	put_fs_context(fc);
 	return err;
 }
@@ -2741,8 +2767,13 @@ static int do_new_mount_fc(struct fs_context *fc, struct path *mountpoint,
 		return PTR_ERR(mnt);
 
 	error = do_add_mount(real_mount(mnt), mountpoint, mnt_flags);
-	if (error < 0)
+	if (error < 0) {
 		mntput(mnt);
+		return error;
+	}
+
+	mnt_warn_timestamp_expiry(mountpoint, mnt);
+
 	return error;
 }
 
-- 
2.17.1


  parent reply	other threads:[~2019-08-18 17:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-18 16:57 [PATCH v8 00/20] vfs: Add support for timestamp limits Deepa Dinamani
2019-08-18 16:57 ` [PATCH v8 01/20] vfs: Add file timestamp range support Deepa Dinamani
2019-08-18 16:57 ` [PATCH v8 02/20] vfs: Add timestamp_truncate() api Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 03/20] timestamp_truncate: Replace users of timespec64_trunc Deepa Dinamani
2019-08-18 18:34   ` Greg KH
2019-08-18 16:58 ` Deepa Dinamani [this message]
2019-08-18 16:58 ` [PATCH v8 05/20] utimes: Clamp the timestamps before update Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 06/20] fs: Fill in max and min timestamps in superblock Deepa Dinamani
2019-08-20 11:28   ` Anders Larsen
     [not found]   ` <CAK+_RLmK0Vy79giAZnUCmmivvRT+GLZXyiMqBoFB0_Ed1W8BkA@mail.gmail.com>
2019-08-20 12:28     ` Tigran Aivazian
2019-08-18 16:58 ` [PATCH v8 07/20] 9p: Fill min and max timestamps in sb Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 08/20] adfs: Fill in max and min " Deepa Dinamani
2019-08-20 16:28   ` Matthew Wilcox
2019-08-20 23:55     ` Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 09/20] ext4: Initialize timestamps limits Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 10/20] fs: nfs: Initialize filesystem timestamp ranges Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 11/20] fs: cifs: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 12/20] fs: fat: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 13/20] fs: affs: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 14/20] fs: sysv: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 15/20] fs: ceph: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 16/20] fs: orangefs: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 17/20] fs: hpfs: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 18/20] fs: omfs: " Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 19/20] pstore: fs superblock limits Deepa Dinamani
2019-08-20  7:20   ` Kees Cook
2019-08-21  0:03     ` Deepa Dinamani
2019-08-18 16:58 ` [PATCH v8 20/20] isofs: Initialize filesystem timestamp ranges Deepa Dinamani
2019-08-20 11:05 ` [PATCH v8 00/20] vfs: Add support for timestamp limits Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190818165817.32634-5-deepa.kernel@gmail.com \
    --to=deepa.kernel@gmail.com \
    --cc=arnd@arndb.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).