Skip to contentSkip to conversation

ALSA: emu10k1: fix possible info leak to userspace on SNDRV_EMU10K1_IOCTL_INFO

PATCH In review Takashi Iwai 1 participant 2 messages Sep 10, 2018 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: emu10k1: fix possible info leak to userspace on SNDRV_EMU10K1_IOCTL_INFO

From: Willy Tarreau <[email protected]>

snd_emu10k1_fx8010_ioctl(SNDRV_EMU10K1_IOCTL_INFO) allocates memory using kmalloc() and partially fills it by calling snd_emu10k1_fx8010_info() before returning the resulting structure to userspace, leaving uninitialized holes. Let's just use kzalloc() here.

---
 sound/pci/emu10k1/emufx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/emu10k1/emufx.c +1 -1
index 90713741c2dc..6ebe817801ea 100644
@@ -2540,7 +2540,7 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
 		emu->support_tlv = 1;
 		return put_user(SNDRV_EMU10K1_VERSION, (int __user *)argp);
 	case SNDRV_EMU10K1_IOCTL_INFO:
-		info = kmalloc(sizeof(*info), GFP_KERNEL);
+		info = kzalloc(sizeof(*info), GFP_KERNEL);
 		if (!info)
 			return -ENOMEM;
 		snd_emu10k1_fx8010_info(emu, info);
Signature · 1 line
2.18.0
#1 lore raw
Quoted 10 lines · Takashi Iwai

From: Willy Tarreau <[email protected]>

snd_emu10k1_fx8010_ioctl(SNDRV_EMU10K1_IOCTL_INFO) allocates memory using kmalloc() and partially fills it by calling snd_emu10k1_fx8010_info() before returning the resulting structure to userspace, leaving uninitialized holes. Let's just use kzalloc() here.

BTW, for avoiding someone falling into the same pitfall like me:
you can forget about the case 2 in the URL above. It's invalid. We have a complete copy_from_user() at first, so no leak happens.

Takashi