Skip to contentSkip to conversation

4.19.87-stable review

PATCH In review Greg Kroah-Hartman 15 participants 359 messages Nov 27, 2019 – Jan 28, 2020 Page 3 of 3

Subsystems (7)
lore
Share & tools
lore
author maintainer
#318 lore raw

PATCH 287/306 media: uvcvideo: Fix error path in control parsing failure

In reply to Greg Kroah-Hartman

From: Laurent Pinchart <[email protected]>

commit 8c279e9394cade640ed86ec6c6645a0e7df5e0b6 upstream.

When parsing the UVC control descriptors fails, the error path tries to cleanup a media device that hasn't been initialised, potentially resulting in a crash. Fix this by initialising the media device before the error handling path can be reached.

Fixes 5a254d751e52 ("[media] uvcvideo: Register a v4l2_device")
Reported-by [email protected]
---
 drivers/media/usb/uvc/uvc_driver.c |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +15 -13
@@ -2124,6 +2124,20 @@ static int uvc_probe(struct usb_interfac
 			   sizeof(dev->name) - len);
 	}
 
+	/* Initialize the media device. */
+#ifdef CONFIG_MEDIA_CONTROLLER
+	dev->mdev.dev = &intf->dev;
+	strscpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model));
+	if (udev->serial)
+		strscpy(dev->mdev.serial, udev->serial,
+			sizeof(dev->mdev.serial));
+	usb_make_path(udev, dev->mdev.bus_info, sizeof(dev->mdev.bus_info));
+	dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
+	media_device_init(&dev->mdev);
+
+	dev->vdev.mdev = &dev->mdev;
+#endif
+
 	/* Parse the Video Class control descriptor. */
 	if (uvc_parse_control(dev) < 0) {
 		uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC "
@@ -2144,19 +2158,7 @@ static int uvc_probe(struct usb_interfac
 			"linux-uvc-devel mailing list.\n");
 	}
 
-	/* Initialize the media device and register the V4L2 device. */
-#ifdef CONFIG_MEDIA_CONTROLLER
-	dev->mdev.dev = &intf->dev;
-	strlcpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model));
-	if (udev->serial)
-		strlcpy(dev->mdev.serial, udev->serial,
-			sizeof(dev->mdev.serial));
-	strcpy(dev->mdev.bus_info, udev->devpath);
-	dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-	media_device_init(&dev->mdev);
-
-	dev->vdev.mdev = &dev->mdev;
-#endif
+	/* Register the V4L2 device. */
 	if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
 		goto error;
 
author maintainer
#319 lore raw

PATCH 288/306 media: b2c2-flexcop-usb: add sanity checking

In reply to Greg Kroah-Hartman

From: Oliver Neukum <[email protected]>

commit 1b976fc6d684e3282914cdbe7a8d68fdce19095c upstream.

The driver needs an isochronous endpoint to be present. It will oops in its absence. Add checking for it.

---
 drivers/media/usb/b2c2/flexcop-usb.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/media/usb/b2c2/flexcop-usb.c +3 -0
@@ -537,6 +537,9 @@ static int flexcop_usb_probe(struct usb_
 	struct flexcop_device *fc = NULL;
 	int ret;
 
+	if (intf->cur_altsetting->desc.bNumEndpoints < 1)
+		return -ENODEV;
+
 	if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
 		err("out of memory\n");
 		return -ENOMEM;
author maintainer
#320 lore raw

PATCH 289/306 media: cxusb: detect cxusb_ctrl_msg error in query

In reply to Greg Kroah-Hartman

From: Vito Caputo <[email protected]>

commit ca8f245f284eeffa56f3b7a5eb6fc503159ee028 upstream.

Don't use uninitialized ircode[] in cxusb_rc_query() when cxusb_ctrl_msg() fails to populate its contents.

syzbot reported:

dvb-usb: bulk message failed: -22 (1/-30591)
=====================================================

BUG: KMSAN: uninit-value in ir_lookup_by_scancode drivers/media/rc/rc-main.c:494 [inline]
BUG: KMSAN: uninit-value in rc_g_keycode_from_table drivers/media/rc/rc-main.c:582 [inline]
BUG: KMSAN: uninit-value in rc_keydown+0x1a6/0x6f0 drivers/media/rc/rc-main.c:816
CPU: 1 PID: 11436 Comm: kworker/1:2 Not tainted 5.3.0-rc7+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events dvb_usb_read_remote_control
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x191/0x1f0 lib/dump_stack.c:113
 kmsan_report+0x13a/0x2b0 mm/kmsan/kmsan_report.c:108
 __msan_warning+0x73/0xe0 mm/kmsan/kmsan_instr.c:250
 bsearch+0x1dd/0x250 lib/bsearch.c:41
 ir_lookup_by_scancode drivers/media/rc/rc-main.c:494 [inline]
 rc_g_keycode_from_table drivers/media/rc/rc-main.c:582 [inline]
 rc_keydown+0x1a6/0x6f0 drivers/media/rc/rc-main.c:816
 cxusb_rc_query+0x2e1/0x360 drivers/media/usb/dvb-usb/cxusb.c:548
 dvb_usb_read_remote_control+0xf9/0x290 drivers/media/usb/dvb-usb/dvb-usb-remote.c:261
 process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269
 worker_thread+0x111b/0x2460 kernel/workqueue.c:2415
 kthread+0x4b5/0x4f0 kernel/kthread.c:256
 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355

Uninit was stored to memory at:

 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:150 [inline]
 kmsan_internal_chain_origin+0xd2/0x170 mm/kmsan/kmsan.c:314
 __msan_chain_origin+0x6b/0xe0 mm/kmsan/kmsan_instr.c:184
 rc_g_keycode_from_table drivers/media/rc/rc-main.c:583 [inline]
 rc_keydown+0x2c4/0x6f0 drivers/media/rc/rc-main.c:816
 cxusb_rc_query+0x2e1/0x360 drivers/media/usb/dvb-usb/cxusb.c:548
 dvb_usb_read_remote_control+0xf9/0x290 drivers/media/usb/dvb-usb/dvb-usb-remote.c:261
 process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269
 worker_thread+0x111b/0x2460 kernel/workqueue.c:2415
 kthread+0x4b5/0x4f0 kernel/kthread.c:256
 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355

Local variable description: ----ircode@cxusb_rc_query Variable was created at:

 cxusb_rc_query+0x4d/0x360 drivers/media/usb/dvb-usb/cxusb.c:543
 dvb_usb_read_remote_control+0xf9/0x290 drivers/media/usb/dvb-usb/dvb-usb-remote.c:261
---
 drivers/media/usb/dvb-usb/cxusb.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb/cxusb.c +2 -1
@@ -457,7 +457,8 @@ static int cxusb_rc_query(struct dvb_usb
 {
 	u8 ircode[4];
 
-	cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
+	if (cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4) < 0)
+		return 0;
 
 	if (ircode[2] || ircode[3])
 		rc_keydown(d->rc_dev, RC_PROTO_NEC,
author maintainer
#321 lore raw

PATCH 290/306 media: imon: invalid dereference in imon_touch_event

In reply to Greg Kroah-Hartman

From: Sean Young <[email protected]>

commit f3f5ba42c58d56d50f539854d8cc188944e96087 upstream.

The touch timer is set up in intf1. If the second interface does not exist, the timer and touch input device are not setup and we get the following error, when touch events are reported via intf0.

kernel BUG at kernel/time/timer.c:956!
invalid opcode: 0000 [#1] SMP KASAN

CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.0-rc1+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__mod_timer kernel/time/timer.c:956 [inline]
RIP: 0010:__mod_timer kernel/time/timer.c:949 [inline]
RIP: 0010:mod_timer+0x5a2/0xb50 kernel/time/timer.c:1100
Code: 45 10 c7 44 24 14 ff ff ff ff 48 89 44 24 08 48 8d 45 20 48 c7 44 24 18 00 00 00 00 48 89 04 24 e9 5a fc ff ff e8 ae ce 0e 00 <0f> 0b e8 a7 ce 0e 00 4c 89 74 24 20 e9 37 fe ff ff e8 98 ce 0e 00
RSP: 0018:ffff8881db209930 EFLAGS: 00010006
RAX: ffffffff86c2b200 RBX: 00000000ffffa688 RCX: ffffffff83efc583
RDX: 0000000000000100 RSI: ffffffff812f4d82 RDI: ffff8881d2356200
RBP: ffff8881d23561e8 R08: ffffffff86c2b200 R09: ffffed103a46abeb
R10: ffffed103a46abea R11: ffff8881d2355f53 R12: dffffc0000000000
R13: 1ffff1103b64132d R14: ffff8881d2355f50 R15: 0000000000000006
FS:  0000000000000000(0000) GS:ffff8881db200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f75e2799000 CR3: 00000001d3b07000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <IRQ>
 imon_touch_event drivers/media/rc/imon.c:1348 [inline]
 imon_incoming_packet.isra.0+0x2546/0x2f10 drivers/media/rc/imon.c:1603
 usb_rx_callback_intf0+0x151/0x1e0 drivers/media/rc/imon.c:1734
 __usb_hcd_giveback_urb+0x1f2/0x470 drivers/usb/core/hcd.c:1654
 usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1719
 dummy_timer+0x120f/0x2fa2 drivers/usb/gadget/udc/dummy_hcd.c:1965
 call_timer_fn+0x179/0x650 kernel/time/timer.c:1404
 expire_timers kernel/time/timer.c:1449 [inline]
 __run_timers kernel/time/timer.c:1773 [inline]
 __run_timers kernel/time/timer.c:1740 [inline]
 run_timer_softirq+0x5e3/0x1490 kernel/time/timer.c:1786
 __do_softirq+0x221/0x912 kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x178/0x1a0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x12f/0x500 arch/x86/kernel/apic/apic.c:1137
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:830
 </IRQ>
RIP: 0010:default_idle+0x28/0x2e0 arch/x86/kernel/process.c:581
Code: 90 90 41 56 41 55 65 44 8b 2d 44 3a 8f 7a 41 54 55 53 0f 1f 44 00 00 e8 36 ee d0 fb e9 07 00 00 00 0f 00 2d fa dd 4f 00 fb f4 <65> 44 8b 2d 20 3a 8f 7a 0f 1f 44 00 00 5b 5d 41 5c 41 5d 41 5e c3
RSP: 0018:ffffffff86c07da8 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: 0000000000000007 RBX: ffffffff86c2b200 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffffffff86c2ba4c
RBP: fffffbfff0d85640 R08: ffffffff86c2b200 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 cpuidle_idle_call kernel/sched/idle.c:154 [inline]
 do_idle+0x3b6/0x500 kernel/sched/idle.c:263
 cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:355
 start_kernel+0x82a/0x864 init/main.c:784
 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:241
Modules linked in:
---
 drivers/media/rc/imon.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/rc/imon.c +1 -2
@@ -1607,8 +1607,7 @@ static void imon_incoming_packet(struct
 	spin_unlock_irqrestore(&ictx->kc_lock, flags);
 
 	/* send touchscreen events through input subsystem if touchpad data */
-	if (ictx->display_type == IMON_DISPLAY_TYPE_VGA && len == 8 &&
-	    buf[7] == 0x86) {
+	if (ictx->touch && len == 8 && buf[7] == 0x86) {
 		imon_touch_event(ictx, buf);
 		return;
 
author maintainer
#322 lore raw

PATCH 291/306 virtio_ring: fix return code on DMA mapping fails

In reply to Greg Kroah-Hartman

From: Halil Pasic <[email protected]>

[ Upstream commit f7728002c1c7bfa787b276a31c3ef458739b8e7c ]

Commit 780bc7903a32 ("virtio_ring: Support DMA APIs") makes virtqueue_add() return -EIO when we fail to map our I/O buffers. This is a very realistic scenario for guests with encrypted memory, as swiotlb may run out of space, depending on it's size and the I/O load.

The virtio-blk driver interprets -EIO form virtqueue_add() as an IO error, despite the fact that swiotlb full is in absence of bugs a recoverable condition.

Let us change the return code to -ENOMEM, and make the block layer recover form these failures when virtio-blk encounters the condition described above.

Fixes 780bc7903a32 ("virtio_ring: Support DMA APIs")
---
 drivers/virtio/virtio_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_ring.c +1 -1
index 9529e28e18222..6228b48d1e127 100644
@@ -431,7 +431,7 @@ unmap_release:
 		kfree(desc);
 
 	END_USE(vq);
-	return -EIO;
+	return -ENOMEM;
 }
 
 /**
Signature · 1 line
2.20.1
author maintainer
#323 lore raw

PATCH 292/306 USBIP: add config dependency for SGL_ALLOC

In reply to Greg Kroah-Hartman

From: Oliver Neukum <[email protected]>

commit 1ec13abac58b6f24e32f0d3081ef4e7456e62ed8 upstream.

USBIP uses lib/scatterlist.h
Hence it needs to set CONFIG_SGL_ALLOC

---
 drivers/usb/usbip/Kconfig |    1 +
 1 file changed, 1 insertion(+)
drivers/usb/usbip/Kconfig +1 -0
@@ -2,6 +2,7 @@ config USBIP_CORE
 	tristate "USB/IP support"
 	depends on NET
 	select USB_COMMON
+	select SGL_ALLOC
 	---help---
 	  This enables pushing USB packets over IP to allow remote
 	  machines direct access to USB devices. It provides the
author maintainer
#324 lore raw

PATCH 293/306 usbip: tools: fix fd leakage in the function of read_attr_usbip_status

In reply to Greg Kroah-Hartman

From: Hewenliang <[email protected]>

commit 26a4d4c00f85cb844dd11dd35e848b079c2f5e8f upstream.

We should close the fd before the return of read_attr_usbip_status.

Fixes 3391ba0e2792 ("usbip: tools: Extract generic code to be shared with vudc backend")
Cc stable <[email protected]>
---
 tools/usb/usbip/libsrc/usbip_host_common.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/usb/usbip/libsrc/usbip_host_common.c +1 -1
@@ -69,7 +69,7 @@ static int32_t read_attr_usbip_status(st
 	}
 
 	value = atoi(status);
-
+	close(fd);
 	return value;
 }
 
author maintainer
#325 lore raw

PATCH 294/306 usbip: Fix uninitialized symbol nents in stub_recv_cmd_submit()

In reply to Greg Kroah-Hartman

From: Suwan Kim <[email protected]>

commit 2a9125317b247f2cf35c196f968906dcf062ae2d upstream.

Smatch reported that nents is not initialized and used in stub_recv_cmd_submit(). nents is currently initialized by sgl_alloc() and used to allocate multiple URBs when host controller doesn't support scatter-gather DMA. The use of uninitialized nents means that buf_len is zero and use_sg is true. But buffer length should not be zero when an URB uses scatter-gather DMA.

To prevent this situation, add the conditional that checks buf_len and use_sg. And move the use of nents right after the sgl_alloc() to avoid the use of uninitialized nents.

If the error occurs, it adds SDEV_EVENT_ERROR_MALLOC and stub_priv will be released by stub event handler and connection will be shut down.

---
 drivers/usb/usbip/stub_rx.c |   50 ++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 18 deletions(-)
drivers/usb/usbip/stub_rx.c +32 -18
@@ -470,18 +470,50 @@ static void stub_recv_cmd_submit(struct
 	if (pipe == -1)
 		return;
 
+	/*
+	 * Smatch reported the error case where use_sg is true and buf_len is 0.
+	 * In this case, It adds SDEV_EVENT_ERROR_MALLOC and stub_priv will be
+	 * released by stub event handler and connection will be shut down.
+	 */
 	priv = stub_priv_alloc(sdev, pdu);
 	if (!priv)
 		return;
 
 	buf_len = (unsigned long long)pdu->u.cmd_submit.transfer_buffer_length;
 
+	if (use_sg && !buf_len) {
+		dev_err(&udev->dev, "sg buffer with zero length\n");
+		goto err_malloc;
+	}
+
 	/* allocate urb transfer buffer, if needed */
 	if (buf_len) {
 		if (use_sg) {
 			sgl = sgl_alloc(buf_len, GFP_KERNEL, &nents);
 			if (!sgl)
 				goto err_malloc;
+
+			/* Check if the server's HCD supports SG */
+			if (!udev->bus->sg_tablesize) {
+				/*
+				 * If the server's HCD doesn't support SG, break
+				 * a single SG request into several URBs and map
+				 * each SG list entry to corresponding URB
+				 * buffer. The previously allocated SG list is
+				 * stored in priv->sgl (If the server's HCD
+				 * support SG, SG list is stored only in
+				 * urb->sg) and it is used as an indicator that
+				 * the server split single SG request into
+				 * several URBs. Later, priv->sgl is used by
+				 * stub_complete() and stub_send_ret_submit() to
+				 * reassemble the divied URBs.
+				 */
+				support_sg = 0;
+				num_urbs = nents;
+				priv->completed_urbs = 0;
+				pdu->u.cmd_submit.transfer_flags &=
+								~URB_DMA_MAP_SG;
+			}
 		} else {
 			buffer = kzalloc(buf_len, GFP_KERNEL);
 			if (!buffer)
@@ -489,24 +521,6 @@ static void stub_recv_cmd_submit(struct
 		}
 	}
 
-	/* Check if the server's HCD supports SG */
-	if (use_sg && !udev->bus->sg_tablesize) {
-		/*
-		 * If the server's HCD doesn't support SG, break a single SG
-		 * request into several URBs and map each SG list entry to
-		 * corresponding URB buffer. The previously allocated SG
-		 * list is stored in priv->sgl (If the server's HCD support SG,
-		 * SG list is stored only in urb->sg) and it is used as an
-		 * indicator that the server split single SG request into
-		 * several URBs. Later, priv->sgl is used by stub_complete() and
-		 * stub_send_ret_submit() to reassemble the divied URBs.
-		 */
-		support_sg = 0;
-		num_urbs = nents;
-		priv->completed_urbs = 0;
-		pdu->u.cmd_submit.transfer_flags &= ~URB_DMA_MAP_SG;
-	}
-
 	/* allocate urb array */
 	priv->num_urbs = num_urbs;
 	priv->urbs = kmalloc_array(num_urbs, sizeof(*priv->urbs), GFP_KERNEL);
author maintainer
#326 lore raw

PATCH 295/306 usb-serial: cp201x: support Mark-10 digital force gauge

In reply to Greg Kroah-Hartman

From: Greg Kroah-Hartman <[email protected]>

commit 347bc8cb26388791c5881a3775cb14a3f765a674 upstream.

Add support for the Mark-10 digital force gauge device to the cp201x driver.

Based on a report and a larger patch from Joel Jennings

---
 drivers/usb/serial/cp210x.c |    1 +
 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -125,6 +125,7 @@ static const struct usb_device_id id_tab
 	{ USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
 	{ USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
 	{ USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
+	{ USB_DEVICE(0x10C4, 0x83AA) }, /* Mark-10 Digital Force Gauge */
 	{ USB_DEVICE(0x10C4, 0x83D8) }, /* DekTec DTA Plus VHF/UHF Booster/Attenuator */
 	{ USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
 	{ USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
author maintainer
#327 lore raw

PATCH 296/306 USB: chaoskey: fix error case of a timeout

In reply to Greg Kroah-Hartman

From: Oliver Neukum <[email protected]>

commit 92aa5986f4f7b5a8bf282ca0f50967f4326559f5 upstream.

In case of a timeout or if a signal aborts a read communication with the device needs to be ended lest we overwrite an active URB the next time we do IO to the device, as the URB may still be active.

---
 drivers/usb/misc/chaoskey.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/usb/misc/chaoskey.c +21 -3
@@ -384,13 +384,17 @@ static int _chaoskey_fill(struct chaoske
 		!dev->reading,
 		(started ? NAK_TIMEOUT : ALEA_FIRST_TIMEOUT) );
 
-	if (result < 0)
+	if (result < 0) {
+		usb_kill_urb(dev->urb);
 		goto out;
+	}
 
-	if (result == 0)
+	if (result == 0) {
 		result = -ETIMEDOUT;
-	else
+		usb_kill_urb(dev->urb);
+	} else {
 		result = dev->valid;
+	}
 out:
 	/* Let the device go back to sleep eventually */
 	usb_autopm_put_interface(dev->interface);
@@ -526,7 +530,21 @@ static int chaoskey_suspend(struct usb_i
 
 static int chaoskey_resume(struct usb_interface *interface)
 {
+	struct chaoskey *dev;
+	struct usb_device *udev = interface_to_usbdev(interface);
+
 	usb_dbg(interface, "resume");
+	dev = usb_get_intfdata(interface);
+
+	/*
+	 * We may have lost power.
+	 * In that case the device that needs a long time
+	 * for the first requests needs an extended timeout
+	 * again
+	 */
+	if (le16_to_cpu(udev->descriptor.idVendor) == ALEA_VENDOR_ID)
+		dev->reads_started = false;
+
 	return 0;
 }
 #else
author maintainer
#328 lore raw

PATCH 297/306 appledisplay: fix error handling in the scheduled work

In reply to Greg Kroah-Hartman

From: Oliver Neukum <[email protected]>

commit 91feb01596e5efc0cc922cc73f5583114dccf4d2 upstream.

The work item can operate on

1. stale memory left over from the last transfer the actual length of the data transfered needs to be checked
2. memory already freed
the error handling in appledisplay_probe() needs to cancel the work in that case

---
 drivers/usb/misc/appledisplay.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/misc/appledisplay.c +7 -1
@@ -170,7 +170,12 @@ static int appledisplay_bl_get_brightnes
 		0,
 		pdata->msgdata, 2,
 		ACD_USB_TIMEOUT);
-	brightness = pdata->msgdata[1];
+	if (retval < 2) {
+		if (retval >= 0)
+			retval = -EMSGSIZE;
+	} else {
+		brightness = pdata->msgdata[1];
+	}
 	mutex_unlock(&pdata->sysfslock);
 
 	if (retval < 0)
@@ -305,6 +310,7 @@ error:
 	if (pdata) {
 		if (pdata->urb) {
 			usb_kill_urb(pdata->urb);
+			cancel_delayed_work_sync(&pdata->work);
 			if (pdata->urbdata)
 				usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
 					pdata->urbdata, pdata->urb->transfer_dma);
author maintainer
#329 lore raw

PATCH 298/306 USB: serial: mos7840: add USB ID to support Moxa UPort 2210

In reply to Greg Kroah-Hartman

From: Pavel Löbl <[email protected]>

commit e696d00e65e81d46e911f24b12e441037bf11b38 upstream.

Add USB ID for MOXA UPort 2210. This device contains mos7820 but it passes GPIO0 check implemented by driver and it's detected as mos7840. Hence product id check is added to force mos7820 mode.

Cc stable <[email protected]>
[ johan: rename id defines and add vendor-id check ]
---
 drivers/usb/serial/mos7840.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/serial/mos7840.c +11 -0
@@ -118,11 +118,15 @@
 /* This driver also supports
  * ATEN UC2324 device using Moschip MCS7840
  * ATEN UC2322 device using Moschip MCS7820
+ * MOXA UPort 2210 device using Moschip MCS7820
  */
 #define USB_VENDOR_ID_ATENINTL		0x0557
 #define ATENINTL_DEVICE_ID_UC2324	0x2011
 #define ATENINTL_DEVICE_ID_UC2322	0x7820
 
+#define USB_VENDOR_ID_MOXA		0x110a
+#define MOXA_DEVICE_ID_2210		0x2210
+
 /* Interrupt Routine Defines    */
 
 #define SERIAL_IIR_RLS      0x06
@@ -193,6 +197,7 @@ static const struct usb_device_id id_tab
 	{USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
 	{USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
 	{USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
+	{USB_DEVICE(USB_VENDOR_ID_MOXA, MOXA_DEVICE_ID_2210)},
 	{}			/* terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, id_table);
@@ -2053,6 +2058,7 @@ static int mos7840_probe(struct usb_seri
 				const struct usb_device_id *id)
 {
 	u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
+	u16 vid = le16_to_cpu(serial->dev->descriptor.idVendor);
 	u8 *buf;
 	int device_type;
 
@@ -2062,6 +2068,11 @@ static int mos7840_probe(struct usb_seri
 		goto out;
 	}
 
+	if (vid == USB_VENDOR_ID_MOXA && product == MOXA_DEVICE_ID_2210) {
+		device_type = MOSCHIP_DEVICE_ID_7820;
+		goto out;
+	}
+
 	buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
author maintainer
#330 lore raw

PATCH 299/306 USB: serial: mos7720: fix remote wakeup

In reply to Greg Kroah-Hartman

From: Johan Hovold <[email protected]>

commit ea422312a462696093b5db59d294439796cba4ad upstream.

The driver was setting the device remote-wakeup feature during probe in violation of the USB specification (which says it should only be set just prior to suspending the device). This could potentially waste power during suspend as well as lead to spurious wakeups.

Note that USB core would clear the remote-wakeup feature at first resume.

Fixes 0f64478cbc7a ("USB: add USB serial mos7720 driver")
Cc stable <[email protected]> # 2.6.19
---
 drivers/usb/serial/mos7720.c |    4 ----
 1 file changed, 4 deletions(-)
drivers/usb/serial/mos7720.c +0 -4
@@ -1894,10 +1894,6 @@ static int mos7720_startup(struct usb_se
 	product = le16_to_cpu(serial->dev->descriptor.idProduct);
 	dev = serial->dev;
 
-	/* setting configuration feature to one */
-	usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-			(__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000);
-
 	if (product == MOSCHIP_DEVICE_ID_7715) {
 		struct urb *urb = serial->port[0]->interrupt_in_urb;
 
author maintainer
#331 lore raw

PATCH 300/306 USB: serial: mos7840: fix remote wakeup

In reply to Greg Kroah-Hartman

From: Johan Hovold <[email protected]>

commit 92fe35fb9c70a00d8fbbf5bd6172c921dd9c7815 upstream.

The driver was setting the device remote-wakeup feature during probe in violation of the USB specification (which says it should only be set just prior to suspending the device). This could potentially waste power during suspend as well as lead to spurious wakeups.

Note that USB core would clear the remote-wakeup feature at first resume.

Fixes 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
Cc stable <[email protected]> # 2.6.19
---
 drivers/usb/serial/mos7840.c |    5 -----
 1 file changed, 5 deletions(-)
drivers/usb/serial/mos7840.c +0 -5
@@ -2325,11 +2325,6 @@ out:
 			goto error;
 		} else
 			dev_dbg(&port->dev, "ZLP_REG5 Writing success status%d\n", status);
-
-		/* setting configuration feature to one */
-		usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-				0x03, 0x00, 0x01, 0x00, NULL, 0x00,
-				MOS_WDR_TIMEOUT);
 	}
 	return 0;
 error:
author maintainer
#332 lore raw

PATCH 301/306 USB: serial: option: add support for DW5821e with eSIM support

In reply to Greg Kroah-Hartman

From: Aleksander Morgado <[email protected]>

commit 957c31ea082e3fe5196f46d5b04018b10de47400 upstream.

The device exposes AT, NMEA and DIAG ports in both USB configurations. Exactly same layout as the default DW5821e module, just a different vid/pid.

P:  Vendor=413c ProdID=81e0 Rev=03.18
S:  Manufacturer=Dell Inc.
S:  Product=DW5821e-eSIM Snapdragon X20 LTE
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#=0x1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
P:  Vendor=413c ProdID=81e0 Rev=03.18
S:  Manufacturer=Dell Inc.
S:  Product=DW5821e-eSIM Snapdragon X20 LTE
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 7 Cfg#= 2 Atr=a0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#=0x6 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
---
 drivers/usb/serial/option.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -197,6 +197,7 @@ static void option_instat_callback(struc
 #define DELL_PRODUCT_5804_MINICARD_ATT		0x819b  /* Novatel E371 */
 
 #define DELL_PRODUCT_5821E			0x81d7
+#define DELL_PRODUCT_5821E_ESIM			0x81e0
 
 #define KYOCERA_VENDOR_ID			0x0c88
 #define KYOCERA_PRODUCT_KPC650			0x17da
@@ -1044,6 +1045,8 @@ static const struct usb_device_id option
 	{ USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5804_MINICARD_ATT, 0xff, 0xff, 0xff) },
 	{ USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E),
 	  .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
+	{ USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E_ESIM),
+	  .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
 	{ USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) },	/* ADU-E100, ADU-310 */
 	{ USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
 	{ USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
author maintainer
#333 lore raw

PATCH 302/306 USB: serial: option: add support for Foxconn T77W968 LTE modules

In reply to Greg Kroah-Hartman

From: Aleksander Morgado <[email protected]>

commit f0797095423e6ea3b4be61134ee353c7f504d440 upstream.

These are the Foxconn-branded variants of the Dell DW5821e modules, same USB layout as those. The device exposes AT, NMEA and DIAG ports in both USB configurations.

P:  Vendor=0489 ProdID=e0b4 Rev=03.18
S:  Manufacturer=FII
S:  Product=T77W968 LTE
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#=0x1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
P:  Vendor=0489 ProdID=e0b4 Rev=03.18
S:  Manufacturer=FII
S:  Product=T77W968 LTE
S:  SerialNumber=0123456789ABCDEF
C:  #Ifs= 7 Cfg#= 2 Atr=a0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I:  If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I:  If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
I:  If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#=0x6 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
---
 drivers/usb/serial/option.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/serial/option.c +4 -0
@@ -1993,6 +1993,10 @@ static const struct usb_device_id option
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x13) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x14) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x1b) },
+	{ USB_DEVICE(0x0489, 0xe0b4),						/* Foxconn T77W968 */
+	  .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
+	{ USB_DEVICE(0x0489, 0xe0b5),						/* Foxconn T77W968 ESIM */
+	  .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
 	{ USB_DEVICE(0x1508, 0x1001),						/* Fibocom NL668 */
 	  .driver_info = RSVD(4) | RSVD(5) | RSVD(6) },
 	{ USB_DEVICE(0x2cb7, 0x0104),						/* Fibocom NL678 series */
author maintainer
#334 lore raw

PATCH 303/306 staging: comedi: usbduxfast: usbduxfast_ai_cmdtest rounding error

In reply to Greg Kroah-Hartman

From: Bernd Porr <[email protected]>

commit 5618332e5b955b4bff06d0b88146b971c8dd7b32 upstream.

The userspace comedilib function 'get_cmd_generic_timed' fills the cmd structure with an informed guess and then calls the function 'usbduxfast_ai_cmdtest' in this driver repeatedly while 'usbduxfast_ai_cmdtest' is modifying the cmd struct until it no longer changes. However, because of rounding errors this never converged because 'steps = (cmd->convert_arg * 30) / 1000' and then back to 'cmd->convert_arg = (steps * 1000) / 30' won't be the same because of rounding errors. 'Steps' should only be converted back to the 'convert_arg' if 'steps' has actually been modified. In addition the case of steps being 0 wasn't checked which is also now done.

---
 drivers/staging/comedi/drivers/usbduxfast.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/staging/comedi/drivers/usbduxfast.c +14 -7
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2004-2014 Bernd Porr, [email protected]
+ *  Copyright (C) 2004-2019 Bernd Porr, [email protected]
  */
 
 /*
@@ -8,7 +8,7 @@
  * Description: University of Stirling USB DAQ & INCITE Technology Limited
  * Devices: [ITL] USB-DUX-FAST (usbduxfast)
  * Author: Bernd Porr <[email protected]>
- * Updated: 10 Oct 2014
+ * Updated: 16 Nov 2019
  * Status: stable
  */
 
@@ -22,6 +22,7 @@
  *
  *
  * Revision history:
+ * 1.0: Fixed a rounding error in usbduxfast_ai_cmdtest
  * 0.9: Dropping the first data packet which seems to be from the last transfer.
  *      Buffer overflows in the FX2 are handed over to comedi.
  * 0.92: Dropping now 4 packets. The quad buffer has to be emptied.
@@ -350,6 +351,7 @@ static int usbduxfast_ai_cmdtest(struct
 				 struct comedi_cmd *cmd)
 {
 	int err = 0;
+	int err2 = 0;
 	unsigned int steps;
 	unsigned int arg;
 
@@ -399,11 +401,16 @@ static int usbduxfast_ai_cmdtest(struct
 	 */
 	steps = (cmd->convert_arg * 30) / 1000;
 	if (cmd->chanlist_len !=  1)
-		err |= comedi_check_trigger_arg_min(&steps,
-						    MIN_SAMPLING_PERIOD);
-	err |= comedi_check_trigger_arg_max(&steps, MAX_SAMPLING_PERIOD);
-	arg = (steps * 1000) / 30;
-	err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
+		err2 |= comedi_check_trigger_arg_min(&steps,
+						     MIN_SAMPLING_PERIOD);
+	else
+		err2 |= comedi_check_trigger_arg_min(&steps, 1);
+	err2 |= comedi_check_trigger_arg_max(&steps, MAX_SAMPLING_PERIOD);
+	if (err2) {
+		err |= err2;
+		arg = (steps * 1000) / 30;
+		err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
+	}
 
 	if (cmd->stop_src == TRIG_COUNT)
 		err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
author maintainer
#335 lore raw

PATCH 304/306 powerpc/64s: support nospectre_v2 cmdline option

In reply to Greg Kroah-Hartman

From: "Christopher M. Riedl" <[email protected]>

commit d8f0e0b073e1ec52a05f0c2a56318b47387d2f10 upstream.

Add support for disabling the kernel implemented spectre v2 mitigation (count cache flush on context switch) via the nospectre_v2 and mitigations=off cmdline options.

---
 arch/powerpc/kernel/security.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
arch/powerpc/kernel/security.c +16 -3
@@ -28,7 +28,7 @@ static enum count_cache_flush_type count
 bool barrier_nospec_enabled;
 static bool no_nospec;
 static bool btb_flush_enabled;
-#ifdef CONFIG_PPC_FSL_BOOK3E
+#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
 static bool no_spectrev2;
 #endif
 
@@ -106,7 +106,7 @@ static __init int barrier_nospec_debugfs
 device_initcall(barrier_nospec_debugfs_init);
 #endif /* CONFIG_DEBUG_FS */
 
-#ifdef CONFIG_PPC_FSL_BOOK3E
+#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64)
 static int __init handle_nospectre_v2(char *p)
 {
 	no_spectrev2 = true;
@@ -114,6 +114,9 @@ static int __init handle_nospectre_v2(ch
 	return 0;
 }
 early_param("nospectre_v2", handle_nospectre_v2);
+#endif /* CONFIG_PPC_FSL_BOOK3E || CONFIG_PPC_BOOK3S_64 */
+
+#ifdef CONFIG_PPC_FSL_BOOK3E
 void setup_spectre_v2(void)
 {
 	if (no_spectrev2 || cpu_mitigations_off())
@@ -391,7 +394,17 @@ static void toggle_count_cache_flush(boo
 
 void setup_count_cache_flush(void)
 {
-	toggle_count_cache_flush(true);
+	bool enable = true;
+
+	if (no_spectrev2 || cpu_mitigations_off()) {
+		if (security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED) ||
+		    security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED))
+			pr_warn("Spectre v2 mitigations not under software control, can't disable\n");
+
+		enable = false;
+	}
+
+	toggle_count_cache_flush(enable);
 }
 
 #ifdef CONFIG_DEBUG_FS
author maintainer
#336 lore raw

PATCH 305/306 powerpc/book3s64: Fix link stack flush on context switch

In reply to Greg Kroah-Hartman

From: Michael Ellerman <[email protected]>

commit 39e72bf96f5847ba87cc5bd7a3ce0fed813dc9ad upstream.

In commit ee13cb249fab ("powerpc/64s: Add support for software count cache flush"), I added support for software to flush the count cache (indirect branch cache) on context switch if firmware told us that was the required mitigation for Spectre v2.

As part of that code we also added a software flush of the link stack (return address stack), which protects against Spectre-RSB between user processes.

That is all correct for CPUs that activate that mitigation, which is currently Power9 Nimbus DD2.3.

What I got wrong is that on older CPUs, where firmware has disabled the count cache, we also need to flush the link stack on context switch.

To fix it we create a new feature bit which is not set by firmware, which tells us we need to flush the link stack. We set that when firmware tells us that either of the existing Spectre v2 mitigations are enabled.

Then we adjust the patching code so that if we see that feature bit we enable the link stack flush. If we're also told to flush the count cache in software then we fall through and do that also.

On the older CPUs we don't need to do do the software count cache flush, firmware has disabled it, so in that case we patch in an early return after the link stack flush.

The naming of some of the functions is awkward after this patch, because they're called "count cache" but they also do link stack. But we'll fix that up in a later commit to ease backporting.

This is the fix for CVE-2019-18660.

Fixes ee13cb249fab ("powerpc/64s: Add support for software count cache flush")
---
 arch/powerpc/include/asm/asm-prototypes.h    |    1 
 arch/powerpc/include/asm/security_features.h |    3 +
 arch/powerpc/kernel/entry_64.S               |    6 +++
 arch/powerpc/kernel/security.c               |   48 ++++++++++++++++++++++++---
 4 files changed, 54 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/asm-prototypes.h +1 -0
@@ -146,6 +146,7 @@ void _kvmppc_save_tm_pr(struct kvm_vcpu
 /* Patch sites */
 extern s32 patch__call_flush_count_cache;
 extern s32 patch__flush_count_cache_return;
+extern s32 patch__flush_link_stack_return;
 extern s32 patch__memset_nocache, patch__memcpy_nocache;
 
 extern long flush_count_cache;
arch/powerpc/include/asm/security_features.h +3 -0
@@ -81,6 +81,9 @@ static inline bool security_ftr_enabled(
 // Software required to flush count cache on context switch
 #define SEC_FTR_FLUSH_COUNT_CACHE	0x0000000000000400ull
 
+// Software required to flush link stack on context switch
+#define SEC_FTR_FLUSH_LINK_STACK	0x0000000000001000ull
+
 
 // Features enabled by default
 #define SEC_FTR_DEFAULT \
arch/powerpc/kernel/entry_64.S +6 -0
@@ -533,6 +533,7 @@ flush_count_cache:
 	/* Save LR into r9 */
 	mflr	r9
 
+	// Flush the link stack
 	.rept 64
 	bl	.+4
 	.endr
@@ -542,6 +543,11 @@ flush_count_cache:
 	.balign 32
 	/* Restore LR */
 1:	mtlr	r9
+
+	// If we're just flushing the link stack, return here
+3:	nop
+	patch_site 3b patch__flush_link_stack_return
+
 	li	r9,0x7fff
 	mtctr	r9
 
arch/powerpc/kernel/security.c +44 -4

90 lines not on this page · raw message

author maintainer
#337 lore raw

PATCH 306/306 KVM: PPC: Book3S HV: Flush link stack on guest exit to host kernel

In reply to Greg Kroah-Hartman

From: Michael Ellerman <[email protected]>

commit af2e8c68b9c5403f77096969c516f742f5bb29e0 upstream.

On some systems that are vulnerable to Spectre v2, it is up to software to flush the link stack (return address stack), in order to protect against Spectre-RSB.

When exiting from a guest we do some house keeping and then potentially exit to C code which is several stack frames deep in the host kernel. We will then execute a series of returns without preceeding calls, opening up the possiblity that the guest could have poisoned the link stack, and direct speculative execution of the host to a gadget of some sort.

To prevent this we add a flush of the link stack on exit from a guest.

[dja: straightforward backport to v4.19]
---
 arch/powerpc/include/asm/asm-prototypes.h |    2 ++
 arch/powerpc/kernel/security.c            |    9 +++++++++
 arch/powerpc/kvm/book3s_hv_rmhandlers.S   |   28 ++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+)
arch/powerpc/include/asm/asm-prototypes.h +2 -0
@@ -147,8 +147,10 @@ void _kvmppc_save_tm_pr(struct kvm_vcpu
 extern s32 patch__call_flush_count_cache;
 extern s32 patch__flush_count_cache_return;
 extern s32 patch__flush_link_stack_return;
+extern s32 patch__call_kvm_flush_link_stack;
 extern s32 patch__memset_nocache, patch__memcpy_nocache;
 
 extern long flush_count_cache;
+extern long kvm_flush_link_stack;
 
 #endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */
arch/powerpc/kernel/security.c +9 -0
@@ -392,6 +392,9 @@ static void toggle_count_cache_flush(boo
 
 	if (!enable) {
 		patch_instruction_site(&patch__call_flush_count_cache, PPC_INST_NOP);
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+		patch_instruction_site(&patch__call_kvm_flush_link_stack, PPC_INST_NOP);
+#endif
 		pr_info("link-stack-flush: software flush disabled.\n");
 		link_stack_flush_enabled = false;
 		no_count_cache_flush();
@@ -402,6 +405,12 @@ static void toggle_count_cache_flush(boo
 	patch_branch_site(&patch__call_flush_count_cache,
 			  (u64)&flush_count_cache, BRANCH_SET_LINK);
 
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+	// This enables the branch from guest_exit_cont to kvm_flush_link_stack
+	patch_branch_site(&patch__call_kvm_flush_link_stack,
+			  (u64)&kvm_flush_link_stack, BRANCH_SET_LINK);
+#endif
+
 	pr_info("link-stack-flush: software flush enabled.\n");
 	link_stack_flush_enabled = true;
 
arch/powerpc/kvm/book3s_hv_rmhandlers.S +28 -0
@@ -18,6 +18,7 @@
  */
 
 #include <asm/ppc_asm.h>
+#include <asm/code-patching-asm.h>
 #include <asm/kvm_asm.h>
 #include <asm/reg.h>
 #include <asm/mmu.h>
@@ -1559,6 +1560,10 @@ mc_cont:
 1:
 #endif /* CONFIG_KVM_XICS */
 
+	/* Possibly flush the link stack here. */
+1:	nop
+	patch_site 1b patch__call_kvm_flush_link_stack
+
 	/* For hash guest, read the guest SLB and save it away */
 	ld	r5, VCPU_KVM(r9)
 	lbz	r0, KVM_RADIX(r5)
@@ -2107,6 +2112,29 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
 	mtlr	r0
 	blr
 
+.balign 32
+.global kvm_flush_link_stack
+kvm_flush_link_stack:
+	/* Save LR into r0 */
+	mflr	r0
+
+	/* Flush the link stack. On Power8 it's up to 32 entries in size. */
+	.rept 32
+	bl	.+4
+	.endr
+
+	/* And on Power9 it's up to 64. */
+BEGIN_FTR_SECTION
+	.rept 32
+	bl	.+4
+	.endr
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
+
+	/* Restore LR */
+	mtlr	r0
+	blr
+
+
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 /*
  * Softpatch interrupt for transactional memory emulation cases
#338 lore raw
In reply to Greg Kroah-Hartman

Hello!

Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

We're seeing this build failure on 4.19 (and 4.14) on x86 32-bits:

Quoted 17 lines

In file included from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/export.h:45:0,

                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/linkage.h:7,
                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/preempt.h:10,
                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/spinlock.h:51,
                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/arch/x86/mm/cpu_entry_area.c:3:
In function 'setup_cpu_entry_area_ptes',
    inlined from 'setup_cpu_entry_areas' at /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/arch/x86/mm/cpu_entry_area.c:209:2:
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/compiler.h:348:38: error: call to '__compiletime_assert_192' declared with attribute error: BUILD_BUG_ON failed: (CPU_ENTRY_AREA_PAGES+1)*PAGE_SIZE != CPU_ENTRY_AREA_MAP_SIZE
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/compiler.h:329:4: note: in definition of macro '__compiletime_assert'
    prefix ## suffix();    \
    ^~~~~~

/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/compiler.h:348:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
^~~~~~~~~~~~~~~~~~~
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'

Quoted 8 lines
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~

/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/build_bug.h:69:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^~~~~~~~~~~~~~~~
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/arch/x86/mm/cpu_entry_area.c:192:2: note: in expansion of macro 'BUILD_BUG_ON'
BUILD_BUG_ON((CPU_ENTRY_AREA_PAGES+1)*PAGE_SIZE != CPU_ENTRY_AREA_MAP_SIZE);
^~~~~~~~~~~~

Bisection points to "x86/cpu_entry_area: Add guard page for entry stack on 32bit" (e50622b4a1, also present in 4.14.y as 880a98c339).

Greetings!

Daniel Díaz
[email protected]

author maintainer
#339 lore raw
Quoted 50 lines · Daniel Díaz

Hello!

Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

We're seeing this build failure on 4.19 (and 4.14) on x86 32-bits:

Quoted 17 lines

In file included from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/export.h:45:0,

                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/linkage.h:7,
                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/preempt.h:10,
                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/spinlock.h:51,
                 from /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/arch/x86/mm/cpu_entry_area.c:3:
In function 'setup_cpu_entry_area_ptes',
    inlined from 'setup_cpu_entry_areas' at /srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/arch/x86/mm/cpu_entry_area.c:209:2:
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/compiler.h:348:38: error: call to '__compiletime_assert_192' declared with attribute error: BUILD_BUG_ON failed: (CPU_ENTRY_AREA_PAGES+1)*PAGE_SIZE != CPU_ENTRY_AREA_MAP_SIZE
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/compiler.h:329:4: note: in definition of macro '__compiletime_assert'
    prefix ## suffix();    \
    ^~~~~~

/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/compiler.h:348:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
^~~~~~~~~~~~~~~~~~~
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'

Quoted 8 lines
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~

/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/include/linux/build_bug.h:69:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^~~~~~~~~~~~~~~~
/srv/oe/build/tmp-lkft-glibc/work-shared/intel-core2-32/kernel-source/arch/x86/mm/cpu_entry_area.c:192:2: note: in expansion of macro 'BUILD_BUG_ON'
BUILD_BUG_ON((CPU_ENTRY_AREA_PAGES+1)*PAGE_SIZE != CPU_ENTRY_AREA_MAP_SIZE);
^~~~~~~~~~~~

Quoted 2 lines

Bisection points to "x86/cpu_entry_area: Add guard page for entry stack on 32bit" (e50622b4a1, also present in 4.14.y as 880a98c339).

Ugh, I was hoping that 32bit stuff "just worked". I'll take a look at the whole series later today and try to work to backport some of the known-missing parts of that series.

thanks,

greg k-h

#340 lore raw
In reply to Greg Kroah-Hartman
Quoted 10 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0

Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

net-sysfs: fix netdev_queue_add_kobject() breakage

kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Summary
------------------------------------------------------------------------

kernel: 4.19.87-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.19.y
git commit: 57c5d287ed483d6100bdca528c57562b894487b5
git describe: v4.19.86-307-g57c5d287ed48
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.19-oe-sanity/build/v4.19.86-307-g57c5d287ed48

Regressions (compared to build v4.19.86)

[    3.556598] BUG: unable to handle kernel NULL pointer dereference
at 0000000000000090
[    3.569683] PGD 0 P4D 0
[    3.572221] Oops: 0000 [#1] SMP PTI
[    3.575705] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.19.87-rc1 #1
[    3.582049] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
2.0b 07/27/2017
[    3.589523] RIP: 0010:kernfs_find_ns+0x1f/0x130
[    3.594053] Code: fe ff ff 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00
55 48 89 e5 41 57 41 56 41 55 41 54 49 89 ff 53 49 89 f6 49 89 d5 48
83 ec 08 <0f> b7 87 90 00 00 00 48 8b 5f 68 66 83 e0 20 66 89 45 d6 8b
05 68
[    3.612788] RSP: 0000:ffffaf514002fba8 EFLAGS: 00010292
[    3.618007] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff95d15b89
[    3.625130] RDX: 0000000000000000 RSI: ffffffff95ddefc7 RDI: 0000000000000000
[    3.632254] RBP: ffffaf514002fbd8 R08: ffffffff94b88f05 R09: 0000000000000001
[    3.639377] R10: ffffaf514002fbd8 R11: 0000000000000001 R12: ffffffff95ddefc7
[    3.646502] R13: 0000000000000000 R14: ffffffff95ddefc7 R15: 0000000000000000
[    3.653625] FS:  0000000000000000(0000) GS:ffff95c0dfb00000(0000)
knlGS:0000000000000000
[    3.661704] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    3.667442] CR2: 0000000000000090 CR3: 00000003bc01e001 CR4: 00000000003606e0
[    3.674565] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[    3.681689] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[    3.688811] Call Trace:
[    3.691259]  kernfs_find_and_get_ns+0x33/0x60
[    3.695616]  sysfs_remove_group+0x2a/0x90
[    3.699622]  netdev_queue_update_kobjects+0xc6/0x150
[    3.704587]  netif_set_real_num_tx_queues+0x7e/0x230
[    3.709546]  ? igb_configure_msix+0xde/0x170
[    3.713816]  __igb_open+0x19e/0x5e0
[    3.717322]  igb_open+0x10/0x20
[    3.720506]  __dev_open+0xd7/0x170
[    3.723904]  ? _raw_spin_unlock_bh+0x35/0x40
[    3.728168]  __dev_change_flags+0x17e/0x1d0
[    3.732363]  dev_change_flags+0x29/0x60
[    3.736195]  ip_auto_config+0x28b/0xf04
[    3.740033]  ? tcp_set_default_congestion_control+0xac/0x150
[    3.745683]  ? root_nfs_parse_addr+0xa5/0xa5
[    3.749948]  ? set_debug_rodata+0x17/0x17
[    3.753951]  do_one_initcall+0x61/0x2b4
[    3.757783]  ? do_one_initcall+0x61/0x2b4
[    3.761793]  ? set_debug_rodata+0xa/0x17
[    3.765713]  ? rcu_read_lock_sched_held+0x81/0x90
[    3.770418]  kernel_init_freeable+0x1d8/0x270
[    3.774777]  ? rest_init+0x190/0x190
[    3.778354]  kernel_init+0xe/0x110
[    3.781753]  ret_from_fork+0x3a/0x50
[    3.785349] Modules linked in:
[    3.788427] CR2: 0000000000000090
[    3.791740] ---[ end trace 831b7578b86a527b ]---
[    3.796358] RIP: 0010:kernfs_find_ns+0x1f/0x130
[    3.800889] Code: fe ff ff 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00
55 48 89 e5 41 57 41 56 41 55 41 54 49 89 ff 53 49 89 f6 49 89 d5 48
83 ec 08 <0f> b7 87 90 00 00 00 48 8b 5f 68 66 83 e0 20 66 89 45 d6 8b
05 68
[    3.819625] RSP: 0000:ffffaf514002fba8 EFLAGS: 00010292
[    3.824843] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff95d15b89
[    3.831968] RDX: 0000000000000000 RSI: ffffffff95ddefc7 RDI: 0000000000000000
[    3.839091] RBP: ffffaf514002fbd8 R08: ffffffff94b88f05 R09: 0000000000000001
[    3.846216] R10: ffffaf514002fbd8 R11: 0000000000000001 R12: ffffffff95ddefc7
[    3.853363] R13: 0000000000000000 R14: ffffffff95ddefc7 R15: 0000000000000000
[    3.860499] FS:  0000000000000000(0000) GS:ffff95c0dfb00000(0000)
knlGS:0000000000000000
[    3.868583] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    3.874323] CR2: 0000000000000090 CR3: 00000003bc01e001 CR4: 00000000003606e0
[    3.881454] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[    3.888576] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[    3.895702] BUG: sleeping function called from invalid context at
/usr/src/kernel/include/linux/percpu-rwsem.h:34
[    3.905946] in_atomic(): 0, irqs_disabled(): 1, pid: 1, name: swapper/0
[    3.912550] INFO: lockdep is turned off.
[    3.916465] irq event stamp: 1027104
[    3.920038] hardirqs last  enabled at (1027103):
[<ffffffff9553abd6>] _raw_spin_unlock_irqrestore+0x36/0x50
[    3.929770] hardirqs last disabled at (1027104):
[<ffffffff94801c8b>] trace_hardirqs_off_thunk+0x1a/0x1c
[    3.939233] softirqs last  enabled at (1025718):
[<ffffffff9580031f>] __do_softirq+0x31f/0x426
[    3.947832] softirqs last disabled at (1025703):
[<ffffffff948eddb6>] irq_exit+0xd6/0xe0
[    3.955916] CPU: 2 PID: 1 Comm: swapper/0 Tainted: G      D
  4.19.87-rc1 #1
[    3.963648] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
2.0b 07/27/2017
[    3.971126] Call Trace:
[    3.973572]  dump_stack+0x7a/0xa5
[    3.976890]  ___might_sleep+0x152/0x240
[    3.980720]  __might_sleep+0x4a/0x80
[    3.984309]  exit_signals+0x33/0x240
[    3.987896]  do_exit+0xbd/0xcf0
[    3.991035]  ? kernel_init_freeable+0x1d8/0x270
[    3.995567]  ? rest_init+0x190/0x190
[    3.999136]  rewind_stack_do_exit+0x17/0x20
[    4.003348] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x00000009
[    4.003348]
[    4.012537] Kernel Offset: 0x13800000 from 0xffffffff81000000
(relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[    4.023318] ---[ end Kernel panic - not syncing: Attempted to kill
init! exitcode=0x00000009
[    4.023318]  ]---

--
Linaro LKFT
https://lkft.linaro.org

author maintainer
#341 lore raw
Quoted 36 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0

Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

net-sysfs: fix netdev_queue_add_kobject() breakage

Quoted 7 lines

kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

#342 lore raw
Quoted 45 lines · Greg Kroah-Hartman
Quoted 36 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
         https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0

Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

net-sysfs: fix netdev_queue_add_kobject() breakage

Quoted 7 lines

kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Quoted 4 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

Ran into this on my test system. I will try rc2.

thanks,
-- Shuah

#343 lore raw
Quoted 49 lines · shuah
Quoted 48 lines · Greg Kroah-Hartman
Quoted 46 lines · Naresh Kamboju
Quoted 13 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one.  If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

Quoted 8 lines

or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
     net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0
Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

     net-sysfs: fix netdev_queue_add_kobject() breakage

     kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Quoted 7 lines
Quoted 4 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

Ran into this on my test system. I will try rc2.

rc2 worked for me.

thanks,
-- Shuah

author maintainer
#344 lore raw
Quoted 51 lines · shuah
Quoted 50 lines · shuah
Quoted 49 lines · Greg Kroah-Hartman
Quoted 38 lines · Naresh Kamboju
Quoted 12 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one.  If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

          https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz
Quoted 8 lines

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
     net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0
Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

     net-sysfs: fix netdev_queue_add_kobject() breakage

Quoted 7 lines

     kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Now queued up, I'll push out -rc2 versions with this fix.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

greg k-h

Ran into this on my test system. I will try rc2.

rc2 worked for me.

Great, thanks for testing and confirming it.

greg k-h

#345 lore raw
In reply to Greg Kroah-Hartman
Quoted 46 lines · Greg Kroah-Hartman
Quoted 36 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0

Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

net-sysfs: fix netdev_queue_add_kobject() breakage

Quoted 7 lines

kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Lukas

author maintainer
#346 lore raw
Quoted 55 lines · Lukas Bulwahn
Quoted 46 lines · Greg Kroah-Hartman
Quoted 36 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

Kernel BUG noticed on x86_64 device while booting 4.19.87-rc1 kernel.

The problematic patch is,

Quoted 2 lines

Jouni Hogander <[email protected]>
net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

And this kernel panic is been fixed by below patch,

commit 48a322b6f9965b2f1e4ce81af972f0e287b07ed0

Author: Eric Dumazet <[email protected]>
Date:   Wed Nov 20 19:19:07 2019 -0800

net-sysfs: fix netdev_queue_add_kobject() breakage

Quoted 7 lines

kobject_put() should only be called in error path.

Fixes b8eb718348b8 ("net-sysfs: Fix reference count leak in

rx|netdev_queue_add_kobject")

Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

#347 lore raw
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

Best Regards,

Jouni Högander

#348 lore raw
Quoted 28 lines · Jouni Högander
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

Quoted 9 lines

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

+ syzkaller list
Jouni et. al, please drop Linus in further responses; Linus, it was wrong to add you to this thread in the first place (reason is explained below)

Jouni, thanks for investigating.

It raises the following questions and comments:

- Does the memory leak NOT appear on 4.9 and earlier LTS branches (or did you not check that)? If it does not appear, can you bisect it with the reproducer to the commit between 4.14 and 4.9?

- Do the reproducers you found with your syzkaller testing show the same behaviour (same bisection) as the reproducers from syzbot?

- I fear syzbot's automatic bisection on is wrong, and Linus' commit 0e034f5c4bc4 ("iwlwifi: fix mis-merge that breaks the driver") is not to blame here; that commit did not cause the memory leak, but fixed some unrelated issue that simply confuses syzbot's automatic bisection.

Just FYI: Dmitry Vyukov's evaluation of the syzbot bisection shows that about 50% are wrong, e.g., due to multiple bugs being triggered with one reproducer and the difficulty of automatically identifying them of being different due to different root causes (despite the smart heuristics of syzkaller & syzbot). So, to identify the actual commit on which the memory leak first appeared, you need to bisect manually with your own judgement if the reported bug stack trace fits to the issue you investigating. Or you use syzbot's automatic bisection but then with a reduced kernel config that cannot be confused by other issues. You might possibly also hit a "beginning of time" in your bisection, where KASAN was simply not supported, then the initially causing commit can simply not determined by bisection with the reproducer and needs some code inspection and archaeology with git. Can you go ahead try to identify the correct commit for this issue?

Lukas

#349 lore raw
Quoted 44 lines · Lukas Bulwahn
Quoted 28 lines · Jouni Högander
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

Quoted 9 lines

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

+ syzkaller list
Jouni et. al, please drop Linus in further responses; Linus, it was wrong to add you to this thread in the first place (reason is explained below)

Quoted 7 lines

Jouni, thanks for investigating.

It raises the following questions and comments:

- Does the memory leak NOT appear on 4.9 and earlier LTS branches (or did you not check that)? If it does not appear, can you bisect it with the reproducer to the commit between 4.14 and 4.9?

I tested and these memory leaks are not reproucible in 4.9 and earlier.

Quoted 3 lines

- Do the reproducers you found with your syzkaller testing show the same behaviour (same bisection) as the reproducers from syzbot?

Yes, they are same.

Quoted 6 lines

- I fear syzbot's automatic bisection on is wrong, and Linus' commit 0e034f5c4bc4 ("iwlwifi: fix mis-merge that breaks the driver") is not to blame here; that commit did not cause the memory leak, but fixed some unrelated issue that simply confuses syzbot's automatic bisection.

Quoted 14 lines

Just FYI: Dmitry Vyukov's evaluation of the syzbot bisection shows that about 50% are wrong, e.g., due to multiple bugs being triggered with one reproducer and the difficulty of automatically identifying them of being different due to different root causes (despite the smart heuristics of syzkaller & syzbot). So, to identify the actual commit on which the memory leak first appeared, you need to bisect manually with your own judgement if the reported bug stack trace fits to the issue you investigating. Or you use syzbot's automatic bisection but then with a reduced kernel config that cannot be confused by other issues. You might possibly also hit a "beginning of time" in your bisection, where KASAN was simply not supported, then the initially causing commit can simply not determined by bisection with the reproducer and needs some code inspection and archaeology with git. Can you go ahead try to identify the correct commit for this issue?

These two commits (that are not in 4.9 and earlier) are intorducing these leaks:

commit e331c9066901dfe40bea4647521b86e9fb9901bb

Author: YueHaibing <[email protected]>
Date:   Tue Mar 19 10:16:53 2019 +0800

net-sysfs: call dev_hold if kobject_init_and_add success

[ Upstream commit a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e ]

In netdev_queue_add_kobject and rx_queue_add_kobject, if sysfs_create_group failed, kobject_put will call netdev_queue_release to decrease dev refcont, however dev_hold has not be called. So we will see this while unregistering dev:

unregister_netdevice: waiting for bcsh0 to become free. Usage count = -1

Fixes d0d668371679 ("net: don't decrement kobj reference count on init fail

ure")

commit d0d6683716791b2a2761a1bb025c613eb73da6c3

Author: stephen hemminger <[email protected]>
Date:   Fri Aug 18 13:46:19 2017 -0700

net: don't decrement kobj reference count on init failure

If kobject_init_and_add failed, then the failure path would decrement the reference count of the queue kobject whose reference count was already zero.

Fixes 114cf5802165 ("bql: Byte queue limits")
Quoted 3 lines

Lukas

BR,

Jouni Högander

#350 lore raw
Quoted 114 lines · Jouni Högander
Quoted 44 lines · Lukas Bulwahn
Quoted 28 lines · Jouni Högander
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

Quoted 9 lines

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

+ syzkaller list
Jouni et. al, please drop Linus in further responses; Linus, it was wrong to add you to this thread in the first place (reason is explained below)

Quoted 7 lines

Jouni, thanks for investigating.

It raises the following questions and comments:

- Does the memory leak NOT appear on 4.9 and earlier LTS branches (or did you not check that)? If it does not appear, can you bisect it with the reproducer to the commit between 4.14 and 4.9?

I tested and these memory leaks are not reproucible in 4.9 and earlier.

Quoted 3 lines

- Do the reproducers you found with your syzkaller testing show the same behaviour (same bisection) as the reproducers from syzbot?

Yes, they are same.

Quoted 6 lines

- I fear syzbot's automatic bisection on is wrong, and Linus' commit 0e034f5c4bc4 ("iwlwifi: fix mis-merge that breaks the driver") is not to blame here; that commit did not cause the memory leak, but fixed some unrelated issue that simply confuses syzbot's automatic bisection.

Quoted 14 lines

Just FYI: Dmitry Vyukov's evaluation of the syzbot bisection shows that about 50% are wrong, e.g., due to multiple bugs being triggered with one reproducer and the difficulty of automatically identifying them of being different due to different root causes (despite the smart heuristics of syzkaller & syzbot). So, to identify the actual commit on which the memory leak first appeared, you need to bisect manually with your own judgement if the reported bug stack trace fits to the issue you investigating. Or you use syzbot's automatic bisection but then with a reduced kernel config that cannot be confused by other issues. You might possibly also hit a "beginning of time" in your bisection, where KASAN was simply not supported, then the initially causing commit can simply not determined by bisection with the reproducer and needs some code inspection and archaeology with git. Can you go ahead try to identify the correct commit for this issue?

These two commits (that are not in 4.9 and earlier) are intorducing these leaks:

commit e331c9066901dfe40bea4647521b86e9fb9901bb

Author: YueHaibing <[email protected]>
Date:   Tue Mar 19 10:16:53 2019 +0800

net-sysfs: call dev_hold if kobject_init_and_add success

[ Upstream commit a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e ]

In netdev_queue_add_kobject and rx_queue_add_kobject, if sysfs_create_group failed, kobject_put will call netdev_queue_release to decrease dev refcont, however dev_hold has not be called. So we will see this while unregistering dev:

unregister_netdevice: waiting for bcsh0 to become free. Usage count = -1

Fixes d0d668371679 ("net: don't decrement kobj reference count on init fail

ure")

commit d0d6683716791b2a2761a1bb025c613eb73da6c3

Author: stephen hemminger <[email protected]>
Date:   Fri Aug 18 13:46:19 2017 -0700

net: don't decrement kobj reference count on init failure

Quoted 8 lines

If kobject_init_and_add failed, then the failure path would decrement the reference count of the queue kobject whose reference count was already zero.

Fixes 114cf5802165 ("bql: Byte queue limits")

But, it seems that we now have just a long sequences of fix patches.

This commit from 2011 seems to be the initial buggy one:

commit 114cf5802165ee93e3ab461c9c505cd94a08b800

Author: Tom Herbert <[email protected]>
Date:   Mon Nov 28 16:33:09 2011 +0000

bql: Byte queue limits

And then we just have fixes over fixes:

114cf5802165ee93e3ab461c9c505cd94a08b800
fixed by d0d6683716791b2a2761a1bb025c613eb73da6c3 fixed by a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e fixed by the sequence of your five patches, mentioned above

If that is right, we should be able to find a reproducer with syzkaller on the versions before d0d668371679 ("net: don't decrement kobj reference count on init failure") with fault injection enabled or some manually injected fault by modifying the source code to always fail on init to really trigger the init failure, and see the reference count go below zero.

All further issues should also have reproducers found with syzkaller. If we have a good feeling on the reproducers and this series of fixes really fixed the issue now here for all cases, we should suggest to backport all of the fixes to 4.4 and 4.9.

We should NOT just have Greg pick up a subset of the patches and backport them to 4.4 and 4.9, that will likely break more than it fixes.

Jouni, did you see Greg's bot inform you that he would pick up your latest patch for 4.4 and 4.9? Please respond to those emails to make sure a complete set of patches is picked up, which we tested with all those intermediate reproducers and an extensive syzkaller run hitting the net-sysfs interface (e.g., by configuring the corpus and check coverage).

If you cannot do this testing for 4.4 and 4.9 now quickly (you potentially have less than 24 hours), we should hold those new patches back for 4.4 and 4.9, as none of the fixes seem to be applied at all right now and the users have not complained yet on 4.4 and 4.9.
Once testing of the whole fix sequence is done, we request to backport all patches at once for 4.4 and 4.9.

Lukas

#351 lore raw
Quoted 150 lines · Lukas Bulwahn
Quoted 114 lines · Jouni Högander
Quoted 44 lines · Lukas Bulwahn
Quoted 28 lines · Jouni Högander
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

Quoted 9 lines

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

+ syzkaller list
Jouni et. al, please drop Linus in further responses; Linus, it was wrong to add you to this thread in the first place (reason is explained below)

Quoted 7 lines

Jouni, thanks for investigating.

It raises the following questions and comments:

- Does the memory leak NOT appear on 4.9 and earlier LTS branches (or did you not check that)? If it does not appear, can you bisect it with the reproducer to the commit between 4.14 and 4.9?

I tested and these memory leaks are not reproucible in 4.9 and earlier.

Quoted 3 lines

- Do the reproducers you found with your syzkaller testing show the same behaviour (same bisection) as the reproducers from syzbot?

Yes, they are same.

Quoted 6 lines

- I fear syzbot's automatic bisection on is wrong, and Linus' commit 0e034f5c4bc4 ("iwlwifi: fix mis-merge that breaks the driver") is not to blame here; that commit did not cause the memory leak, but fixed some unrelated issue that simply confuses syzbot's automatic bisection.

Quoted 14 lines

Just FYI: Dmitry Vyukov's evaluation of the syzbot bisection shows that about 50% are wrong, e.g., due to multiple bugs being triggered with one reproducer and the difficulty of automatically identifying them of being different due to different root causes (despite the smart heuristics of syzkaller & syzbot). So, to identify the actual commit on which the memory leak first appeared, you need to bisect manually with your own judgement if the reported bug stack trace fits to the issue you investigating. Or you use syzbot's automatic bisection but then with a reduced kernel config that cannot be confused by other issues. You might possibly also hit a "beginning of time" in your bisection, where KASAN was simply not supported, then the initially causing commit can simply not determined by bisection with the reproducer and needs some code inspection and archaeology with git. Can you go ahead try to identify the correct commit for this issue?

These two commits (that are not in 4.9 and earlier) are intorducing these leaks:

commit e331c9066901dfe40bea4647521b86e9fb9901bb

Author: YueHaibing <[email protected]>
Date:   Tue Mar 19 10:16:53 2019 +0800

net-sysfs: call dev_hold if kobject_init_and_add success

[ Upstream commit a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e ]

In netdev_queue_add_kobject and rx_queue_add_kobject, if sysfs_create_group failed, kobject_put will call netdev_queue_release to decrease dev refcont, however dev_hold has not be called. So we will see this while unregistering dev:

unregister_netdevice: waiting for bcsh0 to become free. Usage count = -1

Fixes d0d668371679 ("net: don't decrement kobj reference count on init fail

ure")

commit d0d6683716791b2a2761a1bb025c613eb73da6c3

Author: stephen hemminger <[email protected]>
Date:   Fri Aug 18 13:46:19 2017 -0700

net: don't decrement kobj reference count on init failure

Quoted 8 lines

If kobject_init_and_add failed, then the failure path would decrement the reference count of the queue kobject whose reference count was already zero.

Fixes 114cf5802165 ("bql: Byte queue limits")

But, it seems that we now have just a long sequences of fix patches.

This commit from 2011 seems to be the initial buggy one:

commit 114cf5802165ee93e3ab461c9c505cd94a08b800

Author: Tom Herbert <[email protected]>
Date:   Mon Nov 28 16:33:09 2011 +0000

bql: Byte queue limits

And then we just have fixes over fixes:

114cf5802165ee93e3ab461c9c505cd94a08b800
fixed by d0d6683716791b2a2761a1bb025c613eb73da6c3 fixed by a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e fixed by the sequence of your five patches, mentioned above

If that is right, we should be able to find a reproducer with syzkaller on the versions before d0d668371679 ("net: don't decrement kobj reference count on init failure") with fault injection enabled or some manually injected fault by modifying the source code to always fail on init to really trigger the init failure, and see the reference count go below zero.

Quoted 7 lines

All further issues should also have reproducers found with syzkaller. If we have a good feeling on the reproducers and this series of fixes really fixed the issue now here for all cases, we should suggest to backport all of the fixes to 4.4 and 4.9.

We should NOT just have Greg pick up a subset of the patches and backport them to 4.4 and 4.9, that will likely break more than it fixes.

Yes, this is the case.

Quoted 7 lines

Jouni, did you see Greg's bot inform you that he would pick up your latest patch for 4.4 and 4.9? Please respond to those emails to make sure a complete set of patches is picked up, which we tested with all those intermediate reproducers and an extensive syzkaller run hitting the net-sysfs interface (e.g., by configuring the corpus and check coverage).

I already responded to not pick these patches into 4.4 and 4.9.

Quoted 7 lines

If you cannot do this testing for 4.4 and 4.9 now quickly (you potentially have less than 24 hours), we should hold those new patches back for 4.4 and 4.9, as none of the fixes seem to be applied at all right now and the users have not complained yet on 4.4 and 4.9.
Once testing of the whole fix sequence is done, we request to backport all patches at once for 4.4 and 4.9.

If we want to pick whole set including older patches I think I need more time for identifying which older patches (apart from these two I identified causing the memory leak) should be taken in and for testing.

Quoted 2 lines

Lukas

BR,

Jouni Högander

#352 lore raw
In reply to Jouni Högander

Hello Greg,

Quoted 34 lines · [email protected] (Jouni Högander) writes:
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

Quoted 6 lines

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

Best Regards,

Jouni Högander

These four patches are still missing from 4.14 and 4.19 branches:

ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

Could you please consider taking them in or let me know if you want some further activities from my side?

BR,

Jouni Högander

author maintainer
#353 lore raw
Quoted 47 lines · Jouni Högander

Hello Greg,

Quoted 34 lines · [email protected] (Jouni Högander) writes:
Quoted 14 lines · Greg Kroah-Hartman
Quoted 7 lines
Quoted 3 lines

Now queued up, I'll push out -rc2 versions with this fix.

greg k-h

We have also been informed about another regression these two commits are causing:

Quoted 6 lines

https://lore.kernel.org/lkml/[email protected]/

I suggest to drop these two patches from this queue, and give us a week to shake out the regressions of the change, and once ready, we can include the complete set of fixes to stable (probably in a week or two).

Quoted 4 lines

Ok, thanks for the information, I've now dropped them from all of the queues that had them in them.

greg k-h

I have now run more extensive Syzkaller testing on following patches:

cb626bf566eb net-sysfs: Fix reference count leak
ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

These patches are fixing couple of memory leaks including this one found by Syzbot: https://syzkaller.appspot.com/bug?extid=ad8ca40ecd77896d51e2

I can reproduce these memory leaks in following stable branches: 4.14, 4.19, and 5.4.

Quoted 6 lines

These are all now merged into net/master tree and based on my testing they are ready to be taken into stable branches as well.

Best Regards,

Jouni Högander

These four patches are still missing from 4.14 and 4.19 branches:

Quoted 7 lines

ddd9b5e3e765 net-sysfs: Call dev_hold always in rx_queue_add_kobject e0b60903b434 net-sysfs: Call dev_hold always in netdev_queue_add_kobje 48a322b6f996 net-sysfs: fix netdev_queue_add_kobject() breakage b8eb718348b8 net-sysfs: Fix reference count leak in rx|netdev_queue_add_kobject

Could you please consider taking them in or let me know if you want some further activities from my side?

Thanks for the list, I have now queued these all up.

greg k-h

#354 lore raw
In reply to Greg Kroah-Hartman
Quoted 1 line · Greg Kroah-Hartman

Now queued up, I'll push out -rc2 versions with this fix.

Results from Linaro’s test farm.
Regressions detected on i386.

i386 build failed on 4.19 and 4.14

In function 'setup_cpu_entry_area_ptes',

    inlined from 'setup_cpu_entry_areas' at arch/x86/mm/cpu_entry_area.c:209:2:

include/linux/compiler.h:348:38: error: call to '__compiletime_assert_192' declared with attribute error: BUILD_BUG_ON
failed: (CPU_ENTRY_AREA_PAGES+1)*PAGE_SIZE != CPU_ENTRY_AREA_MAP_SIZE
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

                                      ^
include/linux/compiler.h:329:4: note: in definition of macro
'__compiletime_assert'
    prefix ## suffix();    \
    ^~~~~~

include/linux/compiler.h:348:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'

 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~

Bisection points to "x86/cpu_entry_area: Add guard page for entry stack on 32bit" (e50622b4a1, also present in 4.14.y as 880a98c339).

Summary
------------------------------------------------------------------------

kernel: 4.19.87-rc2
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.19.y
git commit: 63633b307be0161e7bd6f854a28d7d9fa05f69ef
git describe: v4.19.86-309-g63633b307be0
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.19-oe/build/v4.19.86-309-g63633b307be0

Regressions (compared to build v4.19.86)
------------------------------------------------------------------------

i386:
build:
* build_process

No fixes (compared to build v4.19.86)

Ran 18913 total tests in the following environments and test suites.

Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- qemu_arm
- qemu_arm64
- qemu_x86_64
- x15 - arm
- x86_64

Test Suites
-----------
* build
* install-android-platform-tools-r2600
* kselftest
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* ltp-fs-tests
* network-basic-tests
* kvm-unit-tests
* ltp-open-posix-tests
* ssuite
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none

Signature · 2 lines
Linaro LKFT
https://lkft.linaro.org
maintainer
#355 lore raw
In reply to Greg Kroah-Hartman
Quoted 14 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.

Quoted 5 lines

thanks,

greg k-h

-------------

All tests are passing for Tegra ...

Test results for stable-v4.19:

    13 builds:	13 pass, 0 fail
    22 boots:	22 pass, 0 fail
    32 tests:	32 pass, 0 fail

Linux version: 4.19.87-rc1-g57c5d287ed48
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,

                tegra194-p2972-0000, tegra20-ventana,
                tegra210-p2371-2180, tegra30-cardhu-a04

Cheers
Jon

Signature · 1 line
nvpublic
#356 lore raw
In reply to Greg Kroah-Hartman
Quoted 8 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

Build results:

	total: 156 pass: 151 fail: 5
Failed builds:
	i386:defconfig
	i386:allyesconfig
	i386:allmodconfig
	i386:allnoconfig
	i386:tinyconfig
Qemu test results:
	total: 390 pass: 365 fail: 25
Failed tests:
	<all i386>

As already reported.

Guenter

author maintainer
#357 lore raw
In reply to Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Quoted 7 lines

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y

I have released -rc3 now:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc3.gz

that should have the i386 and all other reported issues fixed.

thanks,

greg k-h

#358 lore raw
Quoted 15 lines · Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 4.19.87 release. There are 306 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Quoted 7 lines

Responses should be made by Fri, 29 Nov 2019 20:18:09 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

      https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y

Quoted 4 lines

I have released -rc3 now:

        https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.87-rc3.gz

that should have the i386 and all other reported issues fixed.

Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.

Summary
------------------------------------------------------------------------

kernel: 4.19.87-rc3
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.19.y
git commit: cc82722f8f1b05c10e62b80951b3950e453fcb88
git describe: v4.19.86-299-gcc82722f8f1b
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.19-oe/build/v4.19.86-299-gcc82722f8f1b

No regressions (compared to build v4.19.86)

No fixes (compared to build v4.19.86)

Ran 23167 total tests in the following environments and test suites.

Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
- x86_64

Test Suites
-----------
* build
* install-android-platform-tools-r2600
* libhugetlbfs
* linux-log-parser
* kselftest
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* network-basic-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* ltp-open-posix-tests
* kvm-unit-tests
* ssuite
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none

Signature · 2 lines
Linaro LKFT
https://lkft.linaro.org