]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.1-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 1 Aug 2023 08:07:25 +0000 (10:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 1 Aug 2023 08:07:25 +0000 (10:07 +0200)
added patches:
dma-buf-fix-an-error-pointer-vs-null-bug.patch
dma-buf-keep-the-signaling-time-of-merged-fences-v3.patch
test_firmware-return-enomem-instead-of-enospc-on-failed-memory-allocation.patch

queue-6.1/dma-buf-fix-an-error-pointer-vs-null-bug.patch [new file with mode: 0644]
queue-6.1/dma-buf-keep-the-signaling-time-of-merged-fences-v3.patch [new file with mode: 0644]
queue-6.1/series
queue-6.1/test_firmware-return-enomem-instead-of-enospc-on-failed-memory-allocation.patch [new file with mode: 0644]

diff --git a/queue-6.1/dma-buf-fix-an-error-pointer-vs-null-bug.patch b/queue-6.1/dma-buf-fix-an-error-pointer-vs-null-bug.patch
new file mode 100644 (file)
index 0000000..11b89d7
--- /dev/null
@@ -0,0 +1,59 @@
+From 00ae1491f970acc454be0df63f50942d94825860 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@linaro.org>
+Date: Thu, 6 Jul 2023 15:37:51 +0300
+Subject: dma-buf: fix an error pointer vs NULL bug
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Dan Carpenter <dan.carpenter@linaro.org>
+
+commit 00ae1491f970acc454be0df63f50942d94825860 upstream.
+
+Smatch detected potential error pointer dereference.
+
+    drivers/gpu/drm/drm_syncobj.c:888 drm_syncobj_transfer_to_timeline()
+    error: 'fence' dereferencing possible ERR_PTR()
+
+The error pointer comes from dma_fence_allocate_private_stub().  One
+caller expected error pointers and one expected NULL pointers.  Change
+it to return NULL and update the caller which expected error pointers,
+drm_syncobj_assign_null_handle(), to check for NULL instead.
+
+Fixes: f781f661e8c9 ("dma-buf: keep the signaling time of merged fences v3")
+Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
+Reviewed-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>
+Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
+Link: https://patchwork.freedesktop.org/patch/msgid/b09f1996-3838-4fa2-9193-832b68262e43@moroto.mountain
+Cc: Jindong Yue <jindong.yue@nxp.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/dma-buf/dma-fence.c   |    2 +-
+ drivers/gpu/drm/drm_syncobj.c |    4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/dma-buf/dma-fence.c
++++ b/drivers/dma-buf/dma-fence.c
+@@ -160,7 +160,7 @@ struct dma_fence *dma_fence_allocate_pri
+       fence = kzalloc(sizeof(*fence), GFP_KERNEL);
+       if (fence == NULL)
+-              return ERR_PTR(-ENOMEM);
++              return NULL;
+       dma_fence_init(fence,
+                      &dma_fence_stub_ops,
+--- a/drivers/gpu/drm/drm_syncobj.c
++++ b/drivers/gpu/drm/drm_syncobj.c
+@@ -355,8 +355,8 @@ static int drm_syncobj_assign_null_handl
+ {
+       struct dma_fence *fence = dma_fence_allocate_private_stub(ktime_get());
+-      if (IS_ERR(fence))
+-              return PTR_ERR(fence);
++      if (!fence)
++              return -ENOMEM;
+       drm_syncobj_replace_fence(syncobj, fence);
+       dma_fence_put(fence);
diff --git a/queue-6.1/dma-buf-keep-the-signaling-time-of-merged-fences-v3.patch b/queue-6.1/dma-buf-keep-the-signaling-time-of-merged-fences-v3.patch
new file mode 100644 (file)
index 0000000..e8fc8d7
--- /dev/null
@@ -0,0 +1,128 @@
+From f781f661e8c99b0cb34129f2e374234d61864e77 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Tue, 13 Jun 2023 10:09:20 +0200
+Subject: dma-buf: keep the signaling time of merged fences v3
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Christian König <christian.koenig@amd.com>
+
+commit f781f661e8c99b0cb34129f2e374234d61864e77 upstream.
+
+Some Android CTS is testing if the signaling time keeps consistent
+during merges.
+
+v2: use the current time if the fence is still in the signaling path and
+the timestamp not yet available.
+v3: improve comment, fix one more case to use the correct timestamp
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20230630120041.109216-1-christian.koenig@amd.com
+Cc: Jindong Yue <jindong.yue@nxp.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/dma-buf/dma-fence-unwrap.c |   26 ++++++++++++++++++++++----
+ drivers/dma-buf/dma-fence.c        |    5 +++--
+ drivers/gpu/drm/drm_syncobj.c      |    2 +-
+ include/linux/dma-fence.h          |    2 +-
+ 4 files changed, 27 insertions(+), 8 deletions(-)
+
+--- a/drivers/dma-buf/dma-fence-unwrap.c
++++ b/drivers/dma-buf/dma-fence-unwrap.c
+@@ -66,18 +66,36 @@ struct dma_fence *__dma_fence_unwrap_mer
+ {
+       struct dma_fence_array *result;
+       struct dma_fence *tmp, **array;
++      ktime_t timestamp;
+       unsigned int i;
+       size_t count;
+       count = 0;
++      timestamp = ns_to_ktime(0);
+       for (i = 0; i < num_fences; ++i) {
+-              dma_fence_unwrap_for_each(tmp, &iter[i], fences[i])
+-                      if (!dma_fence_is_signaled(tmp))
++              dma_fence_unwrap_for_each(tmp, &iter[i], fences[i]) {
++                      if (!dma_fence_is_signaled(tmp)) {
+                               ++count;
++                      } else if (test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT,
++                                          &tmp->flags)) {
++                              if (ktime_after(tmp->timestamp, timestamp))
++                                      timestamp = tmp->timestamp;
++                      } else {
++                              /*
++                               * Use the current time if the fence is
++                               * currently signaling.
++                               */
++                              timestamp = ktime_get();
++                      }
++              }
+       }
++      /*
++       * If we couldn't find a pending fence just return a private signaled
++       * fence with the timestamp of the last signaled one.
++       */
+       if (count == 0)
+-              return dma_fence_get_stub();
++              return dma_fence_allocate_private_stub(timestamp);
+       array = kmalloc_array(count, sizeof(*array), GFP_KERNEL);
+       if (!array)
+@@ -138,7 +156,7 @@ restart:
+       } while (tmp);
+       if (count == 0) {
+-              tmp = dma_fence_get_stub();
++              tmp = dma_fence_allocate_private_stub(ktime_get());
+               goto return_tmp;
+       }
+--- a/drivers/dma-buf/dma-fence.c
++++ b/drivers/dma-buf/dma-fence.c
+@@ -150,10 +150,11 @@ EXPORT_SYMBOL(dma_fence_get_stub);
+ /**
+  * dma_fence_allocate_private_stub - return a private, signaled fence
++ * @timestamp: timestamp when the fence was signaled
+  *
+  * Return a newly allocated and signaled stub fence.
+  */
+-struct dma_fence *dma_fence_allocate_private_stub(void)
++struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp)
+ {
+       struct dma_fence *fence;
+@@ -169,7 +170,7 @@ struct dma_fence *dma_fence_allocate_pri
+       set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+               &fence->flags);
+-      dma_fence_signal(fence);
++      dma_fence_signal_timestamp(fence, timestamp);
+       return fence;
+ }
+--- a/drivers/gpu/drm/drm_syncobj.c
++++ b/drivers/gpu/drm/drm_syncobj.c
+@@ -353,7 +353,7 @@ EXPORT_SYMBOL(drm_syncobj_replace_fence)
+  */
+ static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
+ {
+-      struct dma_fence *fence = dma_fence_allocate_private_stub();
++      struct dma_fence *fence = dma_fence_allocate_private_stub(ktime_get());
+       if (IS_ERR(fence))
+               return PTR_ERR(fence);
+--- a/include/linux/dma-fence.h
++++ b/include/linux/dma-fence.h
+@@ -584,7 +584,7 @@ static inline signed long dma_fence_wait
+ }
+ struct dma_fence *dma_fence_get_stub(void);
+-struct dma_fence *dma_fence_allocate_private_stub(void);
++struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp);
+ u64 dma_fence_context_alloc(unsigned num);
+ extern const struct dma_fence_ops dma_fence_array_ops;
index 8353f33f3d3afeea8b0e5cfc1a6b05c6714d677b..1391d2992efb084756ffdd8bfe0d3074b4519be1 100644 (file)
@@ -223,3 +223,6 @@ acpi-processor-perflib-avoid-updating-frequency-qos-unnecessarily.patch
 cpufreq-intel_pstate-drop-acpi-_pss-states-table-patching.patch
 mptcp-ensure-subflow-is-unhashed-before-cleaning-the-backlog.patch
 selftests-mptcp-sockopt-use-iptables-legacy-if-available.patch
+test_firmware-return-enomem-instead-of-enospc-on-failed-memory-allocation.patch
+dma-buf-keep-the-signaling-time-of-merged-fences-v3.patch
+dma-buf-fix-an-error-pointer-vs-null-bug.patch
diff --git a/queue-6.1/test_firmware-return-enomem-instead-of-enospc-on-failed-memory-allocation.patch b/queue-6.1/test_firmware-return-enomem-instead-of-enospc-on-failed-memory-allocation.patch
new file mode 100644 (file)
index 0000000..51943c3
--- /dev/null
@@ -0,0 +1,104 @@
+From 7dae593cd226a0bca61201cf85ceb9335cf63682 Mon Sep 17 00:00:00 2001
+From: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
+Date: Tue, 6 Jun 2023 09:08:10 +0200
+Subject: test_firmware: return ENOMEM instead of ENOSPC on failed memory allocation
+
+From: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
+
+commit 7dae593cd226a0bca61201cf85ceb9335cf63682 upstream.
+
+In a couple of situations like
+
+       name = kstrndup(buf, count, GFP_KERNEL);
+       if (!name)
+               return -ENOSPC;
+
+the error is not actually "No space left on device", but "Out of memory".
+
+It is semantically correct to return -ENOMEM in all failed kstrndup()
+and kzalloc() cases in this driver, as it is not a problem with disk
+space, but with kernel memory allocator failing allocation.
+
+The semantically correct should be:
+
+        name = kstrndup(buf, count, GFP_KERNEL);
+        if (!name)
+                return -ENOMEM;
+
+Cc: Dan Carpenter <error27@gmail.com>
+Cc: Takashi Iwai <tiwai@suse.de>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: "Luis R. Rodriguez" <mcgrof@ruslug.rutgers.edu>
+Cc: Scott Branden <sbranden@broadcom.com>
+Cc: Hans de Goede <hdegoede@redhat.com>
+Cc: Brian Norris <briannorris@chromium.org>
+Fixes: c92316bf8e948 ("test_firmware: add batched firmware tests")
+Fixes: 0a8adf584759c ("test: add firmware_class loader test")
+Fixes: 548193cba2a7d ("test_firmware: add support for firmware_request_platform")
+Fixes: eb910947c82f9 ("test: firmware_class: add asynchronous request trigger")
+Fixes: 061132d2b9c95 ("test_firmware: add test custom fallback trigger")
+Fixes: 7feebfa487b92 ("test_firmware: add support for request_firmware_into_buf")
+Signed-off-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
+Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
+Message-ID: <20230606070808.9300-1-mirsad.todorovac@alu.unizg.hr>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ lib/test_firmware.c |   12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- a/lib/test_firmware.c
++++ b/lib/test_firmware.c
+@@ -214,7 +214,7 @@ static int __kstrncpy(char **dst, const
+ {
+       *dst = kstrndup(name, count, gfp);
+       if (!*dst)
+-              return -ENOSPC;
++              return -ENOMEM;
+       return count;
+ }
+@@ -671,7 +671,7 @@ static ssize_t trigger_request_store(str
+       name = kstrndup(buf, count, GFP_KERNEL);
+       if (!name)
+-              return -ENOSPC;
++              return -ENOMEM;
+       pr_info("loading '%s'\n", name);
+@@ -719,7 +719,7 @@ static ssize_t trigger_request_platform_
+       name = kstrndup(buf, count, GFP_KERNEL);
+       if (!name)
+-              return -ENOSPC;
++              return -ENOMEM;
+       pr_info("inserting test platform fw '%s'\n", name);
+       efi_embedded_fw.name = name;
+@@ -772,7 +772,7 @@ static ssize_t trigger_async_request_sto
+       name = kstrndup(buf, count, GFP_KERNEL);
+       if (!name)
+-              return -ENOSPC;
++              return -ENOMEM;
+       pr_info("loading '%s'\n", name);
+@@ -817,7 +817,7 @@ static ssize_t trigger_custom_fallback_s
+       name = kstrndup(buf, count, GFP_KERNEL);
+       if (!name)
+-              return -ENOSPC;
++              return -ENOMEM;
+       pr_info("loading '%s' using custom fallback mechanism\n", name);
+@@ -868,7 +868,7 @@ static int test_fw_run_batch_request(voi
+               test_buf = kzalloc(TEST_FIRMWARE_BUF_SIZE, GFP_KERNEL);
+               if (!test_buf)
+-                      return -ENOSPC;
++                      return -ENOMEM;
+               if (test_fw_config->partial)
+                       req->rc = request_partial_firmware_into_buf