Re: [syzbot] WARNING in dma_map_sgtable (2)

From: Christoph Hellwig
Date: Tue May 31 2022 - 01:45:49 EST


Someohow only the reply from Dan got delivered to me, not the mail
from Hillf he is replying to, so I'm abusing that to reply to the
previous mail..

On Mon, May 30, 2022 at 06:10:44PM +0300, Dan Carpenter wrote:
> > --- y/drivers/dma-buf/udmabuf.c
> > +++ u/drivers/dma-buf/udmabuf.c
> > @@ -273,6 +273,14 @@ static long udmabuf_create(struct miscde
> > if (IS_ERR(buf)) {
> > ret = PTR_ERR(buf);
> > goto err;
> > + } else {
> > + struct device *dev = ubuf->device->this_device;
> > +
> > + if (!dev->dma_mask) {
> > + ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
> > + if (ret)
> > + goto err;
> > + }
> > }

This is compeltely broken. If the underlying device is ot DMA capable and
we can't just set a random mask and still allow DMA mappings.