From 3f744430234e6d6b44147d791b861abbaa2a3135 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 13 Feb 2019 19:30:27 +0800 Subject: [PATCH] pstore: Remove needless lock during console writes mainline inclusion from mainline-5.0 commit b77fa617a2ff category: bugfix bugzilla: 5889 CVE: NA ------------------------------------------------- Since the console writer does not use the preallocated crash dump buffer any more, there is no reason to perform locking around it. Fixes: 70ad35db3321 ("pstore: Convert console write to use ->write_buf") Signed-off-by: Kees Cook Reviewed-by: Joel Fernandes (Google) Signed-off-by: Hou Tao Reviewed-by: Yufen Yu Signed-off-by: Yang Yingliang --- fs/pstore/platform.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index b821054ca3ed..805283b5385d 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -476,31 +476,14 @@ static void pstore_unregister_kmsg(void) #ifdef CONFIG_PSTORE_CONSOLE static void pstore_console_write(struct console *con, const char *s, unsigned c) { - const char *e = s + c; + struct pstore_record record; - while (s < e) { - struct pstore_record record; - unsigned long flags; - - pstore_record_init(&record, psinfo); - record.type = PSTORE_TYPE_CONSOLE; - - if (c > psinfo->bufsize) - c = psinfo->bufsize; + pstore_record_init(&record, psinfo); + record.type = PSTORE_TYPE_CONSOLE; - if (oops_in_progress) { - if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) - break; - } else { - spin_lock_irqsave(&psinfo->buf_lock, flags); - } - record.buf = (char *)s; - record.size = c; - psinfo->write(&record); - spin_unlock_irqrestore(&psinfo->buf_lock, flags); - s += c; - c = e - s; - } + record.buf = (char *)s; + record.size = c; + psinfo->write(&record); } static struct console pstore_console = { -- GitLab