From: sashiko-bot@kernel.org
To: "Joonho Lee" <mynameisjune111@gmail.com>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v2 5/5] ALSA: virtio: Keep control payloads alive through DMA completion
Date: Tue, 13 Oct 2026 07:52:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-169212@kernel.org> (raw)
In-Reply-To: <9fef5c610028744b71ef243edbcd5a020f14180d.1791877396.git.mynameisjune111@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mm: Unaligned memory access due to +1 offset with small DMA cacheline alignment
--
commit d7c4b679538e28af5e6c452343c3bd0ca83a7fd1
Author: Joonho Lee <mynameisjune111@gmail.com>
ALSA: virtio: Keep control payloads alive through DMA completion
Control requests can expose caller-owned payloads to the device after a
synchronous send times out. Allocate request and response headers and
payloads with the reference-counted message, and place each scatterlist
region on separate DMA cacheline boundaries.
> diff --git a/sound/virtio/virtio_ctl_msg.c b/sound/virtio/virtio_ctl_msg.c
> --- a/sound/virtio/virtio_ctl_msg.c
> +++ b/sound/virtio/virtio_ctl_msg.c
[ ... ]
> @@ -85,20 +161,83 @@ struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size,
[ ... ]
> msg = kzalloc(sizeof(*msg), gfp);
> if (!msg)
> return NULL;
>
> - sg_init_one(&msg->sg_request, (u8 *)msg + sizeof(*msg), request_size);
> - sg_init_one(&msg->sg_response, (u8 *)msg + sizeof(*msg) + request_size,
> - response_size);
> + msg->dma_buffer = kzalloc(dma_buffer_size, gfp);
> + if (!msg->dma_buffer) {
> + kfree(msg);
> + return NULL;
> + }
> + data = (u8 *)msg->dma_buffer + 1;
[Severity: High]
When dma_get_cache_alignment() returns 1 (as it typically does on
cache-coherent architectures like x86), does this +1 offset force all
subsequent scatterlist entries to be at an odd, unaligned memory address?
Since the alignment is 1, padding = address % alignment in
virtsnd_ctl_msg_sg_init() will evaluate to 0, leaving the data address
unaligned without any added padding.
Later, callers like virtsnd_kctl_get() cast this response data to
struct virtio_snd_ctl_value and directly load 64-bit integers:
sound/virtio/virtio_kctl.c:virtsnd_kctl_get() {
...
case VIRTIO_SND_CTL_TYPE_INTEGER64:
for (i = 0; i < count; ++i)
uvalue->value.integer64.value[i] =
le64_to_cpu(kvalue->value.integer64[i]);
...
}
Can this lead to an unaligned memory access exception or a kernel panic
when UBSAN is enabled on strict architectures?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791877396.git.mynameisjune111@gmail.com?part=5
next prev parent reply other threads:[~2026-10-13 7:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 7:43 [PATCH v2 0/5] ALSA: virtio: Fix request lifetime and error recovery Joonho Lee
2026-10-13 7:43 ` [PATCH v2 1/5] ALSA: virtio: Propagate PCM send failures through ACK Joonho Lee
2026-10-13 7:54 ` sashiko-bot
2026-10-13 7:43 ` [PATCH v2 2/5] ALSA: virtio: Recover PCM state after a failed start Joonho Lee
2026-10-13 8:04 ` sashiko-bot
2026-10-13 8:58 ` Joonho Lee
2026-10-13 7:43 ` [PATCH v2 3/5] ALSA: virtio: Retain queued messages through device reset Joonho Lee
2026-10-13 7:53 ` sashiko-bot
2026-10-13 7:43 ` [PATCH v2 4/5] ALSA: virtio: Keep PCM DMA buffers alive through device ownership Joonho Lee
2026-10-13 8:01 ` sashiko-bot
2026-10-13 7:43 ` [PATCH v2 5/5] ALSA: virtio: Keep control payloads alive through DMA completion Joonho Lee
2026-10-13 7:52 ` sashiko-bot [this message]
2026-10-13 8:59 ` Joonho Lee
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=sashiko-outbox-169212@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=mst@redhat.com \
--cc=mynameisjune111@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--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 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.