Use the new of_get_compatible_child() helper to lookup the slot child
node instead of using of_find_compatible_node(), which searches the
entire tree from a given start node and thus can return an unrelated
(i.e. non-child) node.
This also addresses a potential use-after-free (e.g. after probe
deferral) as the tree-wide helper drops a reference to its first
argument (i.e. the node of the device being probed).
While at it, also fix up the related slot-node reference leak.
Fixes: ed80a13bb4c4 ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs")
Cc: stable <stable(a)vger.kernel.org> # 4.15
Cc: Carlo Caione <carlo(a)endlessm.com>
Cc: Martin Blumenstingl <martin.blumenstingl(a)googlemail.com>
Cc: Ulf Hansson <ulf.hansson(a)linaro.org>
Acked-by: Martin Blumenstingl <martin.blumenstingl(a)googlemail.com>
Signed-off-by: Johan Hovold <johan(a)kernel.org>
---
drivers/mmc/host/meson-mx-sdio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
index 09cb89645d06..2cfec33178c1 100644
--- a/drivers/mmc/host/meson-mx-sdio.c
+++ b/drivers/mmc/host/meson-mx-sdio.c
@@ -517,19 +517,23 @@ static struct mmc_host_ops meson_mx_mmc_ops = {
static struct platform_device *meson_mx_mmc_slot_pdev(struct device *parent)
{
struct device_node *slot_node;
+ struct platform_device *pdev;
/*
* TODO: the MMC core framework currently does not support
* controllers with multiple slots properly. So we only register
* the first slot for now
*/
- slot_node = of_find_compatible_node(parent->of_node, NULL, "mmc-slot");
+ slot_node = of_get_compatible_child(parent->of_node, "mmc-slot");
if (!slot_node) {
dev_warn(parent, "no 'mmc-slot' sub-node found\n");
return ERR_PTR(-ENOENT);
}
- return of_platform_device_create(slot_node, NULL, parent);
+ pdev = of_platform_device_create(slot_node, NULL, parent);
+ of_node_put(slot_node);
+
+ return pdev;
}
static int meson_mx_mmc_add_host(struct meson_mx_mmc_host *host)
--
2.18.0
xen_swiotlb_{alloc,free}_coherent() actually allocate/free size by order
but used the required size to check if address is physical contiguous,
if first pages are physical contiguous also passed
range_straddles_page_boundary() check, but others were not it will
lead kernel panic.
Signed-off-by: Joe Jin <joe.jin(a)oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk(a)oracle.com>
---
drivers/xen/swiotlb-xen.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index a6f9ba85dc4b..aa081f806728 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -303,6 +303,9 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
*/
flags &= ~(__GFP_DMA | __GFP_HIGHMEM);
+ /* Convert the size to actually allocated. */
+ size = 1UL << (order + XEN_PAGE_SHIFT);
+
/* On ARM this function returns an ioremap'ped virtual address for
* which virt_to_phys doesn't return the corresponding physical
* address. In fact on ARM virt_to_phys only works for kernel direct
@@ -351,6 +354,9 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
* physical address */
phys = xen_bus_to_phys(dev_addr);
+ /* Convert the size to actually allocated. */
+ size = 1UL << (order + XEN_PAGE_SHIFT);
+
if (((dev_addr + size - 1 <= dma_mask)) ||
range_straddles_page_boundary(phys, size))
xen_destroy_contiguous_region(phys, order);
--
2.15.2 (Apple Git-101.1)
This is the start of the stable review cycle for the 3.18.121 release.
There are 56 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 Sep 5 16:49:09 UTC 2018.
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/v3.x/stable-review/patch-3.18.121-r…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-3.18.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 3.18.121-rc1
Scott Bauer <scott.bauer(a)intel.com>
cdrom: Fix info leak/OOB read in cdrom_ioctl_drive_status
Bart Van Assche <bart.vanassche(a)wdc.com>
scsi: core: Avoid that SCSI device removal through sysfs triggers a deadlock
Bart Van Assche <bart.vanassche(a)wdc.com>
scsi: sysfs: Introduce sysfs_{un,}break_active_protection()
Maciej W. Rozycki <macro(a)mips.com>
MIPS: Correct the 64-bit DSP accumulator register size
Masami Hiramatsu <mhiramat(a)kernel.org>
kprobes: Make list and blacklist root user read only
Sebastian Ott <sebott(a)linux.ibm.com>
s390/pci: fix out of bounds access during irq setup
Julian Wiedmann <jwi(a)linux.ibm.com>
s390/qdio: reset old sbal_state flags
Dan Carpenter <dan.carpenter(a)oracle.com>
pinctrl: freescale: off by one in imx1_pinconf_group_dbg_show()
Gustavo A. R. Silva <gustavo(a)embeddedor.com>
ASoC: sirf: Fix potential NULL pointer dereference
Mikulas Patocka <mpatocka(a)redhat.com>
udl-kms: fix crash due to uninitialized memory
Mikulas Patocka <mpatocka(a)redhat.com>
udl-kms: handle allocation failure
Mikulas Patocka <mpatocka(a)redhat.com>
udl-kms: change down_interruptible to down
Kirill Tkhai <ktkhai(a)virtuozzo.com>
fuse: Add missed unlock_page() to fuse_readpages_fill()
Andrey Ryabinin <aryabinin(a)virtuozzo.com>
fuse: Don't access pipe->buffers without pipe_lock()
Rian Hunter <rian(a)alum.mit.edu>
x86/process: Re-export start_thread()
Punit Agrawal <punit.agrawal(a)arm.com>
KVM: arm/arm64: Skip updating PMD entry if no change
Punit Agrawal <punit.agrawal(a)arm.com>
KVM: arm/arm64: Skip updating PTE entry if no change
Greg Hackmann <ghackmann(a)android.com>
arm64: mm: check for upper PAGE_SHIFT bits in pfn_valid()
Eric Sandeen <sandeen(a)redhat.com>
ext4: reset error code in ext4_find_entry in fallback
Claudio Imbrenda <imbrenda(a)linux.vnet.ibm.com>
s390/kvm: fix deadlock when killed by oom
Josef Bacik <josef(a)toxicpanda.com>
btrfs: don't leak ret from do_chunk_alloc
jie@chenjie6@huwei.com <jie@chenjie6@huwei.com>
mm/memory.c: check return value of ioremap_prot
Jim Gill <jgill(a)vmware.com>
scsi: vmw_pvscsi: Return DID_RESET for status SAM_STAT_COMMAND_TERMINATED
Johannes Thumshirn <jthumshirn(a)suse.de>
scsi: fcoe: drop frames in ELS LOGO error path
Colin Ian King <colin.king(a)canonical.com>
drivers: net: lmc: fix case value for target abort error
Randy Dunlap <rdunlap(a)infradead.org>
arc: fix type warnings in arc/mm/cache.c
Randy Dunlap <rdunlap(a)infradead.org>
arc: fix build errors in arc/include/asm/delay.h
Govindarajulu Varadarajan <gvaradar(a)cisco.com>
enic: handle mtu change for vf properly
Rafał Miłecki <rafal(a)milecki.pl>
Revert "MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum"
Calvin Walton <calvin.walton(a)kepstin.ca>
tools/power turbostat: Read extended processor family from CPUID
Li Wang <liwang(a)redhat.com>
zswap: re-check zswap_is_full() after do zswap_shrink()
Masami Hiramatsu <mhiramat(a)kernel.org>
selftests/ftrace: Add snapshot and tracing_on test case
Kiran Kumar Modukuri <kiran.modukuri(a)gmail.com>
cachefiles: Wait rather than BUG'ing on "Unexpected object collision"
Kiran Kumar Modukuri <kiran.modukuri(a)gmail.com>
cachefiles: Fix refcounting bug in backing-file read monitoring
Kiran Kumar Modukuri <kiran.modukuri(a)gmail.com>
fscache: Allow cancelled operations to be enqueued
Shubhrajyoti Datta <shubhrajyoti.datta(a)xilinx.com>
net: axienet: Fix double deregister of mdio
Sudarsana Reddy Kalluru <sudarsana.kalluru(a)cavium.com>
bnx2x: Fix invalid memory access in rss hash config path.
Guenter Roeck <linux(a)roeck-us.net>
media: staging: omap4iss: Include asm/cacheflush.h after generic includes
Nicholas Mc Guire <hofrat(a)osadl.org>
can: mpc5xxx_can: check of_iomap return before use
Florian Westphal <fw(a)strlen.de>
atl1c: reserve min skb headroom
YueHaibing <yuehaibing(a)huawei.com>
net: caif: Add a missing rcu_read_unlock() in caif_flow_cb
Len Brown <len.brown(a)intel.com>
tools/power turbostat: fix -S on UP systems
Eugeniu Rosca <roscaeugeniu(a)gmail.com>
usb: gadget: f_uac2: fix endianness of 'struct cntrl_*_lay3'
Peter Senna Tschudin <peter.senna(a)gmail.com>
tools: usb: ffs-test: Fix build on big endian systems
Randy Dunlap <rdunlap(a)infradead.org>
usb/phy: fix PPC64 build errors in phy-fsl-usb.c
Jia-Ju Bai <baijiaju1990(a)gmail.com>
usb: gadget: r8a66597: Fix a possible sleep-in-atomic-context bugs in r8a66597_queue()
Jia-Ju Bai <baijiaju1990(a)gmail.com>
usb: gadget: r8a66597: Fix two possible sleep-in-atomic-context bugs in init_controller()
Lucas Stach <l.stach(a)pengutronix.de>
drm/imx: imx-ldb: check if channel is enabled before printing warning
Lucas Stach <l.stach(a)pengutronix.de>
drm/imx: imx-ldb: disable LDB on driver bind
Varun Prakash <varun(a)chelsio.com>
scsi: libiscsi: fix possible NULL pointer dereference in case of TMF
Bernd Edlinger <bernd.edlinger(a)hotmail.de>
nl80211: Add a missing break in parse_station_flags
mpubbise(a)codeaurora.org <mpubbise(a)codeaurora.org>
mac80211: add stations tied to AP_VLANs during hw reconfig
Florian Westphal <fw(a)strlen.de>
xfrm: free skb if nlsk pointer is NULL
Tommi Rantala <tommi.t.rantala(a)nokia.com>
xfrm: fix missing dst_release() after policy blocking lbcast and multicast
yujuan.qi <yujuan.qi(a)mediatek.com>
Cipso: cipso_v4_optptr enter infinite loop
Ethan Zhao <ethan.zhao(a)oracle.com>
sched/sysctl: Check user input value of sysctl_sched_time_avg
-------------
Diffstat:
Makefile | 4 +-
arch/arc/include/asm/delay.h | 3 +
arch/arc/mm/cache_arc700.c | 7 +-
arch/arm/kvm/mmu.c | 42 +++++++++---
arch/arm64/mm/init.c | 6 +-
arch/mips/bcm47xx/setup.c | 6 --
arch/mips/include/asm/mipsregs.h | 3 -
arch/mips/include/asm/processor.h | 2 +-
arch/mips/kernel/ptrace.c | 2 +-
arch/mips/kernel/ptrace32.c | 2 +-
arch/s390/include/asm/qdio.h | 1 -
arch/s390/mm/fault.c | 2 +
arch/s390/pci/pci.c | 2 +
arch/x86/kernel/process_64.c | 1 +
drivers/cdrom/cdrom.c | 2 +-
drivers/gpu/drm/udl/udl_fb.c | 2 +-
drivers/gpu/drm/udl/udl_main.c | 35 +++++-----
drivers/net/can/mscan/mpc5xxx_can.c | 5 ++
drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 1 +
.../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 13 +++-
drivers/net/ethernet/cisco/enic/enic_main.c | 78 ++++++++--------------
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c | 1 +
drivers/net/wan/lmc/lmc_main.c | 2 +-
drivers/pinctrl/freescale/pinctrl-imx1-core.c | 2 +-
drivers/s390/cio/qdio_main.c | 5 +-
drivers/scsi/fcoe/fcoe_ctlr.c | 4 +-
drivers/scsi/libiscsi.c | 12 ++--
drivers/scsi/scsi_sysfs.c | 20 +++++-
drivers/scsi/vmw_pvscsi.c | 11 ++-
drivers/staging/imx-drm/imx-ldb.c | 9 ++-
drivers/staging/media/omap4iss/iss_video.c | 3 +-
drivers/usb/gadget/function/f_uac2.c | 20 +++---
drivers/usb/gadget/udc/r8a66597-udc.c | 6 +-
drivers/usb/phy/phy-fsl-usb.c | 4 +-
fs/btrfs/extent-tree.c | 2 +-
fs/cachefiles/namei.c | 1 -
fs/cachefiles/rdwr.c | 17 +++--
fs/ext4/namei.c | 1 +
fs/fscache/operation.c | 6 +-
fs/fuse/dev.c | 7 +-
fs/fuse/file.c | 1 +
fs/sysfs/file.c | 44 ++++++++++++
include/linux/sysfs.h | 14 ++++
kernel/kprobes.c | 4 +-
kernel/sysctl.c | 3 +-
mm/memory.c | 3 +
mm/zswap.c | 9 +++
net/caif/caif_dev.c | 4 +-
net/ipv4/cipso_ipv4.c | 12 +++-
net/mac80211/util.c | 3 +-
net/wireless/nl80211.c | 1 +
net/xfrm/xfrm_policy.c | 3 +
net/xfrm/xfrm_user.c | 10 +--
sound/soc/sirf/sirf-usp.c | 7 +-
tools/power/x86/turbostat/turbostat.c | 8 +--
.../selftests/ftrace/test.d/00basic/snapshot.tc | 28 ++++++++
tools/usb/ffs-test.c | 19 +++++-
57 files changed, 354 insertions(+), 171 deletions(-)
From: Randy Dunlap <rdunlap(a)infradead.org>
Subject: uapi/linux/keyctl.h: don't use C++ reserved keyword as a struct member name
Since this header is in "include/uapi/linux/", apparently people want to
use it in userspace programs -- even in C++ ones. However, the header
uses a C++ reserved keyword ("private"), so change that to "dh_private"
instead to allow the header file to be used in C++ userspace.
Fixes https://bugzilla.kernel.org/show_bug.cgi?id=191051
Link: http://lkml.kernel.org/r/0db6c314-1ef4-9bfa-1baa-7214dd2ee061@infradead.org
Fixes: ddbb41148724 ("KEYS: Add KEYCTL_DH_COMPUTE command")
Signed-off-by: Randy Dunlap <rdunlap(a)infradead.org>
Reviewed-by: Andrew Morton <akpm(a)linux-foundation.org>
Cc: David Howells <dhowells(a)redhat.com>
Cc: James Morris <jmorris(a)namei.org>
Cc: "Serge E. Hallyn" <serge(a)hallyn.com>
Cc: Mat Martineau <mathew.j.martineau(a)linux.intel.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
include/uapi/linux/keyctl.h | 2 +-
security/keys/dh.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/include/uapi/linux/keyctl.h~uapi-linux-keyctlh-dont-use-c-reserved-keyword-as-a-struct-member-name
+++ a/include/uapi/linux/keyctl.h
@@ -65,7 +65,7 @@
/* keyctl structures */
struct keyctl_dh_params {
- __s32 private;
+ __s32 dh_private;
__s32 prime;
__s32 base;
};
--- a/security/keys/dh.c~uapi-linux-keyctlh-dont-use-c-reserved-keyword-as-a-struct-member-name
+++ a/security/keys/dh.c
@@ -300,7 +300,7 @@ long __keyctl_dh_compute(struct keyctl_d
}
dh_inputs.g_size = dlen;
- dlen = dh_data_from_key(pcopy.private, &dh_inputs.key);
+ dlen = dh_data_from_key(pcopy.dh_private, &dh_inputs.key);
if (dlen < 0) {
ret = dlen;
goto out2;
_
From: Mikhail Zaslonko <zaslonko(a)linux.ibm.com>
Subject: memory_hotplug: fix kernel_panic on offline page processing
Within show_valid_zones() the function test_pages_in_a_zone() should be
called for online memory blocks only. Otherwise it might lead to the
VM_BUG_ON due to uninitialized struct pages (when CONFIG_DEBUG_VM_PGFLAGS
kernel option is set):
page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p))
------------[ cut here ]------------
Call Trace:
([<000000000038f91e>] test_pages_in_a_zone+0xe6/0x168)
[<0000000000923472>] show_valid_zones+0x5a/0x1a8
[<0000000000900284>] dev_attr_show+0x3c/0x78
[<000000000046f6f0>] sysfs_kf_seq_show+0xd0/0x150
[<00000000003ef662>] seq_read+0x212/0x4b8
[<00000000003bf202>] __vfs_read+0x3a/0x178
[<00000000003bf3ca>] vfs_read+0x8a/0x148
[<00000000003bfa3a>] ksys_read+0x62/0xb8
[<0000000000bc2220>] system_call+0xdc/0x2d8
That VM_BUG_ON was triggered by the page poisoning introduced in
mm/sparse.c with the git commit d0dc12e86b31 ("mm/memory_hotplug: optimize
memory hotplug") With the same commit the new 'nid' field has been added
to the struct memory_block in order to store and later on derive the node
id for offline pages (instead of accessing struct page which might be
uninitialized). But one reference to nid in show_valid_zones() function
has been overlooked. Fixed with current commit. Also, nr_pages will not
be used any more after test_pages_in_a_zone() call, do not update it.
Link: http://lkml.kernel.org/r/20180828090539.41491-1-zaslonko@linux.ibm.com
Fixes: d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug")
Signed-off-by: Mikhail Zaslonko <zaslonko(a)linux.ibm.com>
Acked-by: Michal Hocko <mhocko(a)suse.com>
Reviewed-by: Pavel Tatashin <pavel.tatashin(a)microsoft.com>
Cc: <stable(a)vger.kernel.org> [4.17+]
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
drivers/base/memory.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
--- a/drivers/base/memory.c~memory_hotplug-fix-kernel_panic-on-offline-page-processing
+++ a/drivers/base/memory.c
@@ -417,25 +417,23 @@ static ssize_t show_valid_zones(struct d
int nid;
/*
- * The block contains more than one zone can not be offlined.
- * This can happen e.g. for ZONE_DMA and ZONE_DMA32
- */
- if (!test_pages_in_a_zone(start_pfn, start_pfn + nr_pages, &valid_start_pfn, &valid_end_pfn))
- return sprintf(buf, "none\n");
-
- start_pfn = valid_start_pfn;
- nr_pages = valid_end_pfn - start_pfn;
-
- /*
* Check the existing zone. Make sure that we do that only on the
* online nodes otherwise the page_zone is not reliable
*/
if (mem->state == MEM_ONLINE) {
+ /*
+ * The block contains more than one zone can not be offlined.
+ * This can happen e.g. for ZONE_DMA and ZONE_DMA32
+ */
+ if (!test_pages_in_a_zone(start_pfn, start_pfn + nr_pages,
+ &valid_start_pfn, &valid_end_pfn))
+ return sprintf(buf, "none\n");
+ start_pfn = valid_start_pfn;
strcat(buf, page_zone(pfn_to_page(start_pfn))->name);
goto out;
}
- nid = pfn_to_nid(start_pfn);
+ nid = mem->nid;
default_zone = zone_for_pfn_range(MMOP_ONLINE_KEEP, nid, start_pfn, nr_pages);
strcat(buf, default_zone->name);
_
From: "Aneesh Kumar K.V" <aneesh.kumar(a)linux.ibm.com>
Subject: mm/hugetlb: filter out hugetlb pages if HUGEPAGE migration is not supported.
When scanning for movable pages, filter out Hugetlb pages if hugepage
migration is not supported. Without this we hit infinte loop in
__offline_pages() where we do
pfn = scan_movable_pages(start_pfn, end_pfn);
if (pfn) { /* We have movable pages */
ret = do_migrate_range(pfn, end_pfn);
goto repeat;
}
Fix this by checking hugepage_migration_supported both in
has_unmovable_pages which is the primary backoff mechanism for page
offlining and for consistency reasons also into scan_movable_pages because
it doesn't make any sense to return a pfn to non-migrateable huge page.
This issue was revealed by, but not caused by 72b39cfc4d75 ("mm,
memory_hotplug: do not fail offlining too early").
Link: http://lkml.kernel.org/r/20180824063314.21981-1-aneesh.kumar@linux.ibm.com
Fixes: 72b39cfc4d75 ("mm, memory_hotplug: do not fail offlining too early")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar(a)linux.ibm.com>
Reported-by: Haren Myneni <haren(a)linux.vnet.ibm.com>
Acked-by: Michal Hocko <mhocko(a)suse.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi(a)ah.jp.nec.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
mm/memory_hotplug.c | 3 ++-
mm/page_alloc.c | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
--- a/mm/memory_hotplug.c~mm-hugetlb-filter-out-hugetlb-pages-if-hugepage-migration-is-not-supported
+++ a/mm/memory_hotplug.c
@@ -1333,7 +1333,8 @@ static unsigned long scan_movable_pages(
if (__PageMovable(page))
return pfn;
if (PageHuge(page)) {
- if (page_huge_active(page))
+ if (hugepage_migration_supported(page_hstate(page)) &&
+ page_huge_active(page))
return pfn;
else
pfn = round_up(pfn + 1,
--- a/mm/page_alloc.c~mm-hugetlb-filter-out-hugetlb-pages-if-hugepage-migration-is-not-supported
+++ a/mm/page_alloc.c
@@ -7708,6 +7708,10 @@ bool has_unmovable_pages(struct zone *zo
* handle each tail page individually in migration.
*/
if (PageHuge(page)) {
+
+ if (!hugepage_migration_supported(page_hstate(page)))
+ goto unmovable;
+
iter = round_up(iter + 1, 1<<compound_order(page)) - 1;
continue;
}
_
From: Nadav Amit <namit(a)vmware.com>
Subject: mm: respect arch_dup_mmap() return value
d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc")
ignored the return value of arch_dup_mmap(). As a result, on x86, a
failure to duplicate the LDT (e.g., due to memory allocation error), would
leave the duplicated memory mapping in an inconsistent state.
Fix by regarding the return value, as it was before the change.
Link: http://lkml.kernel.org/r/20180823051229.211856-1-namit@vmware.com
Fixes: d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc")
Signed-off-by: Nadav Amit <namit(a)vmware.com>
Acked-by: Michal Hocko <mhocko(a)suse.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
kernel/fork.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/kernel/fork.c~mm-respect-arch_dup_mmap-return-value
+++ a/kernel/fork.c
@@ -550,8 +550,7 @@ static __latent_entropy int dup_mmap(str
goto out;
}
/* a new mm has just been created */
- arch_dup_mmap(oldmm, mm);
- retval = 0;
+ retval = arch_dup_mmap(oldmm, mm);
out:
up_write(&mm->mmap_sem);
flush_tlb_mm(oldmm);
_
The steps taken by usb core to set a new interface is very different from
what is done on the xHC host side.
xHC hardware will do everything in one go. One command is used to set up
new endpoints, free old endpoints, check bandwidth, and run the new
endpoints.
All this is done by xHC when usb core asks the hcd to check for
available bandwidth. At this point usb core has not yet flushed the old
endpoints, which will cause use-after-free issues in xhci driver as
queued URBs are cancelled on a re-allocated endpoint.
To resolve this add a call to usb_disable_interface() which will flush
the endpoints before calling usb_hcd_alloc_bandwidth()
Additional checks in xhci driver will also be implemented to gracefully
handle stale URB cancel on freed and re-allocated endpoints
Cc: <stable(a)vger.kernel.org>
Reported-by: Sudip Mukherjee <sudipm.mukherjee(a)gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman(a)linux.intel.com>
---
v2: update kerneldoc as well
---
drivers/usb/core/message.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 228672f..bfa5eda 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1341,6 +1341,11 @@ void usb_enable_interface(struct usb_device *dev,
* is submitted that needs that bandwidth. Some other operating systems
* allocate bandwidth early, when a configuration is chosen.
*
+ * xHCI reserves bandwidth and configures the alternate setting in
+ * usb_hcd_alloc_bandwidth(). If it fails the original interface altsetting
+ * may be disabled. Drivers cannot rely on any particular alternate
+ * setting being in effect after a failure.
+ *
* This call is synchronous, and may not be used in an interrupt context.
* Also, drivers must not change altsettings while urbs are scheduled for
* endpoints in that interface; all such urbs must first be completed
@@ -1376,6 +1381,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
alternate);
return -EINVAL;
}
+ /*
+ * usb3 hosts configure the interface in usb_hcd_alloc_bandwidth,
+ * including freeing dropped endpoint ring buffers.
+ * Make sure the interface endpoints are flushed before that
+ */
+ usb_disable_interface(dev, iface, false);
/* Make sure we have enough bandwidth for this alternate interface.
* Remove the current alt setting and add the new alt setting.
--
2.7.4