[PATCH] ALSA: emu10k1: Require CAP_SYS_ADMIN for SNDRV_EMU10K1_IOCTL_PCM_POKE
From: Suyuan Wang via B4 Relay
Date: Sun Nov 22 2026 - 19:36:30 EST
From: Suyuan Wang <stevewong@xxxxxxxxxxx>
snd_emu10k1_fx8010_ioctl() requires CAP_SYS_ADMIN for the commands that
change the FX8010 DSP state: CODE_POKE, TRAM_SETUP, STOP, CONTINUE,
ZERO_TRAM_COUNTER and SINGLE_STEP. PCM_POKE has no such check, although
it changes the card's FX8010 PCM configuration. snd_emu10k1_ipcm_poke()
stores the GPR and TRAM indices given by the caller without checking
them, and the FX8010 PCM code in emupcm.c later uses them as register
offsets:
snd_emu10k1_ptr_write(emu,
TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], ...);
snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 1);
So a process that can open the hwdep device can change this card-wide
configuration, including which registers the PCM code writes, while the
other DSP configuration commands are limited to CAP_SYS_ADMIN.
Require CAP_SYS_ADMIN for PCM_POKE too, like the other FX8010
configuration commands.
Found with a static analysis tool and checked by hand.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
---
Compile tested on x86_64 (W=1, no new warnings). I don't have an EMU10K1 card.
---
sound/pci/emu10k1/emufx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index ddac6cecc8eb..df4661927041 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -2506,6 +2506,8 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
kfree(icode);
return res;
case SNDRV_EMU10K1_IOCTL_PCM_POKE:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
ipcm = memdup_user(argp, sizeof(*ipcm));
if (IS_ERR(ipcm))
return PTR_ERR(ipcm);