From: Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@kernel.org>
To: perex@perex.cz, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: sis7019: Don't shift the voice IRQ status by 32
Date: Sun, 22 Nov 2026 10:08:16 +0000 [thread overview]
Message-ID: <20261122-sis7019-voice-irq-v1-1-fa5d0cbecf62@gmail.com> (raw)
From: Suyuan Wang <stevewong@hust.edu.cn>
sis_voice_irq() walks the set bits of a PISR_A or PISR_B status word:
bit = __ffs(status);
status >>= bit + 1;
When voice 31 or 63 interrupts, bit is 31 and status is shifted by 32,
which is undefined for a u32. On x86 the shift count is masked to 0, so
status does not change, the loop never ends, and voice keeps moving 32
entries forward on every pass, past the end of sis->voices[], with
sis_update_voice() called on whatever is there. All of this runs in the
hard IRQ handler. Voices are handed out from 0 up, so voice 31 is in use
once enough playback streams are open.
Walk the bits with for_each_set_bit() and index the voice by bit number
instead. The voices are still updated in the same order.
Found with a static analysis tool and checked by hand.
Fixes: 175859bf1602 ("[ALSA] sis7019: support the SiS 7019 Audio Accelerator")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
---
Compile tested (i386, W=1). I don't have a SiS 7019, so I ran the old
and new loop in userspace on the same status words: with 0x80000000 the
old loop trips UBSan's shift check, and without it ASan reports a read
past the 64-entry voice array; the new loop updates voice 31 (or 63)
and stops.
---
sound/pci/sis7019.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index fe5bda5af6a5..f31e62068ee3 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -278,15 +278,11 @@ static void sis_update_voice(struct voice *voice)
static void sis_voice_irq(u32 status, struct voice *voice)
{
+ unsigned long bits = status;
int bit;
- while (status) {
- bit = __ffs(status);
- status >>= bit + 1;
- voice += bit;
- sis_update_voice(voice);
- voice++;
- }
+ for_each_set_bit(bit, &bits, 32)
+ sis_update_voice(&voice[bit]);
}
static irqreturn_t sis_interrupt(int irq, void *dev)
next reply other threads:[~2026-11-22 10:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 10:08 Suyuan Wang via B4 Relay [this message]
2026-11-23 9:00 ` Takashi Iwai
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=20261122-sis7019-voice-irq-v1-1-fa5d0cbecf62@gmail.com \
--to=devnull+shyckless.gmail.com@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shyckless@gmail.com \
--cc=tiwai@suse.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
all inboxes | Powered by JetHome®