lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADyq12xmCgX1_KA+bKt=r=MWRKSX6N3bsuxBn4LRy7M1K9=1mg@mail.gmail.com>
Date: Thu, 20 Nov 2025 13:13:27 -0500
From: Brian Geffon <bgeffon@...gle.com>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Minchan Kim <minchan@...nel.org>, 
	Yuwen Chen <ywen.chen@...mail.com>, Richard Chang <richardycc@...gle.com>, 
	Fengyu Lian <licayy@...look.com>, linux-kernel@...r.kernel.org, linux-mm@...ck.org, 
	linux-block@...r.kernel.org
Subject: Re: [RFC PATCHv5 6/6] zram: read slot block idx under slot lock

On Thu, Nov 20, 2025 at 10:22 AM Sergey Senozhatsky
<senozhatsky@...omium.org> wrote:
>
> Read slot's block id under slot-lock.  We release the
> slot-lock for bdev read so, technically, slot still can
> get freed in the meantime, but at least we will read
> bdev block (page) that holds previous know slot data,
> not from slot->handle bdev block, which can be anything
> at that point.
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
> ---
>  drivers/block/zram/zram_drv.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index ecbd9b25dfed..1f2867cd587e 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -1994,14 +1994,14 @@ static int zram_read_page(struct zram *zram, struct page *page, u32 index,
>                 ret = zram_read_from_zspool(zram, page, index);
>                 zram_slot_unlock(zram, index);
>         } else {
> +               unsigned long blk_idx = zram_get_handle(zram, index);
> +
>                 /*
>                  * The slot should be unlocked before reading from the backing
>                  * device.
>                  */
>                 zram_slot_unlock(zram, index);
> -
> -               ret = read_from_bdev(zram, page, zram_get_handle(zram, index),
> -                                    parent);
> +               ret = read_from_bdev(zram, page, blk_idx, parent);

This patch doesn't really change things in a meaningful way, wouldn't
it be more correct to take the slot lock again after the read and
confirm the handle is the same and it's still ZRAM_WB?

>         }
>
>         /* Should NEVER happen. Return bio error if it does. */
> --
> 2.52.0.rc1.455.g30608eb744-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ