]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.1-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Dec 2024 10:24:43 +0000 (11:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Dec 2024 10:24:43 +0000 (11:24 +0100)
added patches:
sh-clk-fix-clk_enable-to-return-0-on-null-clk.patch
zram-fix-uninitialized-zram-not-releasing-backing-device.patch
zram-refuse-to-use-zero-sized-block-device-as-backing-device.patch

queue-6.1/series
queue-6.1/sh-clk-fix-clk_enable-to-return-0-on-null-clk.patch [new file with mode: 0644]
queue-6.1/zram-fix-uninitialized-zram-not-releasing-backing-device.patch [new file with mode: 0644]
queue-6.1/zram-refuse-to-use-zero-sized-block-device-as-backing-device.patch [new file with mode: 0644]

index 415ad0b0f5cd528bcbb0cb0da461fde88943931a..550243506b5a4d9cac6ddc8b3003bbf43503fe6c 100644 (file)
@@ -53,3 +53,6 @@ hwmon-tmp513-use-si-constants-from-units.h.patch
 hwmon-tmp513-fix-interpretation-of-values-of-shunt-v.patch
 hwmon-tmp513-fix-current-register-value-interpretati.patch
 hwmon-tmp513-fix-interpretation-of-values-of-tempera.patch
+sh-clk-fix-clk_enable-to-return-0-on-null-clk.patch
+zram-refuse-to-use-zero-sized-block-device-as-backing-device.patch
+zram-fix-uninitialized-zram-not-releasing-backing-device.patch
diff --git a/queue-6.1/sh-clk-fix-clk_enable-to-return-0-on-null-clk.patch b/queue-6.1/sh-clk-fix-clk_enable-to-return-0-on-null-clk.patch
new file mode 100644 (file)
index 0000000..c380fd0
--- /dev/null
@@ -0,0 +1,40 @@
+From ff30bd6a6618e979b16977617371c0f28a95036e Mon Sep 17 00:00:00 2001
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+Date: Thu, 2 Feb 2023 17:20:55 +0100
+Subject: sh: clk: Fix clk_enable() to return 0 on NULL clk
+
+From: Geert Uytterhoeven <geert+renesas@glider.be>
+
+commit ff30bd6a6618e979b16977617371c0f28a95036e upstream.
+
+On SH, devm_clk_get_optional_enabled() fails with -EINVAL if the clock
+is not found.  This happens because __devm_clk_get() assumes it can pass
+a NULL clock pointer (as returned by clk_get_optional()) to the init()
+function (clk_prepare_enable() in this case), while the SH
+implementation of clk_enable() considers that an error.
+
+Fix this by making the SH clk_enable() implementation return zero
+instead, like the Common Clock Framework does.
+
+Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+Acked-by: Stephen Boyd <sboyd@kernel.org>
+Link: https://lore.kernel.org/r/b53e6b557b4240579933b3359dda335ff94ed5af.1675354849.git.geert+renesas@glider.be
+Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/sh/clk/core.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/sh/clk/core.c
++++ b/drivers/sh/clk/core.c
+@@ -295,7 +295,7 @@ int clk_enable(struct clk *clk)
+       int ret;
+       if (!clk)
+-              return -EINVAL;
++              return 0;
+       spin_lock_irqsave(&clock_lock, flags);
+       ret = __clk_enable(clk);
diff --git a/queue-6.1/zram-fix-uninitialized-zram-not-releasing-backing-device.patch b/queue-6.1/zram-fix-uninitialized-zram-not-releasing-backing-device.patch
new file mode 100644 (file)
index 0000000..3cabd3a
--- /dev/null
@@ -0,0 +1,60 @@
+From 74363ec674cb172d8856de25776c8f3103f05e2f Mon Sep 17 00:00:00 2001
+From: Kairui Song <kasong@tencent.com>
+Date: Tue, 10 Dec 2024 00:57:16 +0800
+Subject: zram: fix uninitialized ZRAM not releasing backing device
+
+From: Kairui Song <kasong@tencent.com>
+
+commit 74363ec674cb172d8856de25776c8f3103f05e2f upstream.
+
+Setting backing device is done before ZRAM initialization.  If we set the
+backing device, then remove the ZRAM module without initializing the
+device, the backing device reference will be leaked and the device will be
+hold forever.
+
+Fix this by always reset the ZRAM fully on rmmod or reset store.
+
+Link: https://lkml.kernel.org/r/20241209165717.94215-3-ryncsn@gmail.com
+Fixes: 013bf95a83ec ("zram: add interface to specif backing device")
+Signed-off-by: Kairui Song <kasong@tencent.com>
+Reported-by: Desheng Wu <deshengwu@tencent.com>
+Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
+Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/block/zram/zram_drv.c |    9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+--- a/drivers/block/zram/zram_drv.c
++++ b/drivers/block/zram/zram_drv.c
+@@ -1168,12 +1168,16 @@ static void zram_meta_free(struct zram *
+       size_t num_pages = disksize >> PAGE_SHIFT;
+       size_t index;
++      if (!zram->table)
++              return;
++
+       /* Free all pages that are still in this zram device */
+       for (index = 0; index < num_pages; index++)
+               zram_free_page(zram, index);
+       zs_destroy_pool(zram->mem_pool);
+       vfree(zram->table);
++      zram->table = NULL;
+ }
+ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
+@@ -1722,11 +1726,6 @@ static void zram_reset_device(struct zra
+       zram->limit_pages = 0;
+-      if (!init_done(zram)) {
+-              up_write(&zram->init_lock);
+-              return;
+-      }
+-
+       set_capacity_and_notify(zram->disk, 0);
+       part_stat_set_all(zram->disk->part0, 0);
diff --git a/queue-6.1/zram-refuse-to-use-zero-sized-block-device-as-backing-device.patch b/queue-6.1/zram-refuse-to-use-zero-sized-block-device-as-backing-device.patch
new file mode 100644 (file)
index 0000000..77cceff
--- /dev/null
@@ -0,0 +1,61 @@
+From be48c412f6ebf38849213c19547bc6d5b692b5e5 Mon Sep 17 00:00:00 2001
+From: Kairui Song <kasong@tencent.com>
+Date: Tue, 10 Dec 2024 00:57:15 +0800
+Subject: zram: refuse to use zero sized block device as backing device
+
+From: Kairui Song <kasong@tencent.com>
+
+commit be48c412f6ebf38849213c19547bc6d5b692b5e5 upstream.
+
+Patch series "zram: fix backing device setup issue", v2.
+
+This series fixes two bugs of backing device setting:
+
+- ZRAM should reject using a zero sized (or the uninitialized ZRAM
+  device itself) as the backing device.
+- Fix backing device leaking when removing a uninitialized ZRAM
+  device.
+
+
+This patch (of 2):
+
+Setting a zero sized block device as backing device is pointless, and one
+can easily create a recursive loop by setting the uninitialized ZRAM
+device itself as its own backing device by (zram0 is uninitialized):
+
+    echo /dev/zram0 > /sys/block/zram0/backing_dev
+
+It's definitely a wrong config, and the module will pin itself, kernel
+should refuse doing so in the first place.
+
+By refusing to use zero sized device we avoided misuse cases including
+this one above.
+
+Link: https://lkml.kernel.org/r/20241209165717.94215-1-ryncsn@gmail.com
+Link: https://lkml.kernel.org/r/20241209165717.94215-2-ryncsn@gmail.com
+Fixes: 013bf95a83ec ("zram: add interface to specif backing device")
+Signed-off-by: Kairui Song <kasong@tencent.com>
+Reported-by: Desheng Wu <deshengwu@tencent.com>
+Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/block/zram/zram_drv.c |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/block/zram/zram_drv.c
++++ b/drivers/block/zram/zram_drv.c
+@@ -530,6 +530,12 @@ static ssize_t backing_dev_store(struct
+       }
+       nr_pages = i_size_read(inode) >> PAGE_SHIFT;
++      /* Refuse to use zero sized device (also prevents self reference) */
++      if (!nr_pages) {
++              err = -EINVAL;
++              goto out;
++      }
++
+       bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long);
+       bitmap = kvzalloc(bitmap_sz, GFP_KERNEL);
+       if (!bitmap) {