Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1444279
| From | Balbir Singh <bsingharora@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 02/11] mm: Hardened usercopy |
| Date | 2016-07-15 15:00 +0200 |
| Message-ID | <rVaSK-70X-17@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <rUYeS-7FM-5@gated-at.bofh.it> <rUZND-h3-5@gated-at.bofh.it> <rV0ql-uG-13@gated-at.bofh.it> <rV2BP-25M-1@gated-at.bofh.it> <rV3od-2pG-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Jul 14, 2016 at 09:53:31PM -0700, Kees Cook wrote:
> On Thu, Jul 14, 2016 at 9:05 PM, Kees Cook <keescook@chromium.org> wrote:
> > On Thu, Jul 14, 2016 at 6:41 PM, Balbir Singh <bsingharora@gmail.com> wrote:
> >> On Thu, Jul 14, 2016 at 09:04:18PM -0400, Rik van Riel wrote:
> >>> On Fri, 2016-07-15 at 09:20 +1000, Balbir Singh wrote:
> >>>
> >>> > > ==
> >>> > > + ((unsigned long)end & (unsigned
> >>> > > long)PAGE_MASK)))
> >>> > > + return NULL;
> >>> > > +
> >>> > > + /* Allow if start and end are inside the same compound
> >>> > > page. */
> >>> > > + endpage = virt_to_head_page(end);
> >>> > > + if (likely(endpage == page))
> >>> > > + return NULL;
> >>> > > +
> >>> > > + /* Allow special areas, device memory, and sometimes
> >>> > > kernel data. */
> >>> > > + if (PageReserved(page) && PageReserved(endpage))
> >>> > > + return NULL;
> >>> >
> >>> > If we came here, it's likely that endpage > page, do we need to check
> >>> > that only the first and last pages are reserved? What about the ones
> >>> > in
> >>> > the middle?
> >>>
> >>> I think this will be so rare, we can get away with just
> >>> checking the beginning and the end.
> >>>
> >>
> >> But do we want to leave a hole where an aware user space
> >> can try a longer copy_* to avoid this check? If it is unlikely
> >> should we just bite the bullet and do the check for the entire
> >> range?
> >
> > I'd be okay with expanding the test -- it should be an extremely rare
> > situation already since the common Reserved areas (kernel data) will
> > have already been explicitly tested.
> >
> > What's the best way to do "next page"? Should it just be:
> >
> > for ( ; page <= endpage ; ptr += PAGE_SIZE, page = virt_to_head_page(ptr) ) {
> > if (!PageReserved(page))
> > return "<spans multiple pages>";
> > }
> >
> > return NULL;
> >
> > ?
>
> Er, I was testing the wrong thing. How about:
>
> /*
> * Reject if range is not Reserved (i.e. special or device memory),
> * since then the object spans several independently allocated pages.
> */
> for (; ptr <= end ; ptr += PAGE_SIZE, page = virt_to_head_page(ptr)) {
> if (!PageReserved(page))
> return "<spans multiple pages>";
> }
>
> return NULL;
That looks reasonable to me
Balbir
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 02/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-14 00:00 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Balbir Singh <bsingharora@gmail.com> - 2016-07-15 01:30 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Rik van Riel <riel@redhat.com> - 2016-07-15 03:10 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Balbir Singh <bsingharora@gmail.com> - 2016-07-15 03:50 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-15 06:10 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-15 07:00 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Balbir Singh <bsingharora@gmail.com> - 2016-07-15 15:00 +0200
Re: [PATCH v2 02/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-15 06:30 +0200
Re: [kernel-hardening] Re: [PATCH v2 02/11] mm: Hardened usercopy Daniel Micay <danielmicay@gmail.com> - 2016-07-15 21:10 +0200
Re: [kernel-hardening] Re: [PATCH v2 02/11] mm: Hardened usercopy Daniel Micay <danielmicay@gmail.com> - 2016-07-15 21:20 +0200
Re: [kernel-hardening] Re: [PATCH v2 02/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-15 21:30 +0200
Re: [kernel-hardening] Re: [PATCH v2 02/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-15 21:20 +0200
csiph-web