Linux-Next discussions
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	Linux Crypto List <linux-crypto@vger.kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Thorsten Blum <blum@kernel.org>
Subject: linux-next: manual merge of the crypto tree with the origin tree
Date: Mon, 16 Nov 2026 16:43:47 +0000	[thread overview]
Message-ID: <avsyw-Q9dfMw45zX@sirena.org.uk> (raw)

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

Hi all,

Today's linux-next merge of the crypto tree got a conflict in:

  drivers/char/hw_random/virtio-rng.c

between commit:

  0f7bf47f5a0cc ("hwrng: virtio - prevent use-after-free after a failed restore")

from the origin tree and commits:

  a3eaee98eecc4 ("hwrng: virtio - prevent use-after-free after a failed restore")
  277b0dae660c3 ("hwrng: virtio - simplify probe_common()")

from the crypto tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --combined drivers/char/hw_random/virtio-rng.c
index 45d87c0614a5e,892720b1ac6f9..0000000000000
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@@ -70,7 -70,7 +70,7 @@@ static void request_entropy(struct virt
  static unsigned int copy_data(struct virtrng_info *vi, void *buf,
  			      unsigned int size)
  {
- 	unsigned int idx, avail;
+ 	unsigned int idx;
  
  	/*
  	 * vi->data_avail was set from the device-reported used.len and
@@@ -81,13 -81,13 +81,13 @@@
  	 * steered into adjacent slab memory, including under
  	 * speculation.
  	 */
- 	avail = min(vi->data_avail, sizeof(vi->data));
- 	if (vi->data_idx >= avail) {
+ 	if (vi->data_idx >= sizeof(vi->data)) {
  		vi->data_avail = 0;
  		request_entropy(vi);
  		return 0;
  	}
- 	size = min(size, avail - vi->data_idx);
+ 	vi->data_avail = min(vi->data_avail, sizeof(vi->data) - vi->data_idx);
+ 	size = min(size, vi->data_avail);
  	idx = array_index_nospec(vi->data_idx, sizeof(vi->data));
  	memcpy(buf, vi->data + idx, size);
  	vi->data_idx += size;
@@@ -150,17 -150,17 +150,17 @@@ static void virtio_cleanup(struct hwrn
  
  static int probe_common(struct virtio_device *vdev)
  {
- 	int err, index;
- 	struct virtrng_info *vi = NULL;
+ 	int err;
+ 	struct virtrng_info *vi;
  
  	vi = kzalloc_obj(struct virtrng_info);
  	if (!vi)
  		return -ENOMEM;
  
- 	vi->index = index = ida_alloc(&rng_index_ida, GFP_KERNEL);
- 	if (index < 0) {
- 		err = index;
- 		goto err_ida;
+ 	vi->index = ida_alloc(&rng_index_ida, GFP_KERNEL);
+ 	if (vi->index < 0) {
+ 		err = vi->index;
+ 		goto err;
  	}
  	snprintf(vi->name, sizeof(vi->name), "virtio_rng.%d", vi->index);
  	init_completion(&vi->have_data);
@@@ -177,7 -177,8 +177,8 @@@
  	vi->vq = virtio_find_single_vq(vdev, random_recv_done, "input");
  	if (IS_ERR(vi->vq)) {
  		err = PTR_ERR(vi->vq);
- 		goto err_find;
+ 		ida_free(&rng_index_ida, vi->index);
+ 		goto err;
  	}
  
  	virtio_device_ready(vdev);
@@@ -187,9 -188,7 +188,7 @@@
  
  	return 0;
  
- err_find:
- 	ida_free(&rng_index_ida, index);
- err_ida:
+ err:
  	vdev->priv = NULL;
  	kfree(vi);
  	return err;
@@@ -245,26 -244,27 +244,27 @@@ static int virtrng_freeze(struct virtio
  
  static int virtrng_restore(struct virtio_device *vdev)
  {
+ 	struct virtrng_info *vi;
  	int err;
  
  	err = probe_common(vdev);
- 	if (!err) {
- 		struct virtrng_info *vi = vdev->priv;
+ 	if (err)
+ 		return err;
+ 	vi = vdev->priv;
  
- 		/*
- 		 * Set hwrng_removed to ensure that virtio_read()
- 		 * does not block waiting for data before the
- 		 * registration is complete.
- 		 */
- 		vi->hwrng_removed = true;
- 		err = hwrng_register(&vi->hwrng);
- 		if (!err) {
- 			vi->hwrng_register_done = true;
- 			vi->hwrng_removed = false;
- 		}
- 	}
+ 	/*
+ 	 * Set hwrng_removed to ensure that virtio_read()
+ 	 * does not block waiting for data before the
+ 	 * registration is complete.
+ 	 */
+ 	vi->hwrng_removed = true;
+ 	err = hwrng_register(&vi->hwrng);
+ 	if (err)
+ 		return err;
  
- 	return err;
+ 	vi->hwrng_register_done = true;
+ 	vi->hwrng_removed = false;
+ 	return 0;
  }
  
  static const struct virtio_device_id id_table[] = {

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2026-11-16 16:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:43 Mark Brown [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-11-16 16:43 linux-next: manual merge of the crypto tree with the origin tree Mark Brown

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=avsyw-Q9dfMw45zX@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=blum@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mst@redhat.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