linux/sound/usb/usx2y
Baul Lee 2ca1eea3cd ALSA: usx2y: bound the hwdep mmap fault offset
snd_us428ctls_vm_fault() turns the faulting page offset into a kernel
address with no bound of any kind:

	offset = vmf->pgoff << PAGE_SHIFT;
	vaddr = (char *)(...)->us428ctls_sharedmem + offset;
	page = virt_to_page(vaddr);
	get_page(page);
	vmf->page = page;

	return 0;

snd_us428ctls_mmap() checks only the length of the mapping, never the
offset, and us428ctls_sharedmem is a single page from
alloc_pages_exact().  For a character device file_mmap_size_max()
returns ULONG_MAX, so the mm layer imposes no ceiling either.  Every page
offset above zero resolves to a struct page outside the object, and the
handler installs it into the caller's address space read-write; the vma
is not marked read-only.

The caller picks the page frame with a single mmap() argument and gets
read-write access to a page of kernel memory it does not own; an offset
that lands in an unpopulated vmemmap region oopses instead.

A process that can open the hwdep node of an attached US-X2Y reaches
this after loading the FPGA image through the same node; no capability
check is involved.

On 7.2.0-rc5 (arm64), mmap() with a large offset:

  Unable to handle kernel paging request at virtual address fffffdffc45d5ac8
  pc : snd_us428ctls_vm_fault+0x68/0x140 [snd_usb_usx2y]
  Call trace:
   snd_us428ctls_vm_fault+0x68/0x140 [snd_usb_usx2y]
   __do_fault
   __handle_mm_fault
   handle_mm_fault
   el0_da

Reject any offset outside the shared region.  The pcm hwdep handler in
usx2yhwdeppcm.c computes its address the same way and needs the same
bound.

Discovered by XBOW, triaged by Baul Lee <baul.lee@xbow.com>

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
Reported-by: Baul Lee <baul.lee@xbow.com>
Cc: stable@vger.kernel.org
Signed-off-by: Baul Lee <baul.lee@xbow.com>
Link: https://patch.msgid.link/20260805013445.38283-1-baul.lee@xbow.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
History 2026-08-05 09:37:27 +02:00
..
Makefile ALSA: usb-audio: Add infrastructure for TASCAM US-144MKII 2025-08-15 17:53:47 +02:00
us122l.c ALSA: us122l: drop redundant interface references 2026-03-05 14:00:55 +01:00
us122l.h ALSA: us122l: Drop mmap_count field 2024-11-13 13:33:47 +01:00
us144mkii.c ALSA: usx2y: us144mkii: fix work UAF on disconnect 2026-07-01 13:54:23 +02:00
us144mkii.h ALSA: usb-audio: us144mkii: Fixes for handshake, MIDI out and cleanup 2025-08-26 10:59:46 +02:00
us144mkii_capture.c ALSA: us144mkii: re-anchor capture URBs on resubmission 2026-08-04 18:06:37 +02:00
us144mkii_controls.c ALSA: us144mkii: Drop kernel-doc markers 2026-02-26 16:56:36 +01:00
us144mkii_midi.c ALSA: us144mkii: Drop kernel-doc markers 2026-02-26 16:56:36 +01:00
us144mkii_pcm.c ALSA: usx2y: Relax __free() variable declarations 2025-12-17 10:08:30 +01:00
us144mkii_pcm.h ALSA: usb-audio: us144mkii: Implement audio capture and decoding 2025-08-15 17:53:47 +02:00
us144mkii_playback.c ALSA: us144mkii: Drop kernel-doc markers 2026-02-26 16:56:36 +01:00
usb_stream.c ALSA: usx2y: Drop no longer used variable 2024-08-09 09:57:33 +02:00
usb_stream.h ALSA: usx2y: Use standard print API 2024-08-08 07:49:47 +02:00
usbus428ctldefs.h ALSA: usx2y: Fix potential leaks of uninitialized memory 2021-05-17 16:04:10 +02:00
usbusx2y.c ALSA: usx2y: Drain pending US-428 pipe-4 output commands 2026-05-19 08:09:36 +02:00
usbusx2y.h ALSA: usx2y: validate nrpacks module parameter on probe 2025-03-03 13:40:33 +01:00
usbusx2yaudio.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
usx2y.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
usX2Yhwdep.c ALSA: usx2y: bound the hwdep mmap fault offset 2026-08-05 09:37:27 +02:00
usX2Yhwdep.h ALSA: usx2y: Fix spaces 2021-05-17 16:03:46 +02:00
usx2yhwdeppcm.c ALSA: usx2y: bound the hwdep mmap fault offset 2026-08-05 09:37:27 +02:00
usx2yhwdeppcm.h ALSA: usx2y: Avoid camelCase 2021-05-17 16:03:34 +02:00