The patch titled
Subject: lib/strscpy: remove word-at-a-time optimization.
has been added to the -mm tree. Its filename is
lib-strscpy-remove-word-at-a-time-optimization.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/lib-strscpy-remove-word-at-a-time-…
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/lib-strscpy-remove-word-at-a-time-…
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Andrey Ryabinin <aryabinin(a)virtuozzo.com>
Subject: lib/strscpy: remove word-at-a-time optimization.
strscpy() performs the word-at-a-time optimistic reads. So it may may
access the memory past the end of the object, which is perfectly fine
since strscpy() doesn't use that (past-the-end) data and makes sure the
optimistic read won't cross a page boundary.
But KASAN doesn't know anything about that so it will complain. There are
several possible ways to address this issue, but none are perfect. See
https://lkml.kernel.org/r/9f0a9cf6-51f7-cd1f-5dc6-6d510a7b8ec4@virtuozzo.com
It seems the best solution is to simply disable word-at-a-time
optimization. My trivial testing shows that byte-at-a-time could be up to
x4.3 times slower than word-at-a-time. It may seems like a lot, but it's
actually ~1.2e-10 sec per symbol vs ~4.8e-10 sec per symbol on modern
hardware. And we don't use strscpy() in a performance critical paths to
copy large amounts of data, so it shouldn't matter anyway.
Link: http://lkml.kernel.org/r/20180109163745.3692-1-aryabinin@virtuozzo.com
Fixes: 30035e45753b7 ("string: provide strscpy()")
Signed-off-by: Andrey Ryabinin <aryabinin(a)virtuozzo.com>
Cc: Kees Cook <keescook(a)chromium.org>
Cc: Eryu Guan <eguan(a)redhat.com>
Cc: Alexander Potapenko <glider(a)google.com>
Cc: Chris Metcalf <metcalf(a)alum.mit.edu>
Cc: David Laight <David.Laight(a)ACULAB.COM>
Cc: Dmitry Vyukov <dvyukov(a)google.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
lib/string.c | 38 --------------------------------------
1 file changed, 38 deletions(-)
diff -puN lib/string.c~lib-strscpy-remove-word-at-a-time-optimization lib/string.c
--- a/lib/string.c~lib-strscpy-remove-word-at-a-time-optimization
+++ a/lib/string.c
@@ -29,7 +29,6 @@
#include <linux/errno.h>
#include <asm/byteorder.h>
-#include <asm/word-at-a-time.h>
#include <asm/page.h>
#ifndef __HAVE_ARCH_STRNCASECMP
@@ -177,45 +176,8 @@ EXPORT_SYMBOL(strlcpy);
*/
ssize_t strscpy(char *dest, const char *src, size_t count)
{
- const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
- size_t max = count;
long res = 0;
- if (count == 0)
- return -E2BIG;
-
-#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
- /*
- * If src is unaligned, don't cross a page boundary,
- * since we don't know if the next page is mapped.
- */
- if ((long)src & (sizeof(long) - 1)) {
- size_t limit = PAGE_SIZE - ((long)src & (PAGE_SIZE - 1));
- if (limit < max)
- max = limit;
- }
-#else
- /* If src or dest is unaligned, don't do word-at-a-time. */
- if (((long) dest | (long) src) & (sizeof(long) - 1))
- max = 0;
-#endif
-
- while (max >= sizeof(unsigned long)) {
- unsigned long c, data;
-
- c = *(unsigned long *)(src+res);
- if (has_zero(c, &data, &constants)) {
- data = prep_zero_mask(c, data, &constants);
- data = create_zero_mask(data);
- *(unsigned long *)(dest+res) = c & zero_bytemask(data);
- return res + find_zero(data);
- }
- *(unsigned long *)(dest+res) = c;
- res += sizeof(unsigned long);
- count -= sizeof(unsigned long);
- max -= sizeof(unsigned long);
- }
-
while (count) {
char c;
_
Patches currently in -mm which might be from aryabinin(a)virtuozzo.com are
kasan-makefile-support-llvm-style-asan-parameters.patch
lib-strscpy-remove-word-at-a-time-optimization.patch
> Christoph,
>
> > Ok. If the stable maintainers are ok with your small fix I'm not
> > going to complain too loudly. But I'm always worried about stable
> > trees divering too much from mainline.
>
> The seemingly innocuous transition from SG_GAPS to virt boundary has
> caused several data corruption regressions in the distro kernels. So has the
> corresponding conversion of storvsc.
>
> As a result, getting the current upstream code into 4.1 would mean
> backporting and testing a significant amount of both block layer and driver
> code. I don't think it's worth the risk. This patch is simple and the path of least
> resistance.
>
> Acked-by: Martin K. Petersen <martin.petersen(a)oracle.com>
Sorry to bring up this patch again. It seems it hasn't made it to stable branches.
Please take a look.
>
> --
> Martin K. Petersen Oracle Linux Engineering
This is the start of the stable review cycle for the 4.14.13 release.
There are 38 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 Wed Jan 10 12:59:02 UTC 2018.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.13-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.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 4.14.13-rc1
Christian Borntraeger <borntraeger(a)de.ibm.com>
KVM: s390: prevent buffer overrun on memory hotplug during migration
Christian Borntraeger <borntraeger(a)de.ibm.com>
KVM: s390: fix cmma migration for multiple memory slots
Boris Brezillon <boris.brezillon(a)free-electrons.com>
mtd: nand: pxa3xx: Fix READOOB implementation
Helge Deller <deller(a)gmx.de>
parisc: qemu idle sleep support
Helge Deller <deller(a)gmx.de>
parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel
John Johansen <john.johansen(a)canonical.com>
apparmor: fix regression in mount mediation when feature set is pinned
Tom Lendacky <thomas.lendacky(a)amd.com>
x86/microcode/AMD: Add support for fam17h microcode loading
Aaron Ma <aaron.ma(a)canonical.com>
Input: elantech - add new icbody type 15
John Sperbeck <jsperbeck(a)google.com>
powerpc/mm: Fix SEGV on mapped region to return SEGV_ACCERR
Vineet Gupta <vgupta(a)synopsys.com>
ARC: uaccess: dont use "l" gcc inline asm constraint modifier
Robin Murphy <robin.murphy(a)arm.com>
iommu/arm-smmu-v3: Cope with duplicated Stream IDs
Jean-Philippe Brucker <jean-philippe.brucker(a)arm.com>
iommu/arm-smmu-v3: Don't free page table ops twice
Oleg Nesterov <oleg(a)redhat.com>
kernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal()
Oleg Nesterov <oleg(a)redhat.com>
kernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals
Oleg Nesterov <oleg(a)redhat.com>
kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL
Rafael J. Wysocki <rafael.j.wysocki(a)intel.com>
x86 / CPU: Always show current CPU frequency in /proc/cpuinfo
Rafael J. Wysocki <rafael.j.wysocki(a)intel.com>
x86 / CPU: Avoid unnecessary IPIs in arch_freq_get_on_cpu()
David Howells <dhowells(a)redhat.com>
fscache: Fix the default for fscache_maybe_release_page()
Stefan Brüns <stefan.bruens(a)rwth-aachen.de>
sunxi-rsb: Include OF based modalias in device uevent
Lucas De Marchi <lucas.demarchi(a)intel.com>
drm/i915: Apply Display WA #1183 on skl, kbl, and cfl
Ville Syrjälä <ville.syrjala(a)linux.intel.com>
drm/i915: Disable DC states around GMBUS on GLK
Arnd Bergmann <arnd(a)arndb.de>
crypto: chelsio - select CRYPTO_GF128MUL
Eric Biggers <ebiggers(a)google.com>
crypto: pcrypt - fix freeing pcrypt instances
Eric Biggers <ebiggers(a)google.com>
crypto: chacha20poly1305 - validate the digest size
Jan Engelhardt <jengelh(a)inai.de>
crypto: n2 - cure use after free
Ard Biesheuvel <ard.biesheuvel(a)linaro.org>
efi/capsule-loader: Reinstate virtual capsule mapping
Chris Mason <clm(a)fb.com>
btrfs: fix refcount_t usage when deleting btrfs_delayed_nodes
Andrea Arcangeli <aarcange(a)redhat.com>
userfaultfd: clear the vma->vm_userfaultfd_ctx if UFFD_EVENT_FORK fails
Baoquan He <bhe(a)redhat.com>
mm/sparse.c: wrong allocation for mem_section
Anshuman Khandual <khandual(a)linux.vnet.ibm.com>
mm/mprotect: add a cond_resched() inside change_pmd_range()
Oleg Nesterov <oleg(a)redhat.com>
kernel/acct.c: fix the acct->needcheck check in check_free_space()
Thomas Gleixner <tglx(a)linutronix.de>
x86/pti: Rename BUG_CPU_INSECURE to BUG_CPU_MELTDOWN
David Woodhouse <dwmw(a)amazon.co.uk>
x86/alternatives: Add missing '\n' at end of ALTERNATIVE inline asm
Thomas Gleixner <tglx(a)linutronix.de>
x86/tlb: Drop the _GPL from the cpu_tlbstate export
Peter Zijlstra <peterz(a)infradead.org>
x86/events/intel/ds: Use the proper cache flush method for mapping ds buffers
Thomas Gleixner <tglx(a)linutronix.de>
x86/kaslr: Fix the vaddr_end mess
Thomas Gleixner <tglx(a)linutronix.de>
x86/mm: Map cpu_entry_area at the same place on 4/5 level
Andrey Ryabinin <aryabinin(a)virtuozzo.com>
x86/mm: Set MODULES_END to 0xffffffffff000000
-------------
Diffstat:
Documentation/x86/x86_64/mm.txt | 18 +++++----
Makefile | 4 +-
arch/arc/include/asm/uaccess.h | 5 ++-
arch/parisc/include/asm/ldcw.h | 2 +
arch/parisc/kernel/entry.S | 13 +++++-
arch/parisc/kernel/pacache.S | 9 ++++-
arch/parisc/kernel/process.c | 39 ++++++++++++++++++
arch/powerpc/mm/fault.c | 7 +++-
arch/s390/kvm/kvm-s390.c | 9 +++--
arch/s390/kvm/priv.c | 2 +-
arch/x86/events/intel/ds.c | 16 ++++++++
arch/x86/include/asm/alternative.h | 4 +-
arch/x86/include/asm/cpufeatures.h | 2 +-
arch/x86/include/asm/pgtable_64_types.h | 14 +++++--
arch/x86/kernel/cpu/Makefile | 2 +-
arch/x86/kernel/cpu/aperfmperf.c | 71 ++++++++++++++++++++++++---------
arch/x86/kernel/cpu/common.c | 2 +-
arch/x86/kernel/cpu/cpu.h | 3 ++
arch/x86/kernel/cpu/microcode/amd.c | 4 ++
arch/x86/kernel/cpu/proc.c | 6 ++-
arch/x86/mm/dump_pagetables.c | 2 +-
arch/x86/mm/init.c | 2 +-
arch/x86/mm/kaslr.c | 32 +++++----------
arch/x86/mm/pti.c | 6 +--
arch/x86/platform/efi/quirks.c | 13 +++++-
crypto/chacha20poly1305.c | 6 ++-
crypto/pcrypt.c | 19 ++++-----
drivers/bus/sunxi-rsb.c | 1 +
drivers/crypto/chelsio/Kconfig | 1 +
drivers/crypto/n2_core.c | 3 ++
drivers/firmware/efi/capsule-loader.c | 45 +++++++++++++++++----
drivers/gpu/drm/i915/i915_reg.h | 2 +
drivers/gpu/drm/i915/intel_cdclk.c | 35 +++++++++++-----
drivers/gpu/drm/i915/intel_runtime_pm.c | 11 +++++
drivers/input/mouse/elantech.c | 2 +-
drivers/iommu/arm-smmu-v3.c | 17 ++++++--
drivers/mtd/nand/pxa3xx_nand.c | 1 +
fs/btrfs/delayed-inode.c | 45 ++++++++++++++++-----
fs/proc/cpuinfo.c | 6 +++
fs/userfaultfd.c | 20 +++++++++-
include/linux/cpufreq.h | 1 +
include/linux/efi.h | 4 +-
include/linux/fscache.h | 2 +-
kernel/acct.c | 2 +-
kernel/signal.c | 18 +++++----
mm/mprotect.c | 6 ++-
mm/sparse.c | 2 +-
security/apparmor/mount.c | 12 +++++-
48 files changed, 409 insertions(+), 139 deletions(-)
This is a note to let you know that I've just added the patch titled
ANDROID: binder: remove waitqueue when thread exits.
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From f5cb779ba16334b45ba8946d6bfa6d9834d1527f Mon Sep 17 00:00:00 2001
From: Martijn Coenen <maco(a)android.com>
Date: Fri, 5 Jan 2018 11:27:07 +0100
Subject: ANDROID: binder: remove waitqueue when thread exits.
binder_poll() passes the thread->wait waitqueue that
can be slept on for work. When a thread that uses
epoll explicitly exits using BINDER_THREAD_EXIT,
the waitqueue is freed, but it is never removed
from the corresponding epoll data structure. When
the process subsequently exits, the epoll cleanup
code tries to access the waitlist, which results in
a use-after-free.
Prevent this by using POLLFREE when the thread exits.
Signed-off-by: Martijn Coenen <maco(a)android.com>
Reported-by: syzbot <syzkaller(a)googlegroups.com>
Cc: stable <stable(a)vger.kernel.org> # 4.14
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/android/binder.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 82fcc1e64e82..de4b67f09ddb 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4365,6 +4365,18 @@ static int binder_thread_release(struct binder_proc *proc,
if (t)
spin_lock(&t->lock);
}
+
+ /*
+ * If this thread used poll, make sure we remove the waitqueue
+ * from any epoll data structures holding it with POLLFREE.
+ * waitqueue_active() is safe to use here because we're holding
+ * the inner lock.
+ */
+ if ((thread->looper & BINDER_LOOPER_STATE_POLL) &&
+ waitqueue_active(&thread->wait)) {
+ wake_up_poll(&thread->wait, POLLHUP | POLLFREE);
+ }
+
binder_inner_proc_unlock(thread->proc);
if (send_reply)
--
2.15.1
This is a note to let you know that I've just added the patch titled
usb: f_fs: Prevent gadget unbind if it is already unbound
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From ce5bf9a50daf2d9078b505aca1cea22e88ecb94a Mon Sep 17 00:00:00 2001
From: Hemant Kumar <hemantk(a)codeaurora.org>
Date: Tue, 9 Jan 2018 12:30:53 +0530
Subject: usb: f_fs: Prevent gadget unbind if it is already unbound
Upon usb composition switch there is possibility of ep0 file
release happening after gadget driver bind. In case of composition
switch from adb to a non-adb composition gadget will never gets
bound again resulting into failure of usb device enumeration. Fix
this issue by checking FFS_FL_BOUND flag and avoid extra
gadget driver unbind if it is already done as part of composition
switch.
This fixes adb reconnection error reported on Android running
v4.4 and above kernel versions. Verified on Hikey running vanilla
v4.15-rc7 + few out of tree Mali patches.
Reviewed-at: https://android-review.googlesource.com/#/c/582632/
Cc: Felipe Balbi <balbi(a)kernel.org>
Cc: Greg KH <gregkh(a)linux-foundation.org>
Cc: Michal Nazarewicz <mina86(a)mina86.com>
Cc: John Stultz <john.stultz(a)linaro.org>
Cc: Dmitry Shmidt <dimitrysh(a)google.com>
Cc: Badhri <badhri(a)google.com>
Cc: Android Kernel Team <kernel-team(a)android.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Hemant Kumar <hemantk(a)codeaurora.org>
[AmitP: Cherry-picked it from android-4.14 and updated the commit log]
Signed-off-by: Amit Pundir <amit.pundir(a)linaro.org>
Cc: stable <stable(a)vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/usb/gadget/function/f_fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 038a27a13ebc..686af89323a5 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3703,7 +3703,8 @@ static void ffs_closed(struct ffs_data *ffs)
ci = opts->func_inst.group.cg_item.ci_parent->ci_parent;
ffs_dev_unlock();
- unregister_gadget_item(ci);
+ if (test_bit(FFS_FL_BOUND, &ffs->flags))
+ unregister_gadget_item(ci);
return;
done:
ffs_dev_unlock();
--
2.15.1
This is a note to let you know that I've just added the patch titled
serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTS
to my tty git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
in the tty-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From 38b1f0fb42f772b8c9aac53593883a18ff5eb9d7 Mon Sep 17 00:00:00 2001
From: Fabio Estevam <fabio.estevam(a)nxp.com>
Date: Thu, 4 Jan 2018 15:58:34 -0200
Subject: serial: imx: Only wakeup via RTSDEN bit if the system has RTS/CTS
The wakeup mechanism via RTSDEN bit relies on the system using the RTS/CTS
lines, so only allow such wakeup method when the system actually has
RTS/CTS support.
Fixes: bc85734b126f ("serial: imx: allow waking up on RTSD")
Signed-off-by: Fabio Estevam <fabio.estevam(a)nxp.com>
Reviewed-by: Martin Kaiser <martin(a)kaiser.cx>
Acked-by: Fugang Duan <fugang.duan(a)nxp.com>
Cc: stable <stable(a)vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/tty/serial/imx.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index c2b29fd66e8a..7143da39c170 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2225,12 +2225,14 @@ static void serial_imx_enable_wakeup(struct imx_port *sport, bool on)
val &= ~UCR3_AWAKEN;
writel(val, sport->port.membase + UCR3);
- val = readl(sport->port.membase + UCR1);
- if (on)
- val |= UCR1_RTSDEN;
- else
- val &= ~UCR1_RTSDEN;
- writel(val, sport->port.membase + UCR1);
+ if (sport->have_rtscts) {
+ val = readl(sport->port.membase + UCR1);
+ if (on)
+ val |= UCR1_RTSDEN;
+ else
+ val &= ~UCR1_RTSDEN;
+ writel(val, sport->port.membase + UCR1);
+ }
}
static int imx_serial_port_suspend_noirq(struct device *dev)
--
2.15.1
This is a note to let you know that I've just added the patch titled
serial: 8250_uniphier: fix error return code in uniphier_uart_probe()
to my tty git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
in the tty-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From 7defa77d2baca4d6eb85234f10f38ab618332e75 Mon Sep 17 00:00:00 2001
From: Wei Yongjun <weiyongjun1(a)huawei.com>
Date: Thu, 4 Jan 2018 07:42:15 +0000
Subject: serial: 8250_uniphier: fix error return code in uniphier_uart_probe()
Fix to return a negative error code from the port register error
handling case instead of 0, as done elsewhere in this function.
Fixes: 39be40ce066d ("serial: 8250_uniphier: fix serial port index in private data")
Signed-off-by: Wei Yongjun <weiyongjun1(a)huawei.com>
Acked-by: Masahiro Yamada <yamada.masahiro(a)socionext.com>
Cc: stable <stable(a)vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/tty/serial/8250/8250_uniphier.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c
index 45ef506293ae..28d88ccf5a0c 100644
--- a/drivers/tty/serial/8250/8250_uniphier.c
+++ b/drivers/tty/serial/8250/8250_uniphier.c
@@ -250,12 +250,13 @@ static int uniphier_uart_probe(struct platform_device *pdev)
up.dl_read = uniphier_serial_dl_read;
up.dl_write = uniphier_serial_dl_write;
- priv->line = serial8250_register_8250_port(&up);
- if (priv->line < 0) {
+ ret = serial8250_register_8250_port(&up);
+ if (ret < 0) {
dev_err(dev, "failed to register 8250 port\n");
clk_disable_unprepare(priv->clk);
return ret;
}
+ priv->line = ret;
platform_set_drvdata(pdev, priv);
--
2.15.1
This is a note to let you know that I've just added the patch titled
ANDROID: binder: remove waitqueue when thread exits.
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-testing branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will be merged to the char-misc-next branch sometime soon,
after it passes testing, and the merge window is open.
If you have any questions about this process, please let me know.
>From f5cb779ba16334b45ba8946d6bfa6d9834d1527f Mon Sep 17 00:00:00 2001
From: Martijn Coenen <maco(a)android.com>
Date: Fri, 5 Jan 2018 11:27:07 +0100
Subject: ANDROID: binder: remove waitqueue when thread exits.
binder_poll() passes the thread->wait waitqueue that
can be slept on for work. When a thread that uses
epoll explicitly exits using BINDER_THREAD_EXIT,
the waitqueue is freed, but it is never removed
from the corresponding epoll data structure. When
the process subsequently exits, the epoll cleanup
code tries to access the waitlist, which results in
a use-after-free.
Prevent this by using POLLFREE when the thread exits.
Signed-off-by: Martijn Coenen <maco(a)android.com>
Reported-by: syzbot <syzkaller(a)googlegroups.com>
Cc: stable <stable(a)vger.kernel.org> # 4.14
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/android/binder.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 82fcc1e64e82..de4b67f09ddb 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4365,6 +4365,18 @@ static int binder_thread_release(struct binder_proc *proc,
if (t)
spin_lock(&t->lock);
}
+
+ /*
+ * If this thread used poll, make sure we remove the waitqueue
+ * from any epoll data structures holding it with POLLFREE.
+ * waitqueue_active() is safe to use here because we're holding
+ * the inner lock.
+ */
+ if ((thread->looper & BINDER_LOOPER_STATE_POLL) &&
+ waitqueue_active(&thread->wait)) {
+ wake_up_poll(&thread->wait, POLLHUP | POLLFREE);
+ }
+
binder_inner_proc_unlock(thread->proc);
if (send_reply)
--
2.15.1
This is the start of the stable review cycle for the 4.4.111 release.
There are 22 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 Wed Jan 10 12:59:14 UTC 2018.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.111-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.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 4.4.111-rc1
Borislav Petkov <bp(a)suse.de>
Map the vsyscall page with _PAGE_USER
Alexey Dobriyan <adobriyan(a)gmail.com>
proc: much faster /proc/vmstat
Libor Pechacek <lpechacek(a)suse.com>
module: Issue warnings when tainting kernel
Miroslav Benes <mbenes(a)suse.cz>
module: keep percpu symbols in module's symtab
Michal Marek <mmarek(a)suse.com>
genksyms: Handle string literals with spaces in reference files
Thomas Gleixner <tglx(a)linutronix.de>
x86/tlb: Drop the _GPL from the cpu_tlbstate export
Boris Brezillon <boris.brezillon(a)free-electrons.com>
mtd: nand: pxa3xx: Fix READOOB implementation
Helge Deller <deller(a)gmx.de>
parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel
Tom Lendacky <thomas.lendacky(a)amd.com>
x86/microcode/AMD: Add support for fam17h microcode loading
Aaron Ma <aaron.ma(a)canonical.com>
Input: elantech - add new icbody type 15
Vineet Gupta <vgupta(a)synopsys.com>
ARC: uaccess: dont use "l" gcc inline asm constraint modifier
Oleg Nesterov <oleg(a)redhat.com>
kernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal()
Oleg Nesterov <oleg(a)redhat.com>
kernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals
Oleg Nesterov <oleg(a)redhat.com>
kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL
Thiago Rafael Becker <thiago.becker(a)gmail.com>
kernel: make groups_sort calling a responsibility group_info allocators
David Howells <dhowells(a)redhat.com>
fscache: Fix the default for fscache_maybe_release_page()
Stefan Brüns <stefan.bruens(a)rwth-aachen.de>
sunxi-rsb: Include OF based modalias in device uevent
Eric Biggers <ebiggers(a)google.com>
crypto: pcrypt - fix freeing pcrypt instances
Eric Biggers <ebiggers(a)google.com>
crypto: chacha20poly1305 - validate the digest size
Jan Engelhardt <jengelh(a)inai.de>
crypto: n2 - cure use after free
Oleg Nesterov <oleg(a)redhat.com>
kernel/acct.c: fix the acct->needcheck check in check_free_space()
Andrey Ryabinin <aryabinin(a)virtuozzo.com>
x86/kasan: Write protect kasan zero shadow
-------------
Diffstat:
Makefile | 4 ++--
arch/arc/include/asm/uaccess.h | 5 +++--
arch/parisc/include/asm/ldcw.h | 2 ++
arch/parisc/kernel/entry.S | 13 +++++++++++--
arch/parisc/kernel/pacache.S | 9 +++++++--
arch/s390/kernel/compat_linux.c | 1 +
arch/x86/entry/vsyscall/vsyscall_64.c | 5 +++++
arch/x86/include/asm/vsyscall.h | 2 ++
arch/x86/kernel/cpu/microcode/amd.c | 4 ++++
arch/x86/mm/init.c | 2 +-
arch/x86/mm/kaiser.c | 34 ++++++++++++++++++++++++++++++----
arch/x86/mm/kasan_init_64.c | 10 ++++++++--
crypto/chacha20poly1305.c | 6 +++++-
crypto/pcrypt.c | 19 ++++++++++---------
drivers/bus/sunxi-rsb.c | 1 +
drivers/crypto/n2_core.c | 3 +++
drivers/input/mouse/elantech.c | 2 +-
drivers/mtd/nand/pxa3xx_nand.c | 1 +
fs/nfsd/auth.c | 3 +++
include/linux/cred.h | 1 +
include/linux/fscache.h | 2 +-
kernel/acct.c | 2 +-
kernel/groups.c | 5 +++--
kernel/module.c | 26 +++++++++++++++++++++-----
kernel/signal.c | 18 ++++++++++--------
kernel/uid16.c | 1 +
mm/vmstat.c | 4 +++-
net/sunrpc/auth_gss/gss_rpc_xdr.c | 1 +
net/sunrpc/auth_gss/svcauth_gss.c | 1 +
net/sunrpc/svcauth_unix.c | 2 ++
scripts/genksyms/genksyms.c | 6 ++++--
31 files changed, 149 insertions(+), 46 deletions(-)