[PATCH 4.18 103/150] bridge: do not add port to router list when receives query with source 0.0.0.0

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Hangbin Liu 

[ Upstream commit 5a2de63fd1a59c30c02526d427bc014b98adf508 ]

Based on RFC 4541, 2.1.1.  IGMP Forwarding Rules

  The switch supporting IGMP snooping must maintain a list of
  multicast routers and the ports on which they are attached.  This
  list can be constructed in any combination of the following ways:

  a) This list should be built by the snooping switch sending
 Multicast Router Solicitation messages as described in IGMP
 Multicast Router Discovery [MRDISC].  It may also snoop
 Multicast Router Advertisement messages sent by and to other
 nodes.

  b) The arrival port for IGMP Queries (sent by multicast routers)
 where the source address is not 0.0.0.0.

We should not add the port to router list when receives query with source
0.0.0.0.

Reported-by: Ying Xu 
Signed-off-by: Hangbin Liu 
Acked-by: Nikolay Aleksandrov 
Acked-by: Roopa Prabhu 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/bridge/br_multicast.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1420,7 +1420,15 @@ static void br_multicast_query_received(
return;
 
br_multicast_update_query_timer(br, query, max_delay);
-   br_multicast_mark_router(br, port);
+
+   /* Based on RFC4541, section 2.1.1 IGMP Forwarding Rules,
+* the arrival port for IGMP Queries where the source address
+* is 0.0.0.0 should not be added to router port list.
+*/
+   if ((saddr->proto == htons(ETH_P_IP) && saddr->u.ip4) ||
+   (saddr->proto == htons(ETH_P_IPV6) &&
+!ipv6_addr_any(>u.ip6)))
+   br_multicast_mark_router(br, port);
 }
 
 static int br_ip4_multicast_query(struct net_bridge *br,




[PATCH 4.18 102/150] perf tools: Disable parallelism for make clean

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit da15fc2fa9c07b23db8f5e479bd8a9f0d741ca07 ]

The Yocto build system does a 'make clean' when rebuilding due to
changed dependencies, and that consistently fails for me (causing the
whole BSP build to fail) with errors such as

| find: '[...]/perf/1.0-r9/perf-1.0/plugin_mac80211.so': No such file or 
directory
| find: '[...]/perf/1.0-r9/perf-1.0/plugin_mac80211.so': No such file or 
directory
| find: find: 
'[...]/perf/1.0-r9/perf-1.0/libtraceevent.a''[...]/perf/1.0-r9/perf-1.0/libtraceevent.a':
 No such file or directory: No such file or directory
|
[...]
| find: cannot delete 
'/mnt/xfs/devel/pil/yocto/tmp-glibc/work/wandboard-oe-linux-gnueabi/perf/1.0-r9/perf-1.0/util/.pstack.o.cmd':
 No such file or directory

Apparently (despite the comment), 'make clean' ends up launching
multiple sub-makes that all want to remove the same things - perhaps
this only happens in combination with a O=... parameter. In any case, we
don't lose much by explicitly disabling the parallelism for the clean
target, and it makes automated builds much more reliable.

Signed-off-by: Rasmus Villemoes 
Acked-by: Jiri Olsa 
Cc: Alexander Shishkin 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20180705131527.19749-1-li...@rasmusvillemoes.dk
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/Makefile |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -84,10 +84,10 @@ endif # has_clean
 endif # MAKECMDGOALS
 
 #
-# The clean target is not really parallel, don't print the jobs info:
+# Explicitly disable parallelism for the clean target.
 #
 clean:
-   $(make)
+   $(make) -j1
 
 #
 # The build-test target is not really parallel, don't print the jobs info,




[PATCH 4.18 082/150] perf record: Use unmapped IP for inline callchain cursors

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 7a8a8fcf7b860e4b2d4edc787c844d41cad9dfcf ]

Only use the mapped IP to find inline frames, but keep using the
unmapped IP for the callchain cursor. This ensures we properly show the
unmapped IP when displaying a frame we received via the
dso__parse_addr_inlines API for a module which does not contain
sufficient debug symbols to show the srcline.

This is another follow-up to commit 19610184693c ("perf script: Show
virtual addresses instead of offsets").

Signed-off-by: Milian Wolff 
Acked-by: Jiri Olsa 
Tested-by: Ravi Bangoria 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jin Yao 
Cc: Namhyung Kim 
Cc: Sandipan Das 
Fixes: 19610184693c ("perf script: Show virtual addresses instead of offsets")
Link: http://lkml.kernel.org/r/20180926135207.30263-2-milian.wo...@kdab.com
Link: http://lkml.kernel.org/r/20181002073949.3297-1-milian.wo...@kdab.com
[ Squashed a fix from Milian for a problem reported by Ravi, fixed up space 
damage ]
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/util/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d49744dc46d7..b70cce40ca97 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2246,7 +2246,8 @@ static int append_inlines(struct callchain_cursor *cursor,
if (!symbol_conf.inline_name || !map || !sym)
return ret;
 
-   addr = map__rip_2objdump(map, ip);
+   addr = map__map_ip(map, ip);
+   addr = map__rip_2objdump(map, addr);
 
inline_node = inlines__tree_find(>dso->inlined_nodes, addr);
if (!inline_node) {
-- 
2.17.1





[PATCH 4.18 082/150] perf record: Use unmapped IP for inline callchain cursors

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 7a8a8fcf7b860e4b2d4edc787c844d41cad9dfcf ]

Only use the mapped IP to find inline frames, but keep using the
unmapped IP for the callchain cursor. This ensures we properly show the
unmapped IP when displaying a frame we received via the
dso__parse_addr_inlines API for a module which does not contain
sufficient debug symbols to show the srcline.

This is another follow-up to commit 19610184693c ("perf script: Show
virtual addresses instead of offsets").

Signed-off-by: Milian Wolff 
Acked-by: Jiri Olsa 
Tested-by: Ravi Bangoria 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jin Yao 
Cc: Namhyung Kim 
Cc: Sandipan Das 
Fixes: 19610184693c ("perf script: Show virtual addresses instead of offsets")
Link: http://lkml.kernel.org/r/20180926135207.30263-2-milian.wo...@kdab.com
Link: http://lkml.kernel.org/r/20181002073949.3297-1-milian.wo...@kdab.com
[ Squashed a fix from Milian for a problem reported by Ravi, fixed up space 
damage ]
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/util/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d49744dc46d7..b70cce40ca97 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2246,7 +2246,8 @@ static int append_inlines(struct callchain_cursor *cursor,
if (!symbol_conf.inline_name || !map || !sym)
return ret;
 
-   addr = map__rip_2objdump(map, ip);
+   addr = map__map_ip(map, ip);
+   addr = map__rip_2objdump(map, addr);
 
inline_node = inlines__tree_find(>dso->inlined_nodes, addr);
if (!inline_node) {
-- 
2.17.1





[PATCH 4.18 059/150] thunderbolt: Initialize after IOMMUs

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eafa717bc145963c944bb0a64d16add683861b35 ]

If IOMMU is enabled and Thunderbolt driver is built into the kernel
image, it will be probed before IOMMUs are attached to the PCI bus.
Because of this DMA mappings the driver does will not go through IOMMU
and start failing right after IOMMUs are enabled.

For this reason move the Thunderbolt driver initialization happen at
rootfs level.

Signed-off-by: Mika Westerberg 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/thunderbolt/nhi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index f5a33e88e676..2d042150e41c 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1147,5 +1147,5 @@ static void __exit nhi_unload(void)
tb_domain_exit();
 }
 
-fs_initcall(nhi_init);
+rootfs_initcall(nhi_init);
 module_exit(nhi_unload);
-- 
2.17.1





[PATCH 4.18 062/150] RISCV: Fix end PFN for low memory

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ef1f2258748b675422ca0107e5bfb9ceeac675de ]

Use memblock_end_of_DRAM which provides correct last low memory
PFN. Without that, DMA32 region becomes empty resulting in zero
pages being allocated for DMA32.

This patch is based on earlier patch from palmer which never
merged into 4.19. I just edited the commit text to make more
sense.

Signed-off-by: Atish Patra 
Signed-off-by: Palmer Dabbelt 
Signed-off-by: Sasha Levin 
---
 arch/riscv/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 0efa5b29d0a3..dcff272aee06 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -165,7 +165,7 @@ static void __init setup_bootmem(void)
BUG_ON(mem_size == 0);
 
set_max_mapnr(PFN_DOWN(mem_size));
-   max_low_pfn = pfn_base + PFN_DOWN(mem_size);
+   max_low_pfn = memblock_end_of_DRAM();
 
 #ifdef CONFIG_BLK_DEV_INITRD
setup_initrd();
-- 
2.17.1





[PATCH 4.18 053/150] perf/core: Fix perf_pmu_unregister() locking

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a9f9772114c8b07ae75bcb3654bd017461248095 ]

When we unregister a PMU, we fail to serialize the @pmu_idr properly.
Fix that by doing the entire thing under pmu_lock.

Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Fixes: 2e80a82a49c4 ("perf: Dynamic pmu types")
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/events/core.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index ae22d93701db..b1ed5e99d9c6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9436,9 +9436,7 @@ static void free_pmu_context(struct pmu *pmu)
if (pmu->task_ctx_nr > perf_invalid_context)
return;
 
-   mutex_lock(_lock);
free_percpu(pmu->pmu_cpu_context);
-   mutex_unlock(_lock);
 }
 
 /*
@@ -9694,12 +9692,8 @@ EXPORT_SYMBOL_GPL(perf_pmu_register);
 
 void perf_pmu_unregister(struct pmu *pmu)
 {
-   int remove_device;
-
mutex_lock(_lock);
-   remove_device = pmu_bus_running;
list_del_rcu(>entry);
-   mutex_unlock(_lock);
 
/*
 * We dereference the pmu list under both SRCU and regular RCU, so
@@ -9711,13 +9705,14 @@ void perf_pmu_unregister(struct pmu *pmu)
free_percpu(pmu->pmu_disable_count);
if (pmu->type >= PERF_TYPE_MAX)
idr_remove(_idr, pmu->type);
-   if (remove_device) {
+   if (pmu_bus_running) {
if (pmu->nr_addr_filters)
device_remove_file(pmu->dev, _attr_nr_addr_filters);
device_del(pmu->dev);
put_device(pmu->dev);
}
free_pmu_context(pmu);
+   mutex_unlock(_lock);
 }
 EXPORT_SYMBOL_GPL(perf_pmu_unregister);
 
-- 
2.17.1





[PATCH 4.18 059/150] thunderbolt: Initialize after IOMMUs

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eafa717bc145963c944bb0a64d16add683861b35 ]

If IOMMU is enabled and Thunderbolt driver is built into the kernel
image, it will be probed before IOMMUs are attached to the PCI bus.
Because of this DMA mappings the driver does will not go through IOMMU
and start failing right after IOMMUs are enabled.

For this reason move the Thunderbolt driver initialization happen at
rootfs level.

Signed-off-by: Mika Westerberg 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/thunderbolt/nhi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index f5a33e88e676..2d042150e41c 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1147,5 +1147,5 @@ static void __exit nhi_unload(void)
tb_domain_exit();
 }
 
-fs_initcall(nhi_init);
+rootfs_initcall(nhi_init);
 module_exit(nhi_unload);
-- 
2.17.1





[PATCH 4.18 062/150] RISCV: Fix end PFN for low memory

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ef1f2258748b675422ca0107e5bfb9ceeac675de ]

Use memblock_end_of_DRAM which provides correct last low memory
PFN. Without that, DMA32 region becomes empty resulting in zero
pages being allocated for DMA32.

This patch is based on earlier patch from palmer which never
merged into 4.19. I just edited the commit text to make more
sense.

Signed-off-by: Atish Patra 
Signed-off-by: Palmer Dabbelt 
Signed-off-by: Sasha Levin 
---
 arch/riscv/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 0efa5b29d0a3..dcff272aee06 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -165,7 +165,7 @@ static void __init setup_bootmem(void)
BUG_ON(mem_size == 0);
 
set_max_mapnr(PFN_DOWN(mem_size));
-   max_low_pfn = pfn_base + PFN_DOWN(mem_size);
+   max_low_pfn = memblock_end_of_DRAM();
 
 #ifdef CONFIG_BLK_DEV_INITRD
setup_initrd();
-- 
2.17.1





[PATCH 4.18 053/150] perf/core: Fix perf_pmu_unregister() locking

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a9f9772114c8b07ae75bcb3654bd017461248095 ]

When we unregister a PMU, we fail to serialize the @pmu_idr properly.
Fix that by doing the entire thing under pmu_lock.

Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Fixes: 2e80a82a49c4 ("perf: Dynamic pmu types")
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/events/core.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index ae22d93701db..b1ed5e99d9c6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9436,9 +9436,7 @@ static void free_pmu_context(struct pmu *pmu)
if (pmu->task_ctx_nr > perf_invalid_context)
return;
 
-   mutex_lock(_lock);
free_percpu(pmu->pmu_cpu_context);
-   mutex_unlock(_lock);
 }
 
 /*
@@ -9694,12 +9692,8 @@ EXPORT_SYMBOL_GPL(perf_pmu_register);
 
 void perf_pmu_unregister(struct pmu *pmu)
 {
-   int remove_device;
-
mutex_lock(_lock);
-   remove_device = pmu_bus_running;
list_del_rcu(>entry);
-   mutex_unlock(_lock);
 
/*
 * We dereference the pmu list under both SRCU and regular RCU, so
@@ -9711,13 +9705,14 @@ void perf_pmu_unregister(struct pmu *pmu)
free_percpu(pmu->pmu_disable_count);
if (pmu->type >= PERF_TYPE_MAX)
idr_remove(_idr, pmu->type);
-   if (remove_device) {
+   if (pmu_bus_running) {
if (pmu->nr_addr_filters)
device_remove_file(pmu->dev, _attr_nr_addr_filters);
device_del(pmu->dev);
put_device(pmu->dev);
}
free_pmu_context(pmu);
+   mutex_unlock(_lock);
 }
 EXPORT_SYMBOL_GPL(perf_pmu_unregister);
 
-- 
2.17.1





[PATCH 4.18 058/150] thunderbolt: Do not handle ICM events after domain is stopped

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 86da809dda64a63fc27e05a215475325c3aaae92 ]

If there is a long chain of devices connected when the driver is loaded
ICM sends device connected event for each and those are put to tb->wq
for later processing. Now if the driver gets unloaded in the middle, so
that the work queue is not yet empty it gets flushed by tb_domain_stop().
However, by that time the root switch is already removed so the driver
crashes when it tries to dereference it in ICM event handling callbacks.

Fix this by checking whether the root switch is already removed. If it
is we know that the domain is stopped and we should merely skip handling
the event.

Signed-off-by: Mika Westerberg 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/thunderbolt/icm.c | 49 ---
 1 file changed, 20 insertions(+), 29 deletions(-)

diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index 500911f16498..5bad9fdec5f8 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -653,14 +653,6 @@ icm_fr_xdomain_connected(struct tb *tb, const struct 
icm_pkg_header *hdr)
bool approved;
u64 route;
 
-   /*
-* After NVM upgrade adding root switch device fails because we
-* initiated reset. During that time ICM might still send
-* XDomain connected message which we ignore here.
-*/
-   if (!tb->root_switch)
-   return;
-
link = pkg->link_info & ICM_LINK_INFO_LINK_MASK;
depth = (pkg->link_info & ICM_LINK_INFO_DEPTH_MASK) >>
ICM_LINK_INFO_DEPTH_SHIFT;
@@ -950,14 +942,6 @@ icm_tr_device_connected(struct tb *tb, const struct 
icm_pkg_header *hdr)
if (pkg->hdr.packet_id)
return;
 
-   /*
-* After NVM upgrade adding root switch device fails because we
-* initiated reset. During that time ICM might still send device
-* connected message which we ignore here.
-*/
-   if (!tb->root_switch)
-   return;
-
route = get_route(pkg->route_hi, pkg->route_lo);
authorized = pkg->link_info & ICM_LINK_INFO_APPROVED;
security_level = (pkg->hdr.flags & ICM_FLAGS_SLEVEL_MASK) >>
@@ -1317,19 +1301,26 @@ static void icm_handle_notification(struct work_struct 
*work)
 
mutex_lock(>lock);
 
-   switch (n->pkg->code) {
-   case ICM_EVENT_DEVICE_CONNECTED:
-   icm->device_connected(tb, n->pkg);
-   break;
-   case ICM_EVENT_DEVICE_DISCONNECTED:
-   icm->device_disconnected(tb, n->pkg);
-   break;
-   case ICM_EVENT_XDOMAIN_CONNECTED:
-   icm->xdomain_connected(tb, n->pkg);
-   break;
-   case ICM_EVENT_XDOMAIN_DISCONNECTED:
-   icm->xdomain_disconnected(tb, n->pkg);
-   break;
+   /*
+* When the domain is stopped we flush its workqueue but before
+* that the root switch is removed. In that case we should treat
+* the queued events as being canceled.
+*/
+   if (tb->root_switch) {
+   switch (n->pkg->code) {
+   case ICM_EVENT_DEVICE_CONNECTED:
+   icm->device_connected(tb, n->pkg);
+   break;
+   case ICM_EVENT_DEVICE_DISCONNECTED:
+   icm->device_disconnected(tb, n->pkg);
+   break;
+   case ICM_EVENT_XDOMAIN_CONNECTED:
+   icm->xdomain_connected(tb, n->pkg);
+   break;
+   case ICM_EVENT_XDOMAIN_DISCONNECTED:
+   icm->xdomain_disconnected(tb, n->pkg);
+   break;
+   }
}
 
mutex_unlock(>lock);
-- 
2.17.1





[PATCH 4.18 061/150] declance: Fix continuation with the adapter identification message

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit fe3a83af6a50199bf250fa331e94216912f79395 ]

Fix a commit 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing
continuation lines") regression with the `declance' driver, which caused
the adapter identification message to be split between two lines, e.g.:

declance.c: v0.011 by Linux MIPS DECstation task force
tc6: PMAD-AA
, addr = 08:00:2b:1b:2a:6a, irq = 14
tc6: registered as eth0.

Address that properly, by printing identification with a single call,
making the messages now look like:

declance.c: v0.011 by Linux MIPS DECstation task force
tc6: PMAD-AA, addr = 08:00:2b:1b:2a:6a, irq = 14
tc6: registered as eth0.

Signed-off-by: Maciej W. Rozycki 
Fixes: 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing continuation 
lines")
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/amd/declance.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/declance.c 
b/drivers/net/ethernet/amd/declance.c
index 116997a8b593..00332a1ea84b 100644
--- a/drivers/net/ethernet/amd/declance.c
+++ b/drivers/net/ethernet/amd/declance.c
@@ -1031,6 +1031,7 @@ static int dec_lance_probe(struct device *bdev, const int 
type)
int i, ret;
unsigned long esar_base;
unsigned char *esar;
+   const char *desc;
 
if (dec_lance_debug && version_printed++ == 0)
printk(version);
@@ -1216,19 +1217,20 @@ static int dec_lance_probe(struct device *bdev, const 
int type)
 */
switch (type) {
case ASIC_LANCE:
-   printk("%s: IOASIC onboard LANCE", name);
+   desc = "IOASIC onboard LANCE";
break;
case PMAD_LANCE:
-   printk("%s: PMAD-AA", name);
+   desc = "PMAD-AA";
break;
case PMAX_LANCE:
-   printk("%s: PMAX onboard LANCE", name);
+   desc = "PMAX onboard LANCE";
break;
}
for (i = 0; i < 6; i++)
dev->dev_addr[i] = esar[i * 4];
 
-   printk(", addr = %pM, irq = %d\n", dev->dev_addr, dev->irq);
+   printk("%s: %s, addr = %pM, irq = %d\n",
+  name, desc, dev->dev_addr, dev->irq);
 
dev->netdev_ops = _netdev_ops;
dev->watchdog_timeo = 5*HZ;
-- 
2.17.1





[PATCH 4.18 074/150] clk: mvebu: armada-37xx-periph: Remove unused var num_parents

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 8927c27b32703e28041ae19bf25ea53461be83a1 ]

When building armada-37xx-periph, num_parents isn't used in function
clk_pm_cpu_get_parent:
drivers/clk/mvebu/armada-37xx-periph.c: In function ‘clk_pm_cpu_get_parent’:
drivers/clk/mvebu/armada-37xx-periph.c:419:6: warning: unused variable 
‘num_parents’ [-Wunused-variable]
  int num_parents = clk_hw_get_num_parents(hw);
  ^~~
Remove the declaration of num_parents to dispose the warning.

Fixes: 616bf80d381d ("clk: mvebu: armada-37xx-periph: Fix wrong return value in 
get_parent")
Signed-off-by: Anders Roxell 
Signed-off-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/clk/mvebu/armada-37xx-periph.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/mvebu/armada-37xx-periph.c 
b/drivers/clk/mvebu/armada-37xx-periph.c
index 6f7637b19738..e764dfdea53f 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -419,7 +419,6 @@ static unsigned int 
armada_3700_pm_dvfs_get_cpu_parent(struct regmap *base)
 static u8 clk_pm_cpu_get_parent(struct clk_hw *hw)
 {
struct clk_pm_cpu *pm_cpu = to_clk_pm_cpu(hw);
-   int num_parents = clk_hw_get_num_parents(hw);
u32 val;
 
if (armada_3700_pm_dvfs_is_enabled(pm_cpu->nb_pm_base)) {
-- 
2.17.1





[PATCH 4.18 077/150] tls: Fix improper revert in zerocopy_from_iter

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 2da19ed3e4a87db16c0f69039da9f17a9596c350 ]

The current code is problematic because the iov_iter is reverted and
never advanced in the non-error case. This patch skips the revert in the
non-error case. This patch also fixes the amount by which the iov_iter
is reverted. Currently, iov_iter is reverted by size, which can be
greater than the amount by which the iter was actually advanced.
Instead, only revert by the amount that the iter was advanced.

Fixes: 4718799817c5 ("tls: Fix zerocopy_from_iter iov handling")
Signed-off-by: Doron Roberts-Kedes 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/tls/tls_sw.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 9fab8e5a4a5b..994ddc7ec9b1 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -286,7 +286,7 @@ static int zerocopy_from_iter(struct sock *sk, struct 
iov_iter *from,
  int length, int *pages_used,
  unsigned int *size_used,
  struct scatterlist *to, int to_max_pages,
- bool charge, bool revert)
+ bool charge)
 {
struct page *pages[MAX_SKB_FRAGS];
 
@@ -335,10 +335,10 @@ static int zerocopy_from_iter(struct sock *sk, struct 
iov_iter *from,
}
 
 out:
+   if (rc)
+   iov_iter_revert(from, size - *size_used);
*size_used = size;
*pages_used = num_elem;
-   if (revert)
-   iov_iter_revert(from, size);
 
return rc;
 }
@@ -440,7 +440,7 @@ alloc_encrypted:
>sg_plaintext_size,
ctx->sg_plaintext_data,
ARRAY_SIZE(ctx->sg_plaintext_data),
-   true, false);
+   true);
if (ret)
goto fallback_to_reg_send;
 
@@ -453,8 +453,6 @@ alloc_encrypted:
 
copied -= try_to_copy;
 fallback_to_reg_send:
-   iov_iter_revert(>msg_iter,
-   ctx->sg_plaintext_size - orig_size);
trim_sg(sk, ctx->sg_plaintext_data,
>sg_plaintext_num_elem,
>sg_plaintext_size,
@@ -828,7 +826,7 @@ int tls_sw_recvmsg(struct sock *sk,
err = zerocopy_from_iter(sk, >msg_iter,
 to_copy, ,
 , [1],
-MAX_SKB_FRAGS, false, 
true);
+MAX_SKB_FRAGS, false);
if (err < 0)
goto fallback_to_reg_recv;
 
-- 
2.17.1





[PATCH 4.18 057/150] perf/x86/amd/uncore: Set ThreadMask and SliceMask for L3 Cache perf events

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit d7cbbe49a9304520181fb8c9272d1327deec8453 ]

In Family 17h, some L3 Cache Performance events require the ThreadMask
and SliceMask to be set. For other events, these fields do not affect
the count either way.

Set ThreadMask and SliceMask to 0xFF and 0xF respectively.

Signed-off-by: Janakarajan Natarajan 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Arnaldo Carvalho de Melo 
Cc: Borislav Petkov 
Cc: H . Peter Anvin 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Suravee 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: http://lkml.kernel.org/r/Message-ID:
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/amd/uncore.c  | 10 ++
 arch/x86/include/asm/perf_event.h |  8 
 2 files changed, 18 insertions(+)

diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
index 981ba5e8241b..8671de126eac 100644
--- a/arch/x86/events/amd/uncore.c
+++ b/arch/x86/events/amd/uncore.c
@@ -36,6 +36,7 @@
 
 static int num_counters_llc;
 static int num_counters_nb;
+static bool l3_mask;
 
 static HLIST_HEAD(uncore_unused_list);
 
@@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event)
hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
hwc->idx = -1;
 
+   /*
+* SliceMask and ThreadMask need to be set for certain L3 events in
+* Family 17h. For other events, the two fields do not affect the count.
+*/
+   if (l3_mask)
+   hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK);
+
if (event->cpu < 0)
return -EINVAL;
 
@@ -525,6 +533,7 @@ static int __init amd_uncore_init(void)
amd_llc_pmu.name  = "amd_l3";
format_attr_event_df.show = _show_df;
format_attr_event_l3.show = _show_l3;
+   l3_mask   = true;
} else {
num_counters_nb   = NUM_COUNTERS_NB;
num_counters_llc  = NUM_COUNTERS_L2;
@@ -532,6 +541,7 @@ static int __init amd_uncore_init(void)
amd_llc_pmu.name  = "amd_l2";
format_attr_event_df  = format_attr_event;
format_attr_event_l3  = format_attr_event;
+   l3_mask   = false;
}
 
amd_nb_pmu.attr_groups  = amd_uncore_attr_groups_df;
diff --git a/arch/x86/include/asm/perf_event.h 
b/arch/x86/include/asm/perf_event.h
index 12f54082f4c8..78241b736f2a 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -46,6 +46,14 @@
 #define INTEL_ARCH_EVENT_MASK  \
(ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT)
 
+#define AMD64_L3_SLICE_SHIFT   48
+#define AMD64_L3_SLICE_MASK\
+   ((0xFULL) << AMD64_L3_SLICE_SHIFT)
+
+#define AMD64_L3_THREAD_SHIFT  56
+#define AMD64_L3_THREAD_MASK   \
+   ((0xFFULL) << AMD64_L3_THREAD_SHIFT)
+
 #define X86_RAW_EVENT_MASK \
(ARCH_PERFMON_EVENTSEL_EVENT |  \
 ARCH_PERFMON_EVENTSEL_UMASK |  \
-- 
2.17.1





[PATCH 4.18 076/150] perf report: Dont try to map ip to invalid map

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ff4ce2885af8f9e8e99864d78dbeb4673f089c76 ]

Fixes a crash when the report encounters an address that could not be
associated with an mmaped region:

  #0  0x557bdc4a in callchain_srcline (ip=, sym=0x0, map=0x0) at util/machine.c:2329
  #1  unwind_entry (entry=entry@entry=0x7fff9180, 
arg=arg@entry=0x75642498) at util/machine.c:2329
  #2  0x558370af in entry (arg=0x75642498, cb=0x557bdb50 
, thread=, ip=18446744073709551615) at 
util/unwind-libunwind-local.c:586
  #3  get_entries (ui=ui@entry=0x7fff9620, cb=0x557bdb50 
, arg=0x75642498, max_stack=) at 
util/unwind-libunwind-local.c:703
  #4  0x55837192 in _unwind__get_entries (cb=, 
arg=, thread=, data=, 
max_stack=) at util/unwind-libunwind-local.c:725
  #5  0x557c310f in thread__resolve_callchain_unwind (max_stack=127, 
sample=0x7fff9830, evsel=0x55c7b3b0, cursor=0x75642498, 
thread=0x55c7f6f0) at util/machine.c:2351
  #6  thread__resolve_callchain (thread=0x55c7f6f0, cursor=0x75642498, 
evsel=0x55c7b3b0, sample=0x7fff9830, parent=0x7fff97b8, 
root_al=0x7fff9750, max_stack=127) at util/machine.c:2378
  #7  0x557ba4ee in sample__resolve_callchain (sample=, 
cursor=, parent=parent@entry=0x7fff97b8, evsel=, al=al@entry=0x7fff9750,
  max_stack=) at util/callchain.c:1085

Signed-off-by: Milian Wolff 
Tested-by: Sandipan Das 
Acked-by: Jiri Olsa 
Cc: Jin Yao 
Cc: Namhyung Kim 
Fixes: 2a9d5050dc84 ("perf script: Show correct offsets for DWARF-based 
unwinding")
Link: http://lkml.kernel.org/r/20180926135207.30263-1-milian.wo...@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/util/machine.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 22dbb6612b41..d49744dc46d7 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2272,7 +2272,7 @@ static int unwind_entry(struct unwind_entry *entry, void 
*arg)
 {
struct callchain_cursor *cursor = arg;
const char *srcline = NULL;
-   u64 addr;
+   u64 addr = entry->ip;
 
if (symbol_conf.hide_unresolved && entry->sym == NULL)
return 0;
@@ -2284,7 +2284,8 @@ static int unwind_entry(struct unwind_entry *entry, void 
*arg)
 * Convert entry->ip from a virtual address to an offset in
 * its corresponding binary.
 */
-   addr = map__map_ip(entry->map, entry->ip);
+   if (entry->map)
+   addr = map__map_ip(entry->map, entry->ip);
 
srcline = callchain_srcline(entry->map, entry->sym, addr);
return callchain_cursor_append(cursor, entry->ip,
-- 
2.17.1





[PATCH 4.18 060/150] net: fec: fix rare tx timeout

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 657ade07df72847f591ccdb36bd9b91ed0edbac3 ]

During certain heavy network loads TX could time out
with TX ring dump.
TX is sometimes never restarted after reaching
"tx_stop_threshold" because function "fec_enet_tx_queue"
only tests the first queue.

In addition the TX timeout callback function failed to
recover because it also operated only on the first queue.

Signed-off-by: Rickard x Andersson 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/fec_main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c 
b/drivers/net/ethernet/freescale/fec_main.c
index c729665107f5..e10471ee0a8b 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1157,7 +1157,7 @@ static void fec_enet_timeout_work(struct work_struct 
*work)
napi_disable(>napi);
netif_tx_lock_bh(ndev);
fec_restart(ndev);
-   netif_wake_queue(ndev);
+   netif_tx_wake_all_queues(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(>napi);
}
@@ -1272,7 +1272,7 @@ skb_done:
 
/* Since we have freed up a buffer, the ring is no longer full
 */
-   if (netif_queue_stopped(ndev)) {
+   if (netif_tx_queue_stopped(nq)) {
entries_free = fec_enet_get_free_txdesc_num(txq);
if (entries_free >= txq->tx_wake_threshold)
netif_tx_wake_queue(nq);
@@ -1745,7 +1745,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
napi_disable(>napi);
netif_tx_lock_bh(ndev);
fec_restart(ndev);
-   netif_wake_queue(ndev);
+   netif_tx_wake_all_queues(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(>napi);
}
@@ -2246,7 +2246,7 @@ static int fec_enet_set_pauseparam(struct net_device 
*ndev,
napi_disable(>napi);
netif_tx_lock_bh(ndev);
fec_restart(ndev);
-   netif_wake_queue(ndev);
+   netif_tx_wake_all_queues(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(>napi);
}
-- 
2.17.1





[PATCH 4.18 075/150] libertas: call into generic suspend code before turning off power

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 4f75cdff0b986195413215eb062b7da6586f ]

When powering down a SDIO connected card during suspend, make sure to call
into the generic lbs_suspend() function before pulling the plug. This will
make sure the card is successfully deregistered from the system to avoid
communication to the card starving out.

Fixes: 7444a8092906 ("libertas: fix suspend and resume for SDIO connected 
cards")
Signed-off-by: Daniel Mack 
Reviewed-by: Ulf Hansson 
Acked-by: Kalle Valo 
Signed-off-by: Ulf Hansson 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/marvell/libertas/if_sdio.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c 
b/drivers/net/wireless/marvell/libertas/if_sdio.c
index 43743c26c071..39bf85d0ade0 100644
--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
+++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
@@ -1317,6 +1317,10 @@ static int if_sdio_suspend(struct device *dev)
if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
dev_info(dev, "Suspend without wake params -- powering down 
card\n");
if (priv->fw_ready) {
+   ret = lbs_suspend(priv);
+   if (ret)
+   return ret;
+
priv->power_up_on_resume = true;
if_sdio_power_off(card);
}
-- 
2.17.1





[PATCH 4.18 079/150] compiler.h: Allow arch-specific asm/compiler.h

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 04f264d3a8b0eb25d378127bd78c3c9a0261c828 ]

We have a need to override the definition of
barrier_before_unreachable() for MIPS, which means we either need to add
architecture-specific code into linux/compiler-gcc.h or we need to allow
the architecture to provide a header that can define the macro before
the generic definition. The latter seems like the better approach.

A straightforward approach to the per-arch header is to make use of
asm-generic to provide a default empty header & adjust architectures
which don't need anything specific to make use of that by adding the
header to generic-y. Unfortunately this doesn't work so well due to
commit 28128c61e08e ("kconfig.h: Include compiler types to avoid missed
struct attributes") which caused linux/compiler_types.h to be included
in the compilation of every C file via the -include linux/kconfig.h flag
in c_flags.

Because the -include flag is present for all C files we compile, we need
the architecture-provided header to be present before any C files are
compiled. If any C files can be compiled prior to the asm-generic header
wrappers being generated then we hit a build failure due to missing
header. Such cases do exist - one pointed out by the kbuild test robot
is the compilation of arch/ia64/kernel/nr-irqs.c, which occurs as part
of the archprepare target [1].

This leaves us with a few options:

  1) Use generic-y & fix any build failures we find by enforcing
 ordering such that the asm-generic target occurs before any C
 compilation, such that linux/compiler_types.h can always include
 the generated asm-generic wrapper which in turn includes the empty
 asm-generic header. This would rely on us finding all the
 problematic cases - I don't know for sure that the ia64 issue is
 the only one.

  2) Add an actual empty header to each architecture, so that we don't
 need the generated asm-generic wrapper. This seems messy.

  3) Give up & add #ifdef CONFIG_MIPS or similar to
 linux/compiler_types.h. This seems messy too.

  4) Include the arch header only when it's actually needed, removing
 the need for the asm-generic wrapper for all other architectures.

This patch allows us to use approach 4, by including an asm/compiler.h
header from linux/compiler_types.h after the inclusion of the
compiler-specific linux/compiler-*.h header(s). We do this
conditionally, only when CONFIG_HAVE_ARCH_COMPILER_H is selected, in
order to avoid the need for asm-generic wrappers & the associated build
ordering issue described above. The asm/compiler.h header is included
after the generic linux/compiler-*.h header(s) for consistency with the
way linux/compiler-intel.h & linux/compiler-clang.h are included after
the linux/compiler-gcc.h header that they override.

[1] https://lists.01.org/pipermail/kbuild-all/2018-August/051175.html

Signed-off-by: Paul Burton 
Reviewed-by: Masahiro Yamada 
Patchwork: https://patchwork.linux-mips.org/patch/20269/
Cc: Arnd Bergmann 
Cc: James Hogan 
Cc: Masahiro Yamada 
Cc: Ralf Baechle 
Cc: linux-a...@vger.kernel.org
Cc: linux-kbu...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Signed-off-by: Sasha Levin 
---
 arch/Kconfig   |  8 
 include/linux/compiler_types.h | 12 
 2 files changed, 20 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index f03b72644902..a18371a36e03 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -977,4 +977,12 @@ config REFCOUNT_FULL
  against various use-after-free conditions that can be used in
  security flaw exploits.
 
+config HAVE_ARCH_COMPILER_H
+   bool
+   help
+ An architecture can select this if it provides an
+ asm/compiler.h header that should be included after
+ linux/compiler-*.h in order to override macro definitions that those
+ headers generally provide.
+
 source "kernel/gcov/Kconfig"
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index a8ba6b04152c..55e4be8b016b 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -78,6 +78,18 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 #include 
 #endif
 
+/*
+ * Some architectures need to provide custom definitions of macros provided
+ * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that
+ * conditionally rather than using an asm-generic wrapper in order to avoid
+ * build failures if any C compilation, which will include this file via an
+ * -include argument in c_flags, occurs prior to the asm-generic wrappers being
+ * generated.
+ */
+#ifdef CONFIG_HAVE_ARCH_COMPILER_H
+#include 
+#endif
+
 /*
  * Generic compiler-dependent macros required for kernel
  * build go below this comment. Actual compiler/compiler version
-- 
2.17.1





[PATCH 4.18 080/150] ARM: dts: imx53-qsb: disable 1.2GHz OPP

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eea96566c189c77e5272585984eb2729881a2f1d ]

The maximum CPU frequency for the i.MX53 QSB is 1GHz, so disable the
1.2GHz OPP. This makes the board work again with configs that have
cpufreq enabled like imx_v6_v7_defconfig on which the board stopped
working with the addition of cpufreq-dt support.

Fixes: 791f416608 ("ARM: dts: imx53: add cpufreq-dt support")

Signed-off-by: Sascha Hauer 
Signed-off-by: Shawn Guo 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/imx53-qsb-common.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi 
b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index ef7658a78836..c1548adee789 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -123,6 +123,17 @@
};
 };
 
+ {
+   /* CPU rated to 1GHz, not 1.2GHz as per the default settings */
+   operating-points = <
+   /* kHz   uV */
+   16  85
+   40  90
+   80  105
+   100 120
+   >;
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_esdhc1>;
-- 
2.17.1





[PATCH 4.18 056/150] perf/x86/intel/uncore: Fix PCI BDF address of M3UPI on SKX

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 9d92cfeaf5215158d26d2991be7f7ff865cb98f3 ]

The counters on M3UPI Link 0 and Link 3 don't count properly, and writing
0 to these counters may causes system crash on some machines.

The PCI BDF addresses of the M3UPI in the current code are incorrect.

The correct addresses should be:

  D18:F10x204D
  D18:F20x204E
  D18:F50x204D

Signed-off-by: Kan Liang 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Fixes: cd34cd97b7b4 ("perf/x86/intel/uncore: Add Skylake server uncore support")
Link: 
http://lkml.kernel.org/r/1537538826-55489-1-git-send-email-kan.li...@linux.intel.com
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/uncore_snbep.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c 
b/arch/x86/events/intel/uncore_snbep.c
index 53b981dcdb42..c07bee31abe8 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -3931,16 +3931,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] 
= {
.driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, 
SKX_PCI_UNCORE_M2PCIE, 3),
},
{ /* M3UPI0 Link 0 */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C),
-   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, 
SKX_PCI_UNCORE_M3UPI, 0),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
+   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, 
SKX_PCI_UNCORE_M3UPI, 0),
},
{ /* M3UPI0 Link 1 */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
-   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, 
SKX_PCI_UNCORE_M3UPI, 1),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E),
+   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, 
SKX_PCI_UNCORE_M3UPI, 1),
},
{ /* M3UPI1 Link 2 */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C),
-   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, 
SKX_PCI_UNCORE_M3UPI, 2),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
+   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, 
SKX_PCI_UNCORE_M3UPI, 2),
},
{ /* end: all zeroes */ }
 };
-- 
2.17.1





[PATCH 4.18 078/150] HID: i2c-hid: Remove RESEND_REPORT_DESCR quirk and its handling

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit afbb1169ed5b58cfca017e368b53e019cf285853 ]

Commit 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system resume")
removes the need for the RESEND_REPORT_DESCR quirk for Raydium devices, but
kept it for the SIS device id 10FB touchscreens, as the author of that
commit could not determine if the quirk is still necessary there.

I've tested suspend/resume on a Toshiba Click Mini L9W-B which is the
device for which this quirk was added in the first place and with the
"Don't reset device upon system resume" fix the quirk is no longer
necessary, so this commit removes it.

Note even better I also had some other devices with SIS touchscreens which
suspend/resume issues, where the RESEND_REPORT_DESCR quirk did not help.

I've also tested these devices with the "Don't reset device upon system
resume" fix and I'm happy to report that that fix also fixes touchscreen
resume on the following devices:

Asus T100HA
Asus T200TA
Peaq C1010

Cc: Kai-Heng Feng 
Acked-by: Benjamin Tissoires 
Signed-off-by: Hans de Goede 
Signed-off-by: Jiri Kosina 
Signed-off-by: Sasha Levin 
---
 drivers/hid/hid-ids.h |  1 -
 drivers/hid/i2c-hid/i2c-hid.c | 18 +++---
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index eee6b79fb131..ae5b72269e27 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -974,7 +974,6 @@
 #define USB_DEVICE_ID_SIS817_TOUCH 0x0817
 #define USB_DEVICE_ID_SIS_TS   0x1013
 #define USB_DEVICE_ID_SIS1030_TOUCH0x1030
-#define USB_DEVICE_ID_SIS10FB_TOUCH0x10fb
 
 #define USB_VENDOR_ID_SKYCABLE 0x1223
 #defineUSB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER   0x3F07
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 37013b58098c..d17cf6e323b2 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -47,8 +47,7 @@
 /* quirks to control the device */
 #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV   BIT(0)
 #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET   BIT(1)
-#define I2C_HID_QUIRK_RESEND_REPORT_DESCR  BIT(2)
-#define I2C_HID_QUIRK_NO_RUNTIME_PMBIT(3)
+#define I2C_HID_QUIRK_NO_RUNTIME_PMBIT(2)
 
 /* flags */
 #define I2C_HID_STARTED0
@@ -172,8 +171,6 @@ static const struct i2c_hid_quirks {
{ I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET |
I2C_HID_QUIRK_NO_RUNTIME_PM },
-   { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH,
-   I2C_HID_QUIRK_RESEND_REPORT_DESCR },
{ 0, 0 }
 };
 
@@ -1241,22 +1238,13 @@ static int i2c_hid_resume(struct device *dev)
 
/* Instead of resetting device, simply powers the device on. This
 * solves "incomplete reports" on Raydium devices 2386:3118 and
-* 2386:4B33
+* 2386:4B33 and fixes various SIS touchscreens no longer sending
+* data after a suspend/resume.
 */
ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
if (ret)
return ret;
 
-   /* Some devices need to re-send report descr cmd
-* after resume, after this it will be back normal.
-* otherwise it issues too many incomplete reports.
-*/
-   if (ihid->quirks & I2C_HID_QUIRK_RESEND_REPORT_DESCR) {
-   ret = i2c_hid_command(client, _report_descr_cmd, NULL, 0);
-   if (ret)
-   return ret;
-   }
-
if (hid->driver && hid->driver->reset_resume) {
ret = hid->driver->reset_resume(hid);
return ret;
-- 
2.17.1





[PATCH 4.18 058/150] thunderbolt: Do not handle ICM events after domain is stopped

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 86da809dda64a63fc27e05a215475325c3aaae92 ]

If there is a long chain of devices connected when the driver is loaded
ICM sends device connected event for each and those are put to tb->wq
for later processing. Now if the driver gets unloaded in the middle, so
that the work queue is not yet empty it gets flushed by tb_domain_stop().
However, by that time the root switch is already removed so the driver
crashes when it tries to dereference it in ICM event handling callbacks.

Fix this by checking whether the root switch is already removed. If it
is we know that the domain is stopped and we should merely skip handling
the event.

Signed-off-by: Mika Westerberg 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/thunderbolt/icm.c | 49 ---
 1 file changed, 20 insertions(+), 29 deletions(-)

diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index 500911f16498..5bad9fdec5f8 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -653,14 +653,6 @@ icm_fr_xdomain_connected(struct tb *tb, const struct 
icm_pkg_header *hdr)
bool approved;
u64 route;
 
-   /*
-* After NVM upgrade adding root switch device fails because we
-* initiated reset. During that time ICM might still send
-* XDomain connected message which we ignore here.
-*/
-   if (!tb->root_switch)
-   return;
-
link = pkg->link_info & ICM_LINK_INFO_LINK_MASK;
depth = (pkg->link_info & ICM_LINK_INFO_DEPTH_MASK) >>
ICM_LINK_INFO_DEPTH_SHIFT;
@@ -950,14 +942,6 @@ icm_tr_device_connected(struct tb *tb, const struct 
icm_pkg_header *hdr)
if (pkg->hdr.packet_id)
return;
 
-   /*
-* After NVM upgrade adding root switch device fails because we
-* initiated reset. During that time ICM might still send device
-* connected message which we ignore here.
-*/
-   if (!tb->root_switch)
-   return;
-
route = get_route(pkg->route_hi, pkg->route_lo);
authorized = pkg->link_info & ICM_LINK_INFO_APPROVED;
security_level = (pkg->hdr.flags & ICM_FLAGS_SLEVEL_MASK) >>
@@ -1317,19 +1301,26 @@ static void icm_handle_notification(struct work_struct 
*work)
 
mutex_lock(>lock);
 
-   switch (n->pkg->code) {
-   case ICM_EVENT_DEVICE_CONNECTED:
-   icm->device_connected(tb, n->pkg);
-   break;
-   case ICM_EVENT_DEVICE_DISCONNECTED:
-   icm->device_disconnected(tb, n->pkg);
-   break;
-   case ICM_EVENT_XDOMAIN_CONNECTED:
-   icm->xdomain_connected(tb, n->pkg);
-   break;
-   case ICM_EVENT_XDOMAIN_DISCONNECTED:
-   icm->xdomain_disconnected(tb, n->pkg);
-   break;
+   /*
+* When the domain is stopped we flush its workqueue but before
+* that the root switch is removed. In that case we should treat
+* the queued events as being canceled.
+*/
+   if (tb->root_switch) {
+   switch (n->pkg->code) {
+   case ICM_EVENT_DEVICE_CONNECTED:
+   icm->device_connected(tb, n->pkg);
+   break;
+   case ICM_EVENT_DEVICE_DISCONNECTED:
+   icm->device_disconnected(tb, n->pkg);
+   break;
+   case ICM_EVENT_XDOMAIN_CONNECTED:
+   icm->xdomain_connected(tb, n->pkg);
+   break;
+   case ICM_EVENT_XDOMAIN_DISCONNECTED:
+   icm->xdomain_disconnected(tb, n->pkg);
+   break;
+   }
}
 
mutex_unlock(>lock);
-- 
2.17.1





[PATCH 4.18 061/150] declance: Fix continuation with the adapter identification message

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit fe3a83af6a50199bf250fa331e94216912f79395 ]

Fix a commit 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing
continuation lines") regression with the `declance' driver, which caused
the adapter identification message to be split between two lines, e.g.:

declance.c: v0.011 by Linux MIPS DECstation task force
tc6: PMAD-AA
, addr = 08:00:2b:1b:2a:6a, irq = 14
tc6: registered as eth0.

Address that properly, by printing identification with a single call,
making the messages now look like:

declance.c: v0.011 by Linux MIPS DECstation task force
tc6: PMAD-AA, addr = 08:00:2b:1b:2a:6a, irq = 14
tc6: registered as eth0.

Signed-off-by: Maciej W. Rozycki 
Fixes: 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing continuation 
lines")
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/amd/declance.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/declance.c 
b/drivers/net/ethernet/amd/declance.c
index 116997a8b593..00332a1ea84b 100644
--- a/drivers/net/ethernet/amd/declance.c
+++ b/drivers/net/ethernet/amd/declance.c
@@ -1031,6 +1031,7 @@ static int dec_lance_probe(struct device *bdev, const int 
type)
int i, ret;
unsigned long esar_base;
unsigned char *esar;
+   const char *desc;
 
if (dec_lance_debug && version_printed++ == 0)
printk(version);
@@ -1216,19 +1217,20 @@ static int dec_lance_probe(struct device *bdev, const 
int type)
 */
switch (type) {
case ASIC_LANCE:
-   printk("%s: IOASIC onboard LANCE", name);
+   desc = "IOASIC onboard LANCE";
break;
case PMAD_LANCE:
-   printk("%s: PMAD-AA", name);
+   desc = "PMAD-AA";
break;
case PMAX_LANCE:
-   printk("%s: PMAX onboard LANCE", name);
+   desc = "PMAX onboard LANCE";
break;
}
for (i = 0; i < 6; i++)
dev->dev_addr[i] = esar[i * 4];
 
-   printk(", addr = %pM, irq = %d\n", dev->dev_addr, dev->irq);
+   printk("%s: %s, addr = %pM, irq = %d\n",
+  name, desc, dev->dev_addr, dev->irq);
 
dev->netdev_ops = _netdev_ops;
dev->watchdog_timeo = 5*HZ;
-- 
2.17.1





[PATCH 4.18 074/150] clk: mvebu: armada-37xx-periph: Remove unused var num_parents

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 8927c27b32703e28041ae19bf25ea53461be83a1 ]

When building armada-37xx-periph, num_parents isn't used in function
clk_pm_cpu_get_parent:
drivers/clk/mvebu/armada-37xx-periph.c: In function ‘clk_pm_cpu_get_parent’:
drivers/clk/mvebu/armada-37xx-periph.c:419:6: warning: unused variable 
‘num_parents’ [-Wunused-variable]
  int num_parents = clk_hw_get_num_parents(hw);
  ^~~
Remove the declaration of num_parents to dispose the warning.

Fixes: 616bf80d381d ("clk: mvebu: armada-37xx-periph: Fix wrong return value in 
get_parent")
Signed-off-by: Anders Roxell 
Signed-off-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/clk/mvebu/armada-37xx-periph.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/mvebu/armada-37xx-periph.c 
b/drivers/clk/mvebu/armada-37xx-periph.c
index 6f7637b19738..e764dfdea53f 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -419,7 +419,6 @@ static unsigned int 
armada_3700_pm_dvfs_get_cpu_parent(struct regmap *base)
 static u8 clk_pm_cpu_get_parent(struct clk_hw *hw)
 {
struct clk_pm_cpu *pm_cpu = to_clk_pm_cpu(hw);
-   int num_parents = clk_hw_get_num_parents(hw);
u32 val;
 
if (armada_3700_pm_dvfs_is_enabled(pm_cpu->nb_pm_base)) {
-- 
2.17.1





[PATCH 4.18 077/150] tls: Fix improper revert in zerocopy_from_iter

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 2da19ed3e4a87db16c0f69039da9f17a9596c350 ]

The current code is problematic because the iov_iter is reverted and
never advanced in the non-error case. This patch skips the revert in the
non-error case. This patch also fixes the amount by which the iov_iter
is reverted. Currently, iov_iter is reverted by size, which can be
greater than the amount by which the iter was actually advanced.
Instead, only revert by the amount that the iter was advanced.

Fixes: 4718799817c5 ("tls: Fix zerocopy_from_iter iov handling")
Signed-off-by: Doron Roberts-Kedes 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 net/tls/tls_sw.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 9fab8e5a4a5b..994ddc7ec9b1 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -286,7 +286,7 @@ static int zerocopy_from_iter(struct sock *sk, struct 
iov_iter *from,
  int length, int *pages_used,
  unsigned int *size_used,
  struct scatterlist *to, int to_max_pages,
- bool charge, bool revert)
+ bool charge)
 {
struct page *pages[MAX_SKB_FRAGS];
 
@@ -335,10 +335,10 @@ static int zerocopy_from_iter(struct sock *sk, struct 
iov_iter *from,
}
 
 out:
+   if (rc)
+   iov_iter_revert(from, size - *size_used);
*size_used = size;
*pages_used = num_elem;
-   if (revert)
-   iov_iter_revert(from, size);
 
return rc;
 }
@@ -440,7 +440,7 @@ alloc_encrypted:
>sg_plaintext_size,
ctx->sg_plaintext_data,
ARRAY_SIZE(ctx->sg_plaintext_data),
-   true, false);
+   true);
if (ret)
goto fallback_to_reg_send;
 
@@ -453,8 +453,6 @@ alloc_encrypted:
 
copied -= try_to_copy;
 fallback_to_reg_send:
-   iov_iter_revert(>msg_iter,
-   ctx->sg_plaintext_size - orig_size);
trim_sg(sk, ctx->sg_plaintext_data,
>sg_plaintext_num_elem,
>sg_plaintext_size,
@@ -828,7 +826,7 @@ int tls_sw_recvmsg(struct sock *sk,
err = zerocopy_from_iter(sk, >msg_iter,
 to_copy, ,
 , [1],
-MAX_SKB_FRAGS, false, 
true);
+MAX_SKB_FRAGS, false);
if (err < 0)
goto fallback_to_reg_recv;
 
-- 
2.17.1





[PATCH 4.18 057/150] perf/x86/amd/uncore: Set ThreadMask and SliceMask for L3 Cache perf events

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit d7cbbe49a9304520181fb8c9272d1327deec8453 ]

In Family 17h, some L3 Cache Performance events require the ThreadMask
and SliceMask to be set. For other events, these fields do not affect
the count either way.

Set ThreadMask and SliceMask to 0xFF and 0xF respectively.

Signed-off-by: Janakarajan Natarajan 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Arnaldo Carvalho de Melo 
Cc: Borislav Petkov 
Cc: H . Peter Anvin 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Suravee 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: http://lkml.kernel.org/r/Message-ID:
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/amd/uncore.c  | 10 ++
 arch/x86/include/asm/perf_event.h |  8 
 2 files changed, 18 insertions(+)

diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
index 981ba5e8241b..8671de126eac 100644
--- a/arch/x86/events/amd/uncore.c
+++ b/arch/x86/events/amd/uncore.c
@@ -36,6 +36,7 @@
 
 static int num_counters_llc;
 static int num_counters_nb;
+static bool l3_mask;
 
 static HLIST_HEAD(uncore_unused_list);
 
@@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event)
hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
hwc->idx = -1;
 
+   /*
+* SliceMask and ThreadMask need to be set for certain L3 events in
+* Family 17h. For other events, the two fields do not affect the count.
+*/
+   if (l3_mask)
+   hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK);
+
if (event->cpu < 0)
return -EINVAL;
 
@@ -525,6 +533,7 @@ static int __init amd_uncore_init(void)
amd_llc_pmu.name  = "amd_l3";
format_attr_event_df.show = _show_df;
format_attr_event_l3.show = _show_l3;
+   l3_mask   = true;
} else {
num_counters_nb   = NUM_COUNTERS_NB;
num_counters_llc  = NUM_COUNTERS_L2;
@@ -532,6 +541,7 @@ static int __init amd_uncore_init(void)
amd_llc_pmu.name  = "amd_l2";
format_attr_event_df  = format_attr_event;
format_attr_event_l3  = format_attr_event;
+   l3_mask   = false;
}
 
amd_nb_pmu.attr_groups  = amd_uncore_attr_groups_df;
diff --git a/arch/x86/include/asm/perf_event.h 
b/arch/x86/include/asm/perf_event.h
index 12f54082f4c8..78241b736f2a 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -46,6 +46,14 @@
 #define INTEL_ARCH_EVENT_MASK  \
(ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT)
 
+#define AMD64_L3_SLICE_SHIFT   48
+#define AMD64_L3_SLICE_MASK\
+   ((0xFULL) << AMD64_L3_SLICE_SHIFT)
+
+#define AMD64_L3_THREAD_SHIFT  56
+#define AMD64_L3_THREAD_MASK   \
+   ((0xFFULL) << AMD64_L3_THREAD_SHIFT)
+
 #define X86_RAW_EVENT_MASK \
(ARCH_PERFMON_EVENTSEL_EVENT |  \
 ARCH_PERFMON_EVENTSEL_UMASK |  \
-- 
2.17.1





[PATCH 4.18 076/150] perf report: Dont try to map ip to invalid map

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ff4ce2885af8f9e8e99864d78dbeb4673f089c76 ]

Fixes a crash when the report encounters an address that could not be
associated with an mmaped region:

  #0  0x557bdc4a in callchain_srcline (ip=, sym=0x0, map=0x0) at util/machine.c:2329
  #1  unwind_entry (entry=entry@entry=0x7fff9180, 
arg=arg@entry=0x75642498) at util/machine.c:2329
  #2  0x558370af in entry (arg=0x75642498, cb=0x557bdb50 
, thread=, ip=18446744073709551615) at 
util/unwind-libunwind-local.c:586
  #3  get_entries (ui=ui@entry=0x7fff9620, cb=0x557bdb50 
, arg=0x75642498, max_stack=) at 
util/unwind-libunwind-local.c:703
  #4  0x55837192 in _unwind__get_entries (cb=, 
arg=, thread=, data=, 
max_stack=) at util/unwind-libunwind-local.c:725
  #5  0x557c310f in thread__resolve_callchain_unwind (max_stack=127, 
sample=0x7fff9830, evsel=0x55c7b3b0, cursor=0x75642498, 
thread=0x55c7f6f0) at util/machine.c:2351
  #6  thread__resolve_callchain (thread=0x55c7f6f0, cursor=0x75642498, 
evsel=0x55c7b3b0, sample=0x7fff9830, parent=0x7fff97b8, 
root_al=0x7fff9750, max_stack=127) at util/machine.c:2378
  #7  0x557ba4ee in sample__resolve_callchain (sample=, 
cursor=, parent=parent@entry=0x7fff97b8, evsel=, al=al@entry=0x7fff9750,
  max_stack=) at util/callchain.c:1085

Signed-off-by: Milian Wolff 
Tested-by: Sandipan Das 
Acked-by: Jiri Olsa 
Cc: Jin Yao 
Cc: Namhyung Kim 
Fixes: 2a9d5050dc84 ("perf script: Show correct offsets for DWARF-based 
unwinding")
Link: http://lkml.kernel.org/r/20180926135207.30263-1-milian.wo...@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/util/machine.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 22dbb6612b41..d49744dc46d7 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2272,7 +2272,7 @@ static int unwind_entry(struct unwind_entry *entry, void 
*arg)
 {
struct callchain_cursor *cursor = arg;
const char *srcline = NULL;
-   u64 addr;
+   u64 addr = entry->ip;
 
if (symbol_conf.hide_unresolved && entry->sym == NULL)
return 0;
@@ -2284,7 +2284,8 @@ static int unwind_entry(struct unwind_entry *entry, void 
*arg)
 * Convert entry->ip from a virtual address to an offset in
 * its corresponding binary.
 */
-   addr = map__map_ip(entry->map, entry->ip);
+   if (entry->map)
+   addr = map__map_ip(entry->map, entry->ip);
 
srcline = callchain_srcline(entry->map, entry->sym, addr);
return callchain_cursor_append(cursor, entry->ip,
-- 
2.17.1





[PATCH 4.18 060/150] net: fec: fix rare tx timeout

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 657ade07df72847f591ccdb36bd9b91ed0edbac3 ]

During certain heavy network loads TX could time out
with TX ring dump.
TX is sometimes never restarted after reaching
"tx_stop_threshold" because function "fec_enet_tx_queue"
only tests the first queue.

In addition the TX timeout callback function failed to
recover because it also operated only on the first queue.

Signed-off-by: Rickard x Andersson 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/fec_main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c 
b/drivers/net/ethernet/freescale/fec_main.c
index c729665107f5..e10471ee0a8b 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1157,7 +1157,7 @@ static void fec_enet_timeout_work(struct work_struct 
*work)
napi_disable(>napi);
netif_tx_lock_bh(ndev);
fec_restart(ndev);
-   netif_wake_queue(ndev);
+   netif_tx_wake_all_queues(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(>napi);
}
@@ -1272,7 +1272,7 @@ skb_done:
 
/* Since we have freed up a buffer, the ring is no longer full
 */
-   if (netif_queue_stopped(ndev)) {
+   if (netif_tx_queue_stopped(nq)) {
entries_free = fec_enet_get_free_txdesc_num(txq);
if (entries_free >= txq->tx_wake_threshold)
netif_tx_wake_queue(nq);
@@ -1745,7 +1745,7 @@ static void fec_enet_adjust_link(struct net_device *ndev)
napi_disable(>napi);
netif_tx_lock_bh(ndev);
fec_restart(ndev);
-   netif_wake_queue(ndev);
+   netif_tx_wake_all_queues(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(>napi);
}
@@ -2246,7 +2246,7 @@ static int fec_enet_set_pauseparam(struct net_device 
*ndev,
napi_disable(>napi);
netif_tx_lock_bh(ndev);
fec_restart(ndev);
-   netif_wake_queue(ndev);
+   netif_tx_wake_all_queues(ndev);
netif_tx_unlock_bh(ndev);
napi_enable(>napi);
}
-- 
2.17.1





[PATCH 4.18 075/150] libertas: call into generic suspend code before turning off power

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 4f75cdff0b986195413215eb062b7da6586f ]

When powering down a SDIO connected card during suspend, make sure to call
into the generic lbs_suspend() function before pulling the plug. This will
make sure the card is successfully deregistered from the system to avoid
communication to the card starving out.

Fixes: 7444a8092906 ("libertas: fix suspend and resume for SDIO connected 
cards")
Signed-off-by: Daniel Mack 
Reviewed-by: Ulf Hansson 
Acked-by: Kalle Valo 
Signed-off-by: Ulf Hansson 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/marvell/libertas/if_sdio.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/marvell/libertas/if_sdio.c 
b/drivers/net/wireless/marvell/libertas/if_sdio.c
index 43743c26c071..39bf85d0ade0 100644
--- a/drivers/net/wireless/marvell/libertas/if_sdio.c
+++ b/drivers/net/wireless/marvell/libertas/if_sdio.c
@@ -1317,6 +1317,10 @@ static int if_sdio_suspend(struct device *dev)
if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
dev_info(dev, "Suspend without wake params -- powering down 
card\n");
if (priv->fw_ready) {
+   ret = lbs_suspend(priv);
+   if (ret)
+   return ret;
+
priv->power_up_on_resume = true;
if_sdio_power_off(card);
}
-- 
2.17.1





[PATCH 4.18 079/150] compiler.h: Allow arch-specific asm/compiler.h

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 04f264d3a8b0eb25d378127bd78c3c9a0261c828 ]

We have a need to override the definition of
barrier_before_unreachable() for MIPS, which means we either need to add
architecture-specific code into linux/compiler-gcc.h or we need to allow
the architecture to provide a header that can define the macro before
the generic definition. The latter seems like the better approach.

A straightforward approach to the per-arch header is to make use of
asm-generic to provide a default empty header & adjust architectures
which don't need anything specific to make use of that by adding the
header to generic-y. Unfortunately this doesn't work so well due to
commit 28128c61e08e ("kconfig.h: Include compiler types to avoid missed
struct attributes") which caused linux/compiler_types.h to be included
in the compilation of every C file via the -include linux/kconfig.h flag
in c_flags.

Because the -include flag is present for all C files we compile, we need
the architecture-provided header to be present before any C files are
compiled. If any C files can be compiled prior to the asm-generic header
wrappers being generated then we hit a build failure due to missing
header. Such cases do exist - one pointed out by the kbuild test robot
is the compilation of arch/ia64/kernel/nr-irqs.c, which occurs as part
of the archprepare target [1].

This leaves us with a few options:

  1) Use generic-y & fix any build failures we find by enforcing
 ordering such that the asm-generic target occurs before any C
 compilation, such that linux/compiler_types.h can always include
 the generated asm-generic wrapper which in turn includes the empty
 asm-generic header. This would rely on us finding all the
 problematic cases - I don't know for sure that the ia64 issue is
 the only one.

  2) Add an actual empty header to each architecture, so that we don't
 need the generated asm-generic wrapper. This seems messy.

  3) Give up & add #ifdef CONFIG_MIPS or similar to
 linux/compiler_types.h. This seems messy too.

  4) Include the arch header only when it's actually needed, removing
 the need for the asm-generic wrapper for all other architectures.

This patch allows us to use approach 4, by including an asm/compiler.h
header from linux/compiler_types.h after the inclusion of the
compiler-specific linux/compiler-*.h header(s). We do this
conditionally, only when CONFIG_HAVE_ARCH_COMPILER_H is selected, in
order to avoid the need for asm-generic wrappers & the associated build
ordering issue described above. The asm/compiler.h header is included
after the generic linux/compiler-*.h header(s) for consistency with the
way linux/compiler-intel.h & linux/compiler-clang.h are included after
the linux/compiler-gcc.h header that they override.

[1] https://lists.01.org/pipermail/kbuild-all/2018-August/051175.html

Signed-off-by: Paul Burton 
Reviewed-by: Masahiro Yamada 
Patchwork: https://patchwork.linux-mips.org/patch/20269/
Cc: Arnd Bergmann 
Cc: James Hogan 
Cc: Masahiro Yamada 
Cc: Ralf Baechle 
Cc: linux-a...@vger.kernel.org
Cc: linux-kbu...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Signed-off-by: Sasha Levin 
---
 arch/Kconfig   |  8 
 include/linux/compiler_types.h | 12 
 2 files changed, 20 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index f03b72644902..a18371a36e03 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -977,4 +977,12 @@ config REFCOUNT_FULL
  against various use-after-free conditions that can be used in
  security flaw exploits.
 
+config HAVE_ARCH_COMPILER_H
+   bool
+   help
+ An architecture can select this if it provides an
+ asm/compiler.h header that should be included after
+ linux/compiler-*.h in order to override macro definitions that those
+ headers generally provide.
+
 source "kernel/gcov/Kconfig"
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index a8ba6b04152c..55e4be8b016b 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -78,6 +78,18 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 #include 
 #endif
 
+/*
+ * Some architectures need to provide custom definitions of macros provided
+ * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that
+ * conditionally rather than using an asm-generic wrapper in order to avoid
+ * build failures if any C compilation, which will include this file via an
+ * -include argument in c_flags, occurs prior to the asm-generic wrappers being
+ * generated.
+ */
+#ifdef CONFIG_HAVE_ARCH_COMPILER_H
+#include 
+#endif
+
 /*
  * Generic compiler-dependent macros required for kernel
  * build go below this comment. Actual compiler/compiler version
-- 
2.17.1





[PATCH 4.18 080/150] ARM: dts: imx53-qsb: disable 1.2GHz OPP

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eea96566c189c77e5272585984eb2729881a2f1d ]

The maximum CPU frequency for the i.MX53 QSB is 1GHz, so disable the
1.2GHz OPP. This makes the board work again with configs that have
cpufreq enabled like imx_v6_v7_defconfig on which the board stopped
working with the addition of cpufreq-dt support.

Fixes: 791f416608 ("ARM: dts: imx53: add cpufreq-dt support")

Signed-off-by: Sascha Hauer 
Signed-off-by: Shawn Guo 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/imx53-qsb-common.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi 
b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index ef7658a78836..c1548adee789 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -123,6 +123,17 @@
};
 };
 
+ {
+   /* CPU rated to 1GHz, not 1.2GHz as per the default settings */
+   operating-points = <
+   /* kHz   uV */
+   16  85
+   40  90
+   80  105
+   100 120
+   >;
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_esdhc1>;
-- 
2.17.1





[PATCH 4.18 056/150] perf/x86/intel/uncore: Fix PCI BDF address of M3UPI on SKX

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 9d92cfeaf5215158d26d2991be7f7ff865cb98f3 ]

The counters on M3UPI Link 0 and Link 3 don't count properly, and writing
0 to these counters may causes system crash on some machines.

The PCI BDF addresses of the M3UPI in the current code are incorrect.

The correct addresses should be:

  D18:F10x204D
  D18:F20x204E
  D18:F50x204D

Signed-off-by: Kan Liang 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Fixes: cd34cd97b7b4 ("perf/x86/intel/uncore: Add Skylake server uncore support")
Link: 
http://lkml.kernel.org/r/1537538826-55489-1-git-send-email-kan.li...@linux.intel.com
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/uncore_snbep.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c 
b/arch/x86/events/intel/uncore_snbep.c
index 53b981dcdb42..c07bee31abe8 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -3931,16 +3931,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] 
= {
.driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, 
SKX_PCI_UNCORE_M2PCIE, 3),
},
{ /* M3UPI0 Link 0 */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C),
-   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, 
SKX_PCI_UNCORE_M3UPI, 0),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
+   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, 
SKX_PCI_UNCORE_M3UPI, 0),
},
{ /* M3UPI0 Link 1 */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
-   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, 
SKX_PCI_UNCORE_M3UPI, 1),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E),
+   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, 
SKX_PCI_UNCORE_M3UPI, 1),
},
{ /* M3UPI1 Link 2 */
-   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C),
-   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, 
SKX_PCI_UNCORE_M3UPI, 2),
+   PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D),
+   .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, 
SKX_PCI_UNCORE_M3UPI, 2),
},
{ /* end: all zeroes */ }
 };
-- 
2.17.1





[PATCH 4.18 078/150] HID: i2c-hid: Remove RESEND_REPORT_DESCR quirk and its handling

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit afbb1169ed5b58cfca017e368b53e019cf285853 ]

Commit 52cf93e63ee6 ("HID: i2c-hid: Don't reset device upon system resume")
removes the need for the RESEND_REPORT_DESCR quirk for Raydium devices, but
kept it for the SIS device id 10FB touchscreens, as the author of that
commit could not determine if the quirk is still necessary there.

I've tested suspend/resume on a Toshiba Click Mini L9W-B which is the
device for which this quirk was added in the first place and with the
"Don't reset device upon system resume" fix the quirk is no longer
necessary, so this commit removes it.

Note even better I also had some other devices with SIS touchscreens which
suspend/resume issues, where the RESEND_REPORT_DESCR quirk did not help.

I've also tested these devices with the "Don't reset device upon system
resume" fix and I'm happy to report that that fix also fixes touchscreen
resume on the following devices:

Asus T100HA
Asus T200TA
Peaq C1010

Cc: Kai-Heng Feng 
Acked-by: Benjamin Tissoires 
Signed-off-by: Hans de Goede 
Signed-off-by: Jiri Kosina 
Signed-off-by: Sasha Levin 
---
 drivers/hid/hid-ids.h |  1 -
 drivers/hid/i2c-hid/i2c-hid.c | 18 +++---
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index eee6b79fb131..ae5b72269e27 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -974,7 +974,6 @@
 #define USB_DEVICE_ID_SIS817_TOUCH 0x0817
 #define USB_DEVICE_ID_SIS_TS   0x1013
 #define USB_DEVICE_ID_SIS1030_TOUCH0x1030
-#define USB_DEVICE_ID_SIS10FB_TOUCH0x10fb
 
 #define USB_VENDOR_ID_SKYCABLE 0x1223
 #defineUSB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER   0x3F07
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 37013b58098c..d17cf6e323b2 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -47,8 +47,7 @@
 /* quirks to control the device */
 #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV   BIT(0)
 #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET   BIT(1)
-#define I2C_HID_QUIRK_RESEND_REPORT_DESCR  BIT(2)
-#define I2C_HID_QUIRK_NO_RUNTIME_PMBIT(3)
+#define I2C_HID_QUIRK_NO_RUNTIME_PMBIT(2)
 
 /* flags */
 #define I2C_HID_STARTED0
@@ -172,8 +171,6 @@ static const struct i2c_hid_quirks {
{ I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET |
I2C_HID_QUIRK_NO_RUNTIME_PM },
-   { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH,
-   I2C_HID_QUIRK_RESEND_REPORT_DESCR },
{ 0, 0 }
 };
 
@@ -1241,22 +1238,13 @@ static int i2c_hid_resume(struct device *dev)
 
/* Instead of resetting device, simply powers the device on. This
 * solves "incomplete reports" on Raydium devices 2386:3118 and
-* 2386:4B33
+* 2386:4B33 and fixes various SIS touchscreens no longer sending
+* data after a suspend/resume.
 */
ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
if (ret)
return ret;
 
-   /* Some devices need to re-send report descr cmd
-* after resume, after this it will be back normal.
-* otherwise it issues too many incomplete reports.
-*/
-   if (ihid->quirks & I2C_HID_QUIRK_RESEND_REPORT_DESCR) {
-   ret = i2c_hid_command(client, _report_descr_cmd, NULL, 0);
-   if (ret)
-   return ret;
-   }
-
if (hid->driver && hid->driver->reset_resume) {
ret = hid->driver->reset_resume(hid);
return ret;
-- 
2.17.1





[PATCH 4.18 068/150] net: cxgb3_main: fix a missing-check bug

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 2c05d88818ab6571816b93edce4d53703870d7ae ]

In cxgb_extension_ioctl(), the command of the ioctl is firstly copied from
the user-space buffer 'useraddr' to 'cmd' and checked through the
switch statement. If the command is not as expected, an error code
EOPNOTSUPP is returned. In the following execution, i.e., the cases of the
switch statement, the whole buffer of 'useraddr' is copied again to a
specific data structure, according to what kind of command is requested.
However, after the second copy, there is no re-check on the newly-copied
command. Given that the buffer 'useraddr' is in the user space, a malicious
user can race to change the command between the two copies. By doing so,
the attacker can supply malicious data to the kernel and cause undefined
behavior.

This patch adds a re-check in each case of the switch statement if there is
a second copy in that case, to re-check whether the command obtained in the
second copy is the same as the one in the first copy. If not, an error code
EINVAL is returned.

Signed-off-by: Wenwen Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c 
b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index a19172dbe6be..c34ea385fe4a 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -2159,6 +2159,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EPERM;
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
+   if (t.cmd != CHELSIO_SET_QSET_PARAMS)
+   return -EINVAL;
if (t.qset_idx >= SGE_QSETS)
return -EINVAL;
if (!in_range(t.intr_lat, 0, M_NEWTIMER) ||
@@ -2258,6 +2260,9 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
 
+   if (t.cmd != CHELSIO_GET_QSET_PARAMS)
+   return -EINVAL;
+
/* Display qsets for all ports when offload enabled */
if (test_bit(OFFLOAD_DEVMAP_BIT, >open_device_map)) {
q1 = 0;
@@ -2303,6 +2308,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EBUSY;
if (copy_from_user(, useraddr, sizeof(edata)))
return -EFAULT;
+   if (edata.cmd != CHELSIO_SET_QSET_NUM)
+   return -EINVAL;
if (edata.val < 1 ||
(edata.val > 1 && !(adapter->flags & USING_MSIX)))
return -EINVAL;
@@ -2343,6 +2350,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EPERM;
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
+   if (t.cmd != CHELSIO_LOAD_FW)
+   return -EINVAL;
/* Check t.len sanity ? */
fw_data = memdup_user(useraddr + sizeof(t), t.len);
if (IS_ERR(fw_data))
@@ -2366,6 +2375,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EBUSY;
if (copy_from_user(, useraddr, sizeof(m)))
return -EFAULT;
+   if (m.cmd != CHELSIO_SETMTUTAB)
+   return -EINVAL;
if (m.nmtus != NMTUS)
return -EINVAL;
if (m.mtus[0] < 81) /* accommodate SACK */
@@ -2407,6 +2418,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EBUSY;
if (copy_from_user(, useraddr, sizeof(m)))
return -EFAULT;
+   if (m.cmd != CHELSIO_SET_PM)
+   return -EINVAL;
if (!is_power_of_2(m.rx_pg_sz) ||
!is_power_of_2(m.tx_pg_sz))
return -EINVAL; /* not power of 2 */
@@ -2440,6 +2453,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EIO;/* need the memory controllers */
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
+   if (t.cmd != CHELSIO_GET_MEM)
+   return -EINVAL;
if ((t.addr & 7) || (t.len & 7))
return -EINVAL;
if (t.mem_id == MEM_CM)
@@ -2492,6 +2507,8 @@ static int 

[PATCH 4.18 072/150] mm/migrate.c: split only transparent huge pages when allocation fails

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit e6112fc300702f96374f34368513d57795fc6d23 ]

split_huge_page_to_list() fails on HugeTLB pages.  I was experimenting
with moving 32MB contig HugeTLB pages on arm64 (with a debug patch
applied) and hit the following stack trace when the kernel crashed.

[ 3732.462797] Call trace:
[ 3732.462835]  split_huge_page_to_list+0x3b0/0x858
[ 3732.462913]  migrate_pages+0x728/0xc20
[ 3732.462999]  soft_offline_page+0x448/0x8b0
[ 3732.463097]  __arm64_sys_madvise+0x724/0x850
[ 3732.463197]  el0_svc_handler+0x74/0x110
[ 3732.463297]  el0_svc+0x8/0xc
[ 3732.463347] Code: d1000400 f90b0e60 f2fbd5a2 a94982a1 (f9000420)

When unmap_and_move[_huge_page]() fails due to lack of memory, the
splitting should happen only for transparent huge pages not for HugeTLB
pages.  PageTransHuge() returns true for both THP and HugeTLB pages.
Hence the conditonal check should test PagesHuge() flag to make sure that
given pages is not a HugeTLB one.

Link: 
http://lkml.kernel.org/r/1537798495-4996-1-git-send-email-anshuman.khand...@arm.com
Fixes: 94723aafb9 ("mm: unclutter THP migration")
Signed-off-by: Anshuman Khandual 
Acked-by: Michal Hocko 
Acked-by: Naoya Horiguchi 
Cc: Kirill A. Shutemov 
Cc: Zi Yan 
Cc: Mike Kravetz 
Cc: Vlastimil Babka 
Signed-off-by: Andrew Morton 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 2a55289ee9f1..f49eb9589d73 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1415,7 +1415,7 @@ retry:
 * we encounter them after the rest of the list
 * is processed.
 */
-   if (PageTransHuge(page)) {
+   if (PageTransHuge(page) && !PageHuge(page)) {
lock_page(page);
rc = split_huge_page_to_list(page, 
from);
unlock_page(page);
-- 
2.17.1





[PATCH 4.18 070/150] ocfs2: fix crash in ocfs2_duplicate_clusters_by_page()

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 69eb7765b9c6902444c89c54e7043242faf981e5 ]

ocfs2_duplicate_clusters_by_page() may crash if one of the extent's pages
is dirty.  When a page has not been written back, it is still in dirty
state.  If ocfs2_duplicate_clusters_by_page() is called against the dirty
page, the crash happens.

To fix this bug, we can just unlock the page and wait until the page until
its not dirty.

The following is the backtrace:

kernel BUG at /root/code/ocfs2/refcounttree.c:2961!
[exception RIP: ocfs2_duplicate_clusters_by_page+822]
__ocfs2_move_extent+0x80/0x450 [ocfs2]
? __ocfs2_claim_clusters+0x130/0x250 [ocfs2]
ocfs2_defrag_extent+0x5b8/0x5e0 [ocfs2]
__ocfs2_move_extents_range+0x2a4/0x470 [ocfs2]
ocfs2_move_extents+0x180/0x3b0 [ocfs2]
? ocfs2_wait_for_recovery+0x13/0x70 [ocfs2]
ocfs2_ioctl_move_extents+0x133/0x2d0 [ocfs2]
ocfs2_ioctl+0x253/0x640 [ocfs2]
do_vfs_ioctl+0x90/0x5f0
SyS_ioctl+0x74/0x80
do_syscall_64+0x74/0x140
entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Once we find the page is dirty, we do not wait until it's clean, rather we
use write_one_page() to write it back

Link: http://lkml.kernel.org/r/20180829074740.9438-1-lc...@suse.com
[lc...@suse.com: update comments]
  Link: http://lkml.kernel.org/r/20180830075041.14879-1-lc...@suse.com
[a...@linux-foundation.org: coding-style fixes]
Signed-off-by: Larry Chen 
Acked-by: Changwei Ge 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: Junxiao Bi 
Cc: Joseph Qi 
Signed-off-by: Andrew Morton 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 fs/ocfs2/refcounttree.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 7869622af22a..7a5ee145c733 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -2946,6 +2946,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
if (map_end & (PAGE_SIZE - 1))
to = map_end & (PAGE_SIZE - 1);
 
+retry:
page = find_or_create_page(mapping, page_index, GFP_NOFS);
if (!page) {
ret = -ENOMEM;
@@ -2954,11 +2955,18 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
}
 
/*
-* In case PAGE_SIZE <= CLUSTER_SIZE, This page
-* can't be dirtied before we CoW it out.
+* In case PAGE_SIZE <= CLUSTER_SIZE, we do not expect a dirty
+* page, so write it back.
 */
-   if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize)
-   BUG_ON(PageDirty(page));
+   if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) {
+   if (PageDirty(page)) {
+   /*
+* write_on_page will unlock the page on return
+*/
+   ret = write_one_page(page);
+   goto retry;
+   }
+   }
 
if (!PageUptodate(page)) {
ret = block_read_full_page(page, ocfs2_get_block);
-- 
2.17.1





[PATCH 4.18 068/150] net: cxgb3_main: fix a missing-check bug

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 2c05d88818ab6571816b93edce4d53703870d7ae ]

In cxgb_extension_ioctl(), the command of the ioctl is firstly copied from
the user-space buffer 'useraddr' to 'cmd' and checked through the
switch statement. If the command is not as expected, an error code
EOPNOTSUPP is returned. In the following execution, i.e., the cases of the
switch statement, the whole buffer of 'useraddr' is copied again to a
specific data structure, according to what kind of command is requested.
However, after the second copy, there is no re-check on the newly-copied
command. Given that the buffer 'useraddr' is in the user space, a malicious
user can race to change the command between the two copies. By doing so,
the attacker can supply malicious data to the kernel and cause undefined
behavior.

This patch adds a re-check in each case of the switch statement if there is
a second copy in that case, to re-check whether the command obtained in the
second copy is the same as the one in the first copy. If not, an error code
EINVAL is returned.

Signed-off-by: Wenwen Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c 
b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index a19172dbe6be..c34ea385fe4a 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -2159,6 +2159,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EPERM;
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
+   if (t.cmd != CHELSIO_SET_QSET_PARAMS)
+   return -EINVAL;
if (t.qset_idx >= SGE_QSETS)
return -EINVAL;
if (!in_range(t.intr_lat, 0, M_NEWTIMER) ||
@@ -2258,6 +2260,9 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
 
+   if (t.cmd != CHELSIO_GET_QSET_PARAMS)
+   return -EINVAL;
+
/* Display qsets for all ports when offload enabled */
if (test_bit(OFFLOAD_DEVMAP_BIT, >open_device_map)) {
q1 = 0;
@@ -2303,6 +2308,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EBUSY;
if (copy_from_user(, useraddr, sizeof(edata)))
return -EFAULT;
+   if (edata.cmd != CHELSIO_SET_QSET_NUM)
+   return -EINVAL;
if (edata.val < 1 ||
(edata.val > 1 && !(adapter->flags & USING_MSIX)))
return -EINVAL;
@@ -2343,6 +2350,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EPERM;
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
+   if (t.cmd != CHELSIO_LOAD_FW)
+   return -EINVAL;
/* Check t.len sanity ? */
fw_data = memdup_user(useraddr + sizeof(t), t.len);
if (IS_ERR(fw_data))
@@ -2366,6 +2375,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EBUSY;
if (copy_from_user(, useraddr, sizeof(m)))
return -EFAULT;
+   if (m.cmd != CHELSIO_SETMTUTAB)
+   return -EINVAL;
if (m.nmtus != NMTUS)
return -EINVAL;
if (m.mtus[0] < 81) /* accommodate SACK */
@@ -2407,6 +2418,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EBUSY;
if (copy_from_user(, useraddr, sizeof(m)))
return -EFAULT;
+   if (m.cmd != CHELSIO_SET_PM)
+   return -EINVAL;
if (!is_power_of_2(m.rx_pg_sz) ||
!is_power_of_2(m.tx_pg_sz))
return -EINVAL; /* not power of 2 */
@@ -2440,6 +2453,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, 
void __user *useraddr)
return -EIO;/* need the memory controllers */
if (copy_from_user(, useraddr, sizeof(t)))
return -EFAULT;
+   if (t.cmd != CHELSIO_GET_MEM)
+   return -EINVAL;
if ((t.addr & 7) || (t.len & 7))
return -EINVAL;
if (t.mem_id == MEM_CM)
@@ -2492,6 +2507,8 @@ static int 

[PATCH 4.18 072/150] mm/migrate.c: split only transparent huge pages when allocation fails

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit e6112fc300702f96374f34368513d57795fc6d23 ]

split_huge_page_to_list() fails on HugeTLB pages.  I was experimenting
with moving 32MB contig HugeTLB pages on arm64 (with a debug patch
applied) and hit the following stack trace when the kernel crashed.

[ 3732.462797] Call trace:
[ 3732.462835]  split_huge_page_to_list+0x3b0/0x858
[ 3732.462913]  migrate_pages+0x728/0xc20
[ 3732.462999]  soft_offline_page+0x448/0x8b0
[ 3732.463097]  __arm64_sys_madvise+0x724/0x850
[ 3732.463197]  el0_svc_handler+0x74/0x110
[ 3732.463297]  el0_svc+0x8/0xc
[ 3732.463347] Code: d1000400 f90b0e60 f2fbd5a2 a94982a1 (f9000420)

When unmap_and_move[_huge_page]() fails due to lack of memory, the
splitting should happen only for transparent huge pages not for HugeTLB
pages.  PageTransHuge() returns true for both THP and HugeTLB pages.
Hence the conditonal check should test PagesHuge() flag to make sure that
given pages is not a HugeTLB one.

Link: 
http://lkml.kernel.org/r/1537798495-4996-1-git-send-email-anshuman.khand...@arm.com
Fixes: 94723aafb9 ("mm: unclutter THP migration")
Signed-off-by: Anshuman Khandual 
Acked-by: Michal Hocko 
Acked-by: Naoya Horiguchi 
Cc: Kirill A. Shutemov 
Cc: Zi Yan 
Cc: Mike Kravetz 
Cc: Vlastimil Babka 
Signed-off-by: Andrew Morton 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 2a55289ee9f1..f49eb9589d73 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1415,7 +1415,7 @@ retry:
 * we encounter them after the rest of the list
 * is processed.
 */
-   if (PageTransHuge(page)) {
+   if (PageTransHuge(page) && !PageHuge(page)) {
lock_page(page);
rc = split_huge_page_to_list(page, 
from);
unlock_page(page);
-- 
2.17.1





[PATCH 4.18 070/150] ocfs2: fix crash in ocfs2_duplicate_clusters_by_page()

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 69eb7765b9c6902444c89c54e7043242faf981e5 ]

ocfs2_duplicate_clusters_by_page() may crash if one of the extent's pages
is dirty.  When a page has not been written back, it is still in dirty
state.  If ocfs2_duplicate_clusters_by_page() is called against the dirty
page, the crash happens.

To fix this bug, we can just unlock the page and wait until the page until
its not dirty.

The following is the backtrace:

kernel BUG at /root/code/ocfs2/refcounttree.c:2961!
[exception RIP: ocfs2_duplicate_clusters_by_page+822]
__ocfs2_move_extent+0x80/0x450 [ocfs2]
? __ocfs2_claim_clusters+0x130/0x250 [ocfs2]
ocfs2_defrag_extent+0x5b8/0x5e0 [ocfs2]
__ocfs2_move_extents_range+0x2a4/0x470 [ocfs2]
ocfs2_move_extents+0x180/0x3b0 [ocfs2]
? ocfs2_wait_for_recovery+0x13/0x70 [ocfs2]
ocfs2_ioctl_move_extents+0x133/0x2d0 [ocfs2]
ocfs2_ioctl+0x253/0x640 [ocfs2]
do_vfs_ioctl+0x90/0x5f0
SyS_ioctl+0x74/0x80
do_syscall_64+0x74/0x140
entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Once we find the page is dirty, we do not wait until it's clean, rather we
use write_one_page() to write it back

Link: http://lkml.kernel.org/r/20180829074740.9438-1-lc...@suse.com
[lc...@suse.com: update comments]
  Link: http://lkml.kernel.org/r/20180830075041.14879-1-lc...@suse.com
[a...@linux-foundation.org: coding-style fixes]
Signed-off-by: Larry Chen 
Acked-by: Changwei Ge 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: Junxiao Bi 
Cc: Joseph Qi 
Signed-off-by: Andrew Morton 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 fs/ocfs2/refcounttree.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 7869622af22a..7a5ee145c733 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -2946,6 +2946,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
if (map_end & (PAGE_SIZE - 1))
to = map_end & (PAGE_SIZE - 1);
 
+retry:
page = find_or_create_page(mapping, page_index, GFP_NOFS);
if (!page) {
ret = -ENOMEM;
@@ -2954,11 +2955,18 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
}
 
/*
-* In case PAGE_SIZE <= CLUSTER_SIZE, This page
-* can't be dirtied before we CoW it out.
+* In case PAGE_SIZE <= CLUSTER_SIZE, we do not expect a dirty
+* page, so write it back.
 */
-   if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize)
-   BUG_ON(PageDirty(page));
+   if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) {
+   if (PageDirty(page)) {
+   /*
+* write_on_page will unlock the page on return
+*/
+   ret = write_one_page(page);
+   goto retry;
+   }
+   }
 
if (!PageUptodate(page)) {
ret = block_read_full_page(page, ocfs2_get_block);
-- 
2.17.1





[PATCH 4.18 071/150] mm/gup_benchmark: fix unsigned comparison to zero in __gup_benchmark_ioctl

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 51896864579d5a3349740847083f4db5c6487164 ]

get_user_pages_fast() will return negative value if no pages were pinned,
then be converted to a unsigned, which is compared to zero, giving the
wrong result.

Link: http://lkml.kernel.org/r/20180921095015.26088-1-yuehaib...@huawei.com
Fixes: 09e35a4a1ca8 ("mm/gup_benchmark: handle gup failures")
Signed-off-by: YueHaibing 
Reviewed-by: Andrew Morton 
Cc: Michael S. Tsirkin 
Signed-off-by: Andrew Morton 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 mm/gup_benchmark.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c
index 6a473709e9b6..7405c9d89d65 100644
--- a/mm/gup_benchmark.c
+++ b/mm/gup_benchmark.c
@@ -19,7 +19,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
struct gup_benchmark *gup)
 {
ktime_t start_time, end_time;
-   unsigned long i, nr, nr_pages, addr, next;
+   unsigned long i, nr_pages, addr, next;
+   int nr;
struct page **pages;
 
nr_pages = gup->size / PAGE_SIZE;
-- 
2.17.1





[PATCH 4.18 067/150] powerpc/numa: Skip onlining a offline node in kdump path

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ac1788cc7da4ce54edcfd2e499afdb0a23d5c41d ]

With commit 2ea626306810 ("powerpc/topology: Get topology for shared
processors at boot"), kdump kernel on shared LPAR may crash.

The necessary conditions are
- Shared LPAR with at least 2 nodes having memory and CPUs.
- Memory requirement for kdump kernel must be met by the first N-1
  nodes where there are at least N nodes with memory and CPUs.

Example numactl of such a machine.
  $ numactl -H
  available: 5 nodes (0,2,5-7)
  node 0 cpus:
  node 0 size: 0 MB
  node 0 free: 0 MB
  node 2 cpus:
  node 2 size: 255 MB
  node 2 free: 189 MB
  node 5 cpus: 24 25 26 27 28 29 30 31
  node 5 size: 4095 MB
  node 5 free: 4024 MB
  node 6 cpus: 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23
  node 6 size: 6353 MB
  node 6 free: 5998 MB
  node 7 cpus: 8 9 10 11 12 13 14 15 32 33 34 35 36 37 38 39
  node 7 size: 7640 MB
  node 7 free: 7164 MB
  node distances:
  node   0   2   5   6   7
0:  10  40  40  40  40
2:  40  10  40  40  40
5:  40  40  10  40  40
6:  40  40  40  10  20
7:  40  40  40  20  10

Steps to reproduce.
1. Load / start kdump service.
2. Trigger a kdump (for example : echo c > /proc/sysrq-trigger)

When booting a kdump kernel with 2048M:

  kexec: Starting switchover sequence.
  I'm in purgatory
  Using 1TB segments
  hash-mmu: Initializing hash mmu with SLB
  Linux version 4.19.0-rc5-master+ (srikar@linux-xxu6) (gcc version 4.8.5 (SUSE 
Linux)) #1 SMP Thu Sep 27 19:45:00 IST 2018
  Found initrd at 0xc9e7:0xcae554b4
  Using pSeries machine description
  -
  ppc64_pft_size= 0x1e
  phys_mem_size = 0x8800
  dcache_bsize  = 0x80
  icache_bsize  = 0x80
  cpu_features  = 0x00ff8f5d91a7
possible= 0xfbffcf5fb1a7
always  = 0x006f8b5c91a1
  cpu_user_features = 0xdc0065c2 0xef00
  mmu_features  = 0x7c006001
  firmware_features = 0x0007c45bfc57
  htab_hash_mask= 0x7f
  physical_start= 0x800
  -
  numa:   NODE_DATA [mem 0x87d5e300-0x87d67fff]
  numa: NODE_DATA(0) on node 6
  numa:   NODE_DATA [mem 0x87d54600-0x87d5e2ff]
  Top of RAM: 0x8800, Total RAM: 0x8800
  Memory hole size: 0MB
  Zone ranges:
DMA  [mem 0x-0x87ff]
DMA32empty
Normal   empty
  Movable zone start for each node
  Early memory node ranges
node   6: [mem 0x-0x87ff]
  Could not find start_pfn for node 0
  Initmem setup node 0 [mem 0x-0x]
  On node 0 totalpages: 0
  Initmem setup node 6 [mem 0x-0x87ff]
  On node 6 totalpages: 34816

  Unable to handle kernel paging request for data at address 0x0060
  Faulting instruction address: 0xc8703a54
  Oops: Kernel access of bad area, sig: 11 [#1]
  LE SMP NR_CPUS=2048 NUMA pSeries
  Modules linked in:
  CPU: 11 PID: 1 Comm: swapper/11 Not tainted 4.19.0-rc5-master+ #1
  NIP:  c8703a54 LR: c8703a38 CTR: 
  REGS: cb673440 TRAP: 0380   Not tainted  (4.19.0-rc5-master+)
  MSR:  82009033   CR: 24022022  XER: 2002
  CFAR: c86fc238 IRQMASK: 0
  GPR00: c8703a38 cb6736c0 c9281900 
  GPR04:   f001 cb660080
  GPR08:    0220
  GPR12: 2200 c9e51400  0008
  GPR16:  c8c152e8 c8c152a8 
  GPR20: c9422fd8 c9412fd8 c9426040 0008
  GPR24:   c9168bc8 c9168c78
  GPR28: cb126410  c916a0b8 cb126400
  NIP [c8703a54] bus_add_device+0x84/0x1e0
  LR [c8703a38] bus_add_device+0x68/0x1e0
  Call Trace:
  [cb6736c0] [c8703a38] bus_add_device+0x68/0x1e0 (unreliable)
  [cb673740] [c8700194] device_add+0x454/0x7c0
  [cb673800] [c872e660] __register_one_node+0xb0/0x240
  [cb673860] [c839a6bc] __try_online_node+0x12c/0x180
  [cb673900] [c839b978] try_online_node+0x58/0x90
  [cb673930] [c80846d8] find_and_online_cpu_nid+0x158/0x190
  [cb673a10] [c80848a0] numa_update_cpu_topology+0x190/0x580
  [cb673c00] [c8d3f2e4] smp_cpus_done+0x94/0x108
  [cb673c70] [c8d5c00c] smp_init+0x174/0x19c
  [cb673d00] [c8d346b8] kernel_init_freeable+0x1e0/0x450
  [cb673dc0] [c80102e8] kernel_init+0x28/0x160
  [cb673e30] [c800b65c] ret_from_kernel_thread+0x5c/0x80
  Instruction dump:
  6000 

[PATCH 4.18 073/150] x86/paravirt: Fix some warning messages

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 571d0563c8881595f4ab027aef9ed1c55e3e7b7c ]

The first argument to WARN_ONCE() is a condition.

Fixes: 5800dc5c19f3 ("x86/paravirt: Fix spectre-v2 mitigations for paravirt 
guests")
Signed-off-by: Dan Carpenter 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Juergen Gross 
Cc: Peter Zijlstra 
Cc: Alok Kataria 
Cc: "H. Peter Anvin" 
Cc: virtualizat...@lists.linux-foundation.org
Cc: kernel-janit...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180919103553.GD9238@mwanda
Signed-off-by: Sasha Levin 
---
 arch/x86/kernel/paravirt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 930c88341e4e..1fbf38dde84c 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -90,7 +90,7 @@ unsigned paravirt_patch_call(void *insnbuf,
 
if (len < 5) {
 #ifdef CONFIG_RETPOLINE
-   WARN_ONCE("Failing to patch indirect CALL in %ps\n", (void 
*)addr);
+   WARN_ONCE(1, "Failing to patch indirect CALL in %ps\n", (void 
*)addr);
 #endif
return len; /* call too long for patch site */
}
@@ -110,7 +110,7 @@ unsigned paravirt_patch_jmp(void *insnbuf, const void 
*target,
 
if (len < 5) {
 #ifdef CONFIG_RETPOLINE
-   WARN_ONCE("Failing to patch indirect JMP in %ps\n", (void 
*)addr);
+   WARN_ONCE(1, "Failing to patch indirect JMP in %ps\n", (void 
*)addr);
 #endif
return len; /* call too long for patch site */
}
-- 
2.17.1





[PATCH 4.18 069/150] yam: fix a missing-check bug

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 0781168e23a2fc8dceb989f11fc5b39b3ccacc35 ]

In yam_ioctl(), the concrete ioctl command is firstly copied from the
user-space buffer 'ifr->ifr_data' to 'ioctl_cmd' and checked through the
following switch statement. If the command is not as expected, an error
code EINVAL is returned. In the following execution the buffer
'ifr->ifr_data' is copied again in the cases of the switch statement to
specific data structures according to what kind of ioctl command is
requested. However, after the second copy, no re-check is enforced on the
newly-copied command. Given that the buffer 'ifr->ifr_data' is in the user
space, a malicious user can race to change the command between the two
copies. This way, the attacker can inject inconsistent data and cause
undefined behavior.

This patch adds a re-check in each case of the switch statement if there is
a second copy in that case, to re-check whether the command obtained in the
second copy is the same as the one in the first copy. If not, an error code
EINVAL will be returned.

Signed-off-by: Wenwen Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/hamradio/yam.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 16ec7af6ab7b..ba9df430fca6 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -966,6 +966,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq 
*ifr, int cmd)
 sizeof(struct yamdrv_ioctl_mcs));
if (IS_ERR(ym))
return PTR_ERR(ym);
+   if (ym->cmd != SIOCYAMSMCS)
+   return -EINVAL;
if (ym->bitrate > YAM_MAXBITRATE) {
kfree(ym);
return -EINVAL;
@@ -981,6 +983,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq 
*ifr, int cmd)
if (copy_from_user(, ifr->ifr_data, sizeof(struct 
yamdrv_ioctl_cfg)))
 return -EFAULT;
 
+   if (yi.cmd != SIOCYAMSCFG)
+   return -EINVAL;
if ((yi.cfg.mask & YAM_IOBASE) && netif_running(dev))
return -EINVAL; /* Cannot change this parameter 
when up */
if ((yi.cfg.mask & YAM_IRQ) && netif_running(dev))
-- 
2.17.1





[PATCH 4.18 055/150] perf/ring_buffer: Prevent concurent ring buffer access

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit cd6fb677ce7e460c25bdd66f689734102ec7d642 ]

Some of the scheduling tracepoints allow the perf_tp_event
code to write to ring buffer under different cpu than the
code is running on.

This results in corrupted ring buffer data demonstrated in
following perf commands:

  # perf record -e 'sched:sched_switch,sched:sched_wakeup' perf bench sched 
messaging
  # Running 'sched/messaging' benchmark:
  # 20 sender and receiver processes per group
  # 10 groups == 400 processes run

   Total time: 0.383 [sec]
  [ perf record: Woken up 8 times to write data ]
  0x42b890 [0]: failed to process type: -1765585640
  [ perf record: Captured and wrote 4.825 MB perf.data (29669 samples) ]

  # perf report --stdio
  0x42b890 [0]: failed to process type: -1765585640

The reason for the corruption are some of the scheduling tracepoints,
that have __perf_task dfined and thus allow to store data to another
cpu ring buffer:

  sched_waking
  sched_wakeup
  sched_wakeup_new
  sched_stat_wait
  sched_stat_sleep
  sched_stat_iowait
  sched_stat_blocked

The perf_tp_event function first store samples for current cpu
related events defined for tracepoint:

hlist_for_each_entry_rcu(event, head, hlist_entry)
  perf_swevent_event(event, count, , regs);

And then iterates events of the 'task' and store the sample
for any task's event that passes tracepoint checks:

  ctx = rcu_dereference(task->perf_event_ctxp[perf_sw_context]);

  list_for_each_entry_rcu(event, >event_list, event_entry) {
if (event->attr.type != PERF_TYPE_TRACEPOINT)
  continue;
if (event->attr.config != entry->type)
  continue;

perf_swevent_event(event, count, , regs);
  }

Above code can race with same code running on another cpu,
ending up with 2 cpus trying to store under the same ring
buffer, which is specifically not allowed.

This patch prevents the problem, by allowing only events with the same
current cpu to receive the event.

NOTE: this requires the use of (per-task-)per-cpu buffers for this
feature to work; perf-record does this.

Signed-off-by: Jiri Olsa 
[peterz: small edits to Changelog]
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Andrew Vagin 
Cc: Arnaldo Carvalho de Melo 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Fixes: e6dab5ffab59 ("perf/trace: Add ability to set a target task for events")
Link: http://lkml.kernel.org/r/20180923161343.GB15054@krava
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/events/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index b1ed5e99d9c6..fc072b7f839d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8319,6 +8319,8 @@ void perf_tp_event(u16 event_type, u64 count, void 
*record, int entry_size,
goto unlock;
 
list_for_each_entry_rcu(event, >event_list, event_entry) {
+   if (event->cpu != smp_processor_id())
+   continue;
if (event->attr.type != PERF_TYPE_TRACEPOINT)
continue;
if (event->attr.config != entry->type)
-- 
2.17.1





[PATCH 4.18 071/150] mm/gup_benchmark: fix unsigned comparison to zero in __gup_benchmark_ioctl

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 51896864579d5a3349740847083f4db5c6487164 ]

get_user_pages_fast() will return negative value if no pages were pinned,
then be converted to a unsigned, which is compared to zero, giving the
wrong result.

Link: http://lkml.kernel.org/r/20180921095015.26088-1-yuehaib...@huawei.com
Fixes: 09e35a4a1ca8 ("mm/gup_benchmark: handle gup failures")
Signed-off-by: YueHaibing 
Reviewed-by: Andrew Morton 
Cc: Michael S. Tsirkin 
Signed-off-by: Andrew Morton 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 mm/gup_benchmark.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c
index 6a473709e9b6..7405c9d89d65 100644
--- a/mm/gup_benchmark.c
+++ b/mm/gup_benchmark.c
@@ -19,7 +19,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
struct gup_benchmark *gup)
 {
ktime_t start_time, end_time;
-   unsigned long i, nr, nr_pages, addr, next;
+   unsigned long i, nr_pages, addr, next;
+   int nr;
struct page **pages;
 
nr_pages = gup->size / PAGE_SIZE;
-- 
2.17.1





[PATCH 4.18 067/150] powerpc/numa: Skip onlining a offline node in kdump path

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit ac1788cc7da4ce54edcfd2e499afdb0a23d5c41d ]

With commit 2ea626306810 ("powerpc/topology: Get topology for shared
processors at boot"), kdump kernel on shared LPAR may crash.

The necessary conditions are
- Shared LPAR with at least 2 nodes having memory and CPUs.
- Memory requirement for kdump kernel must be met by the first N-1
  nodes where there are at least N nodes with memory and CPUs.

Example numactl of such a machine.
  $ numactl -H
  available: 5 nodes (0,2,5-7)
  node 0 cpus:
  node 0 size: 0 MB
  node 0 free: 0 MB
  node 2 cpus:
  node 2 size: 255 MB
  node 2 free: 189 MB
  node 5 cpus: 24 25 26 27 28 29 30 31
  node 5 size: 4095 MB
  node 5 free: 4024 MB
  node 6 cpus: 0 1 2 3 4 5 6 7 16 17 18 19 20 21 22 23
  node 6 size: 6353 MB
  node 6 free: 5998 MB
  node 7 cpus: 8 9 10 11 12 13 14 15 32 33 34 35 36 37 38 39
  node 7 size: 7640 MB
  node 7 free: 7164 MB
  node distances:
  node   0   2   5   6   7
0:  10  40  40  40  40
2:  40  10  40  40  40
5:  40  40  10  40  40
6:  40  40  40  10  20
7:  40  40  40  20  10

Steps to reproduce.
1. Load / start kdump service.
2. Trigger a kdump (for example : echo c > /proc/sysrq-trigger)

When booting a kdump kernel with 2048M:

  kexec: Starting switchover sequence.
  I'm in purgatory
  Using 1TB segments
  hash-mmu: Initializing hash mmu with SLB
  Linux version 4.19.0-rc5-master+ (srikar@linux-xxu6) (gcc version 4.8.5 (SUSE 
Linux)) #1 SMP Thu Sep 27 19:45:00 IST 2018
  Found initrd at 0xc9e7:0xcae554b4
  Using pSeries machine description
  -
  ppc64_pft_size= 0x1e
  phys_mem_size = 0x8800
  dcache_bsize  = 0x80
  icache_bsize  = 0x80
  cpu_features  = 0x00ff8f5d91a7
possible= 0xfbffcf5fb1a7
always  = 0x006f8b5c91a1
  cpu_user_features = 0xdc0065c2 0xef00
  mmu_features  = 0x7c006001
  firmware_features = 0x0007c45bfc57
  htab_hash_mask= 0x7f
  physical_start= 0x800
  -
  numa:   NODE_DATA [mem 0x87d5e300-0x87d67fff]
  numa: NODE_DATA(0) on node 6
  numa:   NODE_DATA [mem 0x87d54600-0x87d5e2ff]
  Top of RAM: 0x8800, Total RAM: 0x8800
  Memory hole size: 0MB
  Zone ranges:
DMA  [mem 0x-0x87ff]
DMA32empty
Normal   empty
  Movable zone start for each node
  Early memory node ranges
node   6: [mem 0x-0x87ff]
  Could not find start_pfn for node 0
  Initmem setup node 0 [mem 0x-0x]
  On node 0 totalpages: 0
  Initmem setup node 6 [mem 0x-0x87ff]
  On node 6 totalpages: 34816

  Unable to handle kernel paging request for data at address 0x0060
  Faulting instruction address: 0xc8703a54
  Oops: Kernel access of bad area, sig: 11 [#1]
  LE SMP NR_CPUS=2048 NUMA pSeries
  Modules linked in:
  CPU: 11 PID: 1 Comm: swapper/11 Not tainted 4.19.0-rc5-master+ #1
  NIP:  c8703a54 LR: c8703a38 CTR: 
  REGS: cb673440 TRAP: 0380   Not tainted  (4.19.0-rc5-master+)
  MSR:  82009033   CR: 24022022  XER: 2002
  CFAR: c86fc238 IRQMASK: 0
  GPR00: c8703a38 cb6736c0 c9281900 
  GPR04:   f001 cb660080
  GPR08:    0220
  GPR12: 2200 c9e51400  0008
  GPR16:  c8c152e8 c8c152a8 
  GPR20: c9422fd8 c9412fd8 c9426040 0008
  GPR24:   c9168bc8 c9168c78
  GPR28: cb126410  c916a0b8 cb126400
  NIP [c8703a54] bus_add_device+0x84/0x1e0
  LR [c8703a38] bus_add_device+0x68/0x1e0
  Call Trace:
  [cb6736c0] [c8703a38] bus_add_device+0x68/0x1e0 (unreliable)
  [cb673740] [c8700194] device_add+0x454/0x7c0
  [cb673800] [c872e660] __register_one_node+0xb0/0x240
  [cb673860] [c839a6bc] __try_online_node+0x12c/0x180
  [cb673900] [c839b978] try_online_node+0x58/0x90
  [cb673930] [c80846d8] find_and_online_cpu_nid+0x158/0x190
  [cb673a10] [c80848a0] numa_update_cpu_topology+0x190/0x580
  [cb673c00] [c8d3f2e4] smp_cpus_done+0x94/0x108
  [cb673c70] [c8d5c00c] smp_init+0x174/0x19c
  [cb673d00] [c8d346b8] kernel_init_freeable+0x1e0/0x450
  [cb673dc0] [c80102e8] kernel_init+0x28/0x160
  [cb673e30] [c800b65c] ret_from_kernel_thread+0x5c/0x80
  Instruction dump:
  6000 

[PATCH 4.18 073/150] x86/paravirt: Fix some warning messages

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 571d0563c8881595f4ab027aef9ed1c55e3e7b7c ]

The first argument to WARN_ONCE() is a condition.

Fixes: 5800dc5c19f3 ("x86/paravirt: Fix spectre-v2 mitigations for paravirt 
guests")
Signed-off-by: Dan Carpenter 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Juergen Gross 
Cc: Peter Zijlstra 
Cc: Alok Kataria 
Cc: "H. Peter Anvin" 
Cc: virtualizat...@lists.linux-foundation.org
Cc: kernel-janit...@vger.kernel.org
Link: https://lkml.kernel.org/r/20180919103553.GD9238@mwanda
Signed-off-by: Sasha Levin 
---
 arch/x86/kernel/paravirt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 930c88341e4e..1fbf38dde84c 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -90,7 +90,7 @@ unsigned paravirt_patch_call(void *insnbuf,
 
if (len < 5) {
 #ifdef CONFIG_RETPOLINE
-   WARN_ONCE("Failing to patch indirect CALL in %ps\n", (void 
*)addr);
+   WARN_ONCE(1, "Failing to patch indirect CALL in %ps\n", (void 
*)addr);
 #endif
return len; /* call too long for patch site */
}
@@ -110,7 +110,7 @@ unsigned paravirt_patch_jmp(void *insnbuf, const void 
*target,
 
if (len < 5) {
 #ifdef CONFIG_RETPOLINE
-   WARN_ONCE("Failing to patch indirect JMP in %ps\n", (void 
*)addr);
+   WARN_ONCE(1, "Failing to patch indirect JMP in %ps\n", (void 
*)addr);
 #endif
return len; /* call too long for patch site */
}
-- 
2.17.1





[PATCH 4.18 069/150] yam: fix a missing-check bug

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 0781168e23a2fc8dceb989f11fc5b39b3ccacc35 ]

In yam_ioctl(), the concrete ioctl command is firstly copied from the
user-space buffer 'ifr->ifr_data' to 'ioctl_cmd' and checked through the
following switch statement. If the command is not as expected, an error
code EINVAL is returned. In the following execution the buffer
'ifr->ifr_data' is copied again in the cases of the switch statement to
specific data structures according to what kind of ioctl command is
requested. However, after the second copy, no re-check is enforced on the
newly-copied command. Given that the buffer 'ifr->ifr_data' is in the user
space, a malicious user can race to change the command between the two
copies. This way, the attacker can inject inconsistent data and cause
undefined behavior.

This patch adds a re-check in each case of the switch statement if there is
a second copy in that case, to re-check whether the command obtained in the
second copy is the same as the one in the first copy. If not, an error code
EINVAL will be returned.

Signed-off-by: Wenwen Wang 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/hamradio/yam.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 16ec7af6ab7b..ba9df430fca6 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -966,6 +966,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq 
*ifr, int cmd)
 sizeof(struct yamdrv_ioctl_mcs));
if (IS_ERR(ym))
return PTR_ERR(ym);
+   if (ym->cmd != SIOCYAMSMCS)
+   return -EINVAL;
if (ym->bitrate > YAM_MAXBITRATE) {
kfree(ym);
return -EINVAL;
@@ -981,6 +983,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq 
*ifr, int cmd)
if (copy_from_user(, ifr->ifr_data, sizeof(struct 
yamdrv_ioctl_cfg)))
 return -EFAULT;
 
+   if (yi.cmd != SIOCYAMSCFG)
+   return -EINVAL;
if ((yi.cfg.mask & YAM_IOBASE) && netif_running(dev))
return -EINVAL; /* Cannot change this parameter 
when up */
if ((yi.cfg.mask & YAM_IRQ) && netif_running(dev))
-- 
2.17.1





[PATCH 4.18 055/150] perf/ring_buffer: Prevent concurent ring buffer access

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit cd6fb677ce7e460c25bdd66f689734102ec7d642 ]

Some of the scheduling tracepoints allow the perf_tp_event
code to write to ring buffer under different cpu than the
code is running on.

This results in corrupted ring buffer data demonstrated in
following perf commands:

  # perf record -e 'sched:sched_switch,sched:sched_wakeup' perf bench sched 
messaging
  # Running 'sched/messaging' benchmark:
  # 20 sender and receiver processes per group
  # 10 groups == 400 processes run

   Total time: 0.383 [sec]
  [ perf record: Woken up 8 times to write data ]
  0x42b890 [0]: failed to process type: -1765585640
  [ perf record: Captured and wrote 4.825 MB perf.data (29669 samples) ]

  # perf report --stdio
  0x42b890 [0]: failed to process type: -1765585640

The reason for the corruption are some of the scheduling tracepoints,
that have __perf_task dfined and thus allow to store data to another
cpu ring buffer:

  sched_waking
  sched_wakeup
  sched_wakeup_new
  sched_stat_wait
  sched_stat_sleep
  sched_stat_iowait
  sched_stat_blocked

The perf_tp_event function first store samples for current cpu
related events defined for tracepoint:

hlist_for_each_entry_rcu(event, head, hlist_entry)
  perf_swevent_event(event, count, , regs);

And then iterates events of the 'task' and store the sample
for any task's event that passes tracepoint checks:

  ctx = rcu_dereference(task->perf_event_ctxp[perf_sw_context]);

  list_for_each_entry_rcu(event, >event_list, event_entry) {
if (event->attr.type != PERF_TYPE_TRACEPOINT)
  continue;
if (event->attr.config != entry->type)
  continue;

perf_swevent_event(event, count, , regs);
  }

Above code can race with same code running on another cpu,
ending up with 2 cpus trying to store under the same ring
buffer, which is specifically not allowed.

This patch prevents the problem, by allowing only events with the same
current cpu to receive the event.

NOTE: this requires the use of (per-task-)per-cpu buffers for this
feature to work; perf-record does this.

Signed-off-by: Jiri Olsa 
[peterz: small edits to Changelog]
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Andrew Vagin 
Cc: Arnaldo Carvalho de Melo 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Fixes: e6dab5ffab59 ("perf/trace: Add ability to set a target task for events")
Link: http://lkml.kernel.org/r/20180923161343.GB15054@krava
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/events/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index b1ed5e99d9c6..fc072b7f839d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8319,6 +8319,8 @@ void perf_tp_event(u16 event_type, u64 count, void 
*record, int entry_size,
goto unlock;
 
list_for_each_entry_rcu(event, >event_list, event_entry) {
+   if (event->cpu != smp_processor_id())
+   continue;
if (event->attr.type != PERF_TYPE_TRACEPOINT)
continue;
if (event->attr.config != entry->type)
-- 
2.17.1





[PATCH 4.18 064/150] locking/ww_mutex: Fix runtime warning in the WW mutex selftest

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit e4a02ed2aaf447fa849e3254bfdb3b9b01e1e520 ]

If CONFIG_WW_MUTEX_SELFTEST=y is enabled, booting an image
in an arm64 virtual machine results in the following
traceback if 8 CPUs are enabled:

  DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current)
  WARNING: CPU: 2 PID: 537 at kernel/locking/mutex.c:1033 
__mutex_unlock_slowpath+0x1a8/0x2e0
  ...
  Call trace:
   __mutex_unlock_slowpath()
   ww_mutex_unlock()
   test_cycle_work()
   process_one_work()
   worker_thread()
   kthread()
   ret_from_fork()

If requesting b_mutex fails with -EDEADLK, the error variable
is reassigned to the return value from calling ww_mutex_lock
on a_mutex again. If this call fails, a_mutex is not locked.
It is, however, unconditionally unlocked subsequently, causing
the reported warning. Fix the problem by using two error variables.

With this change, the selftest still fails as follows:

  cyclic deadlock not resolved, ret[7/8] = -35

However, the traceback is gone.

Signed-off-by: Guenter Roeck 
Cc: Chris Wilson 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Will Deacon 
Fixes: d1b42b800e5d0 ("locking/ww_mutex: Add kselftests for resolving ww_mutex 
cyclic deadlocks")
Link: 
http://lkml.kernel.org/r/1538516929-9734-1-git-send-email-li...@roeck-us.net
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/locking/test-ww_mutex.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 0e4cd64ad2c0..654977862b06 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -260,7 +260,7 @@ static void test_cycle_work(struct work_struct *work)
 {
struct test_cycle *cycle = container_of(work, typeof(*cycle), work);
struct ww_acquire_ctx ctx;
-   int err;
+   int err, erra = 0;
 
ww_acquire_init(, _class);
ww_mutex_lock(>a_mutex, );
@@ -270,17 +270,19 @@ static void test_cycle_work(struct work_struct *work)
 
err = ww_mutex_lock(cycle->b_mutex, );
if (err == -EDEADLK) {
+   err = 0;
ww_mutex_unlock(>a_mutex);
ww_mutex_lock_slow(cycle->b_mutex, );
-   err = ww_mutex_lock(>a_mutex, );
+   erra = ww_mutex_lock(>a_mutex, );
}
 
if (!err)
ww_mutex_unlock(cycle->b_mutex);
-   ww_mutex_unlock(>a_mutex);
+   if (!erra)
+   ww_mutex_unlock(>a_mutex);
ww_acquire_fini();
 
-   cycle->result = err;
+   cycle->result = err ?: erra;
 }
 
 static int __test_cycle(unsigned int nthreads)
-- 
2.17.1





[PATCH 4.18 066/150] be2net: dont flip hw_features when VXLANs are added/deleted

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 2d52527e80c2dc0c5f43f50adf183781262ec565 ]

the be2net implementation of .ndo_tunnel_{add,del}() changes the value of
NETIF_F_GSO_UDP_TUNNEL bit in 'features' and 'hw_features', but it forgets
to call netdev_features_change(). Moreover, ethtool setting for that bit
can potentially be reverted after a tunnel is added or removed.

GSO already does software segmentation when 'hw_enc_features' is 0, even
if VXLAN offload is turned on. In addition, commit 096de2f83ebc ("benet:
stricter vxlan offloading check in be_features_check") avoids hardware
segmentation of non-VXLAN tunneled packets, or VXLAN packets having wrong
destination port. So, it's safe to avoid flipping the above feature on
addition/deletion of VXLAN tunnels.

Fixes: 630f4b70567f ("be2net: Export tunnel offloads only when a VxLAN tunnel 
is created")
Signed-off-by: Davide Caratti 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 8f755009ff38..c8445a4135a9 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3915,8 +3915,6 @@ static int be_enable_vxlan_offloads(struct be_adapter 
*adapter)
netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
   NETIF_F_TSO | NETIF_F_TSO6 |
   NETIF_F_GSO_UDP_TUNNEL;
-   netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
-   netdev->features |= NETIF_F_GSO_UDP_TUNNEL;
 
dev_info(dev, "Enabled VxLAN offloads for UDP port %d\n",
 be16_to_cpu(port));
@@ -3938,8 +3936,6 @@ static void be_disable_vxlan_offloads(struct be_adapter 
*adapter)
adapter->vxlan_port = 0;
 
netdev->hw_enc_features = 0;
-   netdev->hw_features &= ~(NETIF_F_GSO_UDP_TUNNEL);
-   netdev->features &= ~(NETIF_F_GSO_UDP_TUNNEL);
 }
 
 static void be_calculate_vf_res(struct be_adapter *adapter, u16 num_vfs,
@@ -5232,6 +5228,7 @@ static void be_netdev_init(struct net_device *netdev)
struct be_adapter *adapter = netdev_priv(netdev);
 
netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 |
+   NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
NETIF_F_HW_VLAN_CTAG_TX;
if ((be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS))
-- 
2.17.1





[PATCH 4.18 065/150] drm/amd/display: Signal hw_done() after waiting for flip_done()

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 987bf116445db5d63a5c2ed94c4479687d9c9973 ]

In amdgpu_dm_commit_tail(), wait until flip_done() is signaled before
we signal hw_done().

[Why]

This is to temporarily address a paging error that occurs when a
nonblocking commit contends with another commit, particularly in a
mirrored display configuration where at least 2 CRTCs are updated.
The error occurs in drm_atomic_helper_wait_for_flip_done(), when we
attempt to access the contents of new_crtc_state->commit.

Here's the sequence for a mirrored 2 display setup (irrelevant steps
left out for clarity):

**THREAD 1**| **THREAD 2**
|
Initialize atomic state for flip|
|
Queue worker|
   ...

| Do work for flip
|
| Signal hw_done() on CRTC 1
| Signal hw_done() on CRTC 2
|
| Wait for flip_done() on CRTC 1

< **PREEMPTED BY THREAD 1**

Initialize atomic state for cursor  |
update (1)  |
|
Do cursor update work on both CRTCs |
|
Clear atomic state (2)  |
**DONE**|
   ...
|
| Wait for flip_done() on CRTC 2
| *ERROR*
|

The issue starts with (1). When the atomic state is initialized, the
current CRTC states are duplicated to be the new_crtc_states, and
referenced to be the old_crtc_states. (The new_crtc_states are to be
filled with update data.)

Some things to note:

* Due to the mirrored configuration, the cursor updates on both CRTCs.

* At this point, the pflip IRQ has already been handled, and flip_done
  signaled on all CRTCs. The cursor commit can therefore continue.

* The old_crtc_states used by the cursor update are the **same states**
  as the new_crtc_states used by the flip worker.

At (2), the old_crtc_state is freed (*), and the cursor commit
completes. We then context switch back to the flip worker, where we
attempt to access the new_crtc_state->commit object. This is
problematic, as this state has already been freed.

(*) Technically, 'state->crtcs[i].state' is freed, which was made to
reference old_crtc_state in drm_atomic_helper_swap_state()

[How]

By moving hw_done() after wait_for_flip_done(), we're guaranteed that
the new_crtc_state (from the flip worker's perspective) still exists.
This is because any other commit will be blocked, waiting for the
hw_done() signal.

Note that both the i915 and imx drivers have this sequence flipped
already, masking this problem.

Signed-off-by: Shirish S 
Signed-off-by: Leo Li 
Reviewed-by: Harry Wentland 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e484d0a94bdc..5b9cc3aeaa55 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4494,12 +4494,18 @@ static void amdgpu_dm_atomic_commit_tail(struct 
drm_atomic_state *state)
}
spin_unlock_irqrestore(>ddev->event_lock, flags);
 
-   /* Signal HW programming completion */
-   drm_atomic_helper_commit_hw_done(state);
 
if (wait_for_vblank)
drm_atomic_helper_wait_for_flip_done(dev, state);
 
+   /*
+* FIXME:
+* Delay hw_done() until flip_done() is signaled. This is to block
+* another commit from freeing the CRTC state while we're still
+* waiting on flip_done.
+*/
+   drm_atomic_helper_commit_hw_done(state);
+
drm_atomic_helper_cleanup_planes(dev, state);
 
/* Finally, drop a runtime PM reference for each newly disabled CRTC,
-- 
2.17.1





[PATCH 4.18 064/150] locking/ww_mutex: Fix runtime warning in the WW mutex selftest

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit e4a02ed2aaf447fa849e3254bfdb3b9b01e1e520 ]

If CONFIG_WW_MUTEX_SELFTEST=y is enabled, booting an image
in an arm64 virtual machine results in the following
traceback if 8 CPUs are enabled:

  DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current)
  WARNING: CPU: 2 PID: 537 at kernel/locking/mutex.c:1033 
__mutex_unlock_slowpath+0x1a8/0x2e0
  ...
  Call trace:
   __mutex_unlock_slowpath()
   ww_mutex_unlock()
   test_cycle_work()
   process_one_work()
   worker_thread()
   kthread()
   ret_from_fork()

If requesting b_mutex fails with -EDEADLK, the error variable
is reassigned to the return value from calling ww_mutex_lock
on a_mutex again. If this call fails, a_mutex is not locked.
It is, however, unconditionally unlocked subsequently, causing
the reported warning. Fix the problem by using two error variables.

With this change, the selftest still fails as follows:

  cyclic deadlock not resolved, ret[7/8] = -35

However, the traceback is gone.

Signed-off-by: Guenter Roeck 
Cc: Chris Wilson 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Will Deacon 
Fixes: d1b42b800e5d0 ("locking/ww_mutex: Add kselftests for resolving ww_mutex 
cyclic deadlocks")
Link: 
http://lkml.kernel.org/r/1538516929-9734-1-git-send-email-li...@roeck-us.net
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/locking/test-ww_mutex.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 0e4cd64ad2c0..654977862b06 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -260,7 +260,7 @@ static void test_cycle_work(struct work_struct *work)
 {
struct test_cycle *cycle = container_of(work, typeof(*cycle), work);
struct ww_acquire_ctx ctx;
-   int err;
+   int err, erra = 0;
 
ww_acquire_init(, _class);
ww_mutex_lock(>a_mutex, );
@@ -270,17 +270,19 @@ static void test_cycle_work(struct work_struct *work)
 
err = ww_mutex_lock(cycle->b_mutex, );
if (err == -EDEADLK) {
+   err = 0;
ww_mutex_unlock(>a_mutex);
ww_mutex_lock_slow(cycle->b_mutex, );
-   err = ww_mutex_lock(>a_mutex, );
+   erra = ww_mutex_lock(>a_mutex, );
}
 
if (!err)
ww_mutex_unlock(cycle->b_mutex);
-   ww_mutex_unlock(>a_mutex);
+   if (!erra)
+   ww_mutex_unlock(>a_mutex);
ww_acquire_fini();
 
-   cycle->result = err;
+   cycle->result = err ?: erra;
 }
 
 static int __test_cycle(unsigned int nthreads)
-- 
2.17.1





[PATCH 4.18 066/150] be2net: dont flip hw_features when VXLANs are added/deleted

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 2d52527e80c2dc0c5f43f50adf183781262ec565 ]

the be2net implementation of .ndo_tunnel_{add,del}() changes the value of
NETIF_F_GSO_UDP_TUNNEL bit in 'features' and 'hw_features', but it forgets
to call netdev_features_change(). Moreover, ethtool setting for that bit
can potentially be reverted after a tunnel is added or removed.

GSO already does software segmentation when 'hw_enc_features' is 0, even
if VXLAN offload is turned on. In addition, commit 096de2f83ebc ("benet:
stricter vxlan offloading check in be_features_check") avoids hardware
segmentation of non-VXLAN tunneled packets, or VXLAN packets having wrong
destination port. So, it's safe to avoid flipping the above feature on
addition/deletion of VXLAN tunnels.

Fixes: 630f4b70567f ("be2net: Export tunnel offloads only when a VxLAN tunnel 
is created")
Signed-off-by: Davide Caratti 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/emulex/benet/be_main.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c 
b/drivers/net/ethernet/emulex/benet/be_main.c
index 8f755009ff38..c8445a4135a9 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -3915,8 +3915,6 @@ static int be_enable_vxlan_offloads(struct be_adapter 
*adapter)
netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
   NETIF_F_TSO | NETIF_F_TSO6 |
   NETIF_F_GSO_UDP_TUNNEL;
-   netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
-   netdev->features |= NETIF_F_GSO_UDP_TUNNEL;
 
dev_info(dev, "Enabled VxLAN offloads for UDP port %d\n",
 be16_to_cpu(port));
@@ -3938,8 +3936,6 @@ static void be_disable_vxlan_offloads(struct be_adapter 
*adapter)
adapter->vxlan_port = 0;
 
netdev->hw_enc_features = 0;
-   netdev->hw_features &= ~(NETIF_F_GSO_UDP_TUNNEL);
-   netdev->features &= ~(NETIF_F_GSO_UDP_TUNNEL);
 }
 
 static void be_calculate_vf_res(struct be_adapter *adapter, u16 num_vfs,
@@ -5232,6 +5228,7 @@ static void be_netdev_init(struct net_device *netdev)
struct be_adapter *adapter = netdev_priv(netdev);
 
netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 |
+   NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
NETIF_F_HW_VLAN_CTAG_TX;
if ((be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS))
-- 
2.17.1





[PATCH 4.18 065/150] drm/amd/display: Signal hw_done() after waiting for flip_done()

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 987bf116445db5d63a5c2ed94c4479687d9c9973 ]

In amdgpu_dm_commit_tail(), wait until flip_done() is signaled before
we signal hw_done().

[Why]

This is to temporarily address a paging error that occurs when a
nonblocking commit contends with another commit, particularly in a
mirrored display configuration where at least 2 CRTCs are updated.
The error occurs in drm_atomic_helper_wait_for_flip_done(), when we
attempt to access the contents of new_crtc_state->commit.

Here's the sequence for a mirrored 2 display setup (irrelevant steps
left out for clarity):

**THREAD 1**| **THREAD 2**
|
Initialize atomic state for flip|
|
Queue worker|
   ...

| Do work for flip
|
| Signal hw_done() on CRTC 1
| Signal hw_done() on CRTC 2
|
| Wait for flip_done() on CRTC 1

< **PREEMPTED BY THREAD 1**

Initialize atomic state for cursor  |
update (1)  |
|
Do cursor update work on both CRTCs |
|
Clear atomic state (2)  |
**DONE**|
   ...
|
| Wait for flip_done() on CRTC 2
| *ERROR*
|

The issue starts with (1). When the atomic state is initialized, the
current CRTC states are duplicated to be the new_crtc_states, and
referenced to be the old_crtc_states. (The new_crtc_states are to be
filled with update data.)

Some things to note:

* Due to the mirrored configuration, the cursor updates on both CRTCs.

* At this point, the pflip IRQ has already been handled, and flip_done
  signaled on all CRTCs. The cursor commit can therefore continue.

* The old_crtc_states used by the cursor update are the **same states**
  as the new_crtc_states used by the flip worker.

At (2), the old_crtc_state is freed (*), and the cursor commit
completes. We then context switch back to the flip worker, where we
attempt to access the new_crtc_state->commit object. This is
problematic, as this state has already been freed.

(*) Technically, 'state->crtcs[i].state' is freed, which was made to
reference old_crtc_state in drm_atomic_helper_swap_state()

[How]

By moving hw_done() after wait_for_flip_done(), we're guaranteed that
the new_crtc_state (from the flip worker's perspective) still exists.
This is because any other commit will be blocked, waiting for the
hw_done() signal.

Note that both the i915 and imx drivers have this sequence flipped
already, masking this problem.

Signed-off-by: Shirish S 
Signed-off-by: Leo Li 
Reviewed-by: Harry Wentland 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e484d0a94bdc..5b9cc3aeaa55 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4494,12 +4494,18 @@ static void amdgpu_dm_atomic_commit_tail(struct 
drm_atomic_state *state)
}
spin_unlock_irqrestore(>ddev->event_lock, flags);
 
-   /* Signal HW programming completion */
-   drm_atomic_helper_commit_hw_done(state);
 
if (wait_for_vblank)
drm_atomic_helper_wait_for_flip_done(dev, state);
 
+   /*
+* FIXME:
+* Delay hw_done() until flip_done() is signaled. This is to block
+* another commit from freeing the CRTC state while we're still
+* waiting on flip_done.
+*/
+   drm_atomic_helper_commit_hw_done(state);
+
drm_atomic_helper_cleanup_planes(dev, state);
 
/* Finally, drop a runtime PM reference for each newly disabled CRTC,
-- 
2.17.1





[PATCH 4.18 052/150] KVM: nVMX: Fix emulation of VM_ENTRY_LOAD_BNDCFGS

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 62cf9bd8118c4009f02c477ef78c723f49e53e16 ]

L2 IA32_BNDCFGS should be updated with vmcs12->guest_bndcfgs only
when VM_ENTRY_LOAD_BNDCFGS is specified in vmcs12->vm_entry_controls.

Otherwise, L2 IA32_BNDCFGS should be set to vmcs01->guest_bndcfgs which
is L1 IA32_BNDCFGS.

Reviewed-by: Nikita Leshchenko 
Reviewed-by: Darren Kenny 
Signed-off-by: Liran Alon 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Sasha Levin 
---
 arch/x86/kvm/vmx.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2e23fce5eb1f..9efe130ea2e6 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -819,6 +819,7 @@ struct nested_vmx {
 
/* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */
u64 vmcs01_debugctl;
+   u64 vmcs01_guest_bndcfgs;
 
u16 vpid02;
u16 last_vpid;
@@ -11567,8 +11568,13 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, 
struct vmcs12 *vmcs12)
 
set_cr4_guest_host_mask(vmx);
 
-   if (kvm_mpx_supported())
-   vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs);
+   if (kvm_mpx_supported()) {
+   if (vmx->nested.nested_run_pending &&
+   (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS))
+   vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs);
+   else
+   vmcs_write64(GUEST_BNDCFGS, 
vmx->nested.vmcs01_guest_bndcfgs);
+   }
 
if (enable_vpid) {
if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02)
@@ -12082,6 +12088,9 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu 
*vcpu)
 
if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
+   if (kvm_mpx_supported() &&
+   !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS))
+   vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS);
 
vmx_switch_vmcs(vcpu, >nested.vmcs02);
vmx_segment_cache_clear(vmx);
-- 
2.17.1





[PATCH 4.18 026/150] mac80211_hwsim: do not omit multicast announce of first added radio

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 28ef8b49a338dc1844e86b7954cfffc7dfa2660a ]

The allocation of hwsim radio identifiers uses a post-increment from 0,
so the first radio has idx 0. This idx is explicitly excluded from
multicast announcements ever since, but it is unclear why.

Drop that idx check and announce the first radio as well. This makes
userspace happy if it relies on these events.

Signed-off-by: Martin Willi 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/mac80211_hwsim.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index cfd0c58aa02a..58dd217811c8 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2811,8 +2811,7 @@ static int mac80211_hwsim_new_radio(struct genl_info 
*info,
hwsim_radios_generation++;
spin_unlock_bh(_radio_lock);
 
-   if (idx > 0)
-   hwsim_mcast_new_radio(idx, info, param);
+   hwsim_mcast_new_radio(idx, info, param);
 
return idx;
 
-- 
2.17.1





[PATCH 4.18 063/150] Revert "serial: 8250_dw: Fix runtime PM handling"

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit beeeac43b6fae5f5eaf707b6fcc2bf1e09deb785 ]

This reverts commit d76c74387e1c978b6c5524a146ab0f3f72206f98.

While commit d76c74387e1c ("serial: 8250_dw: Fix runtime PM handling")
fixes runtime PM handling when using kgdb, it introduces a traceback for
everyone else.

BUG: sleeping function called from invalid context at

/mnt/host/source/src/third_party/kernel/next/drivers/base/power/runtime.c:1034
in_atomic(): 1, irqs_disabled(): 1, pid: 1, name: swapper/0
7 locks held by swapper/0/1:
 #0: 5ec5bc72 (>mutex){}, at: __driver_attach+0xb5/0x12b
 #1: 5d5fa9e5 (>mutex){}, at: __device_attach+0x3e/0x15b
 #2: 47e93286 (serial_mutex){+.+.}, at: 
serial8250_register_8250_port+0x51/0x8bb
 #3: 3b328f07 (port_mutex){+.+.}, at: uart_add_one_port+0xab/0x8b0
 #4: fa313d4d (>mutex){+.+.}, at: uart_add_one_port+0xcc/0x8b0
 #5: 090983ca (console_lock){+.+.}, at: vprintk_emit+0xdb/0x217
 #6: c743e583 (console_owner){-...}, at: console_unlock+0x211/0x60f
irq event stamp: 735222
__down_trylock_console_sem+0x4a/0x84
console_unlock+0x338/0x60f
__do_softirq+0x4a4/0x50d
irq_exit+0x64/0xe2
CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc5 #6
Hardware name: Google Caroline/Caroline, BIOS Google_Caroline.7820.286.0 
03/15/2017
Call Trace:
 dump_stack+0x7d/0xbd
 ___might_sleep+0x238/0x259
 __pm_runtime_resume+0x4e/0xa4
 ? serial8250_rpm_get+0x2e/0x44
 serial8250_console_write+0x44/0x301
 ? lock_acquire+0x1b8/0x1fa
 console_unlock+0x577/0x60f
 vprintk_emit+0x1f0/0x217
 printk+0x52/0x6e
 register_console+0x43b/0x524
 uart_add_one_port+0x672/0x8b0
 ? set_io_from_upio+0x150/0x162
 serial8250_register_8250_port+0x825/0x8bb
 dw8250_probe+0x80c/0x8b0
 ? dw8250_serial_inq+0x8e/0x8e
 ? dw8250_check_lcr+0x108/0x108
 ? dw8250_runtime_resume+0x5b/0x5b
 ? dw8250_serial_outq+0xa1/0xa1
 ? dw8250_remove+0x115/0x115
 platform_drv_probe+0x76/0xc5
 really_probe+0x1f1/0x3ee
 ? driver_allows_async_probing+0x5d/0x5d
 driver_probe_device+0xd6/0x112
 ? driver_allows_async_probing+0x5d/0x5d
 bus_for_each_drv+0xbe/0xe5
 __device_attach+0xdd/0x15b
 bus_probe_device+0x5a/0x10b
 device_add+0x501/0x894
 ? _raw_write_unlock+0x27/0x3a
 platform_device_add+0x224/0x2b7
 mfd_add_device+0x718/0x75b
 ? __kmalloc+0x144/0x16a
 ? mfd_add_devices+0x38/0xdb
 mfd_add_devices+0x9b/0xdb
 intel_lpss_probe+0x7d4/0x8ee
 intel_lpss_pci_probe+0xac/0xd4
 pci_device_probe+0x101/0x18e
...

Revert the offending patch until a more comprehensive solution
is available.

Cc: Tony Lindgren 
Cc: Andy Shevchenko 
Cc: Phil Edworthy 
Fixes: d76c74387e1c ("serial: 8250_dw: Fix runtime PM handling")
Signed-off-by: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/tty/serial/8250/8250_dw.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index af842000188c..a25f6ea5c784 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -576,10 +576,6 @@ static int dw8250_probe(struct platform_device *pdev)
if (!data->skip_autocfg)
dw8250_setup_port(p);
 
-#ifdef CONFIG_PM
-   uart.capabilities |= UART_CAP_RPM;
-#endif
-
/* If we have a valid fifosize, try hooking up DMA */
if (p->fifosize) {
data->dma.rxconf.src_maxburst = p->fifosize / 4;
-- 
2.17.1





[PATCH 4.18 054/150] perf/x86/intel/uncore: Use boot_cpu_data.phys_proc_id instead of hardcorded physical package ID 0

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 6265adb9726098b7f4f7ca70bc51992b25fdd9d6 ]

Physical package id 0 doesn't always exist, we should use
boot_cpu_data.phys_proc_id here.

Signed-off-by: Masayoshi Mizuma 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: H. Peter Anvin 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Masayoshi Mizuma 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: http://lkml.kernel.org/r/20180910144750.6782-1-msys.miz...@gmail.com
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/uncore_snbep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c 
b/arch/x86/events/intel/uncore_snbep.c
index 51d7c117e3c7..53b981dcdb42 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -3061,7 +3061,7 @@ static struct event_constraint 
bdx_uncore_pcu_constraints[] = {
 
 void bdx_uncore_cpu_init(void)
 {
-   int pkg = topology_phys_to_logical_pkg(0);
+   int pkg = topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id);
 
if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
-- 
2.17.1





[PATCH 4.18 028/150] pxa168fb: prepare the clock

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit d85536cde91fcfed6fb8d983783bd2b92c843939 ]

Add missing prepare/unprepare operations for fbi->clk,
this fixes following kernel warning:

  [ cut here ]
  WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:874 clk_core_enable+0x2c/0x1b0
  Enabling unprepared disp0_clk
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.0-rc8-00032-g02b43ddd4f21-dirty 
#25
  Hardware name: Marvell MMP2 (Device Tree Support)
  [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
  [] (show_stack) from [] (__warn+0xd8/0xf0)
  [] (__warn) from [] (warn_slowpath_fmt+0x44/0x6c)
  [] (warn_slowpath_fmt) from [] 
(clk_core_enable+0x2c/0x1b0)
  [] (clk_core_enable) from [] 
(clk_core_enable_lock+0x18/0x2c)
  [] (clk_core_enable_lock) from [] 
(pxa168fb_probe+0x464/0x6ac)
  [] (pxa168fb_probe) from [] (platform_drv_probe+0x48/0x94)
  [] (platform_drv_probe) from [] 
(driver_probe_device+0x328/0x470)
  [] (driver_probe_device) from [] 
(__driver_attach+0xb0/0x124)
  [] (__driver_attach) from [] (bus_for_each_dev+0x64/0xa0)
  [] (bus_for_each_dev) from [] (bus_add_driver+0x1b8/0x230)
  [] (bus_add_driver) from [] (driver_register+0xac/0xf0)
  [] (driver_register) from [] (do_one_initcall+0xb8/0x1f0)
  [] (do_one_initcall) from [] 
(kernel_init_freeable+0x294/0x2e0)
  [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c)
  [] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
  Exception stack(0xd008bfb0 to 0xd008bff8)
  bfa0:    
  bfc0:        
  bfe0:     0013 
  ---[ end trace c0af40f9e2ed7cb4 ]---

Signed-off-by: Lubomir Rintel 
[b.zolnierkie: enhance patch description a bit]
Signed-off-by: Bartlomiej Zolnierkiewicz 
Signed-off-by: Sasha Levin 
---
 drivers/video/fbdev/pxa168fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c
index def3a501acd6..d059d04c63ac 100644
--- a/drivers/video/fbdev/pxa168fb.c
+++ b/drivers/video/fbdev/pxa168fb.c
@@ -712,7 +712,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
/*
 * enable controller clock
 */
-   clk_enable(fbi->clk);
+   clk_prepare_enable(fbi->clk);
 
pxa168fb_set_par(info);
 
@@ -767,7 +767,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
 failed_free_cmap:
fb_dealloc_cmap(>cmap);
 failed_free_clk:
-   clk_disable(fbi->clk);
+   clk_disable_unprepare(fbi->clk);
 failed_free_fbmem:
dma_free_coherent(fbi->dev, info->fix.smem_len,
info->screen_base, fbi->fb_start_dma);
@@ -807,7 +807,7 @@ static int pxa168fb_remove(struct platform_device *pdev)
dma_free_wc(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
info->screen_base, info->fix.smem_start);
 
-   clk_disable(fbi->clk);
+   clk_disable_unprepare(fbi->clk);
 
framebuffer_release(info);
 
-- 
2.17.1





[PATCH 4.18 021/150] soc: fsl: qbman: qman: avoid allocating from non existing gen_pool

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 64e9e22e68512da8df3c9a7430f07621e48db3c2 ]

If the qman driver didn't probe, calling qman_alloc_fqid_range,
qman_alloc_pool_range or qman_alloc_cgrid_range (as done in dpaa_eth) will
pass a NULL pointer to gen_pool_alloc, leading to a NULL pointer
dereference.

Signed-off-by: Alexandre Belloni 
Reviewed-by: Roy Pledge 
Signed-off-by: Li Yang 
(cherry picked from commit f72487a2788aa70c3aee1d0ebd5470de9bac953a)
Signed-off-by: Olof Johansson 
Signed-off-by: Sasha Levin 
---
 drivers/soc/fsl/qbman/qman.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index ecb22749df0b..8cc015183043 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2729,6 +2729,9 @@ static int qman_alloc_range(struct gen_pool *p, u32 
*result, u32 cnt)
 {
unsigned long addr;
 
+   if (!p)
+   return -ENODEV;
+
addr = gen_pool_alloc(p, cnt);
if (!addr)
return -ENOMEM;
-- 
2.17.1





[PATCH 4.18 030/150] qed: Fix mask parameter in qed_vf_prep_tunn_req_tlv

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit db803f36e56f23b5a2266807e190d1dc11554d54 ]

Clang complains when one enumerated type is implicitly converted to
another.

drivers/net/ethernet/qlogic/qed/qed_vf.c:686:6: warning: implicit
conversion from enumeration type 'enum qed_tunn_mode' to different
enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
 QED_MODE_L2GENEVE_TUNN,
 ^~

Update mask's parameter to expect qed_tunn_mode, which is what was
intended.

Link: https://github.com/ClangBuiltLinux/linux/issues/125
Signed-off-by: Nathan Chancellor 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/qlogic/qed/qed_vf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c 
b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index be6ddde1a104..ac3f54bbe9b9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -572,7 +572,7 @@ free_p_iov:
 static void
 __qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
   struct qed_tunn_update_type *p_src,
-  enum qed_tunn_clss mask, u8 *p_cls)
+  enum qed_tunn_mode mask, u8 *p_cls)
 {
if (p_src->b_update_mode) {
p_req->tun_mode_update_mask |= BIT(mask);
@@ -587,7 +587,7 @@ __qed_vf_prep_tunn_req_tlv(struct 
vfpf_update_tunn_param_tlv *p_req,
 static void
 qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
 struct qed_tunn_update_type *p_src,
-enum qed_tunn_clss mask,
+enum qed_tunn_mode mask,
 u8 *p_cls, struct qed_tunn_update_udp_port *p_port,
 u8 *p_update_port, u16 *p_udp_port)
 {
-- 
2.17.1





[PATCH 4.18 029/150] qed: Avoid implicit enum conversion in qed_set_tunn_cls_info

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a898fba32229efd5e6b6154f83fa86a7145156b9 ]

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:163:25: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->vxlan.tun_cls = type;
 ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:165:26: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->l2_gre.tun_cls = type;
  ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:167:26: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->ip_gre.tun_cls = type;
  ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:169:29: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->l2_geneve.tun_cls = type;
 ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:171:29: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->ip_geneve.tun_cls = type;
 ~ ^~~~
5 warnings generated.

Avoid this by changing type to an int.

Link: https://github.com/ClangBuiltLinux/linux/issues/125
Signed-off-by: Nathan Chancellor 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/qlogic/qed/qed_sp_commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c 
b/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
index 8de644b4721e..77b6248ad3b9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
@@ -154,7 +154,7 @@ qed_set_pf_update_tunn_mode(struct qed_tunnel_info *p_tun,
 static void qed_set_tunn_cls_info(struct qed_tunnel_info *p_tun,
  struct qed_tunnel_info *p_src)
 {
-   enum tunnel_clss type;
+   int type;
 
p_tun->b_update_rx_cls = p_src->b_update_rx_cls;
p_tun->b_update_tx_cls = p_src->b_update_tx_cls;
-- 
2.17.1





[PATCH 4.18 026/150] mac80211_hwsim: do not omit multicast announce of first added radio

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 28ef8b49a338dc1844e86b7954cfffc7dfa2660a ]

The allocation of hwsim radio identifiers uses a post-increment from 0,
so the first radio has idx 0. This idx is explicitly excluded from
multicast announcements ever since, but it is unclear why.

Drop that idx check and announce the first radio as well. This makes
userspace happy if it relies on these events.

Signed-off-by: Martin Willi 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/mac80211_hwsim.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index cfd0c58aa02a..58dd217811c8 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2811,8 +2811,7 @@ static int mac80211_hwsim_new_radio(struct genl_info 
*info,
hwsim_radios_generation++;
spin_unlock_bh(_radio_lock);
 
-   if (idx > 0)
-   hwsim_mcast_new_radio(idx, info, param);
+   hwsim_mcast_new_radio(idx, info, param);
 
return idx;
 
-- 
2.17.1





[PATCH 4.18 063/150] Revert "serial: 8250_dw: Fix runtime PM handling"

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit beeeac43b6fae5f5eaf707b6fcc2bf1e09deb785 ]

This reverts commit d76c74387e1c978b6c5524a146ab0f3f72206f98.

While commit d76c74387e1c ("serial: 8250_dw: Fix runtime PM handling")
fixes runtime PM handling when using kgdb, it introduces a traceback for
everyone else.

BUG: sleeping function called from invalid context at

/mnt/host/source/src/third_party/kernel/next/drivers/base/power/runtime.c:1034
in_atomic(): 1, irqs_disabled(): 1, pid: 1, name: swapper/0
7 locks held by swapper/0/1:
 #0: 5ec5bc72 (>mutex){}, at: __driver_attach+0xb5/0x12b
 #1: 5d5fa9e5 (>mutex){}, at: __device_attach+0x3e/0x15b
 #2: 47e93286 (serial_mutex){+.+.}, at: 
serial8250_register_8250_port+0x51/0x8bb
 #3: 3b328f07 (port_mutex){+.+.}, at: uart_add_one_port+0xab/0x8b0
 #4: fa313d4d (>mutex){+.+.}, at: uart_add_one_port+0xcc/0x8b0
 #5: 090983ca (console_lock){+.+.}, at: vprintk_emit+0xdb/0x217
 #6: c743e583 (console_owner){-...}, at: console_unlock+0x211/0x60f
irq event stamp: 735222
__down_trylock_console_sem+0x4a/0x84
console_unlock+0x338/0x60f
__do_softirq+0x4a4/0x50d
irq_exit+0x64/0xe2
CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc5 #6
Hardware name: Google Caroline/Caroline, BIOS Google_Caroline.7820.286.0 
03/15/2017
Call Trace:
 dump_stack+0x7d/0xbd
 ___might_sleep+0x238/0x259
 __pm_runtime_resume+0x4e/0xa4
 ? serial8250_rpm_get+0x2e/0x44
 serial8250_console_write+0x44/0x301
 ? lock_acquire+0x1b8/0x1fa
 console_unlock+0x577/0x60f
 vprintk_emit+0x1f0/0x217
 printk+0x52/0x6e
 register_console+0x43b/0x524
 uart_add_one_port+0x672/0x8b0
 ? set_io_from_upio+0x150/0x162
 serial8250_register_8250_port+0x825/0x8bb
 dw8250_probe+0x80c/0x8b0
 ? dw8250_serial_inq+0x8e/0x8e
 ? dw8250_check_lcr+0x108/0x108
 ? dw8250_runtime_resume+0x5b/0x5b
 ? dw8250_serial_outq+0xa1/0xa1
 ? dw8250_remove+0x115/0x115
 platform_drv_probe+0x76/0xc5
 really_probe+0x1f1/0x3ee
 ? driver_allows_async_probing+0x5d/0x5d
 driver_probe_device+0xd6/0x112
 ? driver_allows_async_probing+0x5d/0x5d
 bus_for_each_drv+0xbe/0xe5
 __device_attach+0xdd/0x15b
 bus_probe_device+0x5a/0x10b
 device_add+0x501/0x894
 ? _raw_write_unlock+0x27/0x3a
 platform_device_add+0x224/0x2b7
 mfd_add_device+0x718/0x75b
 ? __kmalloc+0x144/0x16a
 ? mfd_add_devices+0x38/0xdb
 mfd_add_devices+0x9b/0xdb
 intel_lpss_probe+0x7d4/0x8ee
 intel_lpss_pci_probe+0xac/0xd4
 pci_device_probe+0x101/0x18e
...

Revert the offending patch until a more comprehensive solution
is available.

Cc: Tony Lindgren 
Cc: Andy Shevchenko 
Cc: Phil Edworthy 
Fixes: d76c74387e1c ("serial: 8250_dw: Fix runtime PM handling")
Signed-off-by: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/tty/serial/8250/8250_dw.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c 
b/drivers/tty/serial/8250/8250_dw.c
index af842000188c..a25f6ea5c784 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -576,10 +576,6 @@ static int dw8250_probe(struct platform_device *pdev)
if (!data->skip_autocfg)
dw8250_setup_port(p);
 
-#ifdef CONFIG_PM
-   uart.capabilities |= UART_CAP_RPM;
-#endif
-
/* If we have a valid fifosize, try hooking up DMA */
if (p->fifosize) {
data->dma.rxconf.src_maxburst = p->fifosize / 4;
-- 
2.17.1





[PATCH 4.18 054/150] perf/x86/intel/uncore: Use boot_cpu_data.phys_proc_id instead of hardcorded physical package ID 0

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 6265adb9726098b7f4f7ca70bc51992b25fdd9d6 ]

Physical package id 0 doesn't always exist, we should use
boot_cpu_data.phys_proc_id here.

Signed-off-by: Masayoshi Mizuma 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: H. Peter Anvin 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Masayoshi Mizuma 
Cc: Peter Zijlstra 
Cc: Stephane Eranian 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Link: http://lkml.kernel.org/r/20180910144750.6782-1-msys.miz...@gmail.com
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/uncore_snbep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/uncore_snbep.c 
b/arch/x86/events/intel/uncore_snbep.c
index 51d7c117e3c7..53b981dcdb42 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -3061,7 +3061,7 @@ static struct event_constraint 
bdx_uncore_pcu_constraints[] = {
 
 void bdx_uncore_cpu_init(void)
 {
-   int pkg = topology_phys_to_logical_pkg(0);
+   int pkg = topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id);
 
if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
-- 
2.17.1





[PATCH 4.18 028/150] pxa168fb: prepare the clock

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit d85536cde91fcfed6fb8d983783bd2b92c843939 ]

Add missing prepare/unprepare operations for fbi->clk,
this fixes following kernel warning:

  [ cut here ]
  WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:874 clk_core_enable+0x2c/0x1b0
  Enabling unprepared disp0_clk
  Modules linked in:
  CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.0-rc8-00032-g02b43ddd4f21-dirty 
#25
  Hardware name: Marvell MMP2 (Device Tree Support)
  [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
  [] (show_stack) from [] (__warn+0xd8/0xf0)
  [] (__warn) from [] (warn_slowpath_fmt+0x44/0x6c)
  [] (warn_slowpath_fmt) from [] 
(clk_core_enable+0x2c/0x1b0)
  [] (clk_core_enable) from [] 
(clk_core_enable_lock+0x18/0x2c)
  [] (clk_core_enable_lock) from [] 
(pxa168fb_probe+0x464/0x6ac)
  [] (pxa168fb_probe) from [] (platform_drv_probe+0x48/0x94)
  [] (platform_drv_probe) from [] 
(driver_probe_device+0x328/0x470)
  [] (driver_probe_device) from [] 
(__driver_attach+0xb0/0x124)
  [] (__driver_attach) from [] (bus_for_each_dev+0x64/0xa0)
  [] (bus_for_each_dev) from [] (bus_add_driver+0x1b8/0x230)
  [] (bus_add_driver) from [] (driver_register+0xac/0xf0)
  [] (driver_register) from [] (do_one_initcall+0xb8/0x1f0)
  [] (do_one_initcall) from [] 
(kernel_init_freeable+0x294/0x2e0)
  [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c)
  [] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
  Exception stack(0xd008bfb0 to 0xd008bff8)
  bfa0:    
  bfc0:        
  bfe0:     0013 
  ---[ end trace c0af40f9e2ed7cb4 ]---

Signed-off-by: Lubomir Rintel 
[b.zolnierkie: enhance patch description a bit]
Signed-off-by: Bartlomiej Zolnierkiewicz 
Signed-off-by: Sasha Levin 
---
 drivers/video/fbdev/pxa168fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/pxa168fb.c b/drivers/video/fbdev/pxa168fb.c
index def3a501acd6..d059d04c63ac 100644
--- a/drivers/video/fbdev/pxa168fb.c
+++ b/drivers/video/fbdev/pxa168fb.c
@@ -712,7 +712,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
/*
 * enable controller clock
 */
-   clk_enable(fbi->clk);
+   clk_prepare_enable(fbi->clk);
 
pxa168fb_set_par(info);
 
@@ -767,7 +767,7 @@ static int pxa168fb_probe(struct platform_device *pdev)
 failed_free_cmap:
fb_dealloc_cmap(>cmap);
 failed_free_clk:
-   clk_disable(fbi->clk);
+   clk_disable_unprepare(fbi->clk);
 failed_free_fbmem:
dma_free_coherent(fbi->dev, info->fix.smem_len,
info->screen_base, fbi->fb_start_dma);
@@ -807,7 +807,7 @@ static int pxa168fb_remove(struct platform_device *pdev)
dma_free_wc(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
info->screen_base, info->fix.smem_start);
 
-   clk_disable(fbi->clk);
+   clk_disable_unprepare(fbi->clk);
 
framebuffer_release(info);
 
-- 
2.17.1





[PATCH 4.18 021/150] soc: fsl: qbman: qman: avoid allocating from non existing gen_pool

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 64e9e22e68512da8df3c9a7430f07621e48db3c2 ]

If the qman driver didn't probe, calling qman_alloc_fqid_range,
qman_alloc_pool_range or qman_alloc_cgrid_range (as done in dpaa_eth) will
pass a NULL pointer to gen_pool_alloc, leading to a NULL pointer
dereference.

Signed-off-by: Alexandre Belloni 
Reviewed-by: Roy Pledge 
Signed-off-by: Li Yang 
(cherry picked from commit f72487a2788aa70c3aee1d0ebd5470de9bac953a)
Signed-off-by: Olof Johansson 
Signed-off-by: Sasha Levin 
---
 drivers/soc/fsl/qbman/qman.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index ecb22749df0b..8cc015183043 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2729,6 +2729,9 @@ static int qman_alloc_range(struct gen_pool *p, u32 
*result, u32 cnt)
 {
unsigned long addr;
 
+   if (!p)
+   return -ENODEV;
+
addr = gen_pool_alloc(p, cnt);
if (!addr)
return -ENOMEM;
-- 
2.17.1





[PATCH 4.18 030/150] qed: Fix mask parameter in qed_vf_prep_tunn_req_tlv

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit db803f36e56f23b5a2266807e190d1dc11554d54 ]

Clang complains when one enumerated type is implicitly converted to
another.

drivers/net/ethernet/qlogic/qed/qed_vf.c:686:6: warning: implicit
conversion from enumeration type 'enum qed_tunn_mode' to different
enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
 QED_MODE_L2GENEVE_TUNN,
 ^~

Update mask's parameter to expect qed_tunn_mode, which is what was
intended.

Link: https://github.com/ClangBuiltLinux/linux/issues/125
Signed-off-by: Nathan Chancellor 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/qlogic/qed/qed_vf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c 
b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index be6ddde1a104..ac3f54bbe9b9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -572,7 +572,7 @@ free_p_iov:
 static void
 __qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
   struct qed_tunn_update_type *p_src,
-  enum qed_tunn_clss mask, u8 *p_cls)
+  enum qed_tunn_mode mask, u8 *p_cls)
 {
if (p_src->b_update_mode) {
p_req->tun_mode_update_mask |= BIT(mask);
@@ -587,7 +587,7 @@ __qed_vf_prep_tunn_req_tlv(struct 
vfpf_update_tunn_param_tlv *p_req,
 static void
 qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req,
 struct qed_tunn_update_type *p_src,
-enum qed_tunn_clss mask,
+enum qed_tunn_mode mask,
 u8 *p_cls, struct qed_tunn_update_udp_port *p_port,
 u8 *p_update_port, u16 *p_udp_port)
 {
-- 
2.17.1





[PATCH 4.18 029/150] qed: Avoid implicit enum conversion in qed_set_tunn_cls_info

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit a898fba32229efd5e6b6154f83fa86a7145156b9 ]

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:163:25: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->vxlan.tun_cls = type;
 ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:165:26: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->l2_gre.tun_cls = type;
  ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:167:26: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->ip_gre.tun_cls = type;
  ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:169:29: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->l2_geneve.tun_cls = type;
 ~ ^~~~
drivers/net/ethernet/qlogic/qed/qed_sp_commands.c:171:29: warning:
implicit conversion from enumeration type 'enum tunnel_clss' to
different enumeration type 'enum qed_tunn_clss' [-Wenum-conversion]
p_tun->ip_geneve.tun_cls = type;
 ~ ^~~~
5 warnings generated.

Avoid this by changing type to an int.

Link: https://github.com/ClangBuiltLinux/linux/issues/125
Signed-off-by: Nathan Chancellor 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/qlogic/qed/qed_sp_commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c 
b/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
index 8de644b4721e..77b6248ad3b9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sp_commands.c
@@ -154,7 +154,7 @@ qed_set_pf_update_tunn_mode(struct qed_tunnel_info *p_tun,
 static void qed_set_tunn_cls_info(struct qed_tunnel_info *p_tun,
  struct qed_tunnel_info *p_src)
 {
-   enum tunnel_clss type;
+   int type;
 
p_tun->b_update_rx_cls = p_src->b_update_rx_cls;
p_tun->b_update_tx_cls = p_src->b_update_tx_cls;
-- 
2.17.1





[PATCH 4.18 052/150] KVM: nVMX: Fix emulation of VM_ENTRY_LOAD_BNDCFGS

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 62cf9bd8118c4009f02c477ef78c723f49e53e16 ]

L2 IA32_BNDCFGS should be updated with vmcs12->guest_bndcfgs only
when VM_ENTRY_LOAD_BNDCFGS is specified in vmcs12->vm_entry_controls.

Otherwise, L2 IA32_BNDCFGS should be set to vmcs01->guest_bndcfgs which
is L1 IA32_BNDCFGS.

Reviewed-by: Nikita Leshchenko 
Reviewed-by: Darren Kenny 
Signed-off-by: Liran Alon 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Sasha Levin 
---
 arch/x86/kvm/vmx.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2e23fce5eb1f..9efe130ea2e6 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -819,6 +819,7 @@ struct nested_vmx {
 
/* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */
u64 vmcs01_debugctl;
+   u64 vmcs01_guest_bndcfgs;
 
u16 vpid02;
u16 last_vpid;
@@ -11567,8 +11568,13 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, 
struct vmcs12 *vmcs12)
 
set_cr4_guest_host_mask(vmx);
 
-   if (kvm_mpx_supported())
-   vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs);
+   if (kvm_mpx_supported()) {
+   if (vmx->nested.nested_run_pending &&
+   (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS))
+   vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs);
+   else
+   vmcs_write64(GUEST_BNDCFGS, 
vmx->nested.vmcs01_guest_bndcfgs);
+   }
 
if (enable_vpid) {
if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02)
@@ -12082,6 +12088,9 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu 
*vcpu)
 
if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
+   if (kvm_mpx_supported() &&
+   !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS))
+   vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS);
 
vmx_switch_vmcs(vcpu, >nested.vmcs02);
vmx_segment_cache_clear(vmx);
-- 
2.17.1





[PATCH 4.18 051/150] KVM: x86: Do not use kvm_x86_ops->mpx_supported() directly

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 503234b3fdcaa578395c07e393ea3e5d13958824 ]

Commit a87036add092 ("KVM: x86: disable MPX if host did not enable
MPX XSAVE features") introduced kvm_mpx_supported() to return true
iff MPX is enabled in the host.

However, that commit seems to have missed replacing some calls to
kvm_x86_ops->mpx_supported() to kvm_mpx_supported().

Complete original commit by replacing remaining calls to
kvm_mpx_supported().

Fixes: a87036add092 ("KVM: x86: disable MPX if host did not enable
MPX XSAVE features")

Suggested-by: Sean Christopherson 
Signed-off-by: Liran Alon 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Sasha Levin 
---
 arch/x86/kvm/vmx.c | 2 +-
 arch/x86/kvm/x86.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ea691ddfc3aa..2e23fce5eb1f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11567,7 +11567,7 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, 
struct vmcs12 *vmcs12)
 
set_cr4_guest_host_mask(vmx);
 
-   if (vmx_mpx_supported())
+   if (kvm_mpx_supported())
vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs);
 
if (enable_vpid) {
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 97fcac34e007..3cd58a5eb449 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4625,7 +4625,7 @@ static void kvm_init_msr_list(void)
 */
switch (msrs_to_save[i]) {
case MSR_IA32_BNDCFGS:
-   if (!kvm_x86_ops->mpx_supported())
+   if (!kvm_mpx_supported())
continue;
break;
case MSR_TSC_AUX:
-- 
2.17.1





[PATCH 4.18 051/150] KVM: x86: Do not use kvm_x86_ops->mpx_supported() directly

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 503234b3fdcaa578395c07e393ea3e5d13958824 ]

Commit a87036add092 ("KVM: x86: disable MPX if host did not enable
MPX XSAVE features") introduced kvm_mpx_supported() to return true
iff MPX is enabled in the host.

However, that commit seems to have missed replacing some calls to
kvm_x86_ops->mpx_supported() to kvm_mpx_supported().

Complete original commit by replacing remaining calls to
kvm_mpx_supported().

Fixes: a87036add092 ("KVM: x86: disable MPX if host did not enable
MPX XSAVE features")

Suggested-by: Sean Christopherson 
Signed-off-by: Liran Alon 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Sasha Levin 
---
 arch/x86/kvm/vmx.c | 2 +-
 arch/x86/kvm/x86.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ea691ddfc3aa..2e23fce5eb1f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -11567,7 +11567,7 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, 
struct vmcs12 *vmcs12)
 
set_cr4_guest_host_mask(vmx);
 
-   if (vmx_mpx_supported())
+   if (kvm_mpx_supported())
vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs);
 
if (enable_vpid) {
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 97fcac34e007..3cd58a5eb449 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4625,7 +4625,7 @@ static void kvm_init_msr_list(void)
 */
switch (msrs_to_save[i]) {
case MSR_IA32_BNDCFGS:
-   if (!kvm_x86_ops->mpx_supported())
+   if (!kvm_mpx_supported())
continue;
break;
case MSR_TSC_AUX:
-- 
2.17.1





[PATCH 4.18 050/150] KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 5f76f6f5ff96587af5acd5930f7d9fea81e0d1a8 ]

Before this commit, KVM exposes MPX VMX controls to L1 guest only based
on if KVM and host processor supports MPX virtualization.
However, these controls should be exposed to guest only in case guest
vCPU supports MPX.

Without this change, a L1 guest running with kernel which don't have
commit 691bd4340bef ("kvm: vmx: allow host to access guest
MSR_IA32_BNDCFGS") asserts in QEMU on the following:
qemu-kvm: error: failed to set MSR 0xd90 to 0x0
qemu-kvm: .../qemu-2.10.0/target/i386/kvm.c:1801 kvm_put_msrs:
Assertion 'ret == cpu->kvm_msr_buf->nmsrs failed'
This is because L1 KVM kvm_init_msr_list() will see that
vmx_mpx_supported() (As it only checks MPX VMX controls support) and
therefore KVM_GET_MSR_INDEX_LIST IOCTL will include MSR_IA32_BNDCFGS.
However, later when L1 will attempt to set this MSR via KVM_SET_MSRS
IOCTL, it will fail because !guest_cpuid_has_mpx(vcpu).

Therefore, fix the issue by exposing MPX VMX controls to L1 guest only
when vCPU supports MPX.

Fixes: 36be0b9deb23 ("KVM: x86: Add nested virtualization support for MPX")

Reported-by: Eyal Moscovici 
Reviewed-by: Nikita Leshchenko 
Reviewed-by: Darren Kenny 
Signed-off-by: Liran Alon 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Sasha Levin 
---
 arch/x86/kvm/vmx.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 32721ef9652d..ea691ddfc3aa 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3395,9 +3395,6 @@ static void nested_vmx_setup_ctls_msrs(struct 
nested_vmx_msrs *msrs, bool apicv)
VM_EXIT_LOAD_IA32_EFER | VM_EXIT_SAVE_IA32_EFER |
VM_EXIT_SAVE_VMX_PREEMPTION_TIMER | VM_EXIT_ACK_INTR_ON_EXIT;
 
-   if (kvm_mpx_supported())
-   msrs->exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS;
-
/* We support free control of debug control saving. */
msrs->exit_ctls_low &= ~VM_EXIT_SAVE_DEBUG_CONTROLS;
 
@@ -3414,8 +3411,6 @@ static void nested_vmx_setup_ctls_msrs(struct 
nested_vmx_msrs *msrs, bool apicv)
VM_ENTRY_LOAD_IA32_PAT;
msrs->entry_ctls_high |=
(VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER);
-   if (kvm_mpx_supported())
-   msrs->entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS;
 
/* We support free control of debug control loading. */
msrs->entry_ctls_low &= ~VM_ENTRY_LOAD_DEBUG_CONTROLS;
@@ -10825,6 +10820,23 @@ static void nested_vmx_cr_fixed1_bits_update(struct 
kvm_vcpu *vcpu)
 #undef cr4_fixed1_update
 }
 
+static void nested_vmx_entry_exit_ctls_update(struct kvm_vcpu *vcpu)
+{
+   struct vcpu_vmx *vmx = to_vmx(vcpu);
+
+   if (kvm_mpx_supported()) {
+   bool mpx_enabled = guest_cpuid_has(vcpu, X86_FEATURE_MPX);
+
+   if (mpx_enabled) {
+   vmx->nested.msrs.entry_ctls_high |= 
VM_ENTRY_LOAD_BNDCFGS;
+   vmx->nested.msrs.exit_ctls_high |= 
VM_EXIT_CLEAR_BNDCFGS;
+   } else {
+   vmx->nested.msrs.entry_ctls_high &= 
~VM_ENTRY_LOAD_BNDCFGS;
+   vmx->nested.msrs.exit_ctls_high &= 
~VM_EXIT_CLEAR_BNDCFGS;
+   }
+   }
+}
+
 static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -10841,8 +10853,10 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
to_vmx(vcpu)->msr_ia32_feature_control_valid_bits &=
~FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX;
 
-   if (nested_vmx_allowed(vcpu))
+   if (nested_vmx_allowed(vcpu)) {
nested_vmx_cr_fixed1_bits_update(vcpu);
+   nested_vmx_entry_exit_ctls_update(vcpu);
+   }
 }
 
 static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
-- 
2.17.1





[PATCH 4.18 025/150] mac80211_hwsim: fix race in radio destruction from netlink notifier

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f1c47eb61d52379de5747d02bb36be20d7a2d0d3 ]

The asynchronous destruction from a work-queue of radios tagged with
destroy-on-close may race with the owning namespace about to exit,
resulting in potential use-after-free of that namespace.

Instead of using a work-queue, move radios about to destroy to a
temporary list, which can be worked on synchronously after releasing
the lock. This should be safe to do from the netlink socket notifier,
as the namespace is guaranteed to not get released.

Signed-off-by: Martin Willi 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/mac80211_hwsim.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 6b90bef58293..cfd0c58aa02a 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -519,7 +519,6 @@ struct mac80211_hwsim_data {
int channels, idx;
bool use_chanctx;
bool destroy_on_close;
-   struct work_struct destroy_work;
u32 portid;
char alpha2[2];
const struct ieee80211_regdomain *regd;
@@ -3442,30 +3441,27 @@ static struct genl_family hwsim_genl_family 
__ro_after_init = {
.n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
 };
 
-static void destroy_radio(struct work_struct *work)
-{
-   struct mac80211_hwsim_data *data =
-   container_of(work, struct mac80211_hwsim_data, destroy_work);
-
-   hwsim_radios_generation++;
-   mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), NULL);
-}
-
 static void remove_user_radios(u32 portid)
 {
struct mac80211_hwsim_data *entry, *tmp;
+   LIST_HEAD(list);
 
spin_lock_bh(_radio_lock);
list_for_each_entry_safe(entry, tmp, _radios, list) {
if (entry->destroy_on_close && entry->portid == portid) {
-   list_del(>list);
+   list_move(>list, );
rhashtable_remove_fast(_radios_rht, >rht,
   hwsim_rht_params);
-   INIT_WORK(>destroy_work, destroy_radio);
-   queue_work(hwsim_wq, >destroy_work);
+   hwsim_radios_generation++;
}
}
spin_unlock_bh(_radio_lock);
+
+   list_for_each_entry_safe(entry, tmp, , list) {
+   list_del(>list);
+   mac80211_hwsim_del_radio(entry, wiphy_name(entry->hw->wiphy),
+NULL);
+   }
 }
 
 static int mac80211_hwsim_netlink_notify(struct notifier_block *nb,
-- 
2.17.1





[PATCH 4.18 024/150] mac80211_hwsim: fix locking when iterating radios during ns exit

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 628980e5c8f038f730582c6ee50b7410741cd96e ]

The cleanup of radios during namespace exit has recently been reworked
to directly delete a radio while temporarily releasing the spinlock,
fixing a race condition between the work-queue execution and namespace
exits. However, the temporary unlock allows unsafe modifications on the
iterated list, resulting in a potential crash when continuing the
iteration of additional radios.

Move radios about to destroy to a temporary list, and clean that up
after releasing the spinlock once iteration is complete.

Fixes: 8cfd36a0b53a ("mac80211_hwsim: fix use-after-free bug in hwsim_exit_net")
Signed-off-by: Martin Willi 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/mac80211_hwsim.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 80e2c8595c7c..6b90bef58293 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3523,6 +3523,7 @@ static __net_init int hwsim_init_net(struct net *net)
 static void __net_exit hwsim_exit_net(struct net *net)
 {
struct mac80211_hwsim_data *data, *tmp;
+   LIST_HEAD(list);
 
spin_lock_bh(_radio_lock);
list_for_each_entry_safe(data, tmp, _radios, list) {
@@ -3533,17 +3534,19 @@ static void __net_exit hwsim_exit_net(struct net *net)
if (data->netgroup == hwsim_net_get_netgroup(_net))
continue;
 
-   list_del(>list);
+   list_move(>list, );
rhashtable_remove_fast(_radios_rht, >rht,
   hwsim_rht_params);
hwsim_radios_generation++;
-   spin_unlock_bh(_radio_lock);
+   }
+   spin_unlock_bh(_radio_lock);
+
+   list_for_each_entry_safe(data, tmp, , list) {
+   list_del(>list);
mac80211_hwsim_del_radio(data,
 wiphy_name(data->hw->wiphy),
 NULL);
-   spin_lock_bh(_radio_lock);
}
-   spin_unlock_bh(_radio_lock);
 
ida_simple_remove(_netgroup_ida, hwsim_net_get_netgroup(net));
 }
-- 
2.17.1





[PATCH 4.18 027/150] Bluetooth: SMP: fix crash in unpairing

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit cb28c306b93b71f2741ce1a5a66289db26715f4d ]

In case unpair_device() was called through mgmt interface at the same time
when pairing was in progress, Bluetooth kernel module crash was seen.

[  600.351225] general protection fault:  [#1] SMP PTI
[  600.351235] CPU: 1 PID: 11096 Comm: btmgmt Tainted: G   OE 
4.19.0-rc1+ #1
[  600.351238] Hardware name: Dell Inc. Latitude E5440/08RCYC, BIOS A18 
05/14/2017
[  600.351272] RIP: 0010:smp_chan_destroy.isra.10+0xce/0x2c0 [bluetooth]
[  600.351276] Code: c0 0f 84 b4 01 00 00 80 78 28 04 0f 84 53 01 00 00 4d 85 
ed 0f 85 ab 00 00 00 48 8b 08 48 8b 50 08 be 10 00 00 00 48 89 51 08 <48> 89 0a 
48 b9 00 02 00 00 00 00 ad de 48 89 48 08 48 8b 83 00 01
[  600.351279] RSP: 0018:a9be839b3b50 EFLAGS: 00010246
[  600.351282] RAX: 9c999ac565a0 RBX: 9c9996e98c00 RCX: 9c999aa28b60
[  600.351285] RDX: dead0200 RSI: 0010 RDI: 9c999e403500
[  600.351287] RBP: a9be839b3b70 R08:  R09: 92a25c00
[  600.351290] R10: a9be839b3ae8 R11: 0001 R12: 9c995375b800
[  600.351292] R13:  R14: 9c99619a5000 R15: 9c9962a01c00
[  600.351295] FS:  7fb2be27c700() GS:9c999e88() 
knlGS:
[  600.351298] CS:  0010 DS:  ES:  CR0: 80050033
[  600.351300] CR2: 7fb2bdadbad0 CR3: 00041c328001 CR4: 001606e0
[  600.351302] Call Trace:
[  600.351325]  smp_failure+0x4f/0x70 [bluetooth]
[  600.351345]  smp_cancel_pairing+0x74/0x80 [bluetooth]
[  600.351370]  unpair_device+0x1c1/0x330 [bluetooth]
[  600.351399]  hci_sock_sendmsg+0x960/0x9f0 [bluetooth]
[  600.351409]  ? apparmor_socket_sendmsg+0x1e/0x20
[  600.351417]  sock_sendmsg+0x3e/0x50
[  600.351422]  sock_write_iter+0x85/0xf0
[  600.351429]  do_iter_readv_writev+0x12b/0x1b0
[  600.351434]  do_iter_write+0x87/0x1a0
[  600.351439]  vfs_writev+0x98/0x110
[  600.351443]  ? ep_poll+0x16d/0x3d0
[  600.351447]  ? ep_modify+0x73/0x170
[  600.351451]  do_writev+0x61/0xf0
[  600.351455]  ? do_writev+0x61/0xf0
[  600.351460]  __x64_sys_writev+0x1c/0x20
[  600.351465]  do_syscall_64+0x5a/0x110
[  600.351471]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  600.351474] RIP: 0033:0x7fb2bdb62fe0
[  600.351477] Code: 73 01 c3 48 8b 0d b8 6e 2c 00 f7 d8 64 89 01 48 83 c8 ff 
c3 66 0f 1f 44 00 00 83 3d 69 c7 2c 00 00 75 10 b8 14 00 00 00 0f 05 <48> 3d 01 
f0 ff ff 73 31 c3 48 83 ec 08 e8 de 80 01 00 48 89 04 24
[  600.351479] RSP: 002b:7ffe062cb8f8 EFLAGS: 0246 ORIG_RAX: 
0014
[  600.351484] RAX: ffda RBX: 0255b3d0 RCX: 7fb2bdb62fe0
[  600.351487] RDX: 0001 RSI: 7ffe062cb920 RDI: 0004
[  600.351490] RBP: 7ffe062cb920 R08: 0255bd80 R09: 
[  600.351494] R10: 0353 R11: 0246 R12: 0001
[  600.351497] R13: 7ffe062cbbe0 R14:  R15: 
[  600.351501] Modules linked in: algif_hash algif_skcipher af_alg cmac 
ipt_MASQUERADE nf_conntrack_netlink nfnetlink xfrm_user xfrm_algo iptable_nat 
nf_nat_ipv4 xt_addrtype iptable_filter ip_tables xt_conntrack x_tables nf_nat 
nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c br_netfilter bridge stp 
llc overlay arc4 nls_iso8859_1 dm_crypt intel_rapl x86_pkg_temp_thermal 
intel_powerclamp coretemp dell_laptop kvm_intel crct10dif_pclmul dell_smm_hwmon 
crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 crypto_simd cryptd 
glue_helper intel_cstate intel_rapl_perf uvcvideo videobuf2_vmalloc 
videobuf2_memops videobuf2_v4l2 videobuf2_common videodev media hid_multitouch 
input_leds joydev serio_raw dell_wmi snd_hda_codec_hdmi snd_hda_codec_realtek 
snd_hda_codec_generic dell_smbios dcdbas sparse_keymap
[  600.351569]  snd_hda_intel btusb snd_hda_codec btrtl btbcm btintel 
snd_hda_core bluetooth(OE) snd_hwdep snd_pcm iwlmvm ecdh_generic wmi_bmof 
dell_wmi_descriptor snd_seq_midi mac80211 snd_seq_midi_event lpc_ich iwlwifi 
snd_rawmidi snd_seq snd_seq_device snd_timer cfg80211 snd soundcore mei_me mei 
dell_rbtn dell_smo8800 mac_hid parport_pc ppdev lp parport autofs4 hid_generic 
usbhid hid i915 nouveau kvmgt vfio_mdev mdev vfio_iommu_type1 vfio kvm 
irqbypass i2c_algo_bit ttm drm_kms_helper syscopyarea sysfillrect sysimgblt 
mxm_wmi psmouse ahci sdhci_pci cqhci libahci fb_sys_fops sdhci drm e1000e video 
wmi
[  600.351637] ---[ end trace e49e9f1df09c94fb ]---
[  600.351664] RIP: 0010:smp_chan_destroy.isra.10+0xce/0x2c0 [bluetooth]
[  600.351666] Code: c0 0f 84 b4 01 00 00 80 78 28 04 0f 84 53 01 00 00 4d 85 
ed 0f 85 ab 00 00 00 48 8b 08 48 8b 50 08 be 10 00 00 00 48 89 51 08 <48> 89 0a 
48 b9 00 02 00 00 00 00 ad de 48 89 48 08 48 8b 83 00 01
[  600.351669] RSP: 0018:a9be839b3b50 EFLAGS: 00010246
[  600.351672] RAX: 9c999ac565a0 RBX: 9c9996e98c00 RCX: 

[PATCH 4.18 050/150] KVM: nVMX: Do not expose MPX VMX controls when guest MPX disabled

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 5f76f6f5ff96587af5acd5930f7d9fea81e0d1a8 ]

Before this commit, KVM exposes MPX VMX controls to L1 guest only based
on if KVM and host processor supports MPX virtualization.
However, these controls should be exposed to guest only in case guest
vCPU supports MPX.

Without this change, a L1 guest running with kernel which don't have
commit 691bd4340bef ("kvm: vmx: allow host to access guest
MSR_IA32_BNDCFGS") asserts in QEMU on the following:
qemu-kvm: error: failed to set MSR 0xd90 to 0x0
qemu-kvm: .../qemu-2.10.0/target/i386/kvm.c:1801 kvm_put_msrs:
Assertion 'ret == cpu->kvm_msr_buf->nmsrs failed'
This is because L1 KVM kvm_init_msr_list() will see that
vmx_mpx_supported() (As it only checks MPX VMX controls support) and
therefore KVM_GET_MSR_INDEX_LIST IOCTL will include MSR_IA32_BNDCFGS.
However, later when L1 will attempt to set this MSR via KVM_SET_MSRS
IOCTL, it will fail because !guest_cpuid_has_mpx(vcpu).

Therefore, fix the issue by exposing MPX VMX controls to L1 guest only
when vCPU supports MPX.

Fixes: 36be0b9deb23 ("KVM: x86: Add nested virtualization support for MPX")

Reported-by: Eyal Moscovici 
Reviewed-by: Nikita Leshchenko 
Reviewed-by: Darren Kenny 
Signed-off-by: Liran Alon 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Sasha Levin 
---
 arch/x86/kvm/vmx.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 32721ef9652d..ea691ddfc3aa 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3395,9 +3395,6 @@ static void nested_vmx_setup_ctls_msrs(struct 
nested_vmx_msrs *msrs, bool apicv)
VM_EXIT_LOAD_IA32_EFER | VM_EXIT_SAVE_IA32_EFER |
VM_EXIT_SAVE_VMX_PREEMPTION_TIMER | VM_EXIT_ACK_INTR_ON_EXIT;
 
-   if (kvm_mpx_supported())
-   msrs->exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS;
-
/* We support free control of debug control saving. */
msrs->exit_ctls_low &= ~VM_EXIT_SAVE_DEBUG_CONTROLS;
 
@@ -3414,8 +3411,6 @@ static void nested_vmx_setup_ctls_msrs(struct 
nested_vmx_msrs *msrs, bool apicv)
VM_ENTRY_LOAD_IA32_PAT;
msrs->entry_ctls_high |=
(VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER);
-   if (kvm_mpx_supported())
-   msrs->entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS;
 
/* We support free control of debug control loading. */
msrs->entry_ctls_low &= ~VM_ENTRY_LOAD_DEBUG_CONTROLS;
@@ -10825,6 +10820,23 @@ static void nested_vmx_cr_fixed1_bits_update(struct 
kvm_vcpu *vcpu)
 #undef cr4_fixed1_update
 }
 
+static void nested_vmx_entry_exit_ctls_update(struct kvm_vcpu *vcpu)
+{
+   struct vcpu_vmx *vmx = to_vmx(vcpu);
+
+   if (kvm_mpx_supported()) {
+   bool mpx_enabled = guest_cpuid_has(vcpu, X86_FEATURE_MPX);
+
+   if (mpx_enabled) {
+   vmx->nested.msrs.entry_ctls_high |= 
VM_ENTRY_LOAD_BNDCFGS;
+   vmx->nested.msrs.exit_ctls_high |= 
VM_EXIT_CLEAR_BNDCFGS;
+   } else {
+   vmx->nested.msrs.entry_ctls_high &= 
~VM_ENTRY_LOAD_BNDCFGS;
+   vmx->nested.msrs.exit_ctls_high &= 
~VM_EXIT_CLEAR_BNDCFGS;
+   }
+   }
+}
+
 static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
 {
struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -10841,8 +10853,10 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
to_vmx(vcpu)->msr_ia32_feature_control_valid_bits &=
~FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX;
 
-   if (nested_vmx_allowed(vcpu))
+   if (nested_vmx_allowed(vcpu)) {
nested_vmx_cr_fixed1_bits_update(vcpu);
+   nested_vmx_entry_exit_ctls_update(vcpu);
+   }
 }
 
 static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
-- 
2.17.1





[PATCH 4.18 025/150] mac80211_hwsim: fix race in radio destruction from netlink notifier

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f1c47eb61d52379de5747d02bb36be20d7a2d0d3 ]

The asynchronous destruction from a work-queue of radios tagged with
destroy-on-close may race with the owning namespace about to exit,
resulting in potential use-after-free of that namespace.

Instead of using a work-queue, move radios about to destroy to a
temporary list, which can be worked on synchronously after releasing
the lock. This should be safe to do from the netlink socket notifier,
as the namespace is guaranteed to not get released.

Signed-off-by: Martin Willi 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/mac80211_hwsim.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 6b90bef58293..cfd0c58aa02a 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -519,7 +519,6 @@ struct mac80211_hwsim_data {
int channels, idx;
bool use_chanctx;
bool destroy_on_close;
-   struct work_struct destroy_work;
u32 portid;
char alpha2[2];
const struct ieee80211_regdomain *regd;
@@ -3442,30 +3441,27 @@ static struct genl_family hwsim_genl_family 
__ro_after_init = {
.n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
 };
 
-static void destroy_radio(struct work_struct *work)
-{
-   struct mac80211_hwsim_data *data =
-   container_of(work, struct mac80211_hwsim_data, destroy_work);
-
-   hwsim_radios_generation++;
-   mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), NULL);
-}
-
 static void remove_user_radios(u32 portid)
 {
struct mac80211_hwsim_data *entry, *tmp;
+   LIST_HEAD(list);
 
spin_lock_bh(_radio_lock);
list_for_each_entry_safe(entry, tmp, _radios, list) {
if (entry->destroy_on_close && entry->portid == portid) {
-   list_del(>list);
+   list_move(>list, );
rhashtable_remove_fast(_radios_rht, >rht,
   hwsim_rht_params);
-   INIT_WORK(>destroy_work, destroy_radio);
-   queue_work(hwsim_wq, >destroy_work);
+   hwsim_radios_generation++;
}
}
spin_unlock_bh(_radio_lock);
+
+   list_for_each_entry_safe(entry, tmp, , list) {
+   list_del(>list);
+   mac80211_hwsim_del_radio(entry, wiphy_name(entry->hw->wiphy),
+NULL);
+   }
 }
 
 static int mac80211_hwsim_netlink_notify(struct notifier_block *nb,
-- 
2.17.1





[PATCH 4.18 024/150] mac80211_hwsim: fix locking when iterating radios during ns exit

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 628980e5c8f038f730582c6ee50b7410741cd96e ]

The cleanup of radios during namespace exit has recently been reworked
to directly delete a radio while temporarily releasing the spinlock,
fixing a race condition between the work-queue execution and namespace
exits. However, the temporary unlock allows unsafe modifications on the
iterated list, resulting in a potential crash when continuing the
iteration of additional radios.

Move radios about to destroy to a temporary list, and clean that up
after releasing the spinlock once iteration is complete.

Fixes: 8cfd36a0b53a ("mac80211_hwsim: fix use-after-free bug in hwsim_exit_net")
Signed-off-by: Martin Willi 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 drivers/net/wireless/mac80211_hwsim.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 80e2c8595c7c..6b90bef58293 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3523,6 +3523,7 @@ static __net_init int hwsim_init_net(struct net *net)
 static void __net_exit hwsim_exit_net(struct net *net)
 {
struct mac80211_hwsim_data *data, *tmp;
+   LIST_HEAD(list);
 
spin_lock_bh(_radio_lock);
list_for_each_entry_safe(data, tmp, _radios, list) {
@@ -3533,17 +3534,19 @@ static void __net_exit hwsim_exit_net(struct net *net)
if (data->netgroup == hwsim_net_get_netgroup(_net))
continue;
 
-   list_del(>list);
+   list_move(>list, );
rhashtable_remove_fast(_radios_rht, >rht,
   hwsim_rht_params);
hwsim_radios_generation++;
-   spin_unlock_bh(_radio_lock);
+   }
+   spin_unlock_bh(_radio_lock);
+
+   list_for_each_entry_safe(data, tmp, , list) {
+   list_del(>list);
mac80211_hwsim_del_radio(data,
 wiphy_name(data->hw->wiphy),
 NULL);
-   spin_lock_bh(_radio_lock);
}
-   spin_unlock_bh(_radio_lock);
 
ida_simple_remove(_netgroup_ida, hwsim_net_get_netgroup(net));
 }
-- 
2.17.1





[PATCH 4.18 027/150] Bluetooth: SMP: fix crash in unpairing

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit cb28c306b93b71f2741ce1a5a66289db26715f4d ]

In case unpair_device() was called through mgmt interface at the same time
when pairing was in progress, Bluetooth kernel module crash was seen.

[  600.351225] general protection fault:  [#1] SMP PTI
[  600.351235] CPU: 1 PID: 11096 Comm: btmgmt Tainted: G   OE 
4.19.0-rc1+ #1
[  600.351238] Hardware name: Dell Inc. Latitude E5440/08RCYC, BIOS A18 
05/14/2017
[  600.351272] RIP: 0010:smp_chan_destroy.isra.10+0xce/0x2c0 [bluetooth]
[  600.351276] Code: c0 0f 84 b4 01 00 00 80 78 28 04 0f 84 53 01 00 00 4d 85 
ed 0f 85 ab 00 00 00 48 8b 08 48 8b 50 08 be 10 00 00 00 48 89 51 08 <48> 89 0a 
48 b9 00 02 00 00 00 00 ad de 48 89 48 08 48 8b 83 00 01
[  600.351279] RSP: 0018:a9be839b3b50 EFLAGS: 00010246
[  600.351282] RAX: 9c999ac565a0 RBX: 9c9996e98c00 RCX: 9c999aa28b60
[  600.351285] RDX: dead0200 RSI: 0010 RDI: 9c999e403500
[  600.351287] RBP: a9be839b3b70 R08:  R09: 92a25c00
[  600.351290] R10: a9be839b3ae8 R11: 0001 R12: 9c995375b800
[  600.351292] R13:  R14: 9c99619a5000 R15: 9c9962a01c00
[  600.351295] FS:  7fb2be27c700() GS:9c999e88() 
knlGS:
[  600.351298] CS:  0010 DS:  ES:  CR0: 80050033
[  600.351300] CR2: 7fb2bdadbad0 CR3: 00041c328001 CR4: 001606e0
[  600.351302] Call Trace:
[  600.351325]  smp_failure+0x4f/0x70 [bluetooth]
[  600.351345]  smp_cancel_pairing+0x74/0x80 [bluetooth]
[  600.351370]  unpair_device+0x1c1/0x330 [bluetooth]
[  600.351399]  hci_sock_sendmsg+0x960/0x9f0 [bluetooth]
[  600.351409]  ? apparmor_socket_sendmsg+0x1e/0x20
[  600.351417]  sock_sendmsg+0x3e/0x50
[  600.351422]  sock_write_iter+0x85/0xf0
[  600.351429]  do_iter_readv_writev+0x12b/0x1b0
[  600.351434]  do_iter_write+0x87/0x1a0
[  600.351439]  vfs_writev+0x98/0x110
[  600.351443]  ? ep_poll+0x16d/0x3d0
[  600.351447]  ? ep_modify+0x73/0x170
[  600.351451]  do_writev+0x61/0xf0
[  600.351455]  ? do_writev+0x61/0xf0
[  600.351460]  __x64_sys_writev+0x1c/0x20
[  600.351465]  do_syscall_64+0x5a/0x110
[  600.351471]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  600.351474] RIP: 0033:0x7fb2bdb62fe0
[  600.351477] Code: 73 01 c3 48 8b 0d b8 6e 2c 00 f7 d8 64 89 01 48 83 c8 ff 
c3 66 0f 1f 44 00 00 83 3d 69 c7 2c 00 00 75 10 b8 14 00 00 00 0f 05 <48> 3d 01 
f0 ff ff 73 31 c3 48 83 ec 08 e8 de 80 01 00 48 89 04 24
[  600.351479] RSP: 002b:7ffe062cb8f8 EFLAGS: 0246 ORIG_RAX: 
0014
[  600.351484] RAX: ffda RBX: 0255b3d0 RCX: 7fb2bdb62fe0
[  600.351487] RDX: 0001 RSI: 7ffe062cb920 RDI: 0004
[  600.351490] RBP: 7ffe062cb920 R08: 0255bd80 R09: 
[  600.351494] R10: 0353 R11: 0246 R12: 0001
[  600.351497] R13: 7ffe062cbbe0 R14:  R15: 
[  600.351501] Modules linked in: algif_hash algif_skcipher af_alg cmac 
ipt_MASQUERADE nf_conntrack_netlink nfnetlink xfrm_user xfrm_algo iptable_nat 
nf_nat_ipv4 xt_addrtype iptable_filter ip_tables xt_conntrack x_tables nf_nat 
nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c br_netfilter bridge stp 
llc overlay arc4 nls_iso8859_1 dm_crypt intel_rapl x86_pkg_temp_thermal 
intel_powerclamp coretemp dell_laptop kvm_intel crct10dif_pclmul dell_smm_hwmon 
crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 crypto_simd cryptd 
glue_helper intel_cstate intel_rapl_perf uvcvideo videobuf2_vmalloc 
videobuf2_memops videobuf2_v4l2 videobuf2_common videodev media hid_multitouch 
input_leds joydev serio_raw dell_wmi snd_hda_codec_hdmi snd_hda_codec_realtek 
snd_hda_codec_generic dell_smbios dcdbas sparse_keymap
[  600.351569]  snd_hda_intel btusb snd_hda_codec btrtl btbcm btintel 
snd_hda_core bluetooth(OE) snd_hwdep snd_pcm iwlmvm ecdh_generic wmi_bmof 
dell_wmi_descriptor snd_seq_midi mac80211 snd_seq_midi_event lpc_ich iwlwifi 
snd_rawmidi snd_seq snd_seq_device snd_timer cfg80211 snd soundcore mei_me mei 
dell_rbtn dell_smo8800 mac_hid parport_pc ppdev lp parport autofs4 hid_generic 
usbhid hid i915 nouveau kvmgt vfio_mdev mdev vfio_iommu_type1 vfio kvm 
irqbypass i2c_algo_bit ttm drm_kms_helper syscopyarea sysfillrect sysimgblt 
mxm_wmi psmouse ahci sdhci_pci cqhci libahci fb_sys_fops sdhci drm e1000e video 
wmi
[  600.351637] ---[ end trace e49e9f1df09c94fb ]---
[  600.351664] RIP: 0010:smp_chan_destroy.isra.10+0xce/0x2c0 [bluetooth]
[  600.351666] Code: c0 0f 84 b4 01 00 00 80 78 28 04 0f 84 53 01 00 00 4d 85 
ed 0f 85 ab 00 00 00 48 8b 08 48 8b 50 08 be 10 00 00 00 48 89 51 08 <48> 89 0a 
48 b9 00 02 00 00 00 00 ad de 48 89 48 08 48 8b 83 00 01
[  600.351669] RSP: 0018:a9be839b3b50 EFLAGS: 00010246
[  600.351672] RAX: 9c999ac565a0 RBX: 9c9996e98c00 RCX: 

[PATCH 4.18 048/150] smsc95xx: Check for Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit c530c471ba37bdd9fe1c7185b01455c00ae606fb ]

The driver does not check for Wake-on-LAN modes specified by an user,
but will conditionally set the device as wake-up enabled or not based on
that, which could be a very confusing user experience.

Fixes: e0e474a83c18 ("smsc95xx: add wol magic packet support")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/smsc95xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 06b4d290784d..262e7a3c23cb 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -774,6 +774,9 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net,
struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
int ret;
 
+   if (wolinfo->wolopts & ~SUPPORTED_WAKE)
+   return -EINVAL;
+
pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
 
ret = device_set_wakeup_enable(>udev->dev, pdata->wolopts);
-- 
2.17.1





[PATCH 4.18 045/150] sr9800: Check for supported Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit c5cb93e994ffb43b7b3b1ff10b9f928f54574a36 ]

The driver currently silently accepts unsupported Wake-on-LAN modes
(other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user,
which is confusing.

Fixes: 19a38d8e0aa3 ("USB2NET : SR9800 : One chip USB2.0 USB2NET SR9800 Device 
Driver Support")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/sr9800.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 9277a0f228df..35f39f23d881 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -421,6 +421,9 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo 
*wolinfo)
struct usbnet *dev = netdev_priv(net);
u8 opt = 0;
 
+   if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
+   return -EINVAL;
+
if (wolinfo->wolopts & WAKE_PHY)
opt |= SR_MONITOR_LINK;
if (wolinfo->wolopts & WAKE_MAGIC)
-- 
2.17.1





[PATCH 4.18 047/150] smsc75xx: Check for Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 9c734b2769a73eea2e9e9767c0e0bf839ff23679 ]

The driver does not check for Wake-on-LAN modes specified by an user,
but will conditionally set the device as wake-up enabled or not based on
that, which could be a very confusing user experience.

Fixes: 6c636503260d ("smsc75xx: add wol magic packet support")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/smsc75xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index b64b1ee56d2d..ec287c9741e8 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
int ret;
 
+   if (wolinfo->wolopts & ~SUPPORTED_WAKE)
+   return -EINVAL;
+
pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
 
ret = device_set_wakeup_enable(>udev->dev, pdata->wolopts);
-- 
2.17.1





[PATCH 4.18 048/150] smsc95xx: Check for Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit c530c471ba37bdd9fe1c7185b01455c00ae606fb ]

The driver does not check for Wake-on-LAN modes specified by an user,
but will conditionally set the device as wake-up enabled or not based on
that, which could be a very confusing user experience.

Fixes: e0e474a83c18 ("smsc95xx: add wol magic packet support")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/smsc95xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 06b4d290784d..262e7a3c23cb 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -774,6 +774,9 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net,
struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
int ret;
 
+   if (wolinfo->wolopts & ~SUPPORTED_WAKE)
+   return -EINVAL;
+
pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
 
ret = device_set_wakeup_enable(>udev->dev, pdata->wolopts);
-- 
2.17.1





[PATCH 4.18 045/150] sr9800: Check for supported Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit c5cb93e994ffb43b7b3b1ff10b9f928f54574a36 ]

The driver currently silently accepts unsupported Wake-on-LAN modes
(other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user,
which is confusing.

Fixes: 19a38d8e0aa3 ("USB2NET : SR9800 : One chip USB2.0 USB2NET SR9800 Device 
Driver Support")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/sr9800.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 9277a0f228df..35f39f23d881 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -421,6 +421,9 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo 
*wolinfo)
struct usbnet *dev = netdev_priv(net);
u8 opt = 0;
 
+   if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
+   return -EINVAL;
+
if (wolinfo->wolopts & WAKE_PHY)
opt |= SR_MONITOR_LINK;
if (wolinfo->wolopts & WAKE_MAGIC)
-- 
2.17.1





[PATCH 4.18 047/150] smsc75xx: Check for Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 9c734b2769a73eea2e9e9767c0e0bf839ff23679 ]

The driver does not check for Wake-on-LAN modes specified by an user,
but will conditionally set the device as wake-up enabled or not based on
that, which could be a very confusing user experience.

Fixes: 6c636503260d ("smsc75xx: add wol magic packet support")
Signed-off-by: Florian Fainelli 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/smsc75xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index b64b1ee56d2d..ec287c9741e8 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
int ret;
 
+   if (wolinfo->wolopts & ~SUPPORTED_WAKE)
+   return -EINVAL;
+
pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
 
ret = device_set_wakeup_enable(>udev->dev, pdata->wolopts);
-- 
2.17.1





[PATCH 4.18 034/150] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 1222a16014888ed9733c11e221730d4a8196222b ]

Use array_index_nospec() to sanitize i with respect to speculation.

Note that the user doesn't control i directly, but can make it out
of bounds by not finding a threshold in the array.

Signed-off-by: Masashi Honma 
[add note about user control, as explained by Masashi]
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 net/wireless/nl80211.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3b80cf012438..214f9ef79a64 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10125,7 +10125,7 @@ static int cfg80211_cqm_rssi_update(struct 
cfg80211_registered_device *rdev,
struct wireless_dev *wdev = dev->ieee80211_ptr;
s32 last, low, high;
u32 hyst;
-   int i, n;
+   int i, n, low_index;
int err;
 
/* RSSI reporting disabled? */
@@ -10162,10 +10162,19 @@ static int cfg80211_cqm_rssi_update(struct 
cfg80211_registered_device *rdev,
if (last < wdev->cqm_config->rssi_thresholds[i])
break;
 
-   low = i > 0 ?
-   (wdev->cqm_config->rssi_thresholds[i - 1] - hyst) : S32_MIN;
-   high = i < n ?
-   (wdev->cqm_config->rssi_thresholds[i] + hyst - 1) : S32_MAX;
+   low_index = i - 1;
+   if (low_index >= 0) {
+   low_index = array_index_nospec(low_index, n);
+   low = wdev->cqm_config->rssi_thresholds[low_index] - hyst;
+   } else {
+   low = S32_MIN;
+   }
+   if (i < n) {
+   i = array_index_nospec(i, n);
+   high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1;
+   } else {
+   high = S32_MAX;
+   }
 
return rdev_set_cqm_rssi_range_config(rdev, dev, low, high);
 }
-- 
2.17.1





[PATCH 4.18 039/150] rxrpc: Fix error distribution

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f334430316e7fd37c4821ebec627e27714bb5d76 ]

Fix error distribution by immediately delivering the errors to all the
affected calls rather than deferring them to a worker thread.  The problem
with the latter is that retries and things can happen in the meantime when we
want to stop that sooner.

To this end:

 (1) Stop the error distributor from removing calls from the error_targets
 list so that peer->lock isn't needed to synchronise against other adds
 and removals.

 (2) Require the peer's error_targets list to be accessed with RCU, thereby
 avoiding the need to take peer->lock over distribution.

 (3) Don't attempt to affect a call's state if it is already marked complete.

Signed-off-by: David Howells 
Signed-off-by: Sasha Levin 
---
 include/trace/events/rxrpc.h |  4 +---
 net/rxrpc/ar-internal.h  |  5 
 net/rxrpc/call_object.c  |  2 +-
 net/rxrpc/conn_client.c  |  4 ++--
 net/rxrpc/conn_object.c  |  2 +-
 net/rxrpc/peer_event.c   | 46 +---
 net/rxrpc/peer_object.c  | 17 -
 7 files changed, 16 insertions(+), 64 deletions(-)

diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h
index 4fff00e9da8a..0a774b64fc29 100644
--- a/include/trace/events/rxrpc.h
+++ b/include/trace/events/rxrpc.h
@@ -56,7 +56,6 @@ enum rxrpc_peer_trace {
rxrpc_peer_new,
rxrpc_peer_processing,
rxrpc_peer_put,
-   rxrpc_peer_queued_error,
 };
 
 enum rxrpc_conn_trace {
@@ -257,8 +256,7 @@ enum rxrpc_tx_fail_trace {
EM(rxrpc_peer_got,  "GOT") \
EM(rxrpc_peer_new,  "NEW") \
EM(rxrpc_peer_processing,   "PRO") \
-   EM(rxrpc_peer_put,  "PUT") \
-   E_(rxrpc_peer_queued_error, "QER")
+   E_(rxrpc_peer_put,  "PUT")
 
 #define rxrpc_conn_traces \
EM(rxrpc_conn_got,  "GOT") \
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 5069193d2cc1..4718d08c0af1 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -293,7 +293,6 @@ struct rxrpc_peer {
struct hlist_node   hash_link;
struct rxrpc_local  *local;
struct hlist_head   error_targets;  /* targets for net error 
distribution */
-   struct work_struct  error_distributor;
struct rb_root  service_conns;  /* Service connections */
struct list_headkeepalive_link; /* Link in 
net->peer_keepalive[] */
time64_tlast_tx_at; /* Last time packet sent here */
@@ -304,8 +303,6 @@ struct rxrpc_peer {
unsigned intmaxdata;/* data size (MTU - hdrsize) */
unsigned short  hdrsize;/* header size (IP + UDP + 
RxRPC) */
int debug_id;   /* debug ID for printks */
-   int error_report;   /* Net (+0) or local (+100) 
to distribute */
-#define RXRPC_LOCAL_ERROR_OFFSET 100
struct sockaddr_rxrpc   srx;/* remote address */
 
/* calculated RTT cache */
@@ -1039,7 +1036,6 @@ void rxrpc_send_keepalive(struct rxrpc_peer *);
  * peer_event.c
  */
 void rxrpc_error_report(struct sock *);
-void rxrpc_peer_error_distributor(struct work_struct *);
 void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace,
rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t);
 void rxrpc_peer_keepalive_worker(struct work_struct *);
@@ -1058,7 +1054,6 @@ void rxrpc_destroy_all_peers(struct rxrpc_net *);
 struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *);
 struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *);
 void rxrpc_put_peer(struct rxrpc_peer *);
-void __rxrpc_queue_peer_error(struct rxrpc_peer *);
 
 /*
  * proc.c
diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
index f6734d8cb01a..ed69257203c2 100644
--- a/net/rxrpc/call_object.c
+++ b/net/rxrpc/call_object.c
@@ -400,7 +400,7 @@ void rxrpc_incoming_call(struct rxrpc_sock *rx,
rcu_assign_pointer(conn->channels[chan].call, call);
 
spin_lock(>params.peer->lock);
-   hlist_add_head(>error_link, >params.peer->error_targets);
+   hlist_add_head_rcu(>error_link, 
>params.peer->error_targets);
spin_unlock(>params.peer->lock);
 
_net("CALL incoming %d on CONN %d", call->debug_id, 
call->conn->debug_id);
diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
index 5736f643c516..0be19132202b 100644
--- a/net/rxrpc/conn_client.c
+++ b/net/rxrpc/conn_client.c
@@ -709,8 +709,8 @@ int rxrpc_connect_call(struct rxrpc_call *call,
}
 
spin_lock_bh(>conn->params.peer->lock);
-   hlist_add_head(>error_link,
-  >conn->params.peer->error_targets);
+   

[PATCH 4.18 044/150] lan78xx: Check for supported Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eb9ad088f96653a26b340f7c447c44cf023d5cdc ]

The driver supports a fair amount of Wake-on-LAN modes, but is not
checking that the user specified one that is supported.

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 
Ethernet device driver")
Signed-off-by: Florian Fainelli 
Reviewed-by: Woojung Huh 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/lan78xx.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index aeca484a75b8..2bb3a081ff10 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device *netdev,
if (ret < 0)
return ret;
 
-   pdata->wol = 0;
-   if (wol->wolopts & WAKE_UCAST)
-   pdata->wol |= WAKE_UCAST;
-   if (wol->wolopts & WAKE_MCAST)
-   pdata->wol |= WAKE_MCAST;
-   if (wol->wolopts & WAKE_BCAST)
-   pdata->wol |= WAKE_BCAST;
-   if (wol->wolopts & WAKE_MAGIC)
-   pdata->wol |= WAKE_MAGIC;
-   if (wol->wolopts & WAKE_PHY)
-   pdata->wol |= WAKE_PHY;
-   if (wol->wolopts & WAKE_ARP)
-   pdata->wol |= WAKE_ARP;
+   if (wol->wolopts & ~WAKE_ALL)
+   return -EINVAL;
+
+   pdata->wol = wol->wolopts;
 
device_set_wakeup_enable(>udev->dev, (bool)wol->wolopts);
 
-- 
2.17.1





[PATCH 4.18 037/150] rxrpc: Fix RTT gathering

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit b604dd9883f783a94020d772e4fe03160f455372 ]

Fix RTT information gathering in AF_RXRPC by the following means:

 (1) Enable Rx timestamping on the transport socket with SO_TIMESTAMPNS.

 (2) If the sk_buff doesn't have a timestamp set when rxrpc_data_ready()
 collects it, set it at that point.

 (3) Allow ACKs to be requested on the last packet of a client call, but
 not a service call.  We need to be careful lest we undo:

bf7d620abf22c321208a4da4f435e7af52551a21
Author: David Howells 
Date:   Thu Oct 6 08:11:51 2016 +0100
rxrpc: Don't request an ACK on the last DATA packet of a call's Tx phase

 but that only really applies to service calls that we're handling,
 since the client side gets to send the final ACK (or not).

 (4) When about to transmit an ACK or DATA packet, record the Tx timestamp
 before only; don't update the timestamp afterwards.

 (5) Switch the ordering between recording the serial and recording the
 timestamp to always set the serial number first.  The serial number
 shouldn't be seen referenced by an ACK packet until we've transmitted
 the packet bearing it - so in the Rx path, we don't need the timestamp
 until we've checked the serial number.

Fixes: cf1a6474f807 ("rxrpc: Add per-peer RTT tracker")
Signed-off-by: David Howells 
Signed-off-by: Sasha Levin 
---
 net/rxrpc/input.c|  8 ++--
 net/rxrpc/local_object.c |  9 +
 net/rxrpc/output.c   | 31 ++-
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 338fbbf216a9..f6027c875876 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -616,13 +616,14 @@ static void rxrpc_input_requested_ack(struct rxrpc_call 
*call,
if (!skb)
continue;
 
+   sent_at = skb->tstamp;
+   smp_rmb(); /* Read timestamp before serial. */
sp = rxrpc_skb(skb);
if (sp->hdr.serial != orig_serial)
continue;
-   smp_rmb();
-   sent_at = skb->tstamp;
goto found;
}
+
return;
 
 found:
@@ -1137,6 +1138,9 @@ void rxrpc_data_ready(struct sock *udp_sk)
return;
}
 
+   if (skb->tstamp == 0)
+   skb->tstamp = ktime_get_real();
+
rxrpc_new_skb(skb, rxrpc_skb_rx_received);
 
_net("recv skb %p", skb);
diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index b493e6b62740..5d89ea5c1976 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -173,6 +173,15 @@ static int rxrpc_open_socket(struct rxrpc_local *local, 
struct net *net)
_debug("setsockopt failed");
goto error;
}
+
+   /* We want receive timestamps. */
+   opt = 1;
+   ret = kernel_setsockopt(local->socket, SOL_SOCKET, 
SO_TIMESTAMPNS,
+   (char *), sizeof(opt));
+   if (ret < 0) {
+   _debug("setsockopt failed");
+   goto error;
+   }
break;
 
default:
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index 4774c8f5634d..6ac21bb2071d 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -124,7 +124,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool 
ping,
struct kvec iov[2];
rxrpc_serial_t serial;
rxrpc_seq_t hard_ack, top;
-   ktime_t now;
size_t len, n;
int ret;
u8 reason;
@@ -196,9 +195,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool 
ping,
/* We need to stick a time in before we send the packet in case
 * the reply gets back before kernel_sendmsg() completes - but
 * asking UDP to send the packet can take a relatively long
-* time, so we update the time after, on the assumption that
-* the packet transmission is more likely to happen towards the
-* end of the kernel_sendmsg() call.
+* time.
 */
call->ping_time = ktime_get_real();
set_bit(RXRPC_CALL_PINGING, >flags);
@@ -206,9 +203,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool 
ping,
}
 
ret = kernel_sendmsg(conn->params.local->socket, , iov, 2, len);
-   now = ktime_get_real();
-   if (ping)
-   call->ping_time = now;
conn->params.peer->last_tx_at = ktime_get_seconds();
if (ret < 0)
trace_rxrpc_tx_fail(call->debug_id, serial, ret,
@@ -357,8 +351,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct 
sk_buff *skb,
 
/* If our RTT cache needs working on, 

[PATCH 4.18 041/150] netfilter: avoid erronous array bounds warning

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 421c119f558761556afca6a62ad183bc2d8659e0 ]

Unfortunately some versions of gcc emit following warning:
  $ make net/xfrm/xfrm_output.o
  linux/compiler.h:252:20: warning: array subscript is above array bounds 
[-Warray-bounds]
  hook_head = rcu_dereference(net->nf.hooks_arp[hook]);
^
xfrm_output_resume passes skb_dst(skb)->ops->family as its 'pf' arg so compiler
can't know that we'll never access hooks_arp[].
(NFPROTO_IPV4 or NFPROTO_IPV6 are only possible cases).

Avoid this by adding an explicit WARN_ON_ONCE() check.

This patch has no effect if the family is a compile-time constant as gcc
will remove the switch() construct entirely.

Reported-by: David Ahern 
Signed-off-by: Florian Westphal 
Reviewed-by: David Ahern 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Sasha Levin 
---
 include/linux/netfilter.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index dd2052f0efb7..11b7b8ab0696 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -215,6 +215,8 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, 
struct net *net,
break;
case NFPROTO_ARP:
 #ifdef CONFIG_NETFILTER_FAMILY_ARP
+   if (WARN_ON_ONCE(hook >= ARRAY_SIZE(net->nf.hooks_arp)))
+   break;
hook_head = rcu_dereference(net->nf.hooks_arp[hook]);
 #endif
break;
-- 
2.17.1





[PATCH 4.18 049/150] cfg80211: fix use-after-free in reg_process_hint()

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 1db58529454742f67ebd96e3588315e880b72837 ]

reg_process_hint_country_ie() can free regulatory_request and return
REG_REQ_ALREADY_SET. We shouldn't use regulatory_request after it's
called. KASAN error was observed when this happens.

BUG: KASAN: use-after-free in reg_process_hint+0x839/0x8aa [cfg80211]
Read of size 4 at addr 8800c430d434 by task kworker/1:3/89

Workqueue: events reg_todo [cfg80211]
Call Trace:
 dump_stack+0xc1/0x10c
 ? _atomic_dec_and_lock+0x1ad/0x1ad
 ? _raw_spin_lock_irqsave+0xa0/0xd2
 print_address_description+0x86/0x26f
 ? reg_process_hint+0x839/0x8aa [cfg80211]
 kasan_report+0x241/0x29b
 reg_process_hint+0x839/0x8aa [cfg80211]
 reg_todo+0x204/0x5b9 [cfg80211]
 process_one_work+0x55f/0x8d0
 ? worker_detach_from_pool+0x1b5/0x1b5
 ? _raw_spin_unlock_irq+0x65/0xdd
 ? _raw_spin_unlock_irqrestore+0xf3/0xf3
 worker_thread+0x5dd/0x841
 ? kthread_parkme+0x1d/0x1d
 kthread+0x270/0x285
 ? pr_cont_work+0xe3/0xe3
 ? rcu_read_unlock_sched_notrace+0xca/0xca
 ret_from_fork+0x22/0x40

Allocated by task 2718:
 set_track+0x63/0xfa
 __kmalloc+0x119/0x1ac
 regulatory_hint_country_ie+0x38/0x329 [cfg80211]
 __cfg80211_connect_result+0x854/0xadd [cfg80211]
 cfg80211_rx_assoc_resp+0x3bc/0x4f0 [cfg80211]
smsc95xx v1.0.6
 ieee80211_sta_rx_queued_mgmt+0x1803/0x7ed5 [mac80211]
 ieee80211_iface_work+0x411/0x696 [mac80211]
 process_one_work+0x55f/0x8d0
 worker_thread+0x5dd/0x841
 kthread+0x270/0x285
 ret_from_fork+0x22/0x40

Freed by task 89:
 set_track+0x63/0xfa
 kasan_slab_free+0x6a/0x87
 kfree+0xdc/0x470
 reg_process_hint+0x31e/0x8aa [cfg80211]
 reg_todo+0x204/0x5b9 [cfg80211]
 process_one_work+0x55f/0x8d0
 worker_thread+0x5dd/0x841
 kthread+0x270/0x285
 ret_from_fork+0x22/0x40


Signed-off-by: Yu Zhao 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 net/wireless/reg.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 765dedb12361..24cfa2776f50 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2661,11 +2661,12 @@ static void reg_process_hint(struct regulatory_request 
*reg_request)
 {
struct wiphy *wiphy = NULL;
enum reg_request_treatment treatment;
+   enum nl80211_reg_initiator initiator = reg_request->initiator;
 
if (reg_request->wiphy_idx != WIPHY_IDX_INVALID)
wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
 
-   switch (reg_request->initiator) {
+   switch (initiator) {
case NL80211_REGDOM_SET_BY_CORE:
treatment = reg_process_hint_core(reg_request);
break;
@@ -2683,7 +2684,7 @@ static void reg_process_hint(struct regulatory_request 
*reg_request)
treatment = reg_process_hint_country_ie(wiphy, reg_request);
break;
default:
-   WARN(1, "invalid initiator %d\n", reg_request->initiator);
+   WARN(1, "invalid initiator %d\n", initiator);
goto out_free;
}
 
@@ -2698,7 +2699,7 @@ static void reg_process_hint(struct regulatory_request 
*reg_request)
 */
if (treatment == REG_REQ_ALREADY_SET && wiphy &&
wiphy->regulatory_flags & REGULATORY_STRICT_REG) {
-   wiphy_update_regulatory(wiphy, reg_request->initiator);
+   wiphy_update_regulatory(wiphy, initiator);
wiphy_all_share_dfs_chan_state(wiphy);
reg_check_channels();
}
-- 
2.17.1





[PATCH 4.18 034/150] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 1222a16014888ed9733c11e221730d4a8196222b ]

Use array_index_nospec() to sanitize i with respect to speculation.

Note that the user doesn't control i directly, but can make it out
of bounds by not finding a threshold in the array.

Signed-off-by: Masashi Honma 
[add note about user control, as explained by Masashi]
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 net/wireless/nl80211.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3b80cf012438..214f9ef79a64 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10125,7 +10125,7 @@ static int cfg80211_cqm_rssi_update(struct 
cfg80211_registered_device *rdev,
struct wireless_dev *wdev = dev->ieee80211_ptr;
s32 last, low, high;
u32 hyst;
-   int i, n;
+   int i, n, low_index;
int err;
 
/* RSSI reporting disabled? */
@@ -10162,10 +10162,19 @@ static int cfg80211_cqm_rssi_update(struct 
cfg80211_registered_device *rdev,
if (last < wdev->cqm_config->rssi_thresholds[i])
break;
 
-   low = i > 0 ?
-   (wdev->cqm_config->rssi_thresholds[i - 1] - hyst) : S32_MIN;
-   high = i < n ?
-   (wdev->cqm_config->rssi_thresholds[i] + hyst - 1) : S32_MAX;
+   low_index = i - 1;
+   if (low_index >= 0) {
+   low_index = array_index_nospec(low_index, n);
+   low = wdev->cqm_config->rssi_thresholds[low_index] - hyst;
+   } else {
+   low = S32_MIN;
+   }
+   if (i < n) {
+   i = array_index_nospec(i, n);
+   high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1;
+   } else {
+   high = S32_MAX;
+   }
 
return rdev_set_cqm_rssi_range_config(rdev, dev, low, high);
 }
-- 
2.17.1





[PATCH 4.18 039/150] rxrpc: Fix error distribution

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit f334430316e7fd37c4821ebec627e27714bb5d76 ]

Fix error distribution by immediately delivering the errors to all the
affected calls rather than deferring them to a worker thread.  The problem
with the latter is that retries and things can happen in the meantime when we
want to stop that sooner.

To this end:

 (1) Stop the error distributor from removing calls from the error_targets
 list so that peer->lock isn't needed to synchronise against other adds
 and removals.

 (2) Require the peer's error_targets list to be accessed with RCU, thereby
 avoiding the need to take peer->lock over distribution.

 (3) Don't attempt to affect a call's state if it is already marked complete.

Signed-off-by: David Howells 
Signed-off-by: Sasha Levin 
---
 include/trace/events/rxrpc.h |  4 +---
 net/rxrpc/ar-internal.h  |  5 
 net/rxrpc/call_object.c  |  2 +-
 net/rxrpc/conn_client.c  |  4 ++--
 net/rxrpc/conn_object.c  |  2 +-
 net/rxrpc/peer_event.c   | 46 +---
 net/rxrpc/peer_object.c  | 17 -
 7 files changed, 16 insertions(+), 64 deletions(-)

diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h
index 4fff00e9da8a..0a774b64fc29 100644
--- a/include/trace/events/rxrpc.h
+++ b/include/trace/events/rxrpc.h
@@ -56,7 +56,6 @@ enum rxrpc_peer_trace {
rxrpc_peer_new,
rxrpc_peer_processing,
rxrpc_peer_put,
-   rxrpc_peer_queued_error,
 };
 
 enum rxrpc_conn_trace {
@@ -257,8 +256,7 @@ enum rxrpc_tx_fail_trace {
EM(rxrpc_peer_got,  "GOT") \
EM(rxrpc_peer_new,  "NEW") \
EM(rxrpc_peer_processing,   "PRO") \
-   EM(rxrpc_peer_put,  "PUT") \
-   E_(rxrpc_peer_queued_error, "QER")
+   E_(rxrpc_peer_put,  "PUT")
 
 #define rxrpc_conn_traces \
EM(rxrpc_conn_got,  "GOT") \
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 5069193d2cc1..4718d08c0af1 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -293,7 +293,6 @@ struct rxrpc_peer {
struct hlist_node   hash_link;
struct rxrpc_local  *local;
struct hlist_head   error_targets;  /* targets for net error 
distribution */
-   struct work_struct  error_distributor;
struct rb_root  service_conns;  /* Service connections */
struct list_headkeepalive_link; /* Link in 
net->peer_keepalive[] */
time64_tlast_tx_at; /* Last time packet sent here */
@@ -304,8 +303,6 @@ struct rxrpc_peer {
unsigned intmaxdata;/* data size (MTU - hdrsize) */
unsigned short  hdrsize;/* header size (IP + UDP + 
RxRPC) */
int debug_id;   /* debug ID for printks */
-   int error_report;   /* Net (+0) or local (+100) 
to distribute */
-#define RXRPC_LOCAL_ERROR_OFFSET 100
struct sockaddr_rxrpc   srx;/* remote address */
 
/* calculated RTT cache */
@@ -1039,7 +1036,6 @@ void rxrpc_send_keepalive(struct rxrpc_peer *);
  * peer_event.c
  */
 void rxrpc_error_report(struct sock *);
-void rxrpc_peer_error_distributor(struct work_struct *);
 void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace,
rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t);
 void rxrpc_peer_keepalive_worker(struct work_struct *);
@@ -1058,7 +1054,6 @@ void rxrpc_destroy_all_peers(struct rxrpc_net *);
 struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *);
 struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *);
 void rxrpc_put_peer(struct rxrpc_peer *);
-void __rxrpc_queue_peer_error(struct rxrpc_peer *);
 
 /*
  * proc.c
diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
index f6734d8cb01a..ed69257203c2 100644
--- a/net/rxrpc/call_object.c
+++ b/net/rxrpc/call_object.c
@@ -400,7 +400,7 @@ void rxrpc_incoming_call(struct rxrpc_sock *rx,
rcu_assign_pointer(conn->channels[chan].call, call);
 
spin_lock(>params.peer->lock);
-   hlist_add_head(>error_link, >params.peer->error_targets);
+   hlist_add_head_rcu(>error_link, 
>params.peer->error_targets);
spin_unlock(>params.peer->lock);
 
_net("CALL incoming %d on CONN %d", call->debug_id, 
call->conn->debug_id);
diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
index 5736f643c516..0be19132202b 100644
--- a/net/rxrpc/conn_client.c
+++ b/net/rxrpc/conn_client.c
@@ -709,8 +709,8 @@ int rxrpc_connect_call(struct rxrpc_call *call,
}
 
spin_lock_bh(>conn->params.peer->lock);
-   hlist_add_head(>error_link,
-  >conn->params.peer->error_targets);
+   

[PATCH 4.18 044/150] lan78xx: Check for supported Wake-on-LAN modes

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit eb9ad088f96653a26b340f7c447c44cf023d5cdc ]

The driver supports a fair amount of Wake-on-LAN modes, but is not
checking that the user specified one that is supported.

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 
Ethernet device driver")
Signed-off-by: Florian Fainelli 
Reviewed-by: Woojung Huh 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/usb/lan78xx.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index aeca484a75b8..2bb3a081ff10 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device *netdev,
if (ret < 0)
return ret;
 
-   pdata->wol = 0;
-   if (wol->wolopts & WAKE_UCAST)
-   pdata->wol |= WAKE_UCAST;
-   if (wol->wolopts & WAKE_MCAST)
-   pdata->wol |= WAKE_MCAST;
-   if (wol->wolopts & WAKE_BCAST)
-   pdata->wol |= WAKE_BCAST;
-   if (wol->wolopts & WAKE_MAGIC)
-   pdata->wol |= WAKE_MAGIC;
-   if (wol->wolopts & WAKE_PHY)
-   pdata->wol |= WAKE_PHY;
-   if (wol->wolopts & WAKE_ARP)
-   pdata->wol |= WAKE_ARP;
+   if (wol->wolopts & ~WAKE_ALL)
+   return -EINVAL;
+
+   pdata->wol = wol->wolopts;
 
device_set_wakeup_enable(>udev->dev, (bool)wol->wolopts);
 
-- 
2.17.1





[PATCH 4.18 037/150] rxrpc: Fix RTT gathering

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit b604dd9883f783a94020d772e4fe03160f455372 ]

Fix RTT information gathering in AF_RXRPC by the following means:

 (1) Enable Rx timestamping on the transport socket with SO_TIMESTAMPNS.

 (2) If the sk_buff doesn't have a timestamp set when rxrpc_data_ready()
 collects it, set it at that point.

 (3) Allow ACKs to be requested on the last packet of a client call, but
 not a service call.  We need to be careful lest we undo:

bf7d620abf22c321208a4da4f435e7af52551a21
Author: David Howells 
Date:   Thu Oct 6 08:11:51 2016 +0100
rxrpc: Don't request an ACK on the last DATA packet of a call's Tx phase

 but that only really applies to service calls that we're handling,
 since the client side gets to send the final ACK (or not).

 (4) When about to transmit an ACK or DATA packet, record the Tx timestamp
 before only; don't update the timestamp afterwards.

 (5) Switch the ordering between recording the serial and recording the
 timestamp to always set the serial number first.  The serial number
 shouldn't be seen referenced by an ACK packet until we've transmitted
 the packet bearing it - so in the Rx path, we don't need the timestamp
 until we've checked the serial number.

Fixes: cf1a6474f807 ("rxrpc: Add per-peer RTT tracker")
Signed-off-by: David Howells 
Signed-off-by: Sasha Levin 
---
 net/rxrpc/input.c|  8 ++--
 net/rxrpc/local_object.c |  9 +
 net/rxrpc/output.c   | 31 ++-
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 338fbbf216a9..f6027c875876 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -616,13 +616,14 @@ static void rxrpc_input_requested_ack(struct rxrpc_call 
*call,
if (!skb)
continue;
 
+   sent_at = skb->tstamp;
+   smp_rmb(); /* Read timestamp before serial. */
sp = rxrpc_skb(skb);
if (sp->hdr.serial != orig_serial)
continue;
-   smp_rmb();
-   sent_at = skb->tstamp;
goto found;
}
+
return;
 
 found:
@@ -1137,6 +1138,9 @@ void rxrpc_data_ready(struct sock *udp_sk)
return;
}
 
+   if (skb->tstamp == 0)
+   skb->tstamp = ktime_get_real();
+
rxrpc_new_skb(skb, rxrpc_skb_rx_received);
 
_net("recv skb %p", skb);
diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index b493e6b62740..5d89ea5c1976 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -173,6 +173,15 @@ static int rxrpc_open_socket(struct rxrpc_local *local, 
struct net *net)
_debug("setsockopt failed");
goto error;
}
+
+   /* We want receive timestamps. */
+   opt = 1;
+   ret = kernel_setsockopt(local->socket, SOL_SOCKET, 
SO_TIMESTAMPNS,
+   (char *), sizeof(opt));
+   if (ret < 0) {
+   _debug("setsockopt failed");
+   goto error;
+   }
break;
 
default:
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index 4774c8f5634d..6ac21bb2071d 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -124,7 +124,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool 
ping,
struct kvec iov[2];
rxrpc_serial_t serial;
rxrpc_seq_t hard_ack, top;
-   ktime_t now;
size_t len, n;
int ret;
u8 reason;
@@ -196,9 +195,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool 
ping,
/* We need to stick a time in before we send the packet in case
 * the reply gets back before kernel_sendmsg() completes - but
 * asking UDP to send the packet can take a relatively long
-* time, so we update the time after, on the assumption that
-* the packet transmission is more likely to happen towards the
-* end of the kernel_sendmsg() call.
+* time.
 */
call->ping_time = ktime_get_real();
set_bit(RXRPC_CALL_PINGING, >flags);
@@ -206,9 +203,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool 
ping,
}
 
ret = kernel_sendmsg(conn->params.local->socket, , iov, 2, len);
-   now = ktime_get_real();
-   if (ping)
-   call->ping_time = now;
conn->params.peer->last_tx_at = ktime_get_seconds();
if (ret < 0)
trace_rxrpc_tx_fail(call->debug_id, serial, ret,
@@ -357,8 +351,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct 
sk_buff *skb,
 
/* If our RTT cache needs working on, 

[PATCH 4.18 041/150] netfilter: avoid erronous array bounds warning

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 421c119f558761556afca6a62ad183bc2d8659e0 ]

Unfortunately some versions of gcc emit following warning:
  $ make net/xfrm/xfrm_output.o
  linux/compiler.h:252:20: warning: array subscript is above array bounds 
[-Warray-bounds]
  hook_head = rcu_dereference(net->nf.hooks_arp[hook]);
^
xfrm_output_resume passes skb_dst(skb)->ops->family as its 'pf' arg so compiler
can't know that we'll never access hooks_arp[].
(NFPROTO_IPV4 or NFPROTO_IPV6 are only possible cases).

Avoid this by adding an explicit WARN_ON_ONCE() check.

This patch has no effect if the family is a compile-time constant as gcc
will remove the switch() construct entirely.

Reported-by: David Ahern 
Signed-off-by: Florian Westphal 
Reviewed-by: David Ahern 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Sasha Levin 
---
 include/linux/netfilter.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index dd2052f0efb7..11b7b8ab0696 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -215,6 +215,8 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, 
struct net *net,
break;
case NFPROTO_ARP:
 #ifdef CONFIG_NETFILTER_FAMILY_ARP
+   if (WARN_ON_ONCE(hook >= ARRAY_SIZE(net->nf.hooks_arp)))
+   break;
hook_head = rcu_dereference(net->nf.hooks_arp[hook]);
 #endif
break;
-- 
2.17.1





[PATCH 4.18 049/150] cfg80211: fix use-after-free in reg_process_hint()

2018-11-02 Thread Greg Kroah-Hartman
4.18-stable review patch.  If anyone has any objections, please let me know.

--

[ Upstream commit 1db58529454742f67ebd96e3588315e880b72837 ]

reg_process_hint_country_ie() can free regulatory_request and return
REG_REQ_ALREADY_SET. We shouldn't use regulatory_request after it's
called. KASAN error was observed when this happens.

BUG: KASAN: use-after-free in reg_process_hint+0x839/0x8aa [cfg80211]
Read of size 4 at addr 8800c430d434 by task kworker/1:3/89

Workqueue: events reg_todo [cfg80211]
Call Trace:
 dump_stack+0xc1/0x10c
 ? _atomic_dec_and_lock+0x1ad/0x1ad
 ? _raw_spin_lock_irqsave+0xa0/0xd2
 print_address_description+0x86/0x26f
 ? reg_process_hint+0x839/0x8aa [cfg80211]
 kasan_report+0x241/0x29b
 reg_process_hint+0x839/0x8aa [cfg80211]
 reg_todo+0x204/0x5b9 [cfg80211]
 process_one_work+0x55f/0x8d0
 ? worker_detach_from_pool+0x1b5/0x1b5
 ? _raw_spin_unlock_irq+0x65/0xdd
 ? _raw_spin_unlock_irqrestore+0xf3/0xf3
 worker_thread+0x5dd/0x841
 ? kthread_parkme+0x1d/0x1d
 kthread+0x270/0x285
 ? pr_cont_work+0xe3/0xe3
 ? rcu_read_unlock_sched_notrace+0xca/0xca
 ret_from_fork+0x22/0x40

Allocated by task 2718:
 set_track+0x63/0xfa
 __kmalloc+0x119/0x1ac
 regulatory_hint_country_ie+0x38/0x329 [cfg80211]
 __cfg80211_connect_result+0x854/0xadd [cfg80211]
 cfg80211_rx_assoc_resp+0x3bc/0x4f0 [cfg80211]
smsc95xx v1.0.6
 ieee80211_sta_rx_queued_mgmt+0x1803/0x7ed5 [mac80211]
 ieee80211_iface_work+0x411/0x696 [mac80211]
 process_one_work+0x55f/0x8d0
 worker_thread+0x5dd/0x841
 kthread+0x270/0x285
 ret_from_fork+0x22/0x40

Freed by task 89:
 set_track+0x63/0xfa
 kasan_slab_free+0x6a/0x87
 kfree+0xdc/0x470
 reg_process_hint+0x31e/0x8aa [cfg80211]
 reg_todo+0x204/0x5b9 [cfg80211]
 process_one_work+0x55f/0x8d0
 worker_thread+0x5dd/0x841
 kthread+0x270/0x285
 ret_from_fork+0x22/0x40


Signed-off-by: Yu Zhao 
Signed-off-by: Johannes Berg 
Signed-off-by: Sasha Levin 
---
 net/wireless/reg.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 765dedb12361..24cfa2776f50 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2661,11 +2661,12 @@ static void reg_process_hint(struct regulatory_request 
*reg_request)
 {
struct wiphy *wiphy = NULL;
enum reg_request_treatment treatment;
+   enum nl80211_reg_initiator initiator = reg_request->initiator;
 
if (reg_request->wiphy_idx != WIPHY_IDX_INVALID)
wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
 
-   switch (reg_request->initiator) {
+   switch (initiator) {
case NL80211_REGDOM_SET_BY_CORE:
treatment = reg_process_hint_core(reg_request);
break;
@@ -2683,7 +2684,7 @@ static void reg_process_hint(struct regulatory_request 
*reg_request)
treatment = reg_process_hint_country_ie(wiphy, reg_request);
break;
default:
-   WARN(1, "invalid initiator %d\n", reg_request->initiator);
+   WARN(1, "invalid initiator %d\n", initiator);
goto out_free;
}
 
@@ -2698,7 +2699,7 @@ static void reg_process_hint(struct regulatory_request 
*reg_request)
 */
if (treatment == REG_REQ_ALREADY_SET && wiphy &&
wiphy->regulatory_flags & REGULATORY_STRICT_REG) {
-   wiphy_update_regulatory(wiphy, reg_request->initiator);
+   wiphy_update_regulatory(wiphy, initiator);
wiphy_all_share_dfs_chan_state(wiphy);
reg_check_channels();
}
-- 
2.17.1





<    4   5   6   7   8   9   10   11   12   13   >