lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5718D3A9.6070005@redhat.com>
Date:	Thu, 21 Apr 2016 09:20:41 -0400
From:	Prarit Bhargava <prarit@...hat.com>
To:	Petr Mladek <pmladek@...e.com>
CC:	Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org,
	John Stultz <john.stultz@...aro.org>,
	Xunlei Pang <pang.xunlei@...aro.org>,
	Baolin Wang <baolin.wang@...aro.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Tejun Heo <tj@...nel.org>,
	Peter Hurley <peter@...leysoftware.com>,
	Vasily Averin <vvs@...tuozzo.com>,
	Joe Perches <joe@...ches.com>
Subject: Re: [PATCH 0/2 v6] printk, Add monotonic and real printk timestamps



On 04/19/2016 04:56 AM, Petr Mladek wrote:
> On Mon 2016-04-18 11:30:52, Prarit Bhargava wrote:

> Hmm, If you allow to change the timestamp format only at boot time, it
> will make things easier. I just wonder if it would work correctly for
> early messages. For example, are there any messages printed before
> the real time clock is initialized? Which timestamp will they use?
>
> Also note that you still need to modify the dmesg code. It must
> not add boot_time when real time timestamp is used.
>

I've got a util-linux patch in-hand that does this (sorry for the
cut-and-paste) and I've verified that ctime, delta, iso, notime and
reltime all appear to work 1) without my kernel patches applied,
2) with my kernel patches applied, and 3) with printk.time=[0-3]
as kernel parameters.

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index cf93331..c49a202 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1194,9 +1194,31 @@ static int which_time_format(const char *optarg)
 	errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
 }

-#ifdef TEST_DMESG
+static int needs_boot_time(void)
+{
+	FILE *fd;
+	int ret = 1;
+	int val;
+
+	/*
+	 * Newer kernels have /sys/modules/printk/parameter/time = [0-3]
+	 * where 0 = off, 1 = local clock, 2 = boot time, and 3 = real time.
+	 * If the file isn't present it means the functionality isn't there
+	 * and the boot_time offset is needed.
+	 */
+	fd = fopen("/sys/module/printk/parameters/time", "r");
+	if (!fd)
+		return ret;
+	fscanf(fd, "%d", &val);
+	if (val == 3)
+		ret = 0;
+	fclose(fd);
+	return ret;
+}
+
 static inline int dmesg_get_boot_time(struct timeval *tv)
 {
+#ifdef TEST_DMESG
 	char *str = getenv("DMESG_TEST_BOOTIME");
 	uintmax_t sec, usec;

@@ -1205,12 +1227,15 @@ static inline int dmesg_get_boot_time(struct timeval *tv)
 		tv->tv_usec = usec;
 		return tv->tv_sec >= 0 && tv->tv_usec >= 0 ? 0 : -EINVAL;
 	}
+#endif
+
+	if (needs_boot_time())
+		return get_boot_time(tv);

-	return get_boot_time(tv);
+	tv->tv_sec = 0;
+	tv->tv_usec = 0;
+	return 0;
 }
-#else
-# define dmesg_get_boot_time	get_boot_time
-#endif

 int main(int argc, char *argv[])
 {
-- 
1.8.3.1

> And you need to modify also the other tools, e.g. crash.
>

I spoke with anderson@...hat.com this morning and he agrees
that no change should be necessary for crash.  A quick test shows that
the logging mechanism (dmesg or log) works after the patches are applied
and printk is in REALTIME mode.

IMO dmesg is the big one and I will modify that after I see acceptance
of this patch.

P.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ