* [PATCH] pstore/ram: no timekeeping calls when unavailable
@ 2012-11-05 21:04 Kees Cook
0 siblings, 0 replies; only message in thread
From: Kees Cook @ 2012-11-05 21:04 UTC (permalink / raw)
To: linux-kernel
Cc: Anton Vorontsov, Colin Cross, Kees Cook, Doug Anderson, Tony Luck
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@chromium.org>
Cc: Anton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
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(×tamp);
+ /* Handle dumping before timekeeping has resumed. */
+ if (unlikely(timekeeping_suspended)) {
+ timestamp.tv_sec = 0;
+ timestamp.tv_usec = 0;
+ } else
+ do_gettimeofday(×tamp);
+
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-11-05 21:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 21:04 [PATCH] pstore/ram: no timekeeping calls when unavailable Kees Cook
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).