All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laura Abbott <labbott@redhat.com>
To: Juerg Haefliger <juerg.haefliger@hpe.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: vpk@cs.brown.edu, Kees Cook <keescook@chromium.org>
Subject: Re: [RFC PATCH] Add support for eXclusive Page Frame Ownership (XPFO)
Date: Mon, 28 Mar 2016 12:29:59 -0700	[thread overview]
Message-ID: <56F98637.4070705@redhat.com> (raw)
In-Reply-To: <56EFB2DB.3090602@hpe.com>

On 03/21/2016 01:37 AM, Juerg Haefliger wrote:
...
>>> +void xpfo_free_page(struct page *page, int order)
>>> +{
>>> +    int i;
>>> +    unsigned long kaddr;
>>> +
>>> +    for (i = 0; i < (1 << order); i++) {
>>> +
>>> +        /* The page frame was previously allocated to user space */
>>> +        if (TEST_AND_CLEAR_XPFO_FLAG(user, page + i)) {
>>> +            kaddr = (unsigned long)page_address(page + i);
>>> +
>>> +            /* Clear the page and mark it accordingly */
>>> +            clear_page((void *)kaddr);
>>
>> Clearing the page isn't related to XPFO. There's other work ongoing to
>> do clearing of the page on free.
>
> It's not strictly related to XPFO but adds another layer of security. Do you
> happen to have a pointer to the ongoing work that you mentioned?
>
>

The work was merged for the 4.6 merge window
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8823b1dbc05fab1a8bec275eeae4709257c2661d

This is a separate option to clear the page.

...

>>> @@ -2072,10 +2076,11 @@ void free_hot_cold_page(struct page *page, bool cold)
>>>        }
>>>
>>>        pcp = &this_cpu_ptr(zone->pageset)->pcp;
>>> -    if (!cold)
>>> +    if (!cold && !xpfo_test_kernel(page))
>>>            list_add(&page->lru, &pcp->lists[migratetype]);
>>>        else
>>>            list_add_tail(&page->lru, &pcp->lists[migratetype]);
>>> +
>>
>> What's the advantage of this?
>
> Allocating a page to userspace that was previously allocated to kernel space
> requires an expensive TLB shootdown. The above will put previously
> kernel-allocated pages in the cold page cache to postpone their allocation as
> long as possible to minimize TLB shootdowns.
>
>

That makes sense. You probably want to make this a separate commmit with
this explanation as the commit text.


>>>        pcp->count++;
>>>        if (pcp->count >= pcp->high) {
>>>            unsigned long batch = READ_ONCE(pcp->batch);
>>>
>
> Thanks for the review and comments! It's highly appreciated.
>
> ...Juerg
>
>
>> Thanks,
>> Laura

WARNING: multiple messages have this Message-ID (diff)
From: Laura Abbott <labbott@redhat.com>
To: Juerg Haefliger <juerg.haefliger@hpe.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: vpk@cs.brown.edu, Kees Cook <keescook@chromium.org>
Subject: Re: [RFC PATCH] Add support for eXclusive Page Frame Ownership (XPFO)
Date: Mon, 28 Mar 2016 12:29:59 -0700	[thread overview]
Message-ID: <56F98637.4070705@redhat.com> (raw)
In-Reply-To: <56EFB2DB.3090602@hpe.com>

On 03/21/2016 01:37 AM, Juerg Haefliger wrote:
...
>>> +void xpfo_free_page(struct page *page, int order)
>>> +{
>>> +    int i;
>>> +    unsigned long kaddr;
>>> +
>>> +    for (i = 0; i < (1 << order); i++) {
>>> +
>>> +        /* The page frame was previously allocated to user space */
>>> +        if (TEST_AND_CLEAR_XPFO_FLAG(user, page + i)) {
>>> +            kaddr = (unsigned long)page_address(page + i);
>>> +
>>> +            /* Clear the page and mark it accordingly */
>>> +            clear_page((void *)kaddr);
>>
>> Clearing the page isn't related to XPFO. There's other work ongoing to
>> do clearing of the page on free.
>
> It's not strictly related to XPFO but adds another layer of security. Do you
> happen to have a pointer to the ongoing work that you mentioned?
>
>

The work was merged for the 4.6 merge window
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8823b1dbc05fab1a8bec275eeae4709257c2661d

This is a separate option to clear the page.

...

>>> @@ -2072,10 +2076,11 @@ void free_hot_cold_page(struct page *page, bool cold)
>>>        }
>>>
>>>        pcp = &this_cpu_ptr(zone->pageset)->pcp;
>>> -    if (!cold)
>>> +    if (!cold && !xpfo_test_kernel(page))
>>>            list_add(&page->lru, &pcp->lists[migratetype]);
>>>        else
>>>            list_add_tail(&page->lru, &pcp->lists[migratetype]);
>>> +
>>
>> What's the advantage of this?
>
> Allocating a page to userspace that was previously allocated to kernel space
> requires an expensive TLB shootdown. The above will put previously
> kernel-allocated pages in the cold page cache to postpone their allocation as
> long as possible to minimize TLB shootdowns.
>
>

That makes sense. You probably want to make this a separate commmit with
this explanation as the commit text.


>>>        pcp->count++;
>>>        if (pcp->count >= pcp->high) {
>>>            unsigned long batch = READ_ONCE(pcp->batch);
>>>
>
> Thanks for the review and comments! It's highly appreciated.
>
> ...Juerg
>
>
>> Thanks,
>> Laura

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

  reply	other threads:[~2016-03-28 19:30 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 14:21 [RFC PATCH] Add support for eXclusive Page Frame Ownership (XPFO) Juerg Haefliger
2016-02-26 14:21 ` Juerg Haefliger
2016-03-01  1:31 ` Laura Abbott
2016-03-01  1:31   ` Laura Abbott
2016-03-21  8:37   ` Juerg Haefliger
2016-03-21  8:37     ` Juerg Haefliger
2016-03-28 19:29     ` Laura Abbott [this message]
2016-03-28 19:29       ` Laura Abbott
2016-03-01  2:10 ` Balbir Singh
2016-03-01  2:10   ` Balbir Singh
2016-03-21  8:44   ` Juerg Haefliger
2016-03-21  8:44     ` Juerg Haefliger
2016-04-01  0:21     ` Balbir Singh
2016-04-01  0:21       ` Balbir Singh
2016-09-02 11:39 ` [RFC PATCH v2 0/3] " Juerg Haefliger
2016-09-02 11:39   ` [kernel-hardening] " Juerg Haefliger
2016-09-02 11:39   ` Juerg Haefliger
2016-09-02 11:39   ` [RFC PATCH v2 1/3] " Juerg Haefliger
2016-09-02 11:39     ` [kernel-hardening] " Juerg Haefliger
2016-09-02 11:39     ` Juerg Haefliger
2016-09-02 11:39   ` [RFC PATCH v2 2/3] xpfo: Only put previous userspace pages into the hot cache Juerg Haefliger
2016-09-02 11:39     ` [kernel-hardening] " Juerg Haefliger
2016-09-02 11:39     ` Juerg Haefliger
2016-09-02 20:39     ` Dave Hansen
2016-09-02 20:39       ` [kernel-hardening] " Dave Hansen
2016-09-02 20:39       ` Dave Hansen
2016-09-05 11:54       ` Juerg Haefliger
2016-09-05 11:54         ` [kernel-hardening] " Juerg Haefliger
2016-09-02 11:39   ` [RFC PATCH v2 3/3] block: Always use a bounce buffer when XPFO is enabled Juerg Haefliger
2016-09-02 11:39     ` [kernel-hardening] " Juerg Haefliger
2016-09-02 11:39     ` Juerg Haefliger
2016-09-14  7:18   ` [RFC PATCH v2 0/3] Add support for eXclusive Page Frame Ownership (XPFO) Juerg Haefliger
2016-09-14  7:18     ` [kernel-hardening] " Juerg Haefliger
2016-09-14  7:18     ` Juerg Haefliger
2016-09-14  7:18     ` [RFC PATCH v2 1/3] " Juerg Haefliger
2016-09-14  7:18       ` [kernel-hardening] " Juerg Haefliger
2016-09-14  7:18       ` Juerg Haefliger
2016-09-14  7:19     ` [RFC PATCH v2 2/3] xpfo: Only put previous userspace pages into the hot cache Juerg Haefliger
2016-09-14  7:19       ` [kernel-hardening] " Juerg Haefliger
2016-09-14  7:19       ` Juerg Haefliger
2016-09-14 14:33       ` [kernel-hardening] " Dave Hansen
2016-09-14 14:33         ` Dave Hansen
2016-09-14 14:40         ` Juerg Haefliger
2016-09-14 14:48           ` Dave Hansen
2016-09-14 14:48             ` Dave Hansen
2016-09-21  5:32             ` Juerg Haefliger
2016-09-14  7:19     ` [RFC PATCH v2 3/3] block: Always use a bounce buffer when XPFO is enabled Juerg Haefliger
2016-09-14  7:19       ` [kernel-hardening] " Juerg Haefliger
2016-09-14  7:19       ` Juerg Haefliger
2016-09-14  7:33       ` Christoph Hellwig
2016-09-14  7:33         ` [kernel-hardening] " Christoph Hellwig
2016-09-14  7:33         ` Christoph Hellwig
2016-09-14  7:23     ` [RFC PATCH v2 0/3] Add support for eXclusive Page Frame Ownership (XPFO) Juerg Haefliger
2016-09-14  7:23       ` [kernel-hardening] " Juerg Haefliger
2016-09-14  9:36     ` [kernel-hardening] " Mark Rutland
2016-09-14  9:36       ` Mark Rutland
2016-09-14  9:49       ` Mark Rutland
2016-09-14  9:49         ` Mark Rutland
2016-11-04 14:45     ` [RFC PATCH v3 0/2] " Juerg Haefliger
2016-11-04 14:45       ` [kernel-hardening] " Juerg Haefliger
2016-11-04 14:45       ` Juerg Haefliger
2016-11-04 14:45       ` [RFC PATCH v3 1/2] " Juerg Haefliger
2016-11-04 14:45         ` [kernel-hardening] " Juerg Haefliger
2016-11-04 14:45         ` Juerg Haefliger
2016-11-04 14:50         ` Christoph Hellwig
2016-11-04 14:50           ` [kernel-hardening] " Christoph Hellwig
2016-11-04 14:50           ` Christoph Hellwig
2016-11-10  5:53         ` [kernel-hardening] " ZhaoJunmin Zhao(Junmin)
2016-11-10  5:53           ` ZhaoJunmin Zhao(Junmin)
2016-11-10  5:53           ` ZhaoJunmin Zhao(Junmin)
2016-11-10 19:11         ` Kees Cook
2016-11-10 19:11           ` [kernel-hardening] " Kees Cook
2016-11-10 19:11           ` Kees Cook
2016-11-15 11:15           ` Juerg Haefliger
2016-11-15 11:15             ` [kernel-hardening] " Juerg Haefliger
2016-11-15 11:15             ` Juerg Haefliger
2016-11-10 19:24         ` Kees Cook
2016-11-10 19:24           ` [kernel-hardening] " Kees Cook
2016-11-10 19:24           ` Kees Cook
2016-11-15 11:18           ` Juerg Haefliger
2016-11-15 11:18             ` [kernel-hardening] " Juerg Haefliger
2016-11-15 11:18             ` Juerg Haefliger
2016-11-24 10:56         ` AKASHI Takahiro
2016-11-24 10:56           ` [kernel-hardening] " AKASHI Takahiro
2016-11-24 10:56           ` AKASHI Takahiro
2016-11-28 11:15           ` Juerg Haefliger
2016-11-28 11:15             ` [kernel-hardening] " Juerg Haefliger
2016-12-09  9:02           ` AKASHI Takahiro
2016-12-09  9:02             ` [kernel-hardening] " AKASHI Takahiro
2016-12-09  9:02             ` AKASHI Takahiro
2016-11-04 14:45       ` [RFC PATCH v3 2/2] xpfo: Only put previous userspace pages into the hot cache Juerg Haefliger
2016-11-04 14:45         ` [kernel-hardening] " Juerg Haefliger
2016-11-04 14:45         ` Juerg Haefliger

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=56F98637.4070705@redhat.com \
    --to=labbott@redhat.com \
    --cc=juerg.haefliger@hpe.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vpk@cs.brown.edu \
    /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.