All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
	Martin Petricek <mp@petricek.net>,
	John Johansen <john.johansen@canonical.com>,
	Ryan Lee <ryan.lee@canonical.com>,
	apparmor@lists.ubuntu.com
Subject: Re: [BUG] apparmor: deadlock in complain-mode change_hat
Date: Tue, 11 Aug 2026 14:55:52 -0400	[thread overview]
Message-ID: <20260811184500.stable-0007-sashal@kernel.org> (raw)
In-Reply-To: <552f7777b10a92ef675cb12a07ba8b7b@petricek.net>

> kernel:  __mutex_lock.constprop.0+0x569/0xa10
> kernel:  aa_new_learning_profile+0x15f/0x210
> kernel:  build_change_hat+0x19f/0x3b0
> kernel:  change_hat.isra.0+0x5dd/0xd60

Thanks for the very complete report - the reproducer and the stack made
this straightforward to pin down.

The commit is 32e92764d6f8 ("apparmor: grab ns lock and refresh when
looking up changehat child profiles"). It makes change_hat() take
ns->lock and hold it across the build: label. In complain mode with no
matching hat, build_change_hat() calls aa_new_learning_profile()
(aa_new_null_profile() on the older trees), which takes the same
ns->lock again - a recursive acquire of a non-recursive mutex, so the
task wedges in D state and never drops the namespace lock. That also
explains why every later change_hat in that namespace hangs behind it.

John, Ryan - this needs an upstream fix; the deadlock is in mainline
too. There is nothing in v7.2-rc7 or in linux-next that addresses it,
and I could not find a posted fix on the list. Two smaller things in the
same commit that look wrong while you are in there: it swapped
aa_get_profile_rcu(&profile->parent) for aa_get_profile(profile->parent)
on an __rcu pointer (the kernel test robot flagged the sparse warning
twice in June), and it adds a label = aa_get_label(label) on entry with
no matching put on either exit path.

-- 
Thanks,
Sasha

  parent reply	other threads:[~2026-08-11 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  1:46 [BUG] apparmor: deadlock in complain-mode change_hat Martin Petricek
2026-08-11  2:26 ` Greg KH
2026-08-11 18:55 ` Sasha Levin [this message]
2026-08-12  8:48   ` John Johansen

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=20260811184500.stable-0007-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=apparmor@lists.ubuntu.com \
    --cc=john.johansen@canonical.com \
    --cc=mp@petricek.net \
    --cc=ryan.lee@canonical.com \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.