lkml.org 
[lkml]   [2022]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] pstore: Don't use sem aphores in always-atomic-context code


On February 18, 2022 10:19:50 AM PST, Jann Horn <jannh@google.com> wrote:
>pstore_dump() is *always* invoked in atomic context (nowadays in an RCU
>read-side critical section, before that under a spinlock).
>It doesn't make sense to try to use semaphores here.

Ah, very nice. Thanks for the analysis!

>[...]
>-static bool pstore_cannot_wait(enum kmsg_dump_reason reason)
>+bool pstore_cannot_block_path(enum kmsg_dump_reason reason)

Why the rename, extern, and EXPORT? This appears to still only have the same single caller?

> [...]
>- pr_err("dump skipped in %s path: may corrupt error record\n",
>- in_nmi() ? "NMI" : why);
>- return;
>- }
>- if (down_interruptible(&psinfo->buf_lock)) {
>- pr_err("could not grab semaphore?!\n");
>+ if (pstore_cannot_block_path(reason)) {
>+ if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) {
>+ pr_err("dump skipped in %s path because of concurrent dump\n"
>+ , in_nmi() ? "NMI" : why);

The pr_err had the comma following the format string moved, and the note about corruption removed. Is that no longer accurate?

Otherwise looks good; thank you!

--
Kees Cook

\
 
 \ /
  Last update: 2022-02-23 08:51    [W:0.093 / U:2.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site