Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Octavian Purdila" <tavip@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] iov_iter: export iov_iter_restore
Date: Tue, 23 Jun 2026 22:28:30 +0000	[thread overview]
Message-ID: <20260623222831.755ED1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260622222757.2130402-2-tavip@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Exporting `iov_iter_restore` exposes a pre-existing logic error where restoring an `ITER_KVEC` iterator falsely triggers a `WARN_ON_ONCE`.
--

commit b7b5854a768fd37654ad61552651a21df8d14c8f
Author: Octavian Purdila <tavip@google.com>

iov_iter: export iov_iter_restore

Export iov_iter_restore so that it can be used by modules. This is needed by
the virtio vsock transport to restore the msg_iter state when transmission
fails.

> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 273919b161617..f5df63961fb24 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1491,6 +1491,7 @@ void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state)
>  		i->__iov -= state->nr_segs - i->nr_segs;
>  	i->nr_segs = state->nr_segs;
>  }
> +EXPORT_SYMBOL_GPL(iov_iter_restore);

[Severity: High]
This isn't a bug introduced by this patch, but exporting this function to
modules exposes a pre-existing issue when restoring an ITER_KVEC iterator.

Looking at iov_iter_restore() in lib/iov_iter.c:

void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state)
{
	if (WARN_ON_ONCE(!iov_iter_is_bvec(i) && !iter_is_iovec(i) &&
			 !iter_is_ubuf(i)) && !iov_iter_is_kvec(i))
		return;

Because !iov_iter_is_kvec(i) is placed outside the WARN_ON_ONCE() parentheses,
restoring an ITER_KVEC evaluates to WARN_ON_ONCE(true) && false. This safely
skips the early return, but still incorrectly triggers the warning, which can
lead to a panic on systems with panic_on_warn enabled.

Since ITER_KVEC is often used for kernel-originated network and storage data,
does exporting this to modules like virtio vsock create a risk of falsely
triggering warnings or a denial of service condition?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260622222757.2130402-1-tavip@google.com?part=1

  reply	other threads:[~2026-06-23 22:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 22:27 [PATCH net v3 0/2] vsock/virtio: fix msg_iter desync on transmission failure Octavian Purdila
2026-06-22 22:27 ` [PATCH net v3 1/2] iov_iter: export iov_iter_restore Octavian Purdila
2026-06-23 22:28   ` sashiko-bot [this message]
2026-06-25 10:43   ` Christian Brauner
2026-07-30 22:59     ` Michael S. Tsirkin
2026-06-22 22:27 ` [PATCH net v3 2/2] vsock/virtio: restore msg_iter on transmission failure Octavian Purdila

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=20260623222831.755ED1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tavip@google.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