linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jerome Glisse <jglisse@redhat.com>
To: Igor Stoppa <igor.stoppa@huawei.com>
Cc: Michal Hocko <mhocko@kernel.org>, Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-security-module@vger.kernel.org,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	Kees Cook <keescook@google.com>
Subject: Re: [RFC] Tagging of vmalloc pages for supporting the pmalloc allocator
Date: Mon, 7 Aug 2017 15:12:36 -0400	[thread overview]
Message-ID: <20170807191235.GE16616@redhat.com> (raw)
In-Reply-To: <555dc453-3028-199a-881a-3ddeb41e4d6d@huawei.com>

On Mon, Aug 07, 2017 at 05:13:00PM +0300, Igor Stoppa wrote:
> 
> 
> On 07/08/17 16:31, Jerome Glisse wrote:
> > On Mon, Aug 07, 2017 at 02:26:21PM +0300, Igor Stoppa wrote:
> 
> [...]
> 
> >> I'll add a vm_area field as you advised.
> >>
> >> Is this something I could send as standalone patch?
> > 
> > Note that vmalloc() is not the only thing that use vmalloc address
> > space. There is also vmap() and i know one set of drivers that use
> > vmap() and also use the mapping field of struct page namely GPU
> > drivers.
> 
> Ah, yes, you mentioned this.
> 
> > So like i said previously i would store a flag inside vm_struct to
> > know if page you are looking at are pmalloc or not.
> 
> And I was planning to follow your advice, using one of the flags.
> But ...
> 
> > Again do you
> > need to store something per page ? Would storing it per vm_struct
> > not be enough ?
> 
> ... there was this further comment, about speeding up the access to
> vm_area, which seemed good from performance perspective.
> 
> ---8<--------------8<--------------8<--------------8<--------------8<---
> On 03/08/17 14:48, Michal Hocko wrote:
> > On Thu 03-08-17 13:11:45, Igor Stoppa wrote:
> 
> [...]
> 
> >> But, to reply more specifically to your advice, yes, I think I could
> >> add a flag to vm_struct and then retrieve its value, for the address
> >> being processed, by passing through find_vm_area().
> >
> > ... and you can store vm_struct pointer to the struct page there and
> > you won't need to do the slow find_vm_area. I haven't checked very
> > closely but this should be possible in principle. I guess other
> > callers might benefit from this as well.
> ---8<--------------8<--------------8<--------------8<--------------8<---
> 
> I do not strictly need to modify the page struct, but it seems it might
> harm performance, if it is added on the path of hardened usercopy.
> 
> I have an updated version of the old proposal:
> 
> * put a magic number in the private field, during initialization of
> pmalloc pages
> 
> * during hardened usercopy verification, when I have to assess if a page
> is of pmalloc type, compare the private field against the magic number
> 
> * if and only if the private field matches the magic number, then invoke
> find_vm_area(), so that the slowness affects only a possibly limited
> amount of false positives.

This all sounds good to me.

Jerome

--
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:[~2017-08-07 19:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 15:14 [RFC] Tagging of vmalloc pages for supporting the pmalloc allocator Igor Stoppa
2017-08-02 17:08 ` Jerome Glisse
2017-08-03 10:11   ` Igor Stoppa
2017-08-03 11:48     ` Michal Hocko
2017-08-03 12:20       ` Igor Stoppa
2017-08-03 13:55         ` Michal Hocko
2017-08-03 14:41           ` Igor Stoppa
2017-08-03 14:47           ` Jerome Glisse
2017-08-03 15:06             ` Igor Stoppa
2017-08-03 15:15               ` Michal Hocko
2017-08-04  8:02                 ` Igor Stoppa
2017-08-04  8:12                   ` Michal Hocko
2017-08-07 11:26                     ` Igor Stoppa
2017-08-07 11:34                       ` Michal Hocko
2017-08-07 13:31                       ` Jerome Glisse
2017-08-07 14:13                         ` Igor Stoppa
2017-08-07 19:12                           ` Jerome Glisse [this message]
2017-08-08 12:59                             ` Igor Stoppa
2017-08-08 23:15                               ` Jerome Glisse
2017-08-09  7:27                                 ` Igor Stoppa
2017-08-10  7:14                                 ` Michal Hocko

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=20170807191235.GE16616@redhat.com \
    --to=jglisse@redhat.com \
    --cc=igor.stoppa@huawei.com \
    --cc=keescook@google.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mhocko@kernel.org \
    /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 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).