Handling CD-ROM devices from libsas is decidedly odd, as libata
relies on SCSI EH to be started to figure out that no medium is
present.
So we cannot do asynchronous aborts for SATA devices.
Fixes: 909657615d9 ("scsi: libsas: allow async aborts")
Cc: <stable(a)vger.kernel.org> # 4.12+
Signed-off-by: Hannes Reinecke <hare(a)suse.com>
Reviewed-by: Christoph Hellwig <hch(a)lst.de>
Tested-by: Yves-Alexis Perez <corsac(a)debian.org>
---
drivers/scsi/libsas/sas_scsi_host.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 6267272..6de9681 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -487,15 +487,28 @@ static int sas_queue_reset(struct domain_device *dev, int reset_type,
int sas_eh_abort_handler(struct scsi_cmnd *cmd)
{
- int res;
+ int res = TMF_RESP_FUNC_FAILED;
struct sas_task *task = TO_SAS_TASK(cmd);
struct Scsi_Host *host = cmd->device->host;
+ struct domain_device *dev = cmd_to_domain_dev(cmd);
struct sas_internal *i = to_sas_internal(host->transportt);
+ unsigned long flags;
if (!i->dft->lldd_abort_task)
return FAILED;
- res = i->dft->lldd_abort_task(task);
+ spin_lock_irqsave(host->host_lock, flags);
+ /* We cannot do async aborts for SATA devices */
+ if (dev_is_sata(dev) && !host->host_eh_scheduled) {
+ spin_unlock_irqrestore(host->host_lock, flags);
+ return FAILED;
+ }
+ spin_unlock_irqrestore(host->host_lock, flags);
+
+ if (task)
+ res = i->dft->lldd_abort_task(task);
+ else
+ SAS_DPRINTK("no task to abort\n");
if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
return SUCCESS;
--
1.8.5.6
From: Eric Biggers <ebiggers(a)google.com>
pipe-user-pages-hard and pipe-user-pages-soft are only supposed to apply
to unprivileged users, as documented in both Documentation/sysctl/fs.txt
and the pipe(7) man page.
However, the capabilities are actually only checked when increasing a
pipe's size using F_SETPIPE_SZ, not when creating a new pipe.
Therefore, if pipe-user-pages-hard has been set, the root user can run
into it and be unable to create pipes. Similarly, if
pipe-user-pages-soft has been set, the root user can run into it and
have their pipes limited to 1 page each.
Fix this by allowing the privileged override in both cases.
Fixes: 759c01142a5d ("pipe: limit the per-user amount of pages allocated in pipes")
Cc: stable(a)vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
fs/pipe.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/pipe.c b/fs/pipe.c
index d0dec5e7ef33..847ecc388820 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -613,6 +613,11 @@ static bool too_many_pipe_buffers_hard(unsigned long user_bufs)
return pipe_user_pages_hard && user_bufs >= pipe_user_pages_hard;
}
+static bool is_unprivileged_user(void)
+{
+ return !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN);
+}
+
struct pipe_inode_info *alloc_pipe_info(void)
{
struct pipe_inode_info *pipe;
@@ -629,12 +634,12 @@ struct pipe_inode_info *alloc_pipe_info(void)
user_bufs = account_pipe_buffers(user, 0, pipe_bufs);
- if (too_many_pipe_buffers_soft(user_bufs)) {
+ if (too_many_pipe_buffers_soft(user_bufs) && is_unprivileged_user()) {
user_bufs = account_pipe_buffers(user, pipe_bufs, 1);
pipe_bufs = 1;
}
- if (too_many_pipe_buffers_hard(user_bufs))
+ if (too_many_pipe_buffers_hard(user_bufs) && is_unprivileged_user())
goto out_revert_acct;
pipe->bufs = kcalloc(pipe_bufs, sizeof(struct pipe_buffer),
@@ -1065,7 +1070,7 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)
if (nr_pages > pipe->buffers &&
(too_many_pipe_buffers_hard(user_bufs) ||
too_many_pipe_buffers_soft(user_bufs)) &&
- !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) {
+ is_unprivileged_user()) {
ret = -EPERM;
goto out_revert_acct;
}
--
2.15.1
Hello Bjorn,
Again, reviving this very old thread :-)
On Thu, 5 Oct 2017 12:23:30 -0500, Bjorn Helgaas wrote:
> > - if (PCI_SLOT(devfn) != 0) {
> > + if ((bus->number == pcie->root_bus_nr) && (PCI_SLOT(devfn) != 0)) {
>
> I'm fine with this, but please take a look at these:
>
> 8e7ca8ca5fd8 PCI: xilinx: Relax device number checking to allow SR-IOV
> e18934b5e9c7 PCI: designware: Relax device number checking to allow SR-IOV
> d99e30b7936a PCI: altera: Relax device number checking to allow SR-IOV
>
> and make sure that reasoning doesn't apply here, too.
>
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8…
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=e…
> http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d…
The original code for xilinx/designware/altera was doing:
if (bus->number == port->root_busno && devfn > 0)
return false;
if (bus->primary == port->root_busno && devfn > 0)
return false;
I.e, it was checking both if bus->number *and* bus->primary were equal
to port->root_busno.
The commit you points removed the check on bus->primary, keeping the
check on bus->number.
Your patch for the Aadvark driver only adds a check on bus->number, i.e
exactly what the xilinx/designware/altera code is still doing today:
Altera:
/* access only one slot on each root port */
if (bus->number == pcie->root_bus_nr && dev > 0)
return false;
Designware:
/* access only one slot on each root port */
if (bus->number == pp->root_bus_nr && dev > 0)
return 0;
Xilinx:
/* Only one device down on each root port */
if (bus->number == port->root_busno && devfn > 0)
return false;
Aardvark (with our patch):
if ((bus->number == pcie->root_bus_nr) && (PCI_SLOT(devfn) != 0)) {
*val = 0xffffffff;
return PCIBIOS_DEVICE_NOT_FOUND;
}
So we're doing exactly the same thing.
Do you agree ?
Best regards,
Thomas Petazzoni
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
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