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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 13 Aug 2018 20:47:54 -0700
From:   Roman Kiryanov <rkir@...gle.com>
To:     joe@...ches.com
Cc:     gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
        Todd Kjos <tkjos@...gle.com>
Subject: Re: [PATCH 6/9] platform: goldfish: pipe: Fail compilation if structs
 are too large

Hi,

thank you for reviewing my patches. I decided to put BUILD_BUG_ON
close to places where it is important that these structs fit into a
memory page to give some context.

Regards,
Roman.
On Mon, Aug 13, 2018 at 6:48 PM Joe Perches <joe@...ches.com> wrote:
>
> On Mon, 2018-08-13 at 16:38 -0700, rkir@...gle.com wrote:
> > From: Roman Kiryanov <rkir@...gle.com>
> >
> > Since the driver provides no workaround prevent in cases if structs do
> > no fit into a memory page, it is better to fail complation to find about
> > the issue earlt instead of returning errors at runtime.
>
> Minor earlt/early typo
>
> > diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
> []
> > @@ -797,9 +798,7 @@ static int goldfish_pipe_device_init(struct platform_device *pdev)
> >        * needs to be contained in a single physical page. The easiest choice
> >        * is to just allocate a page and place the buffers in it.
> >        */
> > -     if (WARN_ON(sizeof(*dev->buffers) > PAGE_SIZE))
> > -             return -ENOMEM;
> > -
> > +     BUILD_BUG_ON(sizeof(*dev->buffers) > PAGE_SIZE);
> >       page = (char *)__get_free_page(GFP_KERNEL);
> >       if (!page) {
> >               kfree(dev->pipes);
> > @@ -842,8 +841,7 @@ static int goldfish_pipe_probe(struct platform_device *pdev)
> >       struct resource *r;
> >       struct goldfish_pipe_dev *dev = pipe_dev;
> >
> > -     if (WARN_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE))
> > -             return -ENOMEM;
> > +     BUILD_BUG_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE);
> >
> >       /* not thread safe, but this should not happen */
> >       WARN_ON(dev->base != NULL);
>
> Why separate these BUILD_BUG_ONs into 2 different functions?
>
> Why not just
>         BUILD_BUG_ON(sizeof(struct goldfish_pipe_command) > PAGE_SIZE);
>         BUILD_BUG_ON(sizeof(struct goldfish_pipe_dev_buffers) > PAGE_SIZE);
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ