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]
Message-ID: <CAMuHMdX=b0iAnDw1=85MXNBSMD=MxZb27QrO3rEWHYq0vB+3ow@mail.gmail.com>
Date:   Mon, 23 Jul 2018 10:49:39 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Jacopo Mondi <jacopo@...ndi.org>
Cc:     Christoph Hellwig <hch@....de>,
        Yoshinori Sato <ysato@...rs.sourceforge.jp>,
        Rich Felker <dalias@...c.org>,
        Jacopo Mondi <jacopo+renesas@...ndi.org>,
        Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
        Linux-sh list <linux-sh@...r.kernel.org>,
        Linux IOMMU <iommu@...ts.linux-foundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/5] sh: split arch/sh/mm/consistent.c

Hi Jacopo,

On Mon, Jul 23, 2018 at 10:42 AM jacopo mondi <jacopo@...ndi.org> wrote:
> I have a single comment on something I noticed which might be an
> implementation bug. On the overall patch architecture, it's very hard
> for me to provide a valuable opinion as it's all relatively new for me
> here :)
>
> On Thu, Jul 19, 2018 at 06:05:15AM -0700, Christoph Hellwig wrote:
> > Half of the file just contains platform device memory setup code which
> > is required for all builds, and half contains helpers for dma coherent
> > allocation, which is only needed if CONFIG_DMA_NONCOHERENT is enabled.
> >
> > Signed-off-by: Christoph Hellwig <hch@....de>

> > --- /dev/null
> > +++ b/arch/sh/kernel/dma-coherent.c
> > @@ -0,0 +1,85 @@
> > +/*
> > + * Copyright (C) 2004 - 2007  Paul Mundt
> > + *
> > + * This file is subject to the terms and conditions of the GNU General Public
> > + * License.  See the file "COPYING" in the main directory of this archive
> > + * for more details.
> > + */
> > +#include <linux/mm.h>
> > +#include <linux/init.h>
> > +#include <linux/dma-mapping.h>
> > +#include <linux/module.h>
> > +#include <asm/cacheflush.h>
> > +#include <asm/addrspace.h>
> > +
> > +void *dma_generic_alloc_coherent(struct device *dev, size_t size,
> > +                              dma_addr_t *dma_handle, gfp_t gfp,
> > +                              unsigned long attrs)
> > +{
> > +     void *ret, *ret_nocache;
> > +     int order = get_order(size);
> > +
> > +     gfp |= __GFP_ZERO;
> > +
> > +     ret = (void *)__get_free_pages(gfp, order);
> > +     if (!ret)
> > +             return NULL;
> > +
> > +     /*
> > +      * Pages from the page allocator may have data present in
> > +      * cache. So flush the cache before using uncached memory.
> > +      */
> > +     sh_sync_dma_for_device(ret, size, DMA_BIDIRECTIONAL);
> > +
> > +     ret_nocache = (void __force *)ioremap_nocache(virt_to_phys(ret), size);
> > +     if (!ret_nocache) {
> > +             free_pages((unsigned long)ret, order);
> > +             return NULL;
> > +     }
> > +
> > +     split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order);
> > +
> > +     *dma_handle = virt_to_phys(ret);
> > +     if (!WARN_ON(!dev))
> > +             *dma_handle - PFN_PHYS(dev->dma_pfn_offset);
>
> I guess this comes from below...

> > -     *dma_handle = virt_to_phys(ret);
> > -     if (!WARN_ON(!dev))
> > -             *dma_handle -= PFN_PHYS(dev->dma_pfn_offset);
>
> ... here
>
> Is the s/-=/- intended?
>
> Snippets copied here below:
>
> > +     *dma_handle = virt_to_phys(ret);
> > +     if (!WARN_ON(!dev))
> > +             *dma_handle - PFN_PHYS(dev->dma_pfn_offset);
> vs
> > -     *dma_handle = virt_to_phys(ret);
> > -     if (!WARN_ON(!dev))
> > -             *dma_handle -= PFN_PHYS(dev->dma_pfn_offset);

Doesn't look right to me, neither.

No complaints for 0day? My gcc says:

    error: statement with no effect [-Werror=unused-value]

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ