All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Tony Luck <tony.luck@intel.com>,
	Andi Kleen <andi.kleen@intel.com>,
	Wu Fengguang <fengguang.wu@intel.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
Date: Tue, 27 Nov 2012 13:54:58 -0800	[thread overview]
Message-ID: <20121127135458.4b7369f7.akpm@linux-foundation.org> (raw)
In-Reply-To: <1354050331-26844-1-git-send-email-n-horiguchi@ah.jp.nec.com>

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>

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Tony Luck <tony.luck@intel.com>,
	Andi Kleen <andi.kleen@intel.com>,
	Wu Fengguang <fengguang.wu@intel.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page()
Date: Tue, 27 Nov 2012 13:54:58 -0800	[thread overview]
Message-ID: <20121127135458.4b7369f7.akpm@linux-foundation.org> (raw)
In-Reply-To: <1354050331-26844-1-git-send-email-n-horiguchi@ah.jp.nec.com>

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?

  parent reply	other threads:[~2012-11-27 21:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 21:05 [PATCH] mm, soft offline: split thp at the beginning of soft_offline_page() Naoya Horiguchi
2012-11-27 21:05 ` Naoya Horiguchi
2012-11-27 21:08 ` Andi Kleen
2012-11-27 21:08   ` Andi Kleen
2012-11-27 21:39   ` Naoya Horiguchi
2012-11-27 21:39     ` Naoya Horiguchi
2012-11-27 21:54 ` Andrew Morton [this message]
2012-11-27 21:54   ` Andrew Morton
2012-11-27 22:42   ` Naoya Horiguchi
2012-11-27 22:42     ` Naoya Horiguchi

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=20121127135458.4b7369f7.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andi.kleen@intel.com \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.