lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABEDWGyZpxkbb-k8ebvbEzgywLg5Fb6X4yqSFwe0JC7WAEmbig@mail.gmail.com>
Date:   Wed, 2 Oct 2019 09:18:08 -0700
From:   Alan Mikhak <alan.mikhak@...ive.com>
To:     Jason Gunthorpe <jgg@...pe.ca>
Cc:     linux-kernel@...r.kernel.org, martin.petersen@...cle.com,
        alexios.zavras@...el.com, ming.lei@...hat.com,
        gregkh@...uxfoundation.org, tglx@...utronix.de,
        christophe.leroy@....fr, thellstrom@...are.com,
        galpress@...zon.com, Palmer Dabbelt <palmer@...ive.com>,
        Paul Walmsley <paul.walmsley@...ive.com>
Subject: Re: [PATCH] scatterlist: Comment on pages for sg_set_page()

On Wed, Oct 2, 2019 at 7:27 AM Jason Gunthorpe <jgg@...pe.ca> wrote:
>
> On Tue, Oct 01, 2019 at 11:32:50AM -0700, Alan Mikhak wrote:
> > From: Alan Mikhak <alan.mikhak@...ive.com>
> >
> > Update the description of sg_set_page() to communicate current
> > requirements for the page pointer parameter.
> >
> > Signed-off-by: Alan Mikhak <alan.mikhak@...ive.com>
> >  include/linux/scatterlist.h | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> > index 6eec50fb36c8..6dda865893aa 100644
> > +++ b/include/linux/scatterlist.h
> > @@ -112,6 +112,12 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
> >   *   of the page pointer. See sg_page() for looking up the page belonging
> >   *   to an sg entry.
> >   *
> > + *   Scatterlist currently expects the page parameter to be a pointer to
> > + *   a page that is backed by a page struct.
> > + *
> > + *   Page pointers derived from addresses obtained from ioremap() are
> > + *   currently not supported since they require use of iomem safe memcpy.
> > + *
> >   **/
> >  static inline void sg_set_page(struct scatterlist *sg, struct page *page,
> >                              unsigned int len, unsigned int offset)
>
> It seems a bit weird to have a comment explaining that 'struct page
> *page' must actually be a valid pointer. Of course it must.
>
> Computing a 'struct page *' to something that doesn't actually have a
> struct page is simply a bug in whoever did that.
>
> Code should never be interchanging ioremap results with the struct
> page* world.
>
> Jason

Agreed. Should scatterlist API sg_set_page() check the page pointer to
prevent such usage that could crash the system? Is it still reasonable
to at least tell the programmer what is not allowed by adding a
comment in the description?

Alan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ