From: Greg Kroah-Hartman Date: Tue, 24 Sep 2019 07:13:06 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v5.3.2~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=505e27918968d59d031e185af8453b44449da910;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: hid-hidraw-fix-invalid-read-in-hidraw_ioctl.patch hid-lg-make-transfer-buffers-dma-capable.patch hid-logitech-fix-general-protection-fault-caused-by-logitech-driver.patch hid-prodikeys-fix-general-protection-fault-during-probe.patch mtd-cfi_cmdset_0002-use-chip_good-to-retry-in-do_write_oneword.patch --- diff --git a/queue-4.4/hid-hidraw-fix-invalid-read-in-hidraw_ioctl.patch b/queue-4.4/hid-hidraw-fix-invalid-read-in-hidraw_ioctl.patch new file mode 100644 index 00000000000..ff654004fc1 --- /dev/null +++ b/queue-4.4/hid-hidraw-fix-invalid-read-in-hidraw_ioctl.patch @@ -0,0 +1,72 @@ +From 416dacb819f59180e4d86a5550052033ebb6d72c Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Wed, 21 Aug 2019 13:27:12 -0400 +Subject: HID: hidraw: Fix invalid read in hidraw_ioctl + +From: Alan Stern + +commit 416dacb819f59180e4d86a5550052033ebb6d72c upstream. + +The syzbot fuzzer has reported a pair of problems in the +hidraw_ioctl() function: slab-out-of-bounds read and use-after-free +read. An example of the first: + +BUG: KASAN: slab-out-of-bounds in strlen+0x79/0x90 lib/string.c:525 +Read of size 1 at addr ffff8881c8035f38 by task syz-executor.4/2833 + +CPU: 1 PID: 2833 Comm: syz-executor.4 Not tainted 5.3.0-rc2+ #1 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS +Google 01/01/2011 +Call Trace: + __dump_stack lib/dump_stack.c:77 [inline] + dump_stack+0xca/0x13e lib/dump_stack.c:113 + print_address_description+0x6a/0x32c mm/kasan/report.c:351 + __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482 + kasan_report+0xe/0x12 mm/kasan/common.c:612 + strlen+0x79/0x90 lib/string.c:525 + strlen include/linux/string.h:281 [inline] + hidraw_ioctl+0x245/0xae0 drivers/hid/hidraw.c:446 + vfs_ioctl fs/ioctl.c:46 [inline] + file_ioctl fs/ioctl.c:509 [inline] + do_vfs_ioctl+0xd2d/0x1330 fs/ioctl.c:696 + ksys_ioctl+0x9b/0xc0 fs/ioctl.c:713 + __do_sys_ioctl fs/ioctl.c:720 [inline] + __se_sys_ioctl fs/ioctl.c:718 [inline] + __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:718 + do_syscall_64+0xb7/0x580 arch/x86/entry/common.c:296 + entry_SYSCALL_64_after_hwframe+0x49/0xbe +RIP: 0033:0x459829 +Code: fd b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 +48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff +ff 0f 83 cb b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 +RSP: 002b:00007f7a68f6dc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 +RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459829 +RDX: 0000000000000000 RSI: 0000000080404805 RDI: 0000000000000004 +RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 +R10: 0000000000000000 R11: 0000000000000246 R12: 00007f7a68f6e6d4 +R13: 00000000004c21de R14: 00000000004d5620 R15: 00000000ffffffff + +The two problems have the same cause: hidraw_ioctl() fails to test +whether the device has been removed. This patch adds the missing test. + +Reported-and-tested-by: syzbot+5a6c4ec678a0c6ee84ba@syzkaller.appspotmail.com +Signed-off-by: Alan Stern +CC: +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hidraw.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/hid/hidraw.c ++++ b/drivers/hid/hidraw.c +@@ -383,7 +383,7 @@ static long hidraw_ioctl(struct file *fi + + mutex_lock(&minors_lock); + dev = hidraw_table[minor]; +- if (!dev) { ++ if (!dev || !dev->exist) { + ret = -ENODEV; + goto out; + } diff --git a/queue-4.4/hid-lg-make-transfer-buffers-dma-capable.patch b/queue-4.4/hid-lg-make-transfer-buffers-dma-capable.patch new file mode 100644 index 00000000000..7dc899c7dc3 --- /dev/null +++ b/queue-4.4/hid-lg-make-transfer-buffers-dma-capable.patch @@ -0,0 +1,56 @@ +From 061232f0d47fa10103f3efa3e890f002a930d902 Mon Sep 17 00:00:00 2001 +From: Benjamin Tissoires +Date: Mon, 21 Nov 2016 11:48:40 +0100 +Subject: HID: lg: make transfer buffers DMA capable + +From: Benjamin Tissoires + +commit 061232f0d47fa10103f3efa3e890f002a930d902 upstream. + +Kernel v4.9 strictly enforces DMA capable buffers, so we need to remove +buffers allocated on the stack. + +[jkosina@suse.cz: fix up second usage of hid_hw_raw_request(), spotted by + 0day build bot] +Signed-off-by: Benjamin Tissoires +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-lg.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +--- a/drivers/hid/hid-lg.c ++++ b/drivers/hid/hid-lg.c +@@ -701,11 +701,16 @@ static int lg_probe(struct hid_device *h + + /* Setup wireless link with Logitech Wii wheel */ + if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) { +- unsigned char buf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ++ const unsigned char cbuf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ++ u8 *buf = kmemdup(cbuf, sizeof(cbuf), GFP_KERNEL); + +- ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), +- HID_FEATURE_REPORT, HID_REQ_SET_REPORT); ++ if (!buf) { ++ ret = -ENOMEM; ++ goto err_free; ++ } + ++ ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf), ++ HID_FEATURE_REPORT, HID_REQ_SET_REPORT); + if (ret >= 0) { + /* insert a little delay of 10 jiffies ~ 40ms */ + wait_queue_head_t wait; +@@ -717,9 +722,10 @@ static int lg_probe(struct hid_device *h + buf[1] = 0xB2; + get_random_bytes(&buf[2], 2); + +- ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), ++ ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf), + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); + } ++ kfree(buf); + } + + if (drv_data->quirks & LG_FF) diff --git a/queue-4.4/hid-logitech-fix-general-protection-fault-caused-by-logitech-driver.patch b/queue-4.4/hid-logitech-fix-general-protection-fault-caused-by-logitech-driver.patch new file mode 100644 index 00000000000..64607ec8219 --- /dev/null +++ b/queue-4.4/hid-logitech-fix-general-protection-fault-caused-by-logitech-driver.patch @@ -0,0 +1,108 @@ +From 5f9242775bb61f390f0885f23fc16397262c7538 Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Tue, 20 Aug 2019 16:00:21 -0400 +Subject: HID: logitech: Fix general protection fault caused by Logitech driver + +From: Alan Stern + +commit 5f9242775bb61f390f0885f23fc16397262c7538 upstream. + +The syzbot fuzzer found a general protection fault in the HID subsystem: + +kasan: CONFIG_KASAN_INLINE enabled +kasan: GPF could be caused by NULL-ptr deref or user memory access +general protection fault: 0000 [#1] SMP KASAN +CPU: 0 PID: 3715 Comm: syz-executor.3 Not tainted 5.2.0-rc6+ #15 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS +Google 01/01/2011 +RIP: 0010:__pm_runtime_resume+0x49/0x180 drivers/base/power/runtime.c:1069 +Code: ed 74 d5 fe 45 85 ed 0f 85 9a 00 00 00 e8 6f 73 d5 fe 48 8d bd c1 02 +00 00 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 48 +89 fa 83 e2 07 38 d0 7f 08 84 c0 0f 85 fe 00 00 00 +RSP: 0018:ffff8881d99d78e0 EFLAGS: 00010202 +RAX: dffffc0000000000 RBX: 0000000000000020 RCX: ffffc90003f3f000 +RDX: 0000000416d8686d RSI: ffffffff82676841 RDI: 00000020b6c3436a +RBP: 00000020b6c340a9 R08: ffff8881c6d64800 R09: fffffbfff0e84c25 +R10: ffff8881d99d7940 R11: ffffffff87426127 R12: 0000000000000004 +R13: 0000000000000000 R14: ffff8881d9b94000 R15: ffffffff897f9048 +FS: 00007f047f542700(0000) GS:ffff8881db200000(0000) knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 0000001b30f21000 CR3: 00000001ca032000 CR4: 00000000001406f0 +DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 +DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 +Call Trace: + pm_runtime_get_sync include/linux/pm_runtime.h:226 [inline] + usb_autopm_get_interface+0x1b/0x50 drivers/usb/core/driver.c:1707 + usbhid_power+0x7c/0xe0 drivers/hid/usbhid/hid-core.c:1234 + hid_hw_power include/linux/hid.h:1038 [inline] + hidraw_open+0x20d/0x740 drivers/hid/hidraw.c:282 + chrdev_open+0x219/0x5c0 fs/char_dev.c:413 + do_dentry_open+0x497/0x1040 fs/open.c:778 + do_last fs/namei.c:3416 [inline] + path_openat+0x1430/0x3ff0 fs/namei.c:3533 + do_filp_open+0x1a1/0x280 fs/namei.c:3563 + do_sys_open+0x3c0/0x580 fs/open.c:1070 + do_syscall_64+0xb7/0x560 arch/x86/entry/common.c:301 + entry_SYSCALL_64_after_hwframe+0x49/0xbe + +It turns out the fault was caused by a bug in the HID Logitech driver, +which violates the requirement that every pathway calling +hid_hw_start() must also call hid_hw_stop(). This patch fixes the bug +by making sure the requirement is met. + +Reported-and-tested-by: syzbot+3cbe5cd105d2ad56a1df@syzkaller.appspotmail.com +Signed-off-by: Alan Stern +CC: +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-lg.c | 10 ++++++---- + drivers/hid/hid-lg4ff.c | 1 - + 2 files changed, 6 insertions(+), 5 deletions(-) + +--- a/drivers/hid/hid-lg.c ++++ b/drivers/hid/hid-lg.c +@@ -706,7 +706,7 @@ static int lg_probe(struct hid_device *h + + if (!buf) { + ret = -ENOMEM; +- goto err_free; ++ goto err_stop; + } + + ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf), +@@ -738,9 +738,12 @@ static int lg_probe(struct hid_device *h + ret = lg4ff_init(hdev); + + if (ret) +- goto err_free; ++ goto err_stop; + + return 0; ++ ++err_stop: ++ hid_hw_stop(hdev); + err_free: + kfree(drv_data); + return ret; +@@ -751,8 +754,7 @@ static void lg_remove(struct hid_device + struct lg_drv_data *drv_data = hid_get_drvdata(hdev); + if (drv_data->quirks & LG_FF4) + lg4ff_deinit(hdev); +- else +- hid_hw_stop(hdev); ++ hid_hw_stop(hdev); + kfree(drv_data); + } + +--- a/drivers/hid/hid-lg4ff.c ++++ b/drivers/hid/hid-lg4ff.c +@@ -1378,7 +1378,6 @@ int lg4ff_deinit(struct hid_device *hid) + } + } + #endif +- hid_hw_stop(hid); + drv_data->device_props = NULL; + + kfree(entry); diff --git a/queue-4.4/hid-prodikeys-fix-general-protection-fault-during-probe.patch b/queue-4.4/hid-prodikeys-fix-general-protection-fault-during-probe.patch new file mode 100644 index 00000000000..54476bfd1c1 --- /dev/null +++ b/queue-4.4/hid-prodikeys-fix-general-protection-fault-during-probe.patch @@ -0,0 +1,76 @@ +From 98375b86c79137416e9fd354177b85e768c16e56 Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Wed, 4 Sep 2019 11:54:20 -0400 +Subject: HID: prodikeys: Fix general protection fault during probe + +From: Alan Stern + +commit 98375b86c79137416e9fd354177b85e768c16e56 upstream. + +The syzbot fuzzer provoked a general protection fault in the +hid-prodikeys driver: + +kasan: CONFIG_KASAN_INLINE enabled +kasan: GPF could be caused by NULL-ptr deref or user memory access +general protection fault: 0000 [#1] SMP KASAN +CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.3.0-rc5+ #28 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS +Google 01/01/2011 +Workqueue: usb_hub_wq hub_event +RIP: 0010:pcmidi_submit_output_report drivers/hid/hid-prodikeys.c:300 [inline] +RIP: 0010:pcmidi_set_operational drivers/hid/hid-prodikeys.c:558 [inline] +RIP: 0010:pcmidi_snd_initialise drivers/hid/hid-prodikeys.c:686 [inline] +RIP: 0010:pk_probe+0xb51/0xfd0 drivers/hid/hid-prodikeys.c:836 +Code: 0f 85 50 04 00 00 48 8b 04 24 4c 89 7d 10 48 8b 58 08 e8 b2 53 e4 fc +48 8b 54 24 20 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f +85 13 04 00 00 48 ba 00 00 00 00 00 fc ff df 49 8b + +The problem is caused by the fact that pcmidi_get_output_report() will +return an error if the HID device doesn't provide the right sort of +output report, but pcmidi_set_operational() doesn't bother to check +the return code and assumes the function call always succeeds. + +This patch adds the missing check and aborts the probe operation if +necessary. + +Reported-and-tested-by: syzbot+1088533649dafa1c9004@syzkaller.appspotmail.com +Signed-off-by: Alan Stern +CC: +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-prodikeys.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +--- a/drivers/hid/hid-prodikeys.c ++++ b/drivers/hid/hid-prodikeys.c +@@ -556,10 +556,14 @@ static void pcmidi_setup_extra_keys( + + static int pcmidi_set_operational(struct pcmidi_snd *pm) + { ++ int rc; ++ + if (pm->ifnum != 1) + return 0; /* only set up ONCE for interace 1 */ + +- pcmidi_get_output_report(pm); ++ rc = pcmidi_get_output_report(pm); ++ if (rc < 0) ++ return rc; + pcmidi_submit_output_report(pm, 0xc1); + return 0; + } +@@ -688,7 +692,11 @@ static int pcmidi_snd_initialise(struct + spin_lock_init(&pm->rawmidi_in_lock); + + init_sustain_timers(pm); +- pcmidi_set_operational(pm); ++ err = pcmidi_set_operational(pm); ++ if (err < 0) { ++ pk_error("failed to find output report\n"); ++ goto fail_register; ++ } + + /* register it */ + err = snd_card_register(card); diff --git a/queue-4.4/mtd-cfi_cmdset_0002-use-chip_good-to-retry-in-do_write_oneword.patch b/queue-4.4/mtd-cfi_cmdset_0002-use-chip_good-to-retry-in-do_write_oneword.patch new file mode 100644 index 00000000000..b0a2767acab --- /dev/null +++ b/queue-4.4/mtd-cfi_cmdset_0002-use-chip_good-to-retry-in-do_write_oneword.patch @@ -0,0 +1,86 @@ +From 37c673ade35c707d50583b5b25091ff8ebdeafd7 Mon Sep 17 00:00:00 2001 +From: Tokunori Ikegami +Date: Tue, 6 Aug 2019 04:03:18 +0900 +Subject: mtd: cfi_cmdset_0002: Use chip_good() to retry in do_write_oneword() + +From: Tokunori Ikegami + +commit 37c673ade35c707d50583b5b25091ff8ebdeafd7 upstream. + +As reported by the OpenWRT team, write requests sometimes fail on some +platforms. +Currently to check the state chip_ready() is used correctly as described by +the flash memory S29GL256P11TFI01 datasheet. +Also chip_good() is used to check if the write is succeeded and it was +implemented by the commit fb4a90bfcd6d8 ("[MTD] CFI-0002 - Improve error +checking"). +But actually the write failure is caused on some platforms and also it can +be fixed by using chip_good() to check the state and retry instead. +Also it seems that it is caused after repeated about 1,000 times to retry +the write one word with the reset command. +By using chip_good() to check the state to be done it can be reduced the +retry with reset. +It is depended on the actual flash chip behavior so the root cause is +unknown. + +Cc: Chris Packham +Cc: Joakim Tjernlund +Cc: linux-mtd@lists.infradead.org +Cc: stable@vger.kernel.org +Reported-by: Fabio Bettoni +Signed-off-by: Felix Fietkau +Signed-off-by: Hauke Mehrtens +Signed-off-by: Tokunori Ikegami +[vigneshr@ti.com: Fix a checkpatch warning] +Signed-off-by: Vignesh Raghavendra +Signed-off-by: Greg Kroah-Hartman + + +--- + drivers/mtd/chips/cfi_cmdset_0002.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -1626,29 +1626,35 @@ static int __xipram do_write_oneword(str + continue; + } + +- if (time_after(jiffies, timeo) && !chip_ready(map, adr)){ ++ /* ++ * We check "time_after" and "!chip_good" before checking ++ * "chip_good" to avoid the failure due to scheduling. ++ */ ++ if (time_after(jiffies, timeo) && !chip_good(map, adr, datum)) { + xip_enable(map, chip, adr); + printk(KERN_WARNING "MTD %s(): software timeout\n", __func__); + xip_disable(map, chip, adr); ++ ret = -EIO; + break; + } + +- if (chip_ready(map, adr)) ++ if (chip_good(map, adr, datum)) + break; + + /* Latency issues. Drop the lock, wait a while and retry */ + UDELAY(map, chip, adr, 1); + } ++ + /* Did we succeed? */ +- if (!chip_good(map, adr, datum)) { ++ if (ret) { + /* reset on all failures. */ + map_write( map, CMD(0xF0), chip->start ); + /* FIXME - should have reset delay before continuing */ + +- if (++retry_cnt <= MAX_RETRIES) ++ if (++retry_cnt <= MAX_RETRIES) { ++ ret = 0; + goto retry; +- +- ret = -EIO; ++ } + } + xip_enable(map, chip, adr); + op_done: diff --git a/queue-4.4/series b/queue-4.4/series index 13deb4519d2..5735362954d 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -1 +1,6 @@ revert-bluetooth-validate-ble-connection-interval-up.patch +hid-prodikeys-fix-general-protection-fault-during-probe.patch +hid-lg-make-transfer-buffers-dma-capable.patch +hid-logitech-fix-general-protection-fault-caused-by-logitech-driver.patch +hid-hidraw-fix-invalid-read-in-hidraw_ioctl.patch +mtd-cfi_cmdset_0002-use-chip_good-to-retry-in-do_write_oneword.patch