Skip to content

Commit

Permalink
pstore: Fix NULL pointer dereference in console writes
Browse files Browse the repository at this point in the history
Passing a NULL id causes a NULL pointer deference in writers such as
erst_writer and efi_pstore_write because they expect to update this id.
Pass a dummy id instead.

This avoids a cascade of oopses caused when the initial
pstore_console_write passes a null which in turn causes writes to the
console causing further oopses in subsequent pstore_console_write calls.

Signed-off-by: Colin Ian King <[email protected]>
Acked-by: Kees Cook <[email protected]>
Cc: [email protected]
Signed-off-by: Anton Vorontsov <[email protected]>
  • Loading branch information
Colin Ian King authored and Anton Vorontsov committed Nov 15, 2012
1 parent 77b6706 commit 70a6f46
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)

while (s < e) {
unsigned long flags;
u64 id;

if (c > psinfo->bufsize)
c = psinfo->bufsize;
Expand All @@ -172,7 +173,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
spin_lock_irqsave(&psinfo->buf_lock, flags);
}
memcpy(psinfo->buf, s, c);
psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo);
psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, c, psinfo);
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
s += c;
c = e - s;
Expand Down

0 comments on commit 70a6f46

Please sign in to comment.