From 6387220ade73d0692e8e461022ddff32626416aa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 21 Nov 2022 12:18:48 +0100 Subject: [PATCH] 4.9-stable patches added patches: alsa-usb-audio-drop-snd_bug_on-from-snd_usbmidi_output_open.patch ftrace-fix-the-possible-incorrect-kernel-message.patch ftrace-optimize-the-allocation-for-mcount-entries.patch ring_buffer-do-not-deactivate-non-existant-pages.patch --- ..._bug_on-from-snd_usbmidi_output_open.patch | 41 +++++++++++++++++++ ...he-possible-incorrect-kernel-message.patch | 36 ++++++++++++++++ ...ze-the-allocation-for-mcount-entries.patch | 36 ++++++++++++++++ ...do-not-deactivate-non-existant-pages.patch | 40 ++++++++++++++++++ queue-4.9/series | 4 ++ 5 files changed, 157 insertions(+) create mode 100644 queue-4.9/alsa-usb-audio-drop-snd_bug_on-from-snd_usbmidi_output_open.patch create mode 100644 queue-4.9/ftrace-fix-the-possible-incorrect-kernel-message.patch create mode 100644 queue-4.9/ftrace-optimize-the-allocation-for-mcount-entries.patch create mode 100644 queue-4.9/ring_buffer-do-not-deactivate-non-existant-pages.patch diff --git a/queue-4.9/alsa-usb-audio-drop-snd_bug_on-from-snd_usbmidi_output_open.patch b/queue-4.9/alsa-usb-audio-drop-snd_bug_on-from-snd_usbmidi_output_open.patch new file mode 100644 index 00000000000..99604a01ace --- /dev/null +++ b/queue-4.9/alsa-usb-audio-drop-snd_bug_on-from-snd_usbmidi_output_open.patch @@ -0,0 +1,41 @@ +From ad72c3c3f6eb81d2cb189ec71e888316adada5df Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Sat, 12 Nov 2022 15:12:23 +0100 +Subject: ALSA: usb-audio: Drop snd_BUG_ON() from snd_usbmidi_output_open() + +From: Takashi Iwai + +commit ad72c3c3f6eb81d2cb189ec71e888316adada5df upstream. + +snd_usbmidi_output_open() has a check of the NULL port with +snd_BUG_ON(). snd_BUG_ON() was used as this shouldn't have happened, +but in reality, the NULL port may be seen when the device gives an +invalid endpoint setup at the descriptor, hence the driver skips the +allocation. That is, the check itself is valid and snd_BUG_ON() +should be dropped from there. Otherwise it's confusing as if it were +a real bug, as recently syzbot stumbled on it. + +Reported-by: syzbot+9abda841d636d86c41da@syzkaller.appspotmail.com +Cc: +Link: https://lore.kernel.org/r/syzbot+9abda841d636d86c41da@syzkaller.appspotmail.com +Link: https://lore.kernel.org/r/20221112141223.6144-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/usb/midi.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/sound/usb/midi.c ++++ b/sound/usb/midi.c +@@ -1148,10 +1148,8 @@ static int snd_usbmidi_output_open(struc + port = &umidi->endpoints[i].out->ports[j]; + break; + } +- if (!port) { +- snd_BUG(); ++ if (!port) + return -ENXIO; +- } + + substream->runtime->private_data = port; + port->state = STATE_UNKNOWN; diff --git a/queue-4.9/ftrace-fix-the-possible-incorrect-kernel-message.patch b/queue-4.9/ftrace-fix-the-possible-incorrect-kernel-message.patch new file mode 100644 index 00000000000..2bd906aa213 --- /dev/null +++ b/queue-4.9/ftrace-fix-the-possible-incorrect-kernel-message.patch @@ -0,0 +1,36 @@ +From 08948caebe93482db1adfd2154eba124f66d161d Mon Sep 17 00:00:00 2001 +From: Wang Wensheng +Date: Wed, 9 Nov 2022 09:44:32 +0000 +Subject: ftrace: Fix the possible incorrect kernel message + +From: Wang Wensheng + +commit 08948caebe93482db1adfd2154eba124f66d161d upstream. + +If the number of mcount entries is an integer multiple of +ENTRIES_PER_PAGE, the page count showing on the console would be wrong. + +Link: https://lkml.kernel.org/r/20221109094434.84046-2-wangwensheng4@huawei.com + +Cc: +Cc: +Cc: stable@vger.kernel.org +Fixes: 5821e1b74f0d0 ("function tracing: fix wrong pos computing when read buffer has been fulfilled") +Signed-off-by: Wang Wensheng +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/ftrace.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/kernel/trace/ftrace.c ++++ b/kernel/trace/ftrace.c +@@ -5177,7 +5177,7 @@ void __init ftrace_init(void) + } + + pr_info("ftrace: allocating %ld entries in %ld pages\n", +- count, count / ENTRIES_PER_PAGE + 1); ++ count, DIV_ROUND_UP(count, ENTRIES_PER_PAGE)); + + last_ftrace_enabled = ftrace_enabled = 1; + diff --git a/queue-4.9/ftrace-optimize-the-allocation-for-mcount-entries.patch b/queue-4.9/ftrace-optimize-the-allocation-for-mcount-entries.patch new file mode 100644 index 00000000000..0873dc369f5 --- /dev/null +++ b/queue-4.9/ftrace-optimize-the-allocation-for-mcount-entries.patch @@ -0,0 +1,36 @@ +From bcea02b096333dc74af987cb9685a4dbdd820840 Mon Sep 17 00:00:00 2001 +From: Wang Wensheng +Date: Wed, 9 Nov 2022 09:44:33 +0000 +Subject: ftrace: Optimize the allocation for mcount entries + +From: Wang Wensheng + +commit bcea02b096333dc74af987cb9685a4dbdd820840 upstream. + +If we can't allocate this size, try something smaller with half of the +size. Its order should be decreased by one instead of divided by two. + +Link: https://lkml.kernel.org/r/20221109094434.84046-3-wangwensheng4@huawei.com + +Cc: +Cc: +Cc: stable@vger.kernel.org +Fixes: a79008755497d ("ftrace: Allocate the mcount record pages as groups") +Signed-off-by: Wang Wensheng +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/ftrace.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/kernel/trace/ftrace.c ++++ b/kernel/trace/ftrace.c +@@ -3013,7 +3013,7 @@ static int ftrace_allocate_records(struc + /* if we can't allocate this size, try something smaller */ + if (!order) + return -ENOMEM; +- order >>= 1; ++ order--; + goto again; + } + diff --git a/queue-4.9/ring_buffer-do-not-deactivate-non-existant-pages.patch b/queue-4.9/ring_buffer-do-not-deactivate-non-existant-pages.patch new file mode 100644 index 00000000000..5094deab1d5 --- /dev/null +++ b/queue-4.9/ring_buffer-do-not-deactivate-non-existant-pages.patch @@ -0,0 +1,40 @@ +From 56f4ca0a79a9f1af98f26c54b9b89ba1f9bcc6bd Mon Sep 17 00:00:00 2001 +From: Daniil Tatianin +Date: Mon, 14 Nov 2022 17:31:29 +0300 +Subject: ring_buffer: Do not deactivate non-existant pages + +From: Daniil Tatianin + +commit 56f4ca0a79a9f1af98f26c54b9b89ba1f9bcc6bd upstream. + +rb_head_page_deactivate() expects cpu_buffer to contain a valid list of +->pages, so verify that the list is actually present before calling it. + +Found by Linux Verification Center (linuxtesting.org) with the SVACE +static analysis tool. + +Link: https://lkml.kernel.org/r/20221114143129.3534443-1-d-tatianin@yandex-team.ru + +Cc: stable@vger.kernel.org +Fixes: 77ae365eca895 ("ring-buffer: make lockless") +Signed-off-by: Daniil Tatianin +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/ring_buffer.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/kernel/trace/ring_buffer.c ++++ b/kernel/trace/ring_buffer.c +@@ -1267,9 +1267,9 @@ static void rb_free_cpu_buffer(struct ri + + free_buffer_page(cpu_buffer->reader_page); + +- rb_head_page_deactivate(cpu_buffer); +- + if (head) { ++ rb_head_page_deactivate(cpu_buffer); ++ + list_for_each_entry_safe(bpage, tmp, head, list) { + list_del_init(&bpage->list); + free_buffer_page(bpage); diff --git a/queue-4.9/series b/queue-4.9/series index 49bd7a3bc92..adb830ccd1c 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -43,3 +43,7 @@ net-caif-fix-double-disconnect-client-in-chnl_net_op.patch xen-pcpu-fix-possible-memory-leak-in-register_pcpu.patch net-x25-fix-skb-leak-in-x25_lapb_receive_frame.patch cifs-fix-wrong-return-value-checking-when-getflags.patch +ftrace-fix-the-possible-incorrect-kernel-message.patch +ftrace-optimize-the-allocation-for-mcount-entries.patch +ring_buffer-do-not-deactivate-non-existant-pages.patch +alsa-usb-audio-drop-snd_bug_on-from-snd_usbmidi_output_open.patch -- 2.47.3