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: <CAKh23Fmxv887dje8r5xF7sQwPumCm15ZWxL7cdpRSZJeBh1FjQ@mail.gmail.com>
Date:	Wed, 9 Jul 2014 15:39:45 -0700
From:	Iyappan Subramanian <isubramanian@....com>
To:	Russell King - ARM Linux <linux@....linux.org.uk>
Cc:	Dann Frazier <dann.frazier@...onical.com>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	"jcm@...hat.com" <jcm@...hat.com>, netdev <netdev@...r.kernel.org>,
	patches <patches@....com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Keyur Chudgar <kchudgar@....com>,
	David Miller <davem@...emloft.net>,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>,
	Ravi Patel <rapatel@....com>
Subject: Re: [PATCH v8 4/4] drivers: net: Add APM X-Gene SoC ethernet driver support.

On Wed, Jun 25, 2014 at 4:04 PM, Russell King - ARM Linux
<linux@....linux.org.uk> wrote:
> On Tue, Jun 24, 2014 at 10:29:48PM -0600, Dann Frazier wrote:
>> On Fri, Jun 20, 2014 at 5:18 PM, Iyappan Subramanian
>> <isubramanian@....com> wrote:
>> > +       ring->desc_addr = dma_zalloc_coherent(dev, size, &ring->dma,
>> > +                                             GFP_KERNEL);
>>
>> Iyappan,
>> When testing this driver on a 3.16-rc2 base, I'm finding that
>> desc_addr gets assigned to NULL here, which results in an oops later
>> on (see below).
>
> Note that on failure here...
>
>> > +       if (!ring->desc_addr)
>> > +               goto err;
>
> we jump to 'err'.
>
>> > +err:
>> > +       dma_free_coherent(dev, size, ring->desc_addr, ring->dma);
>
> which then tries to call dma_free_coherent on a NULL pointer, and
> possibly undefined ring->dma value.  That's not a nice thing to do,
> and will probably lead to problems.  I know that none of the ARM
> flavours of this function will handle this gracefully, and neither
> does x86's version either.  So this is very probably illegal.

I will fix this.

>
>> > +static int xgene_enet_create_desc_rings(struct net_device *ndev)
>> > +{
>> > +       struct xgene_enet_pdata *pdata = netdev_priv(ndev);
>> > +       struct device *dev = &pdata->pdev->dev;
>> > +       struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
>> > +       struct xgene_enet_desc_ring *buf_pool = NULL;
>> > +       u8 cpu_bufnum = 0, eth_bufnum = 0;
>> > +       u8 bp_bufnum = 0x20;
>> > +       u16 ring_id, ring_num = 0;
>> > +       int ret;
>> > +
>> > +       /* allocate rx descriptor ring */
>> > +       ring_id = xgene_enet_get_ring_id(RING_OWNER_CPU, cpu_bufnum++);
>> > +       rx_ring = xgene_enet_create_desc_ring(ndev, ring_num++,
>> > +                                             RING_CFGSIZE_16KB, ring_id);
>> > +       if (IS_ERR_OR_NULL(rx_ring)) {
>> > +               ret = PTR_ERR(rx_ring);
>> > +               goto err;
>> > +       }
>>
>> Here we test for IS_ERR_OR_NULL. In the oops I'm hitting, rx_ring is
>> NULL here - but PTR_ERR() apparently returns 0 in that case. So this
>> function ends up returning no error.
>
> Yes, IS_ERR_OR_NULL is evil for this very reason and should be avoided
> where possible.  There were discussions a while back about removing it,
> or at least deprecating it because it causes more bugs (exactly of this
> type) than it solves.

Thanks for pointing it out.  I will redesign IS_ERR_OR_NULL usage.

>
> --
> FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
> improving, and getting towards what was expected from it.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ