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: <1370958858.2286.5.camel@dabdike>
Date:	Tue, 11 Jun 2013 06:54:18 -0700
From:	James Bottomley <James.Bottomley@...senPartnership.com>
To:	Marek Szyprowski <m.szyprowski@...sung.com>
Cc:	Bjorn Helgaas <bhelgaas@...gle.com>,
	Michal Simek <michal.simek@...inx.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Michal Simek <monstr@...str.eu>, Arnd Bergmann <arnd@...db.de>,
	Linux-Arch <linux-arch@...r.kernel.org>
Subject: Re: [PATCH] dma-mapping: Add BUG_ON for uninitialized dma_ops

On Tue, 2013-06-11 at 13:02 +0200, Marek Szyprowski wrote:
> Hello,
> 
> On 6/11/2013 4:34 AM, Bjorn Helgaas wrote:
> > [+cc Marek]
> >
> > On Mon, Jun 3, 2013 at 6:44 AM, Michal Simek <michal.simek@...inx.com> wrote:
> > > Check that dma_ops are initialized correctly.
> > >
> > > Signed-off-by: Michal Simek <michal.simek@...inx.com>
> > > ---
> > > Functions dma_mmap_attrs(), dma_get_sgtable_attrs()
> > > already have this checking.
> > >
> > > ---
> > >  include/asm-generic/dma-mapping-common.h | 12 ++++++++++++
> > >  1 file changed, 12 insertions(+)
> > >
> > > diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
> > > index de8bf89..d430cab 100644
> > > --- a/include/asm-generic/dma-mapping-common.h
> > > +++ b/include/asm-generic/dma-mapping-common.h
> > > @@ -16,6 +16,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
> > >         dma_addr_t addr;
> > >
> > >         kmemcheck_mark_initialized(ptr, size);
> > > +       BUG_ON(!ops);
> >
> > Does this actually help anything?  I expected that if "ops" is NULL,
> > we would just oops anyway when we attempted to call "ops->map_page()"
> > because we already trap null pointer dereferences.  At least, when I
> > tried leaving a pci_bus.ops pointer NULL, I got a nice panic and
> > backtrace even without adding an explicit BUG_ON().
> >
> > I cc'd Marek, who added the similar BUG_ON()s in dma_mmap_attrs() and
> > dma_get_sgtable_attrs() with d2b7428eb0 and 64ccc9c033.
> 
> I think that I've copied it from dma_alloc_coherent() in microblaze. You 
> are right that lack
> of this check will also trigger oops in ops==NULL case, but I think that 
> adding explicit check
> in all functions, which use it, is a good idea. It serves as a kind of 
> documentation and
> emphasizes that missing ops is really an issue.

Really, no, it's not a good idea at all.  It invites tons of patches
littering the code with BUG_ONs where we might possibly get a NULL
dereference.  All it does is add extra instructions to a code path for
no actual benefit.

If you can answer the question: what more information does the BUG_ON
give you than the NULL deref Oops would not? then it might be
reasonable.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ