From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Alessandro Carminati <acarmina@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Clark Williams <clrkwllms@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev,
Thomas Weissschuh <thomas.weissschuh@linutronix.de>,
Alessandro Carminati <alessandro.carminati@gmail.com>,
Juri Lelli <juri.lelli@redhat.com>,
Gabriele Paoloni <gpaoloni@redhat.com>,
Eric Chanudet <echanude@redhat.com>
Subject: Re: [PATCH] mm/kmemleak: Fix sleeping function called from invalid context in kmemleak_seq_show
Date: Fri, 22 Nov 2024 09:14:37 +0100 [thread overview]
Message-ID: <20241122081437.AKxGgM9n@linutronix.de> (raw)
In-Reply-To: <Zz-HqbsWxFPrrjST@arm.com>
On 2024-11-21 19:19:05 [+0000], Catalin Marinas wrote:
…
> > Maybe SELinux locks should be converted to raw? I don't know how long that
> > lock is held. There are some loops though :-/
> >
> > avc_insert():
> >
> > spin_lock_irqsave(lock, flag);
> > hlist_for_each_entry(pos, head, list) {
> > if (pos->ae.ssid == ssid &&
> > pos->ae.tsid == tsid &&
> > pos->ae.tclass == tclass) {
> > avc_node_replace(node, pos);
> > goto found;
> > }
> > }
> > hlist_add_head_rcu(&node->list, head);
> > found:
> > spin_unlock_irqrestore(lock, flag);
> >
> > Perhaps that could be converted to simple RCU?
> >
> > As I'm sure there's other places that call vsprintf() under a raw_spin_lock
> > or non-preemptable context, perhaps this should be the fix we do.
>
> My preference would also be to convert SELinux rather than avoiding the
> issue in kmemleak (and other similar places).
No. kmemleak has been made use a raw_spinlock_t because most of what it
does is something that is not used in production on a PREEMPT_RT system
and falls in the same category as lockdep for instance. And that code
calls into LSM/ selinux.
Before making the lock in selinux a raw_spinlock_t you have to think
about the consequences in general and audit the code. From a quick
look, there is also avc_insert() invoked in that callchain which
allocates memory and this is a no no.
Also, if you make the solution here in selinux to use a raw_spinlock_t
you would have to do it also in every LSM as they might be used instead
of selinux.
Therefore, I still prefer adding PREEMPT_RT to the restricted_pointer()
category for atomic invocations.
Sebastian
next prev parent reply other threads:[~2024-11-22 8:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 10:23 Alessandro Carminati
2024-11-20 14:53 ` Catalin Marinas
2024-11-20 15:13 ` Thomas Weissschuh
2024-11-20 15:26 ` Steven Rostedt
2024-11-20 16:36 ` Alessandro Carminati
2024-11-20 16:40 ` Sebastian Andrzej Siewior
2024-11-21 16:50 ` Alessandro Carminati
2024-11-21 17:03 ` Sebastian Andrzej Siewior
2024-11-22 10:48 ` Alessandro Carminati
2024-11-26 8:11 ` Thomas Weissschuh
2024-11-26 10:49 ` Catalin Marinas
2024-11-21 19:19 ` Catalin Marinas
2024-11-22 8:14 ` Sebastian Andrzej Siewior [this message]
2024-11-22 10:12 ` Catalin Marinas
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=20241122081437.AKxGgM9n@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=acarmina@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alessandro.carminati@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=clrkwllms@kernel.org \
--cc=echanude@redhat.com \
--cc=gpaoloni@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=rostedt@goodmis.org \
--cc=thomas.weissschuh@linutronix.de \
/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