* [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
@ 2012-11-27 21:05 Naoya Horiguchi
2012-11-27 21:08 ` Andi Kleen
2012-11-27 21:54 ` Andrew Morton
0 siblings, 2 replies; 5+ messages in thread
From: Naoya Horiguchi @ 2012-11-27 21:05 UTC (permalink / raw)
To: Andrew Morton; +Cc: Tony Luck, Andi Kleen, Wu Fengguang, linux-kernel, linux-mm
When we try to soft-offline a thp tail page, put_page() is called on the
tail page unthinkingly and VM_BUG_ON is triggered in put_compound_page().
This patch splits thp before going into the main body of soft-offlining.
The interface of soft-offlining is open for userspace, so this bug can
lead to DoS attack and should be fixed immedately.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: stable@vger.kernel.org
---
mm/memory-failure.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git v3.7-rc7.orig/mm/memory-failure.c v3.7-rc7/mm/memory-failure.c
index 8fe3640..e48e235 100644
--- v3.7-rc7.orig/mm/memory-failure.c
+++ v3.7-rc7/mm/memory-failure.c
@@ -1548,9 +1548,17 @@ int soft_offline_page(struct page *page, int flags)
{
int ret;
unsigned long pfn = page_to_pfn(page);
+ struct page *hpage = compound_trans_head(page);
if (PageHuge(page))
return soft_offline_huge_page(page, flags);
+ if (PageTransHuge(hpage)) {
+ if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
+ pr_info("soft offline: %#lx: failed to split THP\n",
+ pfn);
+ return -EBUSY;
+ }
+ }
ret = get_any_page(page, pfn, flags);
if (ret < 0)
--
1.7.11.7
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
2012-11-27 21:05 [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page() Naoya Horiguchi
@ 2012-11-27 21:08 ` Andi Kleen
2012-11-27 21:39 ` Naoya Horiguchi
2012-11-27 21:54 ` Andrew Morton
1 sibling, 1 reply; 5+ messages in thread
From: Andi Kleen @ 2012-11-27 21:08 UTC (permalink / raw)
To: Naoya Horiguchi
Cc: Andrew Morton, Tony Luck, Andi Kleen, Wu Fengguang, linux-kernel,
linux-mm
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> writes:
> When we try to soft-offline a thp tail page, put_page() is called on the
> tail page unthinkingly and VM_BUG_ON is triggered in put_compound_page().
> This patch splits thp before going into the main body of soft-offlining.
Looks good.
>
> The interface of soft-offlining is open for userspace, so this bug can
> lead to DoS attack and should be fixed immedately.
The interface is root only and root can do everything anyways, so it's
not really a security issue.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
2012-11-27 21:08 ` Andi Kleen
@ 2012-11-27 21:39 ` Naoya Horiguchi
0 siblings, 0 replies; 5+ messages in thread
From: Naoya Horiguchi @ 2012-11-27 21:39 UTC (permalink / raw)
To: Andi Kleen
Cc: Naoya Horiguchi, Andrew Morton, Tony Luck, Andi Kleen,
Wu Fengguang, linux-kernel, linux-mm, stable
On Tue, Nov 27, 2012 at 01:08:38PM -0800, Andi Kleen wrote:
> Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> writes:
>
> > When we try to soft-offline a thp tail page, put_page() is called on the
> > tail page unthinkingly and VM_BUG_ON is triggered in put_compound_page().
> > This patch splits thp before going into the main body of soft-offlining.
>
> Looks good.
>
> >
> > The interface of soft-offlining is open for userspace, so this bug can
> > lead to DoS attack and should be fixed immedately.
>
> The interface is root only and root can do everything anyways, so it's
> not really a security issue.
OK, this description had better not be here. I replace with attached one.
(.. and I forgot to disable suppress-cc for stable@vger.kernel.org in
the initial post so did it now, sorry.)
---
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Date: Tue, 27 Nov 2012 15:38:23 -0500
Subject: [PATCH] mm, soft offline: split thp at the beginning of
soft_offline_page()
When we try to soft-offline a thp tail page, put_page() is called on the
tail page unthinkingly and VM_BUG_ON is triggered in put_compound_page().
This patch splits thp before going into the main body of soft-offlining.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: stable@vger.kernel.org
---
mm/memory-failure.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 8fe3640..e48e235 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1548,9 +1548,17 @@ int soft_offline_page(struct page *page, int flags)
{
int ret;
unsigned long pfn = page_to_pfn(page);
+ struct page *hpage = compound_trans_head(page);
if (PageHuge(page))
return soft_offline_huge_page(page, flags);
+ if (PageTransHuge(hpage)) {
+ if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
+ pr_info("soft offline: %#lx: failed to split THP\n",
+ pfn);
+ return -EBUSY;
+ }
+ }
ret = get_any_page(page, pfn, flags);
if (ret < 0)
--
1.7.11.7
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
2012-11-27 21:05 [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page() Naoya Horiguchi
2012-11-27 21:08 ` Andi Kleen
@ 2012-11-27 21:54 ` Andrew Morton
2012-11-27 22:42 ` Naoya Horiguchi
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2012-11-27 21:54 UTC (permalink / raw)
To: Naoya Horiguchi
Cc: Tony Luck, Andi Kleen, Wu Fengguang, linux-kernel, linux-mm
On Tue, 27 Nov 2012 16:05:31 -0500
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:
> When we try to soft-offline a thp tail page, put_page() is called on the
> tail page unthinkingly and VM_BUG_ON is triggered in put_compound_page().
> This patch splits thp before going into the main body of soft-offlining.
>
> The interface of soft-offlining is open for userspace, so this bug can
> lead to DoS attack and should be fixed immedately.
>
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: stable@vger.kernel.org
> ---
> mm/memory-failure.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git v3.7-rc7.orig/mm/memory-failure.c v3.7-rc7/mm/memory-failure.c
> index 8fe3640..e48e235 100644
> --- v3.7-rc7.orig/mm/memory-failure.c
> +++ v3.7-rc7/mm/memory-failure.c
> @@ -1548,9 +1548,17 @@ int soft_offline_page(struct page *page, int flags)
> {
> int ret;
> unsigned long pfn = page_to_pfn(page);
> + struct page *hpage = compound_trans_head(page);
>
> if (PageHuge(page))
> return soft_offline_huge_page(page, flags);
> + if (PageTransHuge(hpage)) {
> + if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
> + pr_info("soft offline: %#lx: failed to split THP\n",
> + pfn);
> + return -EBUSY;
> + }
> + }
We can use PageTransCompound() here, as we know it isn't a hugetlbfs
page. This will then permit the PageAnon() test to be omitted, methinks?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
2012-11-27 21:54 ` Andrew Morton
@ 2012-11-27 22:42 ` Naoya Horiguchi
0 siblings, 0 replies; 5+ messages in thread
From: Naoya Horiguchi @ 2012-11-27 22:42 UTC (permalink / raw)
To: Andrew Morton
Cc: Naoya Horiguchi, Tony Luck, Andi Kleen, Wu Fengguang,
linux-kernel, linux-mm
On Tue, Nov 27, 2012 at 01:54:58PM -0800, Andrew Morton wrote:
> On Tue, 27 Nov 2012 16:05:31 -0500
> Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:
>
> > When we try to soft-offline a thp tail page, put_page() is called on the
> > tail page unthinkingly and VM_BUG_ON is triggered in put_compound_page().
> > This patch splits thp before going into the main body of soft-offlining.
> >
> > The interface of soft-offlining is open for userspace, so this bug can
> > lead to DoS attack and should be fixed immedately.
> >
> > Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > Cc: stable@vger.kernel.org
> > ---
> > mm/memory-failure.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git v3.7-rc7.orig/mm/memory-failure.c v3.7-rc7/mm/memory-failure.c
> > index 8fe3640..e48e235 100644
> > --- v3.7-rc7.orig/mm/memory-failure.c
> > +++ v3.7-rc7/mm/memory-failure.c
> > @@ -1548,9 +1548,17 @@ int soft_offline_page(struct page *page, int flags)
> > {
> > int ret;
> > unsigned long pfn = page_to_pfn(page);
> > + struct page *hpage = compound_trans_head(page);
> >
> > if (PageHuge(page))
> > return soft_offline_huge_page(page, flags);
> > + if (PageTransHuge(hpage)) {
> > + if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
> > + pr_info("soft offline: %#lx: failed to split THP\n",
> > + pfn);
> > + return -EBUSY;
> > + }
> > + }
>
> We can use PageTransCompound() here, as we know it isn't a hugetlbfs
> page. This will then permit the PageAnon() test to be omitted, methinks?
Using PageTransCompound() is OK for me. But without this PageAnon() test,
we can trigger BUG_ON(!PageAnon) inside split_huge_page() when soft
offlining is kicked on non-huge compound pages.
The point about telling thp from hugetlbfs pages and non-huge compound
pages was discussed last month over 7a71932d5676b7410 ("kpageflags: fix
wrong KPF_THP on non-huge compound pages"), where we used a bit tricky
workaround of using PageTransCompound(page) && PageLRU(compound_trans_head(page)).
Thanks,
Naoya
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-27 22:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 21:05 [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page() Naoya Horiguchi
2012-11-27 21:08 ` Andi Kleen
2012-11-27 21:39 ` Naoya Horiguchi
2012-11-27 21:54 ` Andrew Morton
2012-11-27 22:42 ` Naoya Horiguchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).