Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "wang wei" <a929244872@163.com>
To: "Minchan Kim" <minchan@kernel.org>
Cc: richardycc@google.com, akpm@linux-foundation.org,
	axboe@kernel.dk, bgeffon@google.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	liumartin@google.com, senozhatsky@chromium.org,
	stable@vger.kernel.org
Subject: Re:Re: [PATCH] Re:[PATCH v3] zram: fix use-after-free in zram_writeback_endio
Date: Fri, 15 May 2026 16:23:42 +0800 (CST)	[thread overview]
Message-ID: <3e3db45e.7227.19e2abbf91f.Coremail.a929244872@163.com> (raw)
In-Reply-To: <agZGfRoVRPKW3LEU@google.com>

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

At 2026-05-15 06:02:37, "Minchan Kim" <minchan@kernel.org> wrote:
>On Wed, May 13, 2026 at 10:02:18PM +0800, wang wei wrote:
>> >@@ -847,7 +849,7 @@ static void release_wb_ctl(struct zram_wb_ctl *wb_ctl)
>> > 		release_wb_req(req);
>> > 	}
>> >
>> >-	kfree(wb_ctl);
>> >+	kfree_rcu(wb_ctl, rcu);
>> > }
>> 
>> Do we need to add a 'rcu_assign_pointer(wb_ctl, NULL);' before 'kfree_rcu(wb_ctl, rcu)'?
>> 
>> Signed-off-by: wang wei <a929244872@163.com>
>
>Why do we need it?
>
>My understanding is rcu_assign_pointer() is typically used to publish NULL to
>a shared pointer variable so that future RCU readers (using rcu_dereference)
>won't access the object before kfree_rcu().

That's exactly what I'm worried is that some process might access wb_ctl before kfree_rct().


>However, in our case, wb_ctl is not stored in any shared pointer variable.
>It is a local variable in writeback_store() and RCU readers (zram_writeback_endio)
>do not look up wb_ctl from a shared pointer. They obtain it directly from
>bio->bi_private of the specific bio they are completing.

Thank you for the lessones; I realize my worries were unnecessary.


>Please let me know if I missed anything.

[-- Attachment #2: Type: text/html, Size: 1538 bytes --]

      reply	other threads:[~2026-05-15  8:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-04 12:32 [PATCH] zram: fix use-after-free in zram_writeback_endio Richard Chang
2026-05-05  3:25 ` Sergey Senozhatsky
2026-05-05 16:37 ` Minchan Kim
2026-05-07  9:40   ` Sergey Senozhatsky
2026-05-07 22:56     ` Minchan Kim
2026-05-07 23:38       ` Minchan Kim
2026-05-08  2:40       ` Sergey Senozhatsky
2026-05-08  8:49         ` [PATCH v2] " Richard Chang
2026-05-08 21:16           ` Minchan Kim
2026-05-09  2:18           ` Sergey Senozhatsky
2026-05-12  7:49             ` [PATCH v3] " Richard Chang
2026-05-13 14:02               ` [PATCH] " wang wei
2026-05-14 22:02                 ` Minchan Kim
2026-05-15  8:23                   ` wang wei [this message]

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=3e3db45e.7227.19e2abbf91f.Coremail.a929244872@163.com \
    --to=a929244872@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bgeffon@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liumartin@google.com \
    --cc=minchan@kernel.org \
    --cc=richardycc@google.com \
    --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