linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [bug report] mm: avoid leaving partial pfn mappings around in error case
@ 2024-09-15 10:08 Dan Carpenter
  2024-09-15 10:23 ` Linus Torvalds
  2024-09-15 12:01 ` Lorenzo Stoakes
  0 siblings, 2 replies; 10+ messages in thread
From: Dan Carpenter @ 2024-09-15 10:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-mm

Hi Linus,

Commit 79a61cc3fc04 ("mm: avoid leaving partial pfn mappings around in
error case") from Sep 11, 2024 (linux-next), leads to the following
Smatch static checker warning:

	mm/memory.c:2709 remap_pfn_range_notrack()
	warn: sleeping in atomic context

mm/memory.c
    2696 int remap_pfn_range_notrack(struct vm_area_struct *vma, unsigned long addr,
    2697                 unsigned long pfn, unsigned long size, pgprot_t prot)
    2698 {
    2699         int error = remap_pfn_range_internal(vma, addr, pfn, size, prot);
    2700 
    2701         if (!error)
    2702                 return 0;
    2703 
    2704         /*
    2705          * A partial pfn range mapping is dangerous: it does not
    2706          * maintain page reference counts, and callers may free
    2707          * pages due to the error. So zap it early.
    2708          */
--> 2709         zap_page_range_single(vma, addr, size, NULL);

The lru_add_drain() function at the start of zap_page_range_single() takes a
mutext.

    2710         return error;
    2711 }

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()

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-09-18 21:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-15 10:08 [bug report] mm: avoid leaving partial pfn mappings around in error case Dan Carpenter
2024-09-15 10:23 ` Linus Torvalds
2024-09-15 12:05   ` Dan Carpenter
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox