Skip to contentSkip to conversation

ALSA: pcm: Zero-clear reserved fields of PCM status ioctl in compat mode

PATCH New Takashi Iwai 1 participant 1 message Oct 28, 2014 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Zero-clear reserved fields of PCM status ioctl in compat mode

In compat mode, we copy each field of snd_pcm_status struct but don't touch the reserved fields, and this leaves uninitialized values there. Meanwhile the native ioctl does zero-clear the whole structure, so we should follow the same rule in compat mode, too.

---
 sound/core/pcm_compat.c | 2 ++
 1 file changed, 2 insertions(+)
sound/core/pcm_compat.c +2 -0
index 102e8fd1d450..2d957ba63557 100644
@@ -210,6 +210,8 @@ static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
 	if (err < 0)
 		return err;
 
+	if (clear_user(src, sizeof(*src)))
+		return -EFAULT;
 	if (put_user(status.state, &src->state) ||
 	    compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
 	    compat_put_timespec(&status.tstamp, &src->tstamp) ||
Signature · 1 line
2.1.2