aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pstore
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2012-11-19 13:26:16 -0500
committerJohn Stultz <john.stultz@linaro.org>2013-01-15 21:16:02 -0500
commit1e817fb62cd185a2232ad4302579491805609489 (patch)
treed4155fb65a9fb32cd9236405a8b7534f39c293b9 /fs/pstore
parent9c3f9e281697d02889c3b08922f3b30be75f56c2 (diff)
time: create __getnstimeofday for WARNless calls
The pstore RAM backend can get called during resume, and must be defensive against a suspended time source. Expose getnstimeofday logic that returns an error instead of a WARN. This can be detected and the timestamp can be zeroed out. Reported-by: Doug Anderson <dianders@chromium.org> Cc: John Stultz <johnstul@us.ibm.com> Cc: Anton Vorontsov <anton.vorontsov@linaro.org> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r--fs/pstore/ram.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 1a4f6da58eab..dacfe78aee7e 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -168,12 +168,16 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
168static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz) 168static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
169{ 169{
170 char *hdr; 170 char *hdr;
171 struct timeval timestamp; 171 struct timespec timestamp;
172 size_t len; 172 size_t len;
173 173
174 do_gettimeofday(&timestamp); 174 /* Report zeroed timestamp if called before timekeeping has resumed. */
175 if (__getnstimeofday(&timestamp)) {
176 timestamp.tv_sec = 0;
177 timestamp.tv_nsec = 0;
178 }
175 hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n", 179 hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu\n",
176 (long)timestamp.tv_sec, (long)timestamp.tv_usec); 180 (long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000));
177 WARN_ON_ONCE(!hdr); 181 WARN_ON_ONCE(!hdr);
178 len = hdr ? strlen(hdr) : 0; 182 len = hdr ? strlen(hdr) : 0;
179 persistent_ram_write(prz, hdr, len); 183 persistent_ram_write(prz, hdr, len);