* [PATCH] Fix possible race with 4level-fixup.h
@ 2005-02-17 7:19 Benjamin Herrenschmidt
2005-02-17 8:33 ` Nick Piggin
0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2005-02-17 7:19 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linus Torvalds, Linux Kernel list
Hi !
When using 4level-fixup.h, a PMD page may end up beeing freed before the
matching PGD entry is cleared due to the way the compatibility macros
work. This can cause nasty races on some architectures.
This patch fixes it by defining pud_clear() to be pgd_clear(). That
means we'll actually write 0 twice, a small price to pay here,
especially seeing how easy it is to convert to the new headers anyway
(hint hint, ppc & ppc64 patches as soon as 2.6.11 is out).
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Index: linux-work/include/asm-generic/4level-fixup.h
===================================================================
--- linux-work.orig/include/asm-generic/4level-fixup.h 2005-01-24 17:09:49.000000000 +1100
+++ linux-work/include/asm-generic/4level-fixup.h 2005-02-17 18:10:38.000000000 +1100
@@ -24,7 +24,7 @@
#define pud_bad(pud) 0
#define pud_present(pud) 1
#define pud_ERROR(pud) do { } while (0)
-#define pud_clear(pud) do { } while (0)
+#define pud_clear(pud) pgd_clear((pgd_t *)(pud))
#undef pud_free_tlb
#define pud_free_tlb(tlb, x) do { } while (0)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Fix possible race with 4level-fixup.h
2005-02-17 7:19 [PATCH] Fix possible race with 4level-fixup.h Benjamin Herrenschmidt
@ 2005-02-17 8:33 ` Nick Piggin
2005-02-17 8:40 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Nick Piggin @ 2005-02-17 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Andrew Morton, Linus Torvalds, Linux Kernel list
Benjamin Herrenschmidt wrote:
> Hi !
>
> When using 4level-fixup.h, a PMD page may end up beeing freed before the
> matching PGD entry is cleared due to the way the compatibility macros
> work. This can cause nasty races on some architectures.
>
> This patch fixes it by defining pud_clear() to be pgd_clear(). That
> means we'll actually write 0 twice, a small price to pay here,
> especially seeing how easy it is to convert to the new headers anyway
> (hint hint, ppc & ppc64 patches as soon as 2.6.11 is out).
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>
> Index: linux-work/include/asm-generic/4level-fixup.h
> ===================================================================
> --- linux-work.orig/include/asm-generic/4level-fixup.h 2005-01-24 17:09:49.000000000 +1100
> +++ linux-work/include/asm-generic/4level-fixup.h 2005-02-17 18:10:38.000000000 +1100
> @@ -24,7 +24,7 @@
> #define pud_bad(pud) 0
> #define pud_present(pud) 1
> #define pud_ERROR(pud) do { } while (0)
> -#define pud_clear(pud) do { } while (0)
> +#define pud_clear(pud) pgd_clear((pgd_t *)(pud))
>
Just a small nit - no cast needed here.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Fix possible race with 4level-fixup.h
2005-02-17 8:33 ` Nick Piggin
@ 2005-02-17 8:40 ` Benjamin Herrenschmidt
2005-02-17 9:00 ` Nick Piggin
0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2005-02-17 8:40 UTC (permalink / raw)
To: Nick Piggin; +Cc: Andrew Morton, Linus Torvalds, Linux Kernel list
On Thu, 2005-02-17 at 19:33 +1100, Nick Piggin wrote:
> Benjamin Herrenschmidt wrote:
> > Hi !
> >
> > When using 4level-fixup.h, a PMD page may end up beeing freed before the
> > matching PGD entry is cleared due to the way the compatibility macros
> > work. This can cause nasty races on some architectures.
> >
> > This patch fixes it by defining pud_clear() to be pgd_clear(). That
> > means we'll actually write 0 twice, a small price to pay here,
> > especially seeing how easy it is to convert to the new headers anyway
> > (hint hint, ppc & ppc64 patches as soon as 2.6.11 is out).
> >
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> >
> > Index: linux-work/include/asm-generic/4level-fixup.h
> > ===================================================================
> > --- linux-work.orig/include/asm-generic/4level-fixup.h 2005-01-24 17:09:49.000000000 +1100
> > +++ linux-work/include/asm-generic/4level-fixup.h 2005-02-17 18:10:38.000000000 +1100
> > @@ -24,7 +24,7 @@
> > #define pud_bad(pud) 0
> > #define pud_present(pud) 1
> > #define pud_ERROR(pud) do { } while (0)
> > -#define pud_clear(pud) do { } while (0)
> > +#define pud_clear(pud) pgd_clear((pgd_t *)(pud))
> >
>
> Just a small nit - no cast needed here.
Well, do you know ? pud is a pud_t* and the arch is free to implement
pgd_clear as an inline with strong typing no ?
Ben.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] Fix possible race with 4level-fixup.h
2005-02-17 8:40 ` Benjamin Herrenschmidt
@ 2005-02-17 9:00 ` Nick Piggin
0 siblings, 0 replies; 4+ messages in thread
From: Nick Piggin @ 2005-02-17 9:00 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Andrew Morton, Linus Torvalds, Linux Kernel list
Benjamin Herrenschmidt wrote:
>>>Index: linux-work/include/asm-generic/4level-fixup.h
>>>===================================================================
>>>--- linux-work.orig/include/asm-generic/4level-fixup.h 2005-01-24 17:09:49.000000000 +1100
>>>+++ linux-work/include/asm-generic/4level-fixup.h 2005-02-17 18:10:38.000000000 +1100
>>>@@ -24,7 +24,7 @@
>>> #define pud_bad(pud) 0
>>> #define pud_present(pud) 1
>>> #define pud_ERROR(pud) do { } while (0)
>>>-#define pud_clear(pud) do { } while (0)
>>>+#define pud_clear(pud) pgd_clear((pgd_t *)(pud))
>>>
>>
>>Just a small nit - no cast needed here.
>
>
> Well, do you know ? pud is a pud_t* and the arch is free to implement
> pgd_clear as an inline with strong typing no ?
>
Yeah but if you're using the 4level-fixup.h header, then you get
#define pud_t pgd_t
Not that I really mind, but in this header we've just avoided
doing casts for that reason.
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-02-17 9:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-17 7:19 [PATCH] Fix possible race with 4level-fixup.h Benjamin Herrenschmidt
2005-02-17 8:33 ` Nick Piggin
2005-02-17 8:40 ` Benjamin Herrenschmidt
2005-02-17 9:00 ` Nick Piggin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox