Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1677774 > unrolled thread

Re: [PATCH 4.4 35/46] ravb: unmap descriptors when freeing rings

Started byBen Hutchings <ben.hutchings@codethink.co.uk>
First post2017-06-29 16:00 +0200
Last post2017-07-03 15:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 4.4 35/46] ravb: unmap descriptors when freeing rings Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-06-29 16:00 +0200
    Re: [PATCH 4.4 35/46] ravb: unmap descriptors when freeing rings Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-07-03 15:00 +0200

#1677774 — Re: [PATCH 4.4 35/46] ravb: unmap descriptors when freeing rings

FromBen Hutchings <ben.hutchings@codethink.co.uk>
Date2017-06-29 16:00 +0200
SubjectRe: [PATCH 4.4 35/46] ravb: unmap descriptors when freeing rings
Message-ID<tXI9c-8h6-17@gated-at.bofh.it>
On Thu, 2017-06-15 at 19:52 +0200, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
> 
> 
> [ Upstream commit a47b70ea86bdeb3091341f5ae3ef580f1a1ad822 ]
> 
> "swiotlb buffer is full" errors occur after repeated initialisation of a
> device - f.e. suspend/resume or ip link set up/down. This is because memory
> mapped using dma_map_single() in ravb_ring_format() and ravb_start_xmit()
> is not released.  Resolve this problem by unmapping descriptors when
> freeing rings.

This should be followed by:

commit 79514ef670e9e575a1fe36922268c439d0f0ca8a
Author: Eugeniu Rosca <erosca@de.adit-jv.com>
Date:   Tue Jun 6 00:08:10 2017 +0200

    ravb: Fix use-after-free on `ifconfig eth0 down`

But also, this loop looks wrong:

[...]
>  	if (priv->rx_ring[q]) {
> +		for (i = 0; i < priv->num_rx_ring[q]; i++) {
> +			struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
> +
> +			if (!dma_mapping_error(ndev->dev.parent,
> +					       le32_to_cpu(desc->dptr)))
> +				dma_unmap_single(ndev->dev.parent,
> +						 le32_to_cpu(desc->dptr),
> +						 PKT_BUF_SZ,
> +						 DMA_FROM_DEVICE);
> +		}
[...]

It's possible that the driver hasn't filled (or attempted to fill or
refill) every RX descriptor, so this could result in a double-unmap.  I
think this needs to use cur_rx and dirty_rx to determine which
descriptors to process.

Ben.

-- 
Ben Hutchings
Software Developer, Codethink Ltd.

[toc] | [next] | [standalone]


#1679986

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-07-03 15:00 +0200
Message-ID<tZ97k-1Az-41@gated-at.bofh.it>
In reply to#1677774
On Thu, Jun 29, 2017 at 02:58:09PM +0100, Ben Hutchings wrote:
> On Thu, 2017-06-15 at 19:52 +0200, Greg Kroah-Hartman wrote:
> > 4.4-stable review patch.  If anyone has any objections, please let me know.
> > 
> > ------------------
> > 
> > From: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
> > 
> > 
> > [ Upstream commit a47b70ea86bdeb3091341f5ae3ef580f1a1ad822 ]
> > 
> > "swiotlb buffer is full" errors occur after repeated initialisation of a
> > device - f.e. suspend/resume or ip link set up/down. This is because memory
> > mapped using dma_map_single() in ravb_ring_format() and ravb_start_xmit()
> > is not released.  Resolve this problem by unmapping descriptors when
> > freeing rings.
> 
> This should be followed by:
> 
> commit 79514ef670e9e575a1fe36922268c439d0f0ca8a
> Author: Eugeniu Rosca <erosca@de.adit-jv.com>
> Date:   Tue Jun 6 00:08:10 2017 +0200
> 
>     ravb: Fix use-after-free on `ifconfig eth0 down`

Thanks, now queued up.

> But also, this loop looks wrong:
> 
> [...]
> >  	if (priv->rx_ring[q]) {
> > +		for (i = 0; i < priv->num_rx_ring[q]; i++) {
> > +			struct ravb_ex_rx_desc *desc = &priv->rx_ring[q][i];
> > +
> > +			if (!dma_mapping_error(ndev->dev.parent,
> > +					       le32_to_cpu(desc->dptr)))
> > +				dma_unmap_single(ndev->dev.parent,
> > +						 le32_to_cpu(desc->dptr),
> > +						 PKT_BUF_SZ,
> > +						 DMA_FROM_DEVICE);
> > +		}
> [...]
> 
> It's possible that the driver hasn't filled (or attempted to fill or
> refill) every RX descriptor, so this could result in a double-unmap.  I
> think this needs to use cur_rx and dirty_rx to determine which
> descriptors to process.

I'll let Kazuya fix that :)

thanks,

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web