From: "Jürgen Groß" <jgross@suse.com>
To: Yogesh Gaur <yogeshgaur.83@gmail.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org
Cc: "H . Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org,
syzbot+342762971f666337474e@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] x86/mtrr: allocate the cache map before taking mtrr_mutex
Date: Tue, 6 Oct 2026 15:54:09 +0200 [thread overview]
Message-ID: <938f42ec-8fda-4eca-89b4-e152e5e4d933@suse.com> (raw)
In-Reply-To: <20261005130214.1775-1-yogeshgaur.83@gmail.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 1766 bytes --]
On 05.10.26 15:02, Yogesh Gaur wrote:
> mtrr_copy_map() does a GFP_KERNEL allocation with mtrr_mutex held.
> It runs once at boot from mtrr_init_finalize(), but lockdep keeps
> the mtrr_mutex -> fs_reclaim dependency it records there for the
> life of the system. Once another path gives lockdep the rest of a
> cycle back to a lock held around mtrr_mutex, the next MTRR ioctl
> reports a circular dependency. syzbot found this through nbd, which
> takes cpu_hotplug_lock (via sk_set_memalloc() -> static_key_slow_inc())
> under its tx_lock, while mtrr_del_page() takes mtrr_mutex under
> cpu_hotplug_lock:
>
> WARNING: possible circular locking dependency detected
> syz.9.5848/21744 is trying to acquire lock:
> (mtrr_mutex), at: mtrr_del_page arch/x86/kernel/cpu/mtrr/mtrr.c:408
> but task is already holding lock:
> (cpu_hotplug_lock), at: mtrr_del_page arch/x86/kernel/cpu/mtrr/mtrr.c:407
> -> #1 (fs_reclaim):
> fs_reclaim_acquire
> might_alloc
> slab_pre_alloc_hook
> __kmalloc_noprof
> mtrr_copy_map arch/x86/kernel/cpu/mtrr/generic.c:413
> mtrr_init_finalize arch/x86/kernel/cpu/mtrr/mtrr.c:618
> Chain exists of:
> mtrr_mutex --> &nsock->tx_lock --> cpu_hotplug_lock
>
> The allocation does not need the mutex; only publishing the new map
> does. Allocate first and assign cache_map once mtrr_mutex is held.
> The rest of the function is unchanged.
>
> Fixes: 061b984aab58 ("x86/mtrr: Construct a memory map with cache modes")
> Reported-by: syzbot+342762971f666337474e@syzkaller.appspotmail.com
> Assisted-by: LLM
> Signed-off-by: Yogesh Gaur <yogeshgaur.83@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
prev parent reply other threads:[~2026-10-06 13:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261005102152.368-1-yogeshgaur.83@gmail.com/>
2026-10-05 13:02 ` Yogesh Gaur
2026-10-06 13:54 ` Jürgen Groß [this message]
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=938f42ec-8fda-4eca-89b4-e152e5e4d933@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=syzbot+342762971f666337474e@syzkaller.appspotmail.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
--cc=yogeshgaur.83@gmail.com \
/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
all inboxes | Powered by JetHome®