]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Mar 2023 07:29:01 +0000 (08:29 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Mar 2023 07:29:01 +0000 (08:29 +0100)
added patches:
qede-avoid-uninitialized-entries-in-coal_entry-array.patch

queue-5.15/qede-avoid-uninitialized-entries-in-coal_entry-array.patch [new file with mode: 0644]
queue-5.15/series

diff --git a/queue-5.15/qede-avoid-uninitialized-entries-in-coal_entry-array.patch b/queue-5.15/qede-avoid-uninitialized-entries-in-coal_entry-array.patch
new file mode 100644 (file)
index 0000000..06e2dc3
--- /dev/null
@@ -0,0 +1,77 @@
+From aaa3c08ee0653beaa649d4adfb27ad562641cfd8 Mon Sep 17 00:00:00 2001
+From: Michal Schmidt <mschmidt@redhat.com>
+Date: Fri, 24 Feb 2023 01:41:45 +0100
+Subject: qede: avoid uninitialized entries in coal_entry array
+
+From: Michal Schmidt <mschmidt@redhat.com>
+
+commit aaa3c08ee0653beaa649d4adfb27ad562641cfd8 upstream.
+
+Even after commit 908d4bb7c54c ("qede: fix interrupt coalescing
+configuration"), some entries of the coal_entry array may theoretically
+be used uninitialized:
+
+ 1. qede_alloc_fp_array() allocates QEDE_MAX_RSS_CNT entries for
+    coal_entry. The initial allocation uses kcalloc, so everything is
+    initialized.
+ 2. The user sets a small number of queues (ethtool -L).
+    coal_entry is reallocated for the actual small number of queues.
+ 3. The user sets a bigger number of queues.
+    coal_entry is reallocated bigger. The added entries are not
+    necessarily initialized.
+
+In practice, the reallocations will actually keep using the originally
+allocated region of memory, but we should not rely on it.
+
+The reallocation is unnecessary. coal_entry can always have
+QEDE_MAX_RSS_CNT entries.
+
+Fixes: 908d4bb7c54c ("qede: fix interrupt coalescing configuration")
+Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
+Nacked-by: Manish Chopra <manishc@marvell.com>
+Acked-by: Manish Chopra <manishc@marvell.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/qlogic/qede/qede_main.c |   21 +++++++--------------
+ 1 file changed, 7 insertions(+), 14 deletions(-)
+
+--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
++++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
+@@ -899,7 +899,6 @@ static int qede_alloc_fp_array(struct qe
+ {
+       u8 fp_combined, fp_rx = edev->fp_num_rx;
+       struct qede_fastpath *fp;
+-      void *mem;
+       int i;
+       edev->fp_array = kcalloc(QEDE_QUEUE_CNT(edev),
+@@ -910,21 +909,15 @@ static int qede_alloc_fp_array(struct qe
+       }
+       if (!edev->coal_entry) {
+-              mem = kcalloc(QEDE_MAX_RSS_CNT(edev),
+-                            sizeof(*edev->coal_entry), GFP_KERNEL);
+-      } else {
+-              mem = krealloc(edev->coal_entry,
+-                             QEDE_QUEUE_CNT(edev) * sizeof(*edev->coal_entry),
+-                             GFP_KERNEL);
++              edev->coal_entry = kcalloc(QEDE_MAX_RSS_CNT(edev),
++                                         sizeof(*edev->coal_entry),
++                                         GFP_KERNEL);
++              if (!edev->coal_entry) {
++                      DP_ERR(edev, "coalesce entry allocation failed\n");
++                      goto err;
++              }
+       }
+-      if (!mem) {
+-              DP_ERR(edev, "coalesce entry allocation failed\n");
+-              kfree(edev->coal_entry);
+-              goto err;
+-      }
+-      edev->coal_entry = mem;
+-
+       fp_combined = QEDE_QUEUE_CNT(edev) - fp_rx - edev->fp_num_tx;
+       /* Allocate the FP elements for Rx queues followed by combined and then
index 78ac770dde7d2bb0e2af37a90cfb4a3824b17ad5..9794c7cfc6dd484d73826cdfb238c27d79db167f 100644 (file)
@@ -564,3 +564,4 @@ drm-radeon-fix-edp-for-single-display-imac11-2.patch
 drm-i915-don-t-use-bar-mappings-for-ring-buffers-with-llc.patch
 drm-edid-fix-avi-infoframe-aspect-ratio-handling.patch
 perf-intel-pt-pkt-decoder-add-cfe-and-evd-packets.patch
+qede-avoid-uninitialized-entries-in-coal_entry-array.patch