mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Xiang Lei <leixiang@kylinos.cn>
Cc: Wei Liu <liuwei@kylinos.cn>,
	stable@vger.kernel.org, Laurent Vivier <lvivier@redhat.com>,
	Olivia Mackall <olivia@selenic.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Michael Bommarito <michael.bommarito@gmail.com>,
	virtualization@lists.linux.dev, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwrng: virtio - fix copy_data() handling of partial reads
Date: Fri, 13 Nov 2026 21:10:39 +0800	[thread overview]
Message-ID: <avcMT4v5mo4XT493@gondor.apana.org.au> (raw)
In-Reply-To: <20261105071736.65932-1-leixiang@kylinos.cn>

On Thu, Nov 05, 2026 at 03:17:33PM +0800, Xiang Lei wrote:
> vi->data_avail is decremented on each read, so it holds the remaining
> bytes rather than the total length. Subtracting vi->data_idx from it
> again in commit e3046eeada29 ("hwrng: virtio: clamp device-reported
> used.len at copy_data()") undercounts the bytes left after a partial
> read. This can leave vi->data_avail nonzero without queuing a new
> request, causing virtio_read() to hang on have_data.
> 
> Clamp vi->data_avail to sizeof(vi->data) - vi->data_idx instead.
> 
> Fixes: e3046eeada29 ("hwrng: virtio: clamp device-reported used.len at copy_data()")
> Tested-by: Wei Liu <liuwei@kylinos.cn>
> Cc: stable@vger.kernel.org
> Signed-off-by: Xiang Lei <leixiang@kylinos.cn>
> ---
>  drivers/char/hw_random/virtio-rng.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2026-11-13 13:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  7:17 Xiang Lei
2026-11-13 13:10 ` Herbert Xu [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=avcMT4v5mo4XT493@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=leixiang@kylinos.cn \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuwei@kylinos.cn \
    --cc=lvivier@redhat.com \
    --cc=michael.bommarito@gmail.com \
    --cc=mst@redhat.com \
    --cc=olivia@selenic.com \
    --cc=stable@vger.kernel.org \
    --cc=virtualization@lists.linux.dev \
    /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®