ALSA: pcm: Add sanity NULL check for the default mmap fault handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Takashi Iwai <tiwai@xxxxxxx>

commit d2913a07d9037fe7aed4b7e680684163eaed6bc4 upstream.

A driver might allow the mmap access before initializing its
runtime->dma_area properly.  Add a proper NULL check before passing to
virt_to_page() for avoiding a panic.

Reported-by: syzbot+4bf62a7b1d0f4fdb7ae2@xxxxxxxxxxxxxxxxxxxxxxxxx
Cc: <stable@xxxxxxxxxxxxxxx>
Link: https://patch.msgid.link/20241120141104.7060-1-tiwai@xxxxxxx
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 sound/core/pcm_native.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3789,9 +3789,11 @@ static vm_fault_t snd_pcm_mmap_data_faul
 		return VM_FAULT_SIGBUS;
 	if (substream->ops->page)
 		page = substream->ops->page(substream, offset);
-	else if (!snd_pcm_get_dma_buf(substream))
+	else if (!snd_pcm_get_dma_buf(substream)) {
+		if (WARN_ON_ONCE(!runtime->dma_area))
+			return VM_FAULT_SIGBUS;
 		page = virt_to_page(runtime->dma_area + offset);
-	else
+	} else
 		page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset);
 	if (!page)
 		return VM_FAULT_SIGBUS;


Patches currently in stable-queue which might be from tiwai@xxxxxxx are

queue-6.11/alsa-pcm-add-sanity-null-check-for-the-default-mmap-fault-handler.patch
queue-6.11/alsa-hda-realtek-set-pcbeep-to-default-value-for-alc274.patch
queue-6.11/alsa-6fire-release-resources-at-card-release.patch
queue-6.11/alsa-hda-realtek-add-subwoofer-quirk-for-infinix-zer.patch
queue-6.11/alsa-hda-realtek-apply-quirk-for-medion-e15433.patch
queue-6.11/alsa-ump-fix-evaluation-of-midi-1.0-fb-info.patch
queue-6.11/alsa-usx2y-use-snd_card_free_when_closed-at-disconne.patch
queue-6.11/alsa-hda-realtek-fix-internal-speaker-and-mic-boost-of-infinix-y4-max.patch
queue-6.11/alsa-us122l-use-snd_card_free_when_closed-at-disconn.patch
queue-6.11/alsa-caiaq-use-snd_card_free_when_closed-at-disconne.patch
queue-6.11/alsa-usb-audio-fix-out-of-bounds-reads-when-finding-clock-sources.patch
queue-6.11/alsa-core-fix-possible-null-dereference-caused-by-ku.patch
queue-6.11/alsa-usb-audio-fix-potential-out-of-bound-accesses-for-extigy-and-mbox-devices.patch
queue-6.11/alsa-usb-audio-fix-yamaha-p-125-quirk-entry.patch
queue-6.11/alsa-rawmidi-fix-kvfree-call-in-spinlock.patch
queue-6.11/alsa-hda-realtek-update-alc225-depop-procedure.patch
queue-6.11/alsa-hda-realtek-update-alc256-depop-procedure.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux