From: Greg Kroah-Hartman Date: Fri, 9 Sep 2022 18:38:55 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v5.19.9~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=95ee268587cc2e2bae8ddbe611f884ab9dbaaddb;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch kprobes-prohibit-probes-in-gate-area.patch --- diff --git a/queue-4.14/alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch b/queue-4.14/alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch new file mode 100644 index 00000000000..e86577e90ed --- /dev/null +++ b/queue-4.14/alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch @@ -0,0 +1,49 @@ +From 3e48940abee88b8dbbeeaf8a07e7b2b6be1271b3 Mon Sep 17 00:00:00 2001 +From: Pattara Teerapong +Date: Thu, 1 Sep 2022 14:40:36 +0000 +Subject: ALSA: aloop: Fix random zeros in capture data when using jiffies timer + +From: Pattara Teerapong + +commit 3e48940abee88b8dbbeeaf8a07e7b2b6be1271b3 upstream. + +In loopback_jiffies_timer_pos_update(), we are getting jiffies twice. +First time for playback, second time for capture. Jiffies can be updated +between these two calls and if the capture jiffies is larger, extra zeros +will be filled in the capture buffer. + +Change to get jiffies once and use it for both playback and capture. + +Signed-off-by: Pattara Teerapong +Cc: +Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromium.org +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/drivers/aloop.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/sound/drivers/aloop.c ++++ b/sound/drivers/aloop.c +@@ -477,17 +477,18 @@ static unsigned int loopback_pos_update( + cable->streams[SNDRV_PCM_STREAM_PLAYBACK]; + struct loopback_pcm *dpcm_capt = + cable->streams[SNDRV_PCM_STREAM_CAPTURE]; +- unsigned long delta_play = 0, delta_capt = 0; ++ unsigned long delta_play = 0, delta_capt = 0, cur_jiffies; + unsigned int running, count1, count2; + ++ cur_jiffies = jiffies; + running = cable->running ^ cable->pause; + if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { +- delta_play = jiffies - dpcm_play->last_jiffies; ++ delta_play = cur_jiffies - dpcm_play->last_jiffies; + dpcm_play->last_jiffies += delta_play; + } + + if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) { +- delta_capt = jiffies - dpcm_capt->last_jiffies; ++ delta_capt = cur_jiffies - dpcm_capt->last_jiffies; + dpcm_capt->last_jiffies += delta_capt; + } + diff --git a/queue-4.14/alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch b/queue-4.14/alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch new file mode 100644 index 00000000000..1c95a97fce3 --- /dev/null +++ b/queue-4.14/alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch @@ -0,0 +1,66 @@ +From d29f59051d3a07b81281b2df2b8c9dfe4716067f Mon Sep 17 00:00:00 2001 +From: Tasos Sahanidis +Date: Wed, 7 Sep 2022 04:18:00 +0300 +Subject: ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() + +From: Tasos Sahanidis + +commit d29f59051d3a07b81281b2df2b8c9dfe4716067f upstream. + +The voice allocator sometimes begins allocating from near the end of the +array and then wraps around, however snd_emu10k1_pcm_channel_alloc() +accesses the newly allocated voices as if it never wrapped around. + +This results in out of bounds access if the first voice has a high enough +index so that first_voice + requested_voice_count > NUM_G (64). +The more voices are requested, the more likely it is for this to occur. + +This was initially discovered using PipeWire, however it can be reproduced +by calling aplay multiple times with 16 channels: +aplay -r 48000 -D plughw:CARD=Live,DEV=3 -c 16 /dev/zero + +UBSAN: array-index-out-of-bounds in sound/pci/emu10k1/emupcm.c:127:40 +index 65 is out of range for type 'snd_emu10k1_voice [64]' +CPU: 1 PID: 31977 Comm: aplay Tainted: G W IOE 6.0.0-rc2-emu10k1+ #7 +Hardware name: ASUSTEK COMPUTER INC P5W DH Deluxe/P5W DH Deluxe, BIOS 3002 07/22/2010 +Call Trace: + +dump_stack_lvl+0x49/0x63 +dump_stack+0x10/0x16 +ubsan_epilogue+0x9/0x3f +__ubsan_handle_out_of_bounds.cold+0x44/0x49 +snd_emu10k1_playback_hw_params+0x3bc/0x420 [snd_emu10k1] +snd_pcm_hw_params+0x29f/0x600 [snd_pcm] +snd_pcm_common_ioctl+0x188/0x1410 [snd_pcm] +? exit_to_user_mode_prepare+0x35/0x170 +? do_syscall_64+0x69/0x90 +? syscall_exit_to_user_mode+0x26/0x50 +? do_syscall_64+0x69/0x90 +? exit_to_user_mode_prepare+0x35/0x170 +snd_pcm_ioctl+0x27/0x40 [snd_pcm] +__x64_sys_ioctl+0x95/0xd0 +do_syscall_64+0x5c/0x90 +? do_syscall_64+0x69/0x90 +? do_syscall_64+0x69/0x90 +entry_SYSCALL_64_after_hwframe+0x63/0xcd + +Signed-off-by: Tasos Sahanidis +Cc: +Link: https://lore.kernel.org/r/3707dcab-320a-62ff-63c0-73fc201ef756@tasossah.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/emu10k1/emupcm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/sound/pci/emu10k1/emupcm.c ++++ b/sound/pci/emu10k1/emupcm.c +@@ -137,7 +137,7 @@ static int snd_emu10k1_pcm_channel_alloc + epcm->voices[0]->epcm = epcm; + if (voices > 1) { + for (i = 1; i < voices; i++) { +- epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i]; ++ epcm->voices[i] = &epcm->emu->voices[(epcm->voices[0]->number + i) % NUM_G]; + epcm->voices[i]->epcm = epcm; + } + } diff --git a/queue-4.14/alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch b/queue-4.14/alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch new file mode 100644 index 00000000000..49769e0b32f --- /dev/null +++ b/queue-4.14/alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch @@ -0,0 +1,34 @@ +From e53f47f6c1a56d2af728909f1cb894da6b43d9bf Mon Sep 17 00:00:00 2001 +From: Dongxiang Ke +Date: Tue, 6 Sep 2022 10:49:28 +0800 +Subject: ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() + +From: Dongxiang Ke + +commit e53f47f6c1a56d2af728909f1cb894da6b43d9bf upstream. + +There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and +the number of it's interfaces less than 4, an out-of-bounds read bug occurs +when parsing the interface descriptor for this device. + +Fix this by checking the number of interfaces. + +Signed-off-by: Dongxiang Ke +Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/usb/stream.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/sound/usb/stream.c ++++ b/sound/usb/stream.c +@@ -502,7 +502,7 @@ int snd_usb_parse_audio_interface(struct + * Dallas DS4201 workaround: It presents 5 altsettings, but the last + * one misses syncpipe, and does not produce any sound. + */ +- if (chip->usb_id == USB_ID(0x04fa, 0x4201)) ++ if (chip->usb_id == USB_ID(0x04fa, 0x4201) && num >= 4) + num = 4; + + for (i = 0; i < num; i++) { diff --git a/queue-4.14/kprobes-prohibit-probes-in-gate-area.patch b/queue-4.14/kprobes-prohibit-probes-in-gate-area.patch new file mode 100644 index 00000000000..9b585b5bf83 --- /dev/null +++ b/queue-4.14/kprobes-prohibit-probes-in-gate-area.patch @@ -0,0 +1,117 @@ +From 1efda38d6f9ba26ac88b359c6277f1172db03f1e Mon Sep 17 00:00:00 2001 +From: "Christian A. Ehrhardt" +Date: Wed, 7 Sep 2022 22:09:17 +0200 +Subject: kprobes: Prohibit probes in gate area + +From: Christian A. Ehrhardt + +commit 1efda38d6f9ba26ac88b359c6277f1172db03f1e upstream. + +The system call gate area counts as kernel text but trying +to install a kprobe in this area fails with an Oops later on. +To fix this explicitly disallow the gate area for kprobes. + +Found by syzkaller with the following reproducer: +perf_event_open$cgroup(&(0x7f00000001c0)={0x6, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80ffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_config_ext={0x0, 0xffffffffff600000}}, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0) + +Sample report: +BUG: unable to handle page fault for address: fffffbfff3ac6000 +PGD 6dfcb067 P4D 6dfcb067 PUD 6df8f067 PMD 6de4d067 PTE 0 +Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI +CPU: 0 PID: 21978 Comm: syz-executor.2 Not tainted 6.0.0-rc3-00363-g7726d4c3e60b-dirty #6 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 +RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline] +RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline] +RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134 +Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89 +RSP: 0018:ffffc900088bf860 EFLAGS: 00010246 +RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000 +RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8 +RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8 +R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001 +R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000 +FS: 00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0 +PKRU: 55555554 +Call Trace: + + insn_get_prefixes arch/x86/lib/insn.c:131 [inline] + insn_get_opcode arch/x86/lib/insn.c:272 [inline] + insn_get_modrm+0x64a/0x7b0 arch/x86/lib/insn.c:343 + insn_get_sib+0x29a/0x330 arch/x86/lib/insn.c:421 + insn_get_displacement+0x350/0x6b0 arch/x86/lib/insn.c:464 + insn_get_immediate arch/x86/lib/insn.c:632 [inline] + insn_get_length arch/x86/lib/insn.c:707 [inline] + insn_decode+0x43a/0x490 arch/x86/lib/insn.c:747 + can_probe+0xfc/0x1d0 arch/x86/kernel/kprobes/core.c:282 + arch_prepare_kprobe+0x79/0x1c0 arch/x86/kernel/kprobes/core.c:739 + prepare_kprobe kernel/kprobes.c:1160 [inline] + register_kprobe kernel/kprobes.c:1641 [inline] + register_kprobe+0xb6e/0x1690 kernel/kprobes.c:1603 + __register_trace_kprobe kernel/trace/trace_kprobe.c:509 [inline] + __register_trace_kprobe+0x26a/0x2d0 kernel/trace/trace_kprobe.c:477 + create_local_trace_kprobe+0x1f7/0x350 kernel/trace/trace_kprobe.c:1833 + perf_kprobe_init+0x18c/0x280 kernel/trace/trace_event_perf.c:271 + perf_kprobe_event_init+0xf8/0x1c0 kernel/events/core.c:9888 + perf_try_init_event+0x12d/0x570 kernel/events/core.c:11261 + perf_init_event kernel/events/core.c:11325 [inline] + perf_event_alloc.part.0+0xf7f/0x36a0 kernel/events/core.c:11619 + perf_event_alloc kernel/events/core.c:12059 [inline] + __do_sys_perf_event_open+0x4a8/0x2a00 kernel/events/core.c:12157 + do_syscall_x64 arch/x86/entry/common.c:50 [inline] + do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80 + entry_SYSCALL_64_after_hwframe+0x63/0xcd +RIP: 0033:0x7f63ef7efaed +Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 +RSP: 002b:00007f63eef63028 EFLAGS: 00000246 ORIG_RAX: 000000000000012a +RAX: ffffffffffffffda RBX: 00007f63ef90ff80 RCX: 00007f63ef7efaed +RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 00000000200001c0 +RBP: 00007f63ef86019c R08: 0000000000000000 R09: 0000000000000000 +R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000 +R13: 0000000000000002 R14: 00007f63ef90ff80 R15: 00007f63eef43000 + +Modules linked in: +CR2: fffffbfff3ac6000 +---[ end trace 0000000000000000 ]--- +RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline] +RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline] +RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134 +Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89 +RSP: 0018:ffffc900088bf860 EFLAGS: 00010246 +RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000 +RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8 +RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8 +R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001 +R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000 +FS: 00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0 +PKRU: 55555554 +================================================================== + +Link: https://lkml.kernel.org/r/20220907200917.654103-1-lk@c--e.de + +cc: "Naveen N. Rao" +cc: Anil S Keshavamurthy +cc: "David S. Miller" +Cc: stable@vger.kernel.org +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Acked-by: Masami Hiramatsu (Google) +Signed-off-by: Christian A. Ehrhardt +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/kprobes.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/kernel/kprobes.c ++++ b/kernel/kprobes.c +@@ -1553,6 +1553,7 @@ static int check_kprobe_address_safe(str + /* Ensure it is not in reserved area nor out of text */ + if (!(core_kernel_text((unsigned long) p->addr) || + is_module_text_address((unsigned long) p->addr)) || ++ in_gate_area_no_mm((unsigned long) p->addr) || + within_kprobe_blacklist((unsigned long) p->addr) || + jump_label_text_reserved(p->addr, p->addr) || + find_bug((unsigned long)p->addr)) { diff --git a/queue-4.14/series b/queue-4.14/series index 01415a40d33..36a662f034c 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -41,3 +41,7 @@ parisc-ccio-dma-handle-kmalloc-failure-in-ccio_init_.patch parisc-add-runtime-check-to-prevent-pa2.0-kernels-on.patch arm64-signal-raise-limit-on-stack-frames.patch fbdev-chipsfb-add-missing-pci_disable_device-in-chip.patch +alsa-emu10k1-fix-out-of-bounds-access-in-snd_emu10k1_pcm_channel_alloc.patch +alsa-aloop-fix-random-zeros-in-capture-data-when-using-jiffies-timer.patch +alsa-usb-audio-fix-an-out-of-bounds-bug-in-__snd_usb_parse_audio_interface.patch +kprobes-prohibit-probes-in-gate-area.patch