ALSA: emu10k1: Require CAP_SYS_ADMIN for SNDRV_EMU10K1_IOCTL_PCM_POKE
PATCH 1/1 ALSA: emu10k1: Require CAP_SYS_ADMIN for SNDRV_EMU10K1_IOCTL_PCM_POKE
From: Suyuan Wang <[email protected]>
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.
---
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(+)
sound/pci/emu10k1/emufx.c +2 -0
@@ -2506,6 +2506,8 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, unkfree (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);
Takashi Iwai
AppliedQuoted 22 lines · On Mon, 23 Nov 2026 01:36:20 +0100, Suyuan Wang via B4 Relay wrote:
From: Suyuan Wang <[email protected]>
snd_emu10k1_fx8010_ioctl()requiresCAP_SYS_ADMINfor the commands that change the FX8010 DSP state:CODE_POKE,TRAM_SETUP, STOP, CONTINUE,ZERO_TRAM_COUNTERandSINGLE_STEP.PCM_POKEhas 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 inemupcm.clater 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_ADMINforPCM_POKEtoo, like the other FX8010 configuration commands.
Quoted 7 lines
Found with a static analysis tool and checked by hand.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Co-developed-by Kaixuan Li <[email protected]>Signed-off-by Kaixuan Li <[email protected]>Signed-off-by Suyuan Wang <[email protected]>
Applied to for-next branch. Thanks.
Takashi