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: <BY5PR12MB43221380BB0259FF0693BB0CDC160@BY5PR12MB4322.namprd12.prod.outlook.com>
Date:   Tue, 27 Oct 2020 12:52:30 +0000
From:   Parav Pandit <parav@...dia.com>
To:     "hch@....de" <hch@....de>
CC:     Jakub Kicinski <kuba@...nel.org>,
        syzbot <syzbot+34dc2fea3478e659af01@...kaller.appspotmail.com>,
        "christian.koenig@....com" <christian.koenig@....com>,
        "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
        "iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
        "linaro-mm-sig-owner@...ts.linaro.org" 
        <linaro-mm-sig-owner@...ts.linaro.org>,
        "linaro-mm-sig@...ts.linaro.org" <linaro-mm-sig@...ts.linaro.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-media@...r.kernel.org" <linux-media@...r.kernel.org>,
        "m.szyprowski@...sung.com" <m.szyprowski@...sung.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "robin.murphy@....com" <robin.murphy@....com>,
        "sumit.semwal@...aro.org" <sumit.semwal@...aro.org>,
        "syzkaller-bugs@...glegroups.com" <syzkaller-bugs@...glegroups.com>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>
Subject: RE: WARNING in dma_map_page_attrs


> From: hch@....de <hch@....de>
> Sent: Tuesday, October 27, 2020 1:41 PM
> 
> On Mon, Oct 26, 2020 at 05:23:48AM +0000, Parav Pandit wrote:
> > Hi Christoph,
> >
> > > From: Jakub Kicinski <kuba@...nel.org>
> > > Sent: Saturday, October 24, 2020 11:45 PM
> > >
> > > CC: rdma, looks like rdma from the stack trace
> > >
> > > On Fri, 23 Oct 2020 20:07:17 -0700 syzbot wrote:
> > > > syzbot has found a reproducer for the following issue on:
> > > >
> > > > HEAD commit:    3cb12d27 Merge tag 'net-5.10-rc1' of
> git://git.kernel.org/..
> >
> > In [1] you mentioned that dma_mask should not be set for dma_virt_ops.
> > So patch [2] removed it.
> >
> > But check to validate the dma mask for all dma_ops was added in [3].
> >
> > What is the right way? Did I misunderstood your comment about
> dma_mask in [1]?
> 
> No, I did not say we don't need the mask.  I said copying over the various
> dma-related fields from the parent is bogus.
> 
> I think rxe (and ther other drivers/infiniband/sw drivers) need a simple
> dma_coerce_mask_and_coherent and nothing else.

I see. Does below fix make sense?
Is DMA_MASK_NONE correct?

>From cfad78c35788b4ff604abedd96559500c5fd2a72 Mon Sep 17 00:00:00 2001
From: Parav Pandit <parav@...dia.com>
Date: Tue, 27 Oct 2020 14:20:07 +0200
Subject: [PATCH] RDMA: Fix software RDMA drivers for dma mapping error

A cited commit in fixes tag avoided setting dma_mask of the ib_device.
Commit [1] made dma_mask as mandetory field to be setup even for
dma_virt_ops based dma devices.

Fix it by setting empty DMA MASK for software based RDMA devices.

[1] commit: f959dcd6ddfd2 ("dma-direct: Fix potential NULL pointer dereference")

Reported-by: syzbot+34dc2fea3478e659af01@...kaller.appspotmail.com
Fixes: e0477b34d9d1 ("RDMA: Explicitly pass in the dma_device to ib_register_device")
Signed-off-by: Parav Pandit <parav@...dia.com>
---
 drivers/infiniband/sw/rdmavt/vt.c     | 5 +++--
 drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +++-
 drivers/infiniband/sw/siw/siw_main.c  | 5 +++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
index 52218684ad4a..1b456f4d4fcf 100644
--- a/drivers/infiniband/sw/rdmavt/vt.c
+++ b/drivers/infiniband/sw/rdmavt/vt.c
@@ -580,8 +580,9 @@ int rvt_register_device(struct rvt_dev_info *rdi)
 
 	/* DMA Operations */
 	rdi->ibdev.dev.dma_parms = rdi->ibdev.dev.parent->dma_parms;
-	dma_set_coherent_mask(&rdi->ibdev.dev,
-			      rdi->ibdev.dev.parent->coherent_dma_mask);
+	ret = dma_coerce_mask_and_coherent(&rdi->ibdev.dev, DMA_MASK_NONE);
+	if (ret)
+		goto bail_wss;
 
 	/* Protection Domain */
 	spin_lock_init(&rdi->n_pds_lock);
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 1fc022362fbe..357787688293 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -1130,7 +1130,9 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
 			    rxe->ndev->dev_addr);
 	dev->dev.dma_parms = &rxe->dma_parms;
 	dma_set_max_seg_size(&dev->dev, UINT_MAX);
-	dma_set_coherent_mask(&dev->dev, dma_get_required_mask(&dev->dev));
+	err = dma_coerce_mask_and_coherent(&dev->dev, DMA_MASK_NONE);
+	if (err)
+		return err;
 
 	dev->uverbs_cmd_mask = BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT)
 	    | BIT_ULL(IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL)
diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c
index ca8bc7296867..d3dc50a42dab 100644
--- a/drivers/infiniband/sw/siw/siw_main.c
+++ b/drivers/infiniband/sw/siw/siw_main.c
@@ -384,8 +384,9 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
 	base_dev->dev.parent = parent;
 	base_dev->dev.dma_parms = &sdev->dma_parms;
 	dma_set_max_seg_size(&base_dev->dev, UINT_MAX);
-	dma_set_coherent_mask(&base_dev->dev,
-			      dma_get_required_mask(&base_dev->dev));
+	if (dma_coerce_mask_and_coherent(&base_dev->dev, DMA_MASK_NONE))
+		goto error;
+
 	base_dev->num_comp_vectors = num_possible_cpus();
 
 	xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1);
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ