Re: [PATCH 6/6] staging: vme_user: provide DMA functionality

From: Dan Carpenter
Date: Fri May 22 2015 - 03:59:27 EST


On Fri, May 22, 2015 at 01:12:19AM +0300, Dmitry Kalinkin wrote:
> On Tue, May 19, 2015 at 12:18 PM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> > On Mon, May 18, 2015 at 09:56:33PM +0300, Dmitry Kalinkin wrote:
> >>
> >> + for_each_sg(sgt->sgl, sg, sg_count, i) {
> >> + struct vme_dma_attr *pci_attr, *vme_attr, *dest, *src;
> >> + dma_addr_t hw_address = sg_dma_address(sg);
> >> + unsigned int hw_len = sg_dma_len(sg);
> >> +
> >> + vme_attr = vme_dma_vme_attribute(dma_op->vme_addr + pos,
> > ^^^^^^^^^^^^^^^^^^^^^^
> >
> > ->vme_addr comes from the user and we don't seem to have done any
> > validation that it's correct. This addition can overflow. How is this
> > safe? (This is not a rhetorical question, I am a newbie in this).
> >
> This expression calculates address on the VME bus, where we already have
> full access. There shouldn't have security implications. Such transfer will
> most likely wrap or cause DMA transfer error (gives EIO).

Ahh... Thanks. Again I was just asking because I'm a bit of a newbie
here so there wasn't really a need to add the other check just to make
me happy. But I do like the new check as well.

regards,
dan carpenter

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