From: Dan Carpenter <dan.carpenter@linaro.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-mm@kvack.org
Subject: Re: [bug report] mm: avoid leaving partial pfn mappings around in error case
Date: Sun, 15 Sep 2024 15:05:38 +0300 [thread overview]
Message-ID: <58a7aebb-6ffe-4909-a7cd-d98063509a57@stanley.mountain> (raw)
In-Reply-To: <CAHk-=wh7E+g_iCmCtVRQqrpN7S3VSBpEssf19s1QJHbDqfADyw@mail.gmail.com>
On Sun, Sep 15, 2024 at 12:23:31PM +0200, Linus Torvalds wrote:
> On Sun, 15 Sept 2024 at 12:08, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > The lru_add_drain() function at the start of zap_page_range_single() takes a
> > mutex.
>
> Yes, that shouldn't be problematic. But:
>
> > It's the preempt_disable() in gru_fault() which is the issue. The call tree
> > is:
> >
> > gru_fault() <- disables preempt
> > -> remap_pfn_range()
> > -> remap_pfn_range_notrack()
>
> That code is very odd. It was invalid to call remap_pfn_range() with
> preemption disabled even before, because it will allocate the page
> tables that it fills in.
>
> But presumably *that* never happened in practice, and so nobody
> noticed how broken that code was before.
>
> Now smatch seems to see a new problem, but I *think* it's because
> smatch didn't notice the sleeping by p4d_alloc() / pud_alloc() /
> pmd_alloc() because those allocations are all conditional (so smatch
> doesn't see them as static violations).
>
> Put another way: I do not believe this is a new issue, but perhaps a
> "new to smatch" issue?
>
Yep. You're right. Smatch doesn't count allocations as sleeping when we pass a
variable to for the gfp flags and those functions do "get_zeroed_page(gfp)".
I've been intending for years to handle bitmasks better but I've never
implemented that code.
regards,
dan carpenter
next prev parent reply other threads:[~2024-09-15 12:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-15 10:08 Dan Carpenter
2024-09-15 10:23 ` Linus Torvalds
2024-09-15 12:05 ` Dan Carpenter [this message]
2024-09-15 13:14 ` Linus Torvalds
2024-09-18 21:08 ` Dimitri Sivanich
2024-09-15 12:01 ` Lorenzo Stoakes
2024-09-15 12:09 ` Dan Carpenter
2024-09-15 12:38 ` Lorenzo Stoakes
2024-09-15 13:14 ` Dan Carpenter
2024-09-15 13:26 ` Lorenzo Stoakes
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=58a7aebb-6ffe-4909-a7cd-d98063509a57@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox