Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: emu10k1: Require CAP_SYS_ADMIN for SNDRV_EMU10K1_IOCTL_PCM_POKE
@ 2026-11-23  0:36 Suyuan Wang via B4 Relay
  2026-11-23  9:49 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Suyuan Wang via B4 Relay @ 2026-11-23  0:36 UTC (permalink / raw)
  To: perex, tiwai; +Cc: linux-sound, linux-kernel

From: Suyuan Wang <stevewong@hust.edu.cn>

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@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 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);





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  0:36 [PATCH] ALSA: emu10k1: Require CAP_SYS_ADMIN for SNDRV_EMU10K1_IOCTL_PCM_POKE Suyuan Wang via B4 Relay
2026-11-23  9:49 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox