pstore/ram: no timekeeping calls when unavailable
PATCH 1/1 pstore/ram: no timekeeping calls when unavailable
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 <[email protected]>
Cc Anton Vorontsov <[email protected]>
Signed-off-by Kees Cook <[email protected]>
--- fs/pstore/ram.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/pstore/ram.c +7 -1
@@ -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);
Signature · 6 lines
1.7.9.5 -- Kees Cook Chrome OS Security