From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Pooyan Azadparvar <pooyan.azadparvar@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>, Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: zram: block_state returns premature EOF with short read buffers
Date: Tue, 29 Sep 2026 13:28:37 +0900 [thread overview]
Message-ID: <ars-NNUnD1dc-CTR@google.com> (raw)
In-Reply-To: <ars5x7UjjU10KOjE@google.com>
On (26/09/29 13:13), Sergey Senozhatsky wrote:
> > However, reading the same file with a one-byte buffer returns zero
> > bytes:
> >
> > # python3 - <<'PY'
> > import os
> >
> > path = "/sys/kernel/debug/zram/zram0/block_state"
> > fd = os.open(path, os.O_RDONLY)
> >
> > try:
> > for attempt in range(3):
> > data = os.read(fd, 1)
> > offset = os.lseek(fd, 0, os.SEEK_CUR)
> > print(
> > f"read {attempt}: bytes={len(data)}, "
> > f"data={data!r}, offset={offset}"
> > )
> > finally:
> > os.close(fd)
> > PY
> >
> > read 0: bytes=0, data=b'', offset=0
> > read 1: bytes=0, data=b'', offset=0
> > read 2: bytes=0, data=b'', offset=0
> >
> > The file contains a valid record, but the short-buffer reads return zero
> > bytes repeatedly and the file position remains unchanged.
> >
> > This does not appear to be a memory-safety or security issue. The
> > observed impact is that userspace readers using a short buffer receive
> > zero bytes and cannot make progress through this debugfs file.
> >
> > Could you please confirm whether this short-read behavior is expected
> > for block_state?
>
> I don't think I tend to see this as a problem. Why would anyone do
> a 1-byte (or any other tiny buffer) read in a loop? block_state holds
> a lot of data, just pass a huge buffer maybe?
If we can find a real-world library/tool (rust, go, etc.) that does those
short reads then I guess we might want to fix this.
prev parent reply other threads:[~2026-09-29 4:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 16:27 Pooyan Azadparvar
2026-09-28 16:48 ` [PATCH] zram: fix short reads from block_state Pooyan Azad
2026-09-29 4:52 ` Sergey Senozhatsky
2026-09-29 7:18 ` [PATCH v2] " Pooyan Azad
2026-09-29 8:36 ` Sergey Senozhatsky
2026-09-29 4:13 ` zram: block_state returns premature EOF with short read buffers Sergey Senozhatsky
2026-09-29 4:28 ` Sergey Senozhatsky [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=ars-NNUnD1dc-CTR@google.com \
--to=senozhatsky@chromium.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=pooyan.azadparvar@gmail.com \
/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
all inboxes | Powered by JetHome®