]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Jan 2022 11:21:01 +0000 (12:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Jan 2022 11:21:01 +0000 (12:21 +0100)
added patches:
tracing-fix-check-for-trace_percpu_buffer-validity-in-get_trace_buf.patch
tracing-tag-trace_percpu_buffer-as-a-percpu-pointer.patch
virtio_pci-support-surprise-removal-of-virtio-pci-device.patch

queue-4.9/series
queue-4.9/tracing-fix-check-for-trace_percpu_buffer-validity-in-get_trace_buf.patch [new file with mode: 0644]
queue-4.9/tracing-tag-trace_percpu_buffer-as-a-percpu-pointer.patch [new file with mode: 0644]
queue-4.9/virtio_pci-support-surprise-removal-of-virtio-pci-device.patch [new file with mode: 0644]

index 7bc7d02640be8752747511fc4df81fe8c88d2bc2..d49f55d3b69f0a8c327544a71a3686a44f23294b 100644 (file)
@@ -1 +1,4 @@
 bluetooth-btusb-apply-qca-rome-patches-for-some-ath3012-models.patch
+tracing-fix-check-for-trace_percpu_buffer-validity-in-get_trace_buf.patch
+tracing-tag-trace_percpu_buffer-as-a-percpu-pointer.patch
+virtio_pci-support-surprise-removal-of-virtio-pci-device.patch
diff --git a/queue-4.9/tracing-fix-check-for-trace_percpu_buffer-validity-in-get_trace_buf.patch b/queue-4.9/tracing-fix-check-for-trace_percpu_buffer-validity-in-get_trace_buf.patch
new file mode 100644 (file)
index 0000000..49f20fc
--- /dev/null
@@ -0,0 +1,59 @@
+From 823e670f7ed616d0ce993075c8afe0217885f79d Mon Sep 17 00:00:00 2001
+From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
+Date: Thu, 23 Dec 2021 16:04:38 +0530
+Subject: tracing: Fix check for trace_percpu_buffer validity in get_trace_buf()
+
+From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+
+commit 823e670f7ed616d0ce993075c8afe0217885f79d upstream.
+
+With the new osnoise tracer, we are seeing the below splat:
+    Kernel attempted to read user page (c7d880000) - exploit attempt? (uid: 0)
+    BUG: Unable to handle kernel data access on read at 0xc7d880000
+    Faulting instruction address: 0xc0000000002ffa10
+    Oops: Kernel access of bad area, sig: 11 [#1]
+    LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
+    ...
+    NIP [c0000000002ffa10] __trace_array_vprintk.part.0+0x70/0x2f0
+    LR [c0000000002ff9fc] __trace_array_vprintk.part.0+0x5c/0x2f0
+    Call Trace:
+    [c0000008bdd73b80] [c0000000001c49cc] put_prev_task_fair+0x3c/0x60 (unreliable)
+    [c0000008bdd73be0] [c000000000301430] trace_array_printk_buf+0x70/0x90
+    [c0000008bdd73c00] [c0000000003178b0] trace_sched_switch_callback+0x250/0x290
+    [c0000008bdd73c90] [c000000000e70d60] __schedule+0x410/0x710
+    [c0000008bdd73d40] [c000000000e710c0] schedule+0x60/0x130
+    [c0000008bdd73d70] [c000000000030614] interrupt_exit_user_prepare_main+0x264/0x270
+    [c0000008bdd73de0] [c000000000030a70] syscall_exit_prepare+0x150/0x180
+    [c0000008bdd73e10] [c00000000000c174] system_call_vectored_common+0xf4/0x278
+
+osnoise tracer on ppc64le is triggering osnoise_taint() for negative
+duration in get_int_safe_duration() called from
+trace_sched_switch_callback()->thread_exit().
+
+The problem though is that the check for a valid trace_percpu_buffer is
+incorrect in get_trace_buf(). The check is being done after calculating
+the pointer for the current cpu, rather than on the main percpu pointer.
+Fix the check to be against trace_percpu_buffer.
+
+Link: https://lkml.kernel.org/r/a920e4272e0b0635cf20c444707cbce1b2c8973d.1640255304.git.naveen.n.rao@linux.vnet.ibm.com
+
+Cc: stable@vger.kernel.org
+Fixes: e2ace001176dc9 ("tracing: Choose static tp_printk buffer by explicit nesting count")
+Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/trace/trace.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -2364,7 +2364,7 @@ static char *get_trace_buf(void)
+ {
+       struct trace_buffer_struct *buffer = this_cpu_ptr(trace_percpu_buffer);
+-      if (!buffer || buffer->nesting >= 4)
++      if (!trace_percpu_buffer || buffer->nesting >= 4)
+               return NULL;
+       buffer->nesting++;
diff --git a/queue-4.9/tracing-tag-trace_percpu_buffer-as-a-percpu-pointer.patch b/queue-4.9/tracing-tag-trace_percpu_buffer-as-a-percpu-pointer.patch
new file mode 100644 (file)
index 0000000..9658e80
--- /dev/null
@@ -0,0 +1,50 @@
+From f28439db470cca8b6b082239314e9fd10bd39034 Mon Sep 17 00:00:00 2001
+From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
+Date: Thu, 23 Dec 2021 16:04:39 +0530
+Subject: tracing: Tag trace_percpu_buffer as a percpu pointer
+
+From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+
+commit f28439db470cca8b6b082239314e9fd10bd39034 upstream.
+
+Tag trace_percpu_buffer as a percpu pointer to resolve warnings
+reported by sparse:
+  /linux/kernel/trace/trace.c:3218:46: warning: incorrect type in initializer (different address spaces)
+  /linux/kernel/trace/trace.c:3218:46:    expected void const [noderef] __percpu *__vpp_verify
+  /linux/kernel/trace/trace.c:3218:46:    got struct trace_buffer_struct *
+  /linux/kernel/trace/trace.c:3234:9: warning: incorrect type in initializer (different address spaces)
+  /linux/kernel/trace/trace.c:3234:9:    expected void const [noderef] __percpu *__vpp_verify
+  /linux/kernel/trace/trace.c:3234:9:    got int *
+
+Link: https://lkml.kernel.org/r/ebabd3f23101d89cb75671b68b6f819f5edc830b.1640255304.git.naveen.n.rao@linux.vnet.ibm.com
+
+Cc: stable@vger.kernel.org
+Reported-by: kernel test robot <lkp@intel.com>
+Fixes: 07d777fe8c398 ("tracing: Add percpu buffers for trace_printk()")
+Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/trace/trace.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -2354,7 +2354,7 @@ struct trace_buffer_struct {
+       char buffer[4][TRACE_BUF_SIZE];
+ };
+-static struct trace_buffer_struct *trace_percpu_buffer;
++static struct trace_buffer_struct __percpu *trace_percpu_buffer;
+ /*
+  * Thise allows for lockless recording.  If we're nested too deeply, then
+@@ -2383,7 +2383,7 @@ static void put_trace_buf(void)
+ static int alloc_percpu_trace_buffer(void)
+ {
+-      struct trace_buffer_struct *buffers;
++      struct trace_buffer_struct __percpu *buffers;
+       buffers = alloc_percpu(struct trace_buffer_struct);
+       if (WARN(!buffers, "Could not allocate percpu trace_printk buffer"))
diff --git a/queue-4.9/virtio_pci-support-surprise-removal-of-virtio-pci-device.patch b/queue-4.9/virtio_pci-support-surprise-removal-of-virtio-pci-device.patch
new file mode 100644 (file)
index 0000000..6f74f4b
--- /dev/null
@@ -0,0 +1,76 @@
+From 43bb40c5b92659966bdf4bfe584fde0a3575a049 Mon Sep 17 00:00:00 2001
+From: Parav Pandit <parav@nvidia.com>
+Date: Wed, 21 Jul 2021 17:26:48 +0300
+Subject: virtio_pci: Support surprise removal of virtio pci device
+
+From: Parav Pandit <parav@nvidia.com>
+
+commit 43bb40c5b92659966bdf4bfe584fde0a3575a049 upstream.
+
+When a virtio pci device undergo surprise removal (aka async removal in
+PCIe spec), mark the device as broken so that any upper layer drivers can
+abort any outstanding operation.
+
+When a virtio net pci device undergo surprise removal which is used by a
+NetworkManager, a below call trace was observed.
+
+kernel:watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [kworker/1:1:27059]
+watchdog: BUG: soft lockup - CPU#1 stuck for 52s! [kworker/1:1:27059]
+CPU: 1 PID: 27059 Comm: kworker/1:1 Tainted: G S      W I  L    5.13.0-hotplug+ #8
+Hardware name: Dell Inc. PowerEdge R640/0H28RR, BIOS 2.9.4 11/06/2020
+Workqueue: events linkwatch_event
+RIP: 0010:virtnet_send_command+0xfc/0x150 [virtio_net]
+Call Trace:
+ virtnet_set_rx_mode+0xcf/0x2a7 [virtio_net]
+ ? __hw_addr_create_ex+0x85/0xc0
+ __dev_mc_add+0x72/0x80
+ igmp6_group_added+0xa7/0xd0
+ ipv6_mc_up+0x3c/0x60
+ ipv6_find_idev+0x36/0x80
+ addrconf_add_dev+0x1e/0xa0
+ addrconf_dev_config+0x71/0x130
+ addrconf_notify+0x1f5/0xb40
+ ? rtnl_is_locked+0x11/0x20
+ ? __switch_to_asm+0x42/0x70
+ ? finish_task_switch+0xaf/0x2c0
+ ? raw_notifier_call_chain+0x3e/0x50
+ raw_notifier_call_chain+0x3e/0x50
+ netdev_state_change+0x67/0x90
+ linkwatch_do_dev+0x3c/0x50
+ __linkwatch_run_queue+0xd2/0x220
+ linkwatch_event+0x21/0x30
+ process_one_work+0x1c8/0x370
+ worker_thread+0x30/0x380
+ ? process_one_work+0x370/0x370
+ kthread+0x118/0x140
+ ? set_kthread_struct+0x40/0x40
+ ret_from_fork+0x1f/0x30
+
+Hence, add the ability to abort the command on surprise removal
+which prevents infinite loop and system lockup.
+
+Signed-off-by: Parav Pandit <parav@nvidia.com>
+Link: https://lore.kernel.org/r/20210721142648.1525924-5-parav@nvidia.com
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Yang Wei <yang.wei@linux.alibaba.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/virtio/virtio_pci_common.c |    7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/virtio/virtio_pci_common.c
++++ b/drivers/virtio/virtio_pci_common.c
+@@ -547,6 +547,13 @@ static void virtio_pci_remove(struct pci
+       struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
+       struct device *dev = get_device(&vp_dev->vdev.dev);
++      /*
++       * Device is marked broken on surprise removal so that virtio upper
++       * layers can abort any ongoing operation.
++       */
++      if (!pci_device_is_present(pci_dev))
++              virtio_break_device(&vp_dev->vdev);
++
+       unregister_virtio_device(&vp_dev->vdev);
+       if (vp_dev->ioaddr)