ALSA: pcm: Make mmap status read-only
authorTakashi Iwai <tiwai@suse.de>
Mon, 26 Sep 2022 13:55:49 +0000 (15:55 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 27 Sep 2022 06:46:03 +0000 (08:46 +0200)
The mmap status record should be read-only.  Modifying it from
user-space may screw up things unexpectedly, so let's clear the write
bits at exposing it.

Note that alsa-lib and other known user-space apps access the mmapped
status only as read-only, hence this change shouldn't break the
existing applications.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20220926135558.26580-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_native.c

index d9485b1..33769ca 100644 (file)
@@ -3668,6 +3668,7 @@ static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file
        area->vm_ops = &snd_pcm_vm_ops_status;
        area->vm_private_data = substream;
        area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+       area->vm_flags &= ~(VM_WRITE | VM_MAYWRITE);
        return 0;
 }