linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org
Subject: Re: [PATCH 15/16] zram: fix synchronous reads
Date: Thu, 6 Apr 2023 17:23:51 -0700	[thread overview]
Message-ID: <ZC9il6lWSKEZxDUr@google.com> (raw)
In-Reply-To: <20230406155810.abc9a2b5c72f43f03a5d5800@linux-foundation.org>

On Thu, Apr 06, 2023 at 03:58:10PM -0700, Andrew Morton wrote:
> On Thu, 6 Apr 2023 15:05:22 -0700 Minchan Kim <minchan@kernel.org> wrote:
> 
> > On Thu, Apr 06, 2023 at 04:41:01PM +0200, Christoph Hellwig wrote:
> > > Currently nothing waits for the synchronous reads before accessing
> > > the data.  Switch them to an on-stack bio and submit_bio_wait to
> > > make sure the I/O has actually completed when the work item has been
> > > flushed.  This also removes the call to page_endio that would unlock
> > > a page that has never been locked.
> > > 
> > > Drop the partial_io/sync flag, as chaining only makes sense for the
> > > asynchronous reads of the entire page.
> > > 
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > > Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> > Acked-by: Minchan Kim <minchan@kernel.org>
> > 
> > So this fixes zram_rw_page + CONFIG_ZRAM_WRITEBACK feature on
> > ppc some arch where PAGE_SIZE is not 4K.
> > 
> > IIRC, we didn't have any report since the writeback feature was
> > introduced. Then, we may skip having the fix into stable?
> 
> Someone may develop such a use case in the future.  And backporting
> this fix will be difficult, unless people backport all the other
> patches, which is also difficult.

I think the simple fix is just bail out for partial IO case from
rw_page path so that bio comes next to serve the rw_page failure.
In the case, zram will always do chained bio so we are fine with
asynchronous IO.

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index b8549c61ff2c..23fa0e03cdc1 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1264,6 +1264,8 @@ static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index,
                struct bio_vec bvec;

                zram_slot_unlock(zram, index);
+               if (partial_io)
+                       return -EAGAIN;

                bvec.bv_page = page;
                bvec.bv_len = PAGE_SIZE;

> 
> What are the user-visible effects of this bug?  It sounds like it will
> give userspace access to unintialized kernel memory, which isn't good.

It's true.

Without better suggestion or objections, I could cook the stable patch.

  reply	other threads:[~2023-04-07  0:23 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06 14:40 zram I/O path cleanups and fixups v2 Christoph Hellwig
2023-04-06 14:40 ` [PATCH 01/16] zram: remove valid_io_request Christoph Hellwig
2023-04-06 21:10   ` Minchan Kim
2023-04-07  1:04     ` Sergey Senozhatsky
2023-04-07  1:14       ` Minchan Kim
2023-04-06 14:40 ` [PATCH 02/16] zram: make zram_bio_discard more self-contained Christoph Hellwig
2023-04-06 21:10   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 03/16] zram: simplify bvec iteration in __zram_make_request Christoph Hellwig
2023-04-06 21:12   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 04/16] zram: move discard handling to zram_submit_bio Christoph Hellwig
2023-04-06 21:12   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 05/16] zram: return early on error in zram_bvec_rw Christoph Hellwig
2023-04-06 21:13   ` Minchan Kim
2023-04-07  1:01   ` Sergey Senozhatsky
2023-04-06 14:40 ` [PATCH 06/16] zram: refactor highlevel read and write handling Christoph Hellwig
2023-04-06 21:15   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 07/16] zram: don't use highmem for the bounce buffer in zram_bvec_{read,write} Christoph Hellwig
2023-04-06 21:16   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 08/16] zram: rename __zram_bvec_read to zram_read_page Christoph Hellwig
2023-04-06 21:17   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 09/16] zram: directly call zram_read_page in writeback_store Christoph Hellwig
2023-04-06 21:19   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 10/16] zram: refactor zram_bdev_read Christoph Hellwig
2023-04-06 21:20   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 11/16] zram: don't pass a bvec to __zram_bvec_write Christoph Hellwig
2023-04-06 21:22   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 12/16] zram: refactor zram_bdev_write Christoph Hellwig
2023-04-06 21:22   ` Minchan Kim
2023-04-06 14:40 ` [PATCH 13/16] zram: pass a page to read_from_bdev Christoph Hellwig
2023-04-06 21:23   ` Minchan Kim
2023-04-06 14:41 ` [PATCH 14/16] zram: don't return errors from read_from_bdev_async Christoph Hellwig
2023-04-06 21:24   ` Minchan Kim
2023-04-06 14:41 ` [PATCH 15/16] zram: fix synchronous reads Christoph Hellwig
2023-04-06 22:05   ` Minchan Kim
2023-04-06 22:58     ` Andrew Morton
2023-04-07  0:23       ` Minchan Kim [this message]
2023-04-07  0:37         ` Andrew Morton
2023-04-07  4:37         ` Christoph Hellwig
2023-04-07 22:37           ` Minchan Kim
2023-04-07  4:33     ` Christoph Hellwig
2023-04-07  7:22   ` Christoph Hellwig
2023-04-06 14:41 ` [PATCH 16/16] zram: return errors from read_from_bdev_sync Christoph Hellwig
2023-04-06 22:05   ` Minchan Kim
2023-04-06 22:06 ` zram I/O path cleanups and fixups v2 Minchan Kim
  -- strict thread matches above, loose matches on Subject: below --
2023-04-04 15:05 zram I/O path cleanups and fixups Christoph Hellwig
2023-04-04 15:05 ` [PATCH 15/16] zram: fix synchronous reads Christoph Hellwig
2023-04-06  6:41   ` Sergey Senozhatsky

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=ZC9il6lWSKEZxDUr@google.com \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=senozhatsky@chromium.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;
as well as URLs for NNTP newsgroup(s).