All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Pooyan Azadparvar <pooyan.azadparvar@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>,
	 Sergey Senozhatsky <senozhatsky@chromium.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-kernel@vger.kernel.org,  linux-block@vger.kernel.org
Subject: Re: zram: block_state returns premature EOF with short read buffers
Date: Tue, 29 Sep 2026 13:13:08 +0900	[thread overview]
Message-ID: <ars5x7UjjU10KOjE@google.com> (raw)
In-Reply-To: <CANC3H+LdtoydSp+o2ecErAw7k6R2+gRf9LyxcaoHv_mGhJmyQQ@mail.gmail.com>


Sorry for the delay in response, your email somehow fell through
the cracks.

On (26/09/20 18:27), Pooyan Azadparvar 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?

  parent reply	other threads:[~2026-09-29  4:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 16:27 zram: block_state returns premature EOF with short read buffers 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 ` Sergey Senozhatsky [this message]
2026-09-29  4:28   ` zram: block_state returns premature EOF with short read buffers 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=ars5x7UjjU10KOjE@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.