All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-next 0/6] Updates for 5.19
@ 2022-05-20 18:36 Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 1/6] RDMA/hfi1: Prevent use of lock before it is initialized Dennis Dalessandro
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:36 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma

Here are some clean up patches, for the driver mersion that got missed and
diagpkt removal. Doug has two fixes as well.

---

Dennis Dalessandro (4):
      RDMA/hfi1: Fix potential integer multiplication overflow errors
      RDMA/hfi1: Remove pointless driver version
      RDMA/hfi1: Consolidate software versions
      RDMA/hfi1: Remove all traces of diagpkt support

Douglas Miller (2):
      RDMA/hfi1: Prevent use of lock before it is initialized
      RDMA/hfi1: Prevent panic when SDMA is disabled


 drivers/infiniband/hw/hfi1/common.h   |   55 ---------------------------------
 drivers/infiniband/hw/hfi1/driver.c   |    6 ----
 drivers/infiniband/hw/hfi1/file_ops.c |    5 ++-
 drivers/infiniband/hw/hfi1/init.c     |    2 +
 drivers/infiniband/hw/hfi1/sdma.c     |   12 ++++---
 5 files changed, 12 insertions(+), 68 deletions(-)

--
-Denny

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH for-next 1/6] RDMA/hfi1: Prevent use of lock before it is initialized
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
@ 2022-05-20 18:37 ` Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 2/6] RDMA/hfi1: Prevent panic when SDMA is disabled Dennis Dalessandro
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:37 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma, Zheyu Ma, Douglas Miller

From: Douglas Miller <doug.miller@cornelisnetworks.com>

If there is a failure during probe of hfi1 before the sdma_map_lock is
initialized, the call to hfi1_free_devdata() will attempt to use a lock
that has not been initialized. If the locking correctness validator is on
then an INFO message and stack trace resembling the following may be seen:

INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
Call Trace:
register_lock_class+0x11b/0x880
__lock_acquire+0xf3/0x7930
lock_acquire+0xff/0x2d0
_raw_spin_lock_irq+0x46/0x60
sdma_clean+0x42a/0x660 [hfi1]
hfi1_free_devdata+0x3a7/0x420 [hfi1]
init_one+0x867/0x11a0 [hfi1]
pci_device_probe+0x40e/0x8d0

The use of sdma_map_lock in sdma_clean() is for freeing the sdma_map
memory, and sdma_map is not allocated/initialized until after
sdma_map_lock has been initialized. This code only needs to be run if
sdma_map is not NULL, and so checking for that condition will avoid
trying to use the lock before it is initialized.

Fixes: 473291b3ea0e1 ("IB/hfi1: Fix for early release of sdma context")
Fixes: 7724105686e71 ("IB/hfi1: add driver files")

Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Douglas Miller <doug.miller@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/sdma.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/sdma.c b/drivers/infiniband/hw/hfi1/sdma.c
index f07d328..a95b654 100644
--- a/drivers/infiniband/hw/hfi1/sdma.c
+++ b/drivers/infiniband/hw/hfi1/sdma.c
@@ -1288,11 +1288,13 @@ void sdma_clean(struct hfi1_devdata *dd, size_t num_engines)
 		kvfree(sde->tx_ring);
 		sde->tx_ring = NULL;
 	}
-	spin_lock_irq(&dd->sde_map_lock);
-	sdma_map_free(rcu_access_pointer(dd->sdma_map));
-	RCU_INIT_POINTER(dd->sdma_map, NULL);
-	spin_unlock_irq(&dd->sde_map_lock);
-	synchronize_rcu();
+	if (rcu_access_pointer(dd->sdma_map)) {
+		spin_lock_irq(&dd->sde_map_lock);
+		sdma_map_free(rcu_access_pointer(dd->sdma_map));
+		RCU_INIT_POINTER(dd->sdma_map, NULL);
+		spin_unlock_irq(&dd->sde_map_lock);
+		synchronize_rcu();
+	}
 	kfree(dd->per_sdma);
 	dd->per_sdma = NULL;
 


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 2/6] RDMA/hfi1: Prevent panic when SDMA is disabled
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 1/6] RDMA/hfi1: Prevent use of lock before it is initialized Dennis Dalessandro
@ 2022-05-20 18:37 ` Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 3/6] RDMA/hfi1: Fix potential integer multiplication overflow errors Dennis Dalessandro
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:37 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma, Douglas Miller

From: Douglas Miller <doug.miller@cornelisnetworks.com>

If the hfi1 module is loaded with HFI1_CAP_SDMA off,
a call to hfi1_write_iter() will dereference a NULL pointer
and panic. A typical stack frame is:

sdma_select_user_engine [hfi1]
hfi1_user_sdma_process_request [hfi1]
hfi1_write_iter [hfi1]
do_iter_readv_writev
do_iter_write
vfs_writev
do_writev
do_syscall_64

The fix is to test for SDMA in hfi1_write_iter() and fail
the I/O with EINVAL.

Signed-off-by: Douglas Miller <doug.miller@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/file_ops.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 1783a6e..cb65f31 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -265,6 +265,9 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from)
 	unsigned long dim = from->nr_segs;
 	int idx;
 
+	if (!HFI1_CAP_IS_KSET(SDMA)) {
+		return -EINVAL;
+	}
 	idx = srcu_read_lock(&fd->pq_srcu);
 	pq = srcu_dereference(fd->pq, &fd->pq_srcu);
 	if (!cq || !pq) {


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 3/6] RDMA/hfi1: Fix potential integer multiplication overflow errors
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 1/6] RDMA/hfi1: Prevent use of lock before it is initialized Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 2/6] RDMA/hfi1: Prevent panic when SDMA is disabled Dennis Dalessandro
@ 2022-05-20 18:37 ` Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 4/6] RDMA/hfi1: Remove pointless driver version Dennis Dalessandro
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:37 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma, Mike Marciniszyn, stable

When multiplying of different types, an overflow is possible even
when storing the result in a larger type. This is because the
conversion is done after the multiplication. So arithmetic
overflow and thus in incorrect value is possible.

Correct an instance of this in the inter packet delay calculation.
Fix by ensuring one of the operands is u64 which will promote the
other to u64 as well ensuring no overflow.

Fixes: 7724105686e7 ("IB/hfi1: add driver files")
Cc: stable@vger.kernel.org
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index 4436ed4..436372b 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -489,7 +489,7 @@ void set_link_ipg(struct hfi1_pportdata *ppd)
 	u16 shift, mult;
 	u64 src;
 	u32 current_egress_rate; /* Mbits /sec */
-	u32 max_pkt_time;
+	u64 max_pkt_time;
 	/*
 	 * max_pkt_time is the maximum packet egress time in units
 	 * of the fabric clock period 1/(805 MHz).


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 4/6] RDMA/hfi1: Remove pointless driver version
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
                   ` (2 preceding siblings ...)
  2022-05-20 18:37 ` [PATCH for-next 3/6] RDMA/hfi1: Fix potential integer multiplication overflow errors Dennis Dalessandro
@ 2022-05-20 18:37 ` Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 5/6] RDMA/hfi1: Consolidate software versions Dennis Dalessandro
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:37 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma

Driver versions have long been forbidden in the RDMA subsystem. We removed most
of the code relating to them and have been very strict about not allowing.
However there is some leftover versioning that we do not need. Get rid of that.

Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/common.h |   15 ---------------
 drivers/infiniband/hw/hfi1/driver.c |    6 ------
 2 files changed, 21 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/common.h b/drivers/infiniband/hw/hfi1/common.h
index 995991d..73a2f13 100644
--- a/drivers/infiniband/hw/hfi1/common.h
+++ b/drivers/infiniband/hw/hfi1/common.h
@@ -155,21 +155,6 @@
 #define HFI1_KERN_SWVERSION ((HFI1_KERN_TYPE << 31) | HFI1_USER_SWVERSION)
 
 /*
- * Define the driver version number.  This is something that refers only
- * to the driver itself, not the software interfaces it supports.
- */
-#ifndef HFI1_DRIVER_VERSION_BASE
-#define HFI1_DRIVER_VERSION_BASE "0.9-294"
-#endif
-
-/* create the final driver version string */
-#ifdef HFI1_IDSTR
-#define HFI1_DRIVER_VERSION HFI1_DRIVER_VERSION_BASE " " HFI1_IDSTR
-#else
-#define HFI1_DRIVER_VERSION HFI1_DRIVER_VERSION_BASE
-#endif
-
-/*
  * Diagnostics can send a packet by writing the following
  * struct to the diag packet special file.
  *
diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
index e2c634a..8e71bef 100644
--- a/drivers/infiniband/hw/hfi1/driver.c
+++ b/drivers/infiniband/hw/hfi1/driver.c
@@ -29,12 +29,6 @@
 #undef pr_fmt
 #define pr_fmt(fmt) DRIVER_NAME ": " fmt
 
-/*
- * The size has to be longer than this string, so we can append
- * board/chip information to it in the initialization code.
- */
-const char ib_hfi1_version[] = HFI1_DRIVER_VERSION "\n";
-
 DEFINE_MUTEX(hfi1_mutex);	/* general driver use */
 
 unsigned int hfi1_max_mtu = HFI1_DEFAULT_MAX_MTU;


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 5/6] RDMA/hfi1: Consolidate software versions
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
                   ` (3 preceding siblings ...)
  2022-05-20 18:37 ` [PATCH for-next 4/6] RDMA/hfi1: Remove pointless driver version Dennis Dalessandro
@ 2022-05-20 18:37 ` Dennis Dalessandro
  2022-05-20 18:37 ` [PATCH for-next 6/6] RDMA/hfi1: Remove all traces of diagpkt support Dennis Dalessandro
  2022-05-24 18:43 ` [PATCH for-next 0/6] Updates for 5.19 Jason Gunthorpe
  6 siblings, 0 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:37 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma

There is no need to have separate user and kernel software versions. There is a
single software that the kernel is compatible with.

Also remove the notion of a "kernel type" that is long since deprecated.

Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/common.h   |   17 -----------------
 drivers/infiniband/hw/hfi1/file_ops.c |    2 +-
 2 files changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/common.h b/drivers/infiniband/hw/hfi1/common.h
index 73a2f13..f32f858 100644
--- a/drivers/infiniband/hw/hfi1/common.h
+++ b/drivers/infiniband/hw/hfi1/common.h
@@ -137,23 +137,6 @@
 #define HFI1_USER_SWVERSION ((HFI1_USER_SWMAJOR << HFI1_SWMAJOR_SHIFT) | \
 			     HFI1_USER_SWMINOR)
 
-#ifndef HFI1_KERN_TYPE
-#define HFI1_KERN_TYPE 0
-#endif
-
-/*
- * Similarly, this is the kernel version going back to the user.  It's
- * slightly different, in that we want to tell if the driver was built as
- * part of a Intel release, or from the driver from openfabrics.org,
- * kernel.org, or a standard distribution, for support reasons.
- * The high bit is 0 for non-Intel and 1 for Intel-built/supplied.
- *
- * It's returned by the driver to the user code during initialization in the
- * spi_sw_version field of hfi1_base_info, so the user code can in turn
- * check for compatibility with the kernel.
-*/
-#define HFI1_KERN_SWVERSION ((HFI1_KERN_TYPE << 31) | HFI1_USER_SWVERSION)
-
 /*
  * Diagnostics can send a packet by writing the following
  * struct to the diag packet special file.
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index cb65f31..231cced 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -1223,7 +1223,7 @@ static int get_base_info(struct hfi1_filedata *fd, unsigned long arg, u32 len)
 
 	memset(&binfo, 0, sizeof(binfo));
 	binfo.hw_version = dd->revision;
-	binfo.sw_version = HFI1_KERN_SWVERSION;
+	binfo.sw_version = HFI1_USER_SWVERSION;
 	binfo.bthqp = RVT_KDETH_QP_PREFIX;
 	binfo.jkey = uctxt->jkey;
 	/*


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH for-next 6/6] RDMA/hfi1: Remove all traces of diagpkt support
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
                   ` (4 preceding siblings ...)
  2022-05-20 18:37 ` [PATCH for-next 5/6] RDMA/hfi1: Consolidate software versions Dennis Dalessandro
@ 2022-05-20 18:37 ` Dennis Dalessandro
  2022-05-24 18:43 ` [PATCH for-next 0/6] Updates for 5.19 Jason Gunthorpe
  6 siblings, 0 replies; 8+ messages in thread
From: Dennis Dalessandro @ 2022-05-20 18:37 UTC (permalink / raw)
  To: leonro, jgg; +Cc: linux-rdma

One of the concessions we made to get our driver upstream was to remove the
diagnostic packet support. There is however still some cruft that was left over.
Remove it.

Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/common.h |   23 -----------------------
 1 file changed, 23 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/common.h b/drivers/infiniband/hw/hfi1/common.h
index f32f858..166ad6b 100644
--- a/drivers/infiniband/hw/hfi1/common.h
+++ b/drivers/infiniband/hw/hfi1/common.h
@@ -138,29 +138,6 @@
 			     HFI1_USER_SWMINOR)
 
 /*
- * Diagnostics can send a packet by writing the following
- * struct to the diag packet special file.
- *
- * This allows a custom PBC qword, so that special modes and deliberate
- * changes to CRCs can be used.
- */
-#define _DIAG_PKT_VERS 1
-struct diag_pkt {
-	__u16 version;		/* structure version */
-	__u16 unit;		/* which device */
-	__u16 sw_index;		/* send sw index to use */
-	__u16 len;		/* data length, in bytes */
-	__u16 port;		/* port number */
-	__u16 unused;
-	__u32 flags;		/* call flags */
-	__u64 data;		/* user data pointer */
-	__u64 pbc;		/* PBC for the packet */
-};
-
-/* diag_pkt flags */
-#define F_DIAGPKT_WAIT 0x1	/* wait until packet is sent */
-
-/*
  * The next set of defines are for packet headers, and chip register
  * and memory bits that are visible to and/or used by user-mode software.
  */


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH for-next 0/6] Updates for 5.19
  2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
                   ` (5 preceding siblings ...)
  2022-05-20 18:37 ` [PATCH for-next 6/6] RDMA/hfi1: Remove all traces of diagpkt support Dennis Dalessandro
@ 2022-05-24 18:43 ` Jason Gunthorpe
  6 siblings, 0 replies; 8+ messages in thread
From: Jason Gunthorpe @ 2022-05-24 18:43 UTC (permalink / raw)
  To: Dennis Dalessandro; +Cc: leonro, linux-rdma

On Fri, May 20, 2022 at 02:36:56PM -0400, Dennis Dalessandro wrote:
> Here are some clean up patches, for the driver mersion that got missed and
> diagpkt removal. Doug has two fixes as well.
> 
> 
> Dennis Dalessandro (4):
>       RDMA/hfi1: Fix potential integer multiplication overflow errors
>       RDMA/hfi1: Remove pointless driver version
>       RDMA/hfi1: Consolidate software versions
>       RDMA/hfi1: Remove all traces of diagpkt support
> 
> Douglas Miller (2):
>       RDMA/hfi1: Prevent use of lock before it is initialized
>       RDMA/hfi1: Prevent panic when SDMA is disabled

Applied to for-next
 
Lets not send patches during the merge window again please

Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-24 18:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 18:36 [PATCH for-next 0/6] Updates for 5.19 Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 1/6] RDMA/hfi1: Prevent use of lock before it is initialized Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 2/6] RDMA/hfi1: Prevent panic when SDMA is disabled Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 3/6] RDMA/hfi1: Fix potential integer multiplication overflow errors Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 4/6] RDMA/hfi1: Remove pointless driver version Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 5/6] RDMA/hfi1: Consolidate software versions Dennis Dalessandro
2022-05-20 18:37 ` [PATCH for-next 6/6] RDMA/hfi1: Remove all traces of diagpkt support Dennis Dalessandro
2022-05-24 18:43 ` [PATCH for-next 0/6] Updates for 5.19 Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.