linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@codethink.co.uk>
To: Deepa Dinamani <deepa.kernel@gmail.com>,
	viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de
Subject: Re: [Y2038] [PATCH 04/20] mount: Add mount warning for impending timestamp expiry
Date: Mon, 05 Aug 2019 15:12:41 +0100	[thread overview]
Message-ID: <eb2027cdccc0a0ff0a9d061fa8dd04a927c63819.camel@codethink.co.uk> (raw)
In-Reply-To: <20190730014924.2193-5-deepa.kernel@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1866 bytes --]

On Mon, 2019-07-29 at 18:49 -0700, Deepa Dinamani wrote:
> The warning reuses the uptime max of 30 years used by the
> setitimeofday().
> 
> Note that the warning is only added for new filesystem mounts
> through the mount syscall. Automounts do not have the same warning.
> 
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
> ---
>  fs/namespace.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index b26778bdc236..5314fac8035e 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2739,6 +2739,17 @@ static int do_new_mount_fc(struct fs_context *fc, struct path *mountpoint,
>  	error = do_add_mount(real_mount(mnt), mountpoint, mnt_flags);
>  	if (error < 0)
>  		mntput(mnt);
> +
> +	if (!error && sb->s_time_max &&

I don't know why you are testing sb->s_time_max here - it should always
be non-zero since alloc_super() sets it to TIME64_MAX.

> +	    (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);
> +
> +		pr_warn("Mounted %s file system at %s supports timestamps until 0x%llx\n",
> +			fc->fs_type->name, mntpath, (unsigned long long)sb->s_time_max);

This doesn't seem like a helpful way to log the time.  Maybe use
time64_to_tm() to convert to "broken down" time and then print it with
"%ptR"... but that wants struct rtc_time.  If you apply the attached
patch, however, you should then be able to print struct tm with
"%ptT".

Ben.

> +		free_page((unsigned long)buf);
> +	}
> +
>  	return error;
>  }
>  
-- 
Ben Hutchings, Software Developer                         Codethink Ltd
https://www.codethink.co.uk/                 Dale House, 35 Dale Street
                                     Manchester, M1 2HF, United Kingdom

[-- Attachment #2: 0001-vsprintf-Add-support-for-printing-struct-tm-in-human.patch --]
[-- Type: text/x-patch, Size: 3926 bytes --]

From 40cd51356d366110d33b891a6b9f3a428ed4ab2e Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben.hutchings@codethink.co.uk>
Date: Mon, 5 Aug 2019 14:49:33 +0100
Subject: [PATCH] vsprintf: Add support for printing struct tm in
 human-readable format

Change date_str(), time_str(), rtc_str() to take a struct tm (the main
kAPI type) instead of struct rtc_time (uAPI type), and rename rtc_str()
accordingly.

Change time_and_date() to accept either a struct rtc_time ('R') or
a struct tm ('T'), converting the former to the latter.

Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
---
 Documentation/core-api/printk-formats.rst |  6 ++--
 lib/vsprintf.c                            | 34 ++++++++++++++++-------
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
index 75d2bbe9813f..fbae020bcc22 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -436,10 +436,10 @@ Time and date (struct rtc_time)
 	%ptR		YYYY-mm-ddTHH:MM:SS
 	%ptRd		YYYY-mm-dd
 	%ptRt		HH:MM:SS
-	%ptR[dt][r]
+	%pt[RT][dt][r]
 
-For printing date and time as represented by struct rtc_time structure in
-human readable format.
+For printing date and time as represented by struct rtc_time (R) or struct
+tm (T) structure in human readable format.
 
 By default year will be incremented by 1900 and month by 1. Use %ptRr (raw)
 to suppress this behaviour.
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 63937044c57d..dc32742876fd 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1699,7 +1699,7 @@ char *address_val(char *buf, char *end, const void *addr,
 }
 
 static noinline_for_stack
-char *date_str(char *buf, char *end, const struct rtc_time *tm, bool r)
+char *date_str(char *buf, char *end, const struct tm *tm, bool r)
 {
 	int year = tm->tm_year + (r ? 0 : 1900);
 	int mon = tm->tm_mon + (r ? 0 : 1);
@@ -1718,7 +1718,7 @@ char *date_str(char *buf, char *end, const struct rtc_time *tm, bool r)
 }
 
 static noinline_for_stack
-char *time_str(char *buf, char *end, const struct rtc_time *tm, bool r)
+char *time_str(char *buf, char *end, const struct tm *tm, bool r)
 {
 	buf = number(buf, end, tm->tm_hour, default_dec02_spec);
 	if (buf < end)
@@ -1734,16 +1734,13 @@ char *time_str(char *buf, char *end, const struct rtc_time *tm, bool r)
 }
 
 static noinline_for_stack
-char *rtc_str(char *buf, char *end, const struct rtc_time *tm,
-	      struct printf_spec spec, const char *fmt)
+char *struct_tm_str(char *buf, char *end, const struct tm *tm,
+		    struct printf_spec spec, const char *fmt)
 {
 	bool have_t = true, have_d = true;
 	bool raw = false;
 	int count = 2;
 
-	if (check_pointer(&buf, end, tm, spec))
-		return buf;
-
 	switch (fmt[count]) {
 	case 'd':
 		have_t = false;
@@ -1775,11 +1772,28 @@ static noinline_for_stack
 char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec,
 		    const char *fmt)
 {
+	if (check_pointer(&buf, end, ptr, spec))
+		return buf;
+
 	switch (fmt[1]) {
-	case 'R':
-		return rtc_str(buf, end, (const struct rtc_time *)ptr, spec, fmt);
+	case 'R': {
+		const struct rtc_time *rtm = (const struct rtc_time *)ptr;
+		struct tm tm = {
+			.tm_sec  = rtm->tm_sec,
+			.tm_min  = rtm->tm_min,
+			.tm_hour = rtm->tm_hour,
+			.tm_mday = rtm->tm_mday,
+			.tm_mon  = rtm->tm_mon,
+			.tm_year = rtm->tm_year,
+		};
+
+		return struct_tm_str(buf, end, &tm, spec, fmt);
+	}
+	case 'T':
+		return struct_tm_str(buf, end, (const struct tm *)ptr,
+				     spec, fmt);
 	default:
-		return error_string(buf, end, "(%ptR?)", spec);
+		return error_string(buf, end, "(%pt?)", spec);
 	}
 }
 
-- 
Ben Hutchings, Software Developer                         Codethink Ltd
https://www.codethink.co.uk/                 Dale House, 35 Dale Street
                                     Manchester, M1 2HF, United Kingdom


  reply	other threads:[~2019-08-05 14:12 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30  1:49 [PATCH 00/20] vfs: Add support for timestamp limits Deepa Dinamani
2019-07-30  1:49 ` [PATCH 01/20] vfs: Add file timestamp range support Deepa Dinamani
2019-07-30  1:49 ` [PATCH 02/20] vfs: Add timestamp_truncate() api Deepa Dinamani
2019-07-30  1:49 ` [PATCH 03/20] timestamp_truncate: Replace users of timespec64_trunc Deepa Dinamani
2019-07-30  8:27   ` OGAWA Hirofumi
2019-07-30 17:26     ` Deepa Dinamani
2019-07-30 22:28       ` Anton Altaparmakov
2019-07-31  0:08         ` Deepa Dinamani
2019-07-30  1:49 ` [PATCH 04/20] mount: Add mount warning for impending timestamp expiry Deepa Dinamani
2019-08-05 14:12   ` Ben Hutchings [this message]
2019-08-05 14:40     ` [Y2038] " Arnd Bergmann
2019-08-10 20:47     ` Deepa Dinamani
2019-08-05 14:14   ` Ben Hutchings
2019-08-10 20:44     ` Deepa Dinamani
2019-08-12 13:25       ` Ben Hutchings
2019-08-12 14:11         ` Arnd Bergmann
2019-08-12 16:09           ` Deepa Dinamani
2019-08-12 16:15             ` Deepa Dinamani
2019-08-12 17:43               ` Ben Hutchings
2019-07-30  1:49 ` [PATCH 05/20] utimes: Clamp the timestamps before update Deepa Dinamani
2019-07-31 15:14   ` Darrick J. Wong
2019-07-31 15:33     ` Deepa Dinamani
2019-08-05 13:30   ` [Y2038] " Ben Hutchings
2019-08-10 20:36     ` Deepa Dinamani
2019-07-30  1:49 ` [PATCH 06/20] fs: Fill in max and min timestamps in superblock Deepa Dinamani
2019-07-31 15:28   ` Darrick J. Wong
2019-07-30  1:49 ` [PATCH 07/20] 9p: Fill min and max timestamps in sb Deepa Dinamani
2019-07-30  1:49 ` [PATCH 08/20] adfs: Fill in max and min " Deepa Dinamani
2019-07-30  1:49 ` [PATCH 09/20] ext4: Initialize timestamps limits Deepa Dinamani
2019-07-31 15:26   ` Darrick J. Wong
2019-08-01 19:18     ` Deepa Dinamani
2019-08-01 22:43       ` Theodore Y. Ts'o
2019-08-02 10:39         ` Arnd Bergmann
2019-08-02 15:43           ` Theodore Y. Ts'o
2019-08-02 19:00             ` Arnd Bergmann
2019-08-02 21:39               ` Theodore Y. Ts'o
2019-08-03  9:30                 ` Arnd Bergmann
2019-08-03 16:02                   ` Theodore Y. Ts'o
2019-08-03 20:24                     ` Arnd Bergmann
2019-08-07 18:04                       ` Andreas Dilger
2019-08-08 18:27                         ` Deepa Dinamani
2019-07-30  1:49 ` [PATCH 10/20] fs: nfs: Initialize filesystem timestamp ranges Deepa Dinamani
2019-07-30  1:49 ` [PATCH 11/20] fs: cifs: " Deepa Dinamani
2019-07-30  1:49 ` [PATCH 12/20] fs: fat: " Deepa Dinamani
2019-07-30  9:31   ` OGAWA Hirofumi
2019-07-30 17:39     ` Deepa Dinamani
2019-07-31  0:48       ` OGAWA Hirofumi
2019-07-30  1:49 ` [PATCH 13/20] fs: affs: " Deepa Dinamani
2019-08-01 11:28   ` David Sterba
2019-07-30  1:49 ` [PATCH 14/20] fs: sysv: " Deepa Dinamani
2019-07-30  1:49 ` [PATCH 15/20] fs: ceph: " Deepa Dinamani
2019-07-30  1:49 ` [PATCH 16/20] fs: orangefs: " Deepa Dinamani
2019-07-30  1:49 ` [PATCH 17/20] fs: hpfs: " Deepa Dinamani
2019-07-30  1:49 ` [PATCH 18/20] fs: omfs: " Deepa Dinamani
2019-07-30 14:25   ` Bob Copeland
2019-07-30  1:49 ` [PATCH 19/20] pstore: fs superblock limits Deepa Dinamani
2019-07-30  4:31   ` Kees Cook
2019-07-30  7:36     ` Arnd Bergmann
2019-08-02  2:26       ` Deepa Dinamani
2019-08-02  7:15         ` Arnd Bergmann
2019-08-18 14:00           ` Deepa Dinamani
2019-07-30  1:49 ` [PATCH 20/20] isofs: Initialize filesystem timestamp ranges Deepa Dinamani

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=eb2027cdccc0a0ff0a9d061fa8dd04a927c63819.camel@codethink.co.uk \
    --to=ben.hutchings@codethink.co.uk \
    --cc=arnd@arndb.de \
    --cc=deepa.kernel@gmail.com \
    --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).