From: Sasha Levin Date: Mon, 23 Mar 2020 17:11:51 +0000 (-0400) Subject: Fixes for 4.9 X-Git-Tag: v4.19.113~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd487f1565dc803dfc026d665cae8f9eb40feb0f;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/kbuild-disable-wpointer-to-enum-cast.patch b/queue-4.9/kbuild-disable-wpointer-to-enum-cast.patch new file mode 100644 index 00000000000..176e1a3709e --- /dev/null +++ b/queue-4.9/kbuild-disable-wpointer-to-enum-cast.patch @@ -0,0 +1,48 @@ +From cc888e31982a545c8cc9af6b119cec8a1c62f818 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 11 Mar 2020 12:41:21 -0700 +Subject: kbuild: Disable -Wpointer-to-enum-cast + +From: Nathan Chancellor + +commit 82f2bc2fcc0160d6f82dd1ac64518ae0a4dd183f upstream. + +Clang's -Wpointer-to-int-cast deviates from GCC in that it warns when +casting to enums. The kernel does this in certain places, such as device +tree matches to set the version of the device being used, which allows +the kernel to avoid using a gigantic union. + +https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L428 +https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L402 +https://elixir.bootlin.com/linux/v5.5.8/source/include/linux/mod_devicetable.h#L264 + +To avoid a ton of false positive warnings, disable this particular part +of the warning, which has been split off into a separate diagnostic so +that the entire warning does not need to be turned off for clang. It +will be visible under W=1 in case people want to go about fixing these +easily and enabling the warning treewide. + +Cc: stable@vger.kernel.org +Link: https://github.com/ClangBuiltLinux/linux/issues/887 +Link: https://github.com/llvm/llvm-project/commit/2a41b31fcdfcb67ab7038fc2ffb606fd50b83a84 +Signed-off-by: Nathan Chancellor +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + scripts/Makefile.extrawarn | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn +index d08b6fbdfa853..1532038f60055 100644 +--- a/scripts/Makefile.extrawarn ++++ b/scripts/Makefile.extrawarn +@@ -70,5 +70,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format) + KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare) + KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length) + KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized) ++KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) + endif + endif +-- +2.20.1 + diff --git a/queue-4.9/series b/queue-4.9/series index 554bd08b074..0d9a83b7d01 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -25,3 +25,6 @@ memcg-fix-null-pointer-dereference-in-__mem_cgroup_usage_unregister_event.patch mm-slub-be-more-careful-about-the-double-cmpxchg-of-freelist.patch mm-slub-prevent-kmalloc_node-crashes-and-memory-leaks.patch x86-mm-split-vmalloc_sync_all.patch +usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch +usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch +kbuild-disable-wpointer-to-enum-cast.patch diff --git a/queue-4.9/usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch b/queue-4.9/usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch new file mode 100644 index 00000000000..57de27e94c2 --- /dev/null +++ b/queue-4.9/usb-cdc-acm-fix-close_delay-and-closing_wait-units-i.patch @@ -0,0 +1,55 @@ +From dde5a09d44ab41478932fbcfe9683531b6ecd516 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 12 Mar 2020 14:31:00 +0100 +Subject: USB: cdc-acm: fix close_delay and closing_wait units in TIOCSSERIAL + +From: Anthony Mallet + +[ Upstream commit 633e2b2ded739a34bd0fb1d8b5b871f7e489ea29 ] + +close_delay and closing_wait are specified in hundredth of a second but stored +internally in jiffies. Use the jiffies_to_msecs() and msecs_to_jiffies() +functions to convert from each other. + +Signed-off-by: Anthony Mallet +Cc: stable +Link: https://lore.kernel.org/r/20200312133101.7096-1-anthony.mallet@laas.fr +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/class/cdc-acm.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c +index b2edbd4bf8c44..9fd1cd99aa977 100644 +--- a/drivers/usb/class/cdc-acm.c ++++ b/drivers/usb/class/cdc-acm.c +@@ -828,10 +828,10 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info) + tmp.flags = ASYNC_LOW_LATENCY; + tmp.xmit_fifo_size = acm->writesize; + tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); +- tmp.close_delay = acm->port.close_delay / 10; ++ tmp.close_delay = jiffies_to_msecs(acm->port.close_delay) / 10; + tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? + ASYNC_CLOSING_WAIT_NONE : +- acm->port.closing_wait / 10; ++ jiffies_to_msecs(acm->port.closing_wait) / 10; + + if (copy_to_user(info, &tmp, sizeof(tmp))) + return -EFAULT; +@@ -849,9 +849,10 @@ static int set_serial_info(struct acm *acm, + if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) + return -EFAULT; + +- close_delay = new_serial.close_delay * 10; ++ close_delay = msecs_to_jiffies(new_serial.close_delay * 10); + closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ? +- ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10; ++ ASYNC_CLOSING_WAIT_NONE : ++ msecs_to_jiffies(new_serial.closing_wait * 10); + + mutex_lock(&acm->port.mutex); + +-- +2.20.1 + diff --git a/queue-4.9/usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch b/queue-4.9/usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch new file mode 100644 index 00000000000..0e7e3e36393 --- /dev/null +++ b/queue-4.9/usb-cdc-acm-fix-rounding-error-in-tiocsserial.patch @@ -0,0 +1,84 @@ +From 30f60b6da383440926631eb1ef0dc40d2558be44 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 12 Mar 2020 14:31:01 +0100 +Subject: USB: cdc-acm: fix rounding error in TIOCSSERIAL + +From: Anthony Mallet + +[ Upstream commit b401f8c4f492cbf74f3f59c9141e5be3071071bb ] + +By default, tty_port_init() initializes those parameters to a multiple +of HZ. For instance in line 69 of tty_port.c: + port->close_delay = (50 * HZ) / 100; +https://github.com/torvalds/linux/blob/master/drivers/tty/tty_port.c#L69 + +With e.g. CONFIG_HZ = 250 (as this is the case for Ubuntu 18.04 +linux-image-4.15.0-37-generic), the default setting for close_delay is +thus 125. + +When ioctl(fd, TIOCGSERIAL, &s) is executed, the setting returned in +user space is '12' (125/10). When ioctl(fd, TIOCSSERIAL, &s) is then +executed with the same setting '12', the value is interpreted as '120' +which is different from the current setting and a EPERM error may be +raised by set_serial_info() if !CAP_SYS_ADMIN. +https://github.com/torvalds/linux/blob/master/drivers/usb/class/cdc-acm.c#L919 + +Fixes: ba2d8ce9db0a6 ("cdc-acm: implement TIOCSSERIAL to avoid blocking close(2)") +Signed-off-by: Anthony Mallet +Cc: stable +Link: https://lore.kernel.org/r/20200312133101.7096-2-anthony.mallet@laas.fr +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/class/cdc-acm.c | 25 ++++++++++++++++--------- + 1 file changed, 16 insertions(+), 9 deletions(-) + +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c +index 9fd1cd99aa977..13df3c8cd7bfa 100644 +--- a/drivers/usb/class/cdc-acm.c ++++ b/drivers/usb/class/cdc-acm.c +@@ -844,6 +844,7 @@ static int set_serial_info(struct acm *acm, + { + struct serial_struct new_serial; + unsigned int closing_wait, close_delay; ++ unsigned int old_closing_wait, old_close_delay; + int retval = 0; + + if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) +@@ -854,18 +855,24 @@ static int set_serial_info(struct acm *acm, + ASYNC_CLOSING_WAIT_NONE : + msecs_to_jiffies(new_serial.closing_wait * 10); + ++ /* we must redo the rounding here, so that the values match */ ++ old_close_delay = jiffies_to_msecs(acm->port.close_delay) / 10; ++ old_closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? ++ ASYNC_CLOSING_WAIT_NONE : ++ jiffies_to_msecs(acm->port.closing_wait) / 10; ++ + mutex_lock(&acm->port.mutex); + +- if (!capable(CAP_SYS_ADMIN)) { +- if ((close_delay != acm->port.close_delay) || +- (closing_wait != acm->port.closing_wait)) ++ if ((new_serial.close_delay != old_close_delay) || ++ (new_serial.closing_wait != old_closing_wait)) { ++ if (!capable(CAP_SYS_ADMIN)) + retval = -EPERM; +- else +- retval = -EOPNOTSUPP; +- } else { +- acm->port.close_delay = close_delay; +- acm->port.closing_wait = closing_wait; +- } ++ else { ++ acm->port.close_delay = close_delay; ++ acm->port.closing_wait = closing_wait; ++ } ++ } else ++ retval = -EOPNOTSUPP; + + mutex_unlock(&acm->port.mutex); + return retval; +-- +2.20.1 +