From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Kairui Song <kasong@tencent.com>,
Desheng Wu <deshengwu@tencent.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 6.1 57/83] zram: refuse to use zero sized block device as backing device
Date: Mon, 23 Dec 2024 16:59:36 +0100 [thread overview]
Message-ID: <20241223155355.834709053@linuxfoundation.org> (raw)
In-Reply-To: <20241223155353.641267612@linuxfoundation.org>
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
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) {
next prev parent reply other threads:[~2024-12-23 16:19 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-23 15:58 [PATCH 6.1 00/83] 6.1.122-rc1 review Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 01/83] net: sched: fix ordering of qlen adjustment Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 02/83] PCI/AER: Disable AER service on suspend Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 03/83] PCI: Use preserve_config in place of pci_flags Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 04/83] PCI: vmd: Create domain symlink before pci_bus_add_devices() Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 05/83] usb: cdns3: Add quirk flag to enable suspend residency Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 06/83] ASoC: Intel: sof_sdw: fix jack detection on ADL-N variant RVP Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 07/83] ASoC: Intel: sof_sdw: add quirk for Dell SKU 0B8C Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 08/83] PCI: Add ACS quirk for Broadcom BCM5760X NIC Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 09/83] MIPS: Loongson64: DTS: Fix msi node for ls7a Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 10/83] usb: dwc2: gadget: Dont write invalid mapped sg entries into dma_desc with iommu enabled Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 11/83] PCI: Introduce pci_resource_n() Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 12/83] platform/x86: p2sb: Make p2sb_get_devfn() return void Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 13/83] p2sb: Factor out p2sb_read_from_cache() Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 14/83] p2sb: Introduce the global flag p2sb_hidden_by_bios Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 15/83] p2sb: Move P2SB hide and unhide code to p2sb_scan_and_cache() Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 16/83] p2sb: Do not scan and remove the P2SB device when it is unhidden Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 17/83] i2c: pnx: Fix timeout in wait functions Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 18/83] cxl/region: Fix region creation for greater than x2 switches Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 19/83] net/smc: protect link down work from execute after lgr freed Greg Kroah-Hartman
2024-12-23 15:58 ` [PATCH 6.1 20/83] net/smc: check sndbuf_space again after NOSPACE flag is set in smc_poll Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 21/83] net/smc: check iparea_offset and ipv6_prefixes_cnt when receiving proposal msg Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 22/83] net/smc: check smcd_v2_ext_offset " Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 23/83] net/smc: check return value of sock_recvmsg when draining clc data Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 24/83] net: mscc: ocelot: fix incorrect IFH SRC_PORT field in ocelot_ifh_set_basic() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 25/83] netdevsim: prevent bad user input in nsim_dev_health_break_write() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 26/83] ionic: Fix netdev notifier unregister on failure Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 27/83] ionic: use ee->offset when returning sprom data Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 28/83] net: hinic: Fix cleanup in create_rxqs/txqs() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 29/83] net: ethernet: bgmac-platform: fix an OF node reference leak Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 30/83] netfilter: ipset: Fix for recursive locking warning Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 31/83] net: mdiobus: fix an OF node reference leak Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 32/83] mmc: sdhci-tegra: Remove SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC quirk Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 33/83] KVM: x86: Cache CPUID.0xD XSTATE offsets+sizes during module init Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 34/83] chelsio/chtls: prevent potential integer overflow on 32bit Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 35/83] i2c: riic: Always round-up when calculating bus period Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 36/83] efivarfs: Fix error on non-existent file Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 37/83] hexagon: Disable constant extender optimization for LLVM prior to 19.1.0 Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 38/83] USB: serial: option: add TCL IK512 MBIM & ECM Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 39/83] USB: serial: option: add MeiG Smart SLM770A Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 40/83] USB: serial: option: add Netprisma LCUK54 modules for WWAN Ready Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 41/83] USB: serial: option: add MediaTek T7XX compositions Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 42/83] USB: serial: option: add Telit FE910C04 rmnet compositions Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 43/83] thunderbolt: Improve redrive mode handling Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 44/83] drm/modes: Avoid divide by zero harder in drm_mode_vrefresh() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 45/83] drm/panel: novatek-nt35950: fix return value check in nt35950_probe() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 46/83] i915/guc: Reset engine utilization buffer before registration Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 47/83] i915/guc: Ensure busyness counter increases motonically Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 48/83] i915/guc: Accumulate active runtime on gt reset Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 49/83] drm/amdgpu: dont access invalid sched Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 50/83] hwmon: (tmp513) Dont use "proxy" headers Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 51/83] hwmon: (tmp513) Simplify with dev_err_probe() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 52/83] hwmon: (tmp513) Use SI constants from units.h Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 53/83] hwmon: (tmp513) Fix interpretation of values of Shunt Voltage and Limit Registers Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 54/83] hwmon: (tmp513) Fix Current Register value interpretation Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 55/83] hwmon: (tmp513) Fix interpretation of values of Temperature Result and Limit Registers Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 56/83] sh: clk: Fix clk_enable() to return 0 on NULL clk Greg Kroah-Hartman
2024-12-23 15:59 ` Greg Kroah-Hartman [this message]
2024-12-23 15:59 ` [PATCH 6.1 58/83] zram: fix uninitialized ZRAM not releasing backing device Greg Kroah-Hartman
2025-01-08 3:57 ` Sergey Senozhatsky
2024-12-23 15:59 ` [PATCH 6.1 59/83] btrfs: tree-checker: reject inline extent items with 0 ref count Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 60/83] Drivers: hv: util: Avoid accessing a ringbuffer not initialized yet Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 61/83] KVM: x86: Play nice with protected guests in complete_hypercall_exit() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 62/83] tracing: Fix test_event_printk() to process entire print argument Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 63/83] tracing: Add missing helper functions in event pointer dereference check Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 64/83] tracing: Add "%s" check in test_event_printk() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 65/83] selftests/bpf: Use asm constraint "m" for LoongArch Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 66/83] io_uring: Fix registered ring file refcount leak Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 67/83] io_uring: check if iowq is killed before queuing Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 68/83] NFS/pnfs: Fix a live lock between recalled layouts and layoutget Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 69/83] of/irq: Fix interrupt-map cell length check in of_irq_parse_imap_parent() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 70/83] of/irq: Fix using uninitialized variable @addr_len in API of_irq_parse_one() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 71/83] nilfs2: fix buffer head leaks in calls to truncate_inode_pages() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 72/83] nilfs2: prevent use of deleted inode Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 73/83] udmabuf: also check for F_SEAL_FUTURE_WRITE Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 74/83] of: Fix error path in of_parse_phandle_with_args_map() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 75/83] of: Fix refcount leakage for OF node returned by __of_get_dma_parent() Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 76/83] ceph: validate snapdirname option length when mounting Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 77/83] udf: Fix directory iteration for longer tail extents Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 78/83] epoll: Add synchronous wakeup support for ep_poll_callback Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 79/83] io_uring/rw: split io_read() into a helper Greg Kroah-Hartman
2024-12-23 15:59 ` [PATCH 6.1 80/83] io_uring/rw: treat -EOPNOTSUPP for IOCB_NOWAIT like -EAGAIN Greg Kroah-Hartman
2024-12-23 16:00 ` [PATCH 6.1 81/83] io_uring/rw: avoid punting to io-wq directly Greg Kroah-Hartman
2024-12-23 16:00 ` [PATCH 6.1 82/83] dt-bindings: net: fec: add pps channel property Greg Kroah-Hartman
2024-12-23 16:00 ` [PATCH 6.1 83/83] drm/amdgpu: Handle NULL bo->tbo.resource (again) in amdgpu_vm_bo_update Greg Kroah-Hartman
2024-12-23 21:14 ` [PATCH 6.1 00/83] 6.1.122-rc1 review SeongJae Park
2024-12-23 22:45 ` Shuah Khan
2024-12-24 10:24 ` Peter Schneider
2024-12-24 10:30 ` Ron Economos
2024-12-24 13:26 ` Jon Hunter
2024-12-24 19:49 ` Naresh Kamboju
2024-12-25 1:50 ` Zhao Mengmeng
2024-12-26 10:20 ` Muhammad Usama Anjum
2024-12-26 16:49 ` Florian Fainelli
2024-12-26 19:25 ` [PATCH 6.1] " Hardik Garg
2024-12-26 20:20 ` [PATCH 6.1 00/83] " Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241223155355.834709053@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=deshengwu@tencent.com \
--cc=kasong@tencent.com \
--cc=patches@lists.linux.dev \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox