[PATCH] pstore/ram: no timekeeping calls when unavailable

From: Kees Cook
Date: Mon Nov 05 2012 - 16:04:24 EST


We must not call timekeeping functions unless they are available. If we dump
before they have resumed, avoid a WARN_ON by setting the timestamp to 0.

Reported-by: Doug Anderson <dianders@xxxxxxxxxxxx>
Cc: Anton Vorontsov <cbouatmailru@xxxxxxxxx>
Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
---
fs/pstore/ram.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 1a4f6da..6d014e0 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -171,7 +171,13 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
struct timeval timestamp;
size_t len;

- do_gettimeofday(&timestamp);
+ /* Handle dumping before timekeeping has resumed. */
+ if (unlikely(timekeeping_suspended)) {
+ timestamp.tv_sec = 0;
+ timestamp.tv_usec = 0;
+ } else
+ do_gettimeofday(&timestamp);
+
hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
(long)timestamp.tv_sec, (long)timestamp.tv_usec);
WARN_ON_ONCE(!hdr);
--
1.7.9.5


--
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/