From: Kees Cook <kees@kernel.org>
To: Wen Yang <wen.yang@linux.dev>
Cc: Greg KH <gregkh@linuxfoundation.org>,
Tony Luck <tony.luck@intel.com>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pstore: replace spinlock_t by raw_spinlock_t
Date: Mon, 26 Aug 2024 13:33:31 -0700 [thread overview]
Message-ID: <202408261332.84DE549F0@keescook> (raw)
In-Reply-To: <e7b031d7-3916-4d6d-8dfd-70412c5d24b6@linux.dev>
On Sat, Aug 24, 2024 at 03:25:04PM +0800, Wen Yang wrote:
>
>
> On 2024/8/20 01:45, Greg KH wrote:
> > On Mon, Aug 19, 2024 at 10:59:45PM +0800, Wen Yang wrote:
> > > pstore_dump() is called when both preemption and local IRQ are disabled,
> > > and a spinlock is obtained, which is problematic for the RT kernel because
> > > in this configuration, spinlocks are sleep locks.
> > >
> > > Replace the spinlock_t with raw_spinlock_t to avoid sleeping in atomic context.
> >
> > This feels odd, is it only an out-of-tree RT thing? Or does this affect
> > in-kernel code as well? What prevents any normal spinlock from sleeping
> > in your system configuration as well?
> >
>
> Thank you for your comment.
>
> If we enable PREEMPT_RT, it will also affect in-kernel code, such as in the
> following scenario:
>
> echo b > /proc/sysrq-trigger
> - sysrq_handle_reboot
> - emergency_restart
> - kmsg_dump
> - pstore_dump
> Obtained psinfo->buf_lock, if there is a lot of error log in the kernel, it
> will last for a long time
>
> If the system unexpectedly crashes at this time:
> - panic()
> - kmsg_dump
> - pstore_dump
> Attempting to obtain psinfo->buf_lock while disabling interrupts and
> preemption, but since this lock is already held by the above process, it
> will result in illegal sleep.
Reading Documentation/locking/locktypes.rst seems to suggest pstore does
want the raw version. I'm surprised there aren't many more cases where
this is a problem. :P
--
Kees Cook
next prev parent reply other threads:[~2024-08-26 20:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 14:59 [PATCH] pstore: replace spinlock_t by raw_spinlock_t Wen Yang
2024-08-19 17:45 ` Greg KH
2024-08-24 7:25 ` Wen Yang
2024-08-26 20:33 ` Kees Cook [this message]
2024-08-26 20:34 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202408261332.84DE549F0@keescook \
--to=kees@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=wen.yang@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox