[PATCH 5.4 012/142] net: qrtr: Fix passing invalid reference to qrtr_local_enqueue()

2020-06-01 Thread Greg Kroah-Hartman
From: Manivannan Sadhasivam 

[ Upstream commit d28ea1fbbf437054ef339afec241019f2c4e2bb6 ]

Once the traversal of the list is completed with list_for_each_entry(),
the iterator (node) will point to an invalid object. So passing this to
qrtr_local_enqueue() which is outside of the iterator block is erroneous
eventhough the object is not used.

So fix this by passing NULL to qrtr_local_enqueue().

Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-by: kbuild test robot 
Reported-by: Julia Lawall 
Signed-off-by: Manivannan Sadhasivam 
Reviewed-by: Bjorn Andersson 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/qrtr/qrtr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -711,7 +711,7 @@ static int qrtr_bcast_enqueue(struct qrt
}
mutex_unlock(_node_lock);
 
-   qrtr_local_enqueue(node, skb, type, from, to);
+   qrtr_local_enqueue(NULL, skb, type, from, to);
 
return 0;
 }




[PATCH 5.4 027/142] net/tls: fix encryption error checking

2020-06-01 Thread Greg Kroah-Hartman
From: Vadim Fedorenko 

commit a7bff11f6f9afa87c25711db8050c9b5324db0e2 upstream.

bpf_exec_tx_verdict() can return negative value for copied
variable. In that case this value will be pushed back to caller
and the real error code will be lost. Fix it using signed type and
checking for positive value.

Fixes: d10523d0b3d7 ("net/tls: free the record on encryption error")
Fixes: d3b18ad31f93 ("tls: add bpf support to sk_msg handling")
Signed-off-by: Vadim Fedorenko 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 net/tls/tls_sw.c |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -781,7 +781,7 @@ static int tls_push_record(struct sock *
 
 static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk,
   bool full_record, u8 record_type,
-  size_t *copied, int flags)
+  ssize_t *copied, int flags)
 {
struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx);
@@ -917,7 +917,8 @@ int tls_sw_sendmsg(struct sock *sk, stru
unsigned char record_type = TLS_RECORD_TYPE_DATA;
bool is_kvec = iov_iter_is_kvec(>msg_iter);
bool eor = !(msg->msg_flags & MSG_MORE);
-   size_t try_to_copy, copied = 0;
+   size_t try_to_copy;
+   ssize_t copied = 0;
struct sk_msg *msg_pl, *msg_en;
struct tls_rec *rec;
int required_size;
@@ -1126,7 +1127,7 @@ send_end:
 
release_sock(sk);
mutex_unlock(_ctx->tx_lock);
-   return copied ? copied : ret;
+   return copied > 0 ? copied : ret;
 }
 
 static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
@@ -1140,7 +1141,7 @@ static int tls_sw_do_sendpage(struct soc
struct sk_msg *msg_pl;
struct tls_rec *rec;
int num_async = 0;
-   size_t copied = 0;
+   ssize_t copied = 0;
bool full_record;
int record_room;
int ret = 0;
@@ -1242,7 +1243,7 @@ wait_for_memory:
}
 sendpage_end:
ret = sk_stream_error(sk, flags, ret);
-   return copied ? copied : ret;
+   return copied > 0 ? copied : ret;
 }
 
 int tls_sw_sendpage_locked(struct sock *sk, struct page *page,




[PATCH 5.4 014/142] net sched: fix reporting the first-time use timestamp

2020-06-01 Thread Greg Kroah-Hartman
From: Roman Mashak 

[ Upstream commit b15e62631c5f19fea9895f7632dae9c1b27fe0cd ]

When a new action is installed, firstuse field of 'tcf_t' is explicitly set
to 0. Value of zero means "new action, not yet used"; as a packet hits the
action, 'firstuse' is stamped with the current jiffies value.

tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.

Fixes: 48d8ee1694dd ("net sched actions: aggregate dumping of actions timeinfo")
Cc: Jamal Hadi Salim 
Signed-off-by: Roman Mashak 
Acked-by: Jamal Hadi Salim 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 include/net/act_api.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -69,7 +69,8 @@ static inline void tcf_tm_dump(struct tc
 {
dtm->install = jiffies_to_clock_t(jiffies - stm->install);
dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse);
-   dtm->firstuse = jiffies_to_clock_t(jiffies - stm->firstuse);
+   dtm->firstuse = stm->firstuse ?
+   jiffies_to_clock_t(jiffies - stm->firstuse) : 0;
dtm->expires = jiffies_to_clock_t(stm->expires);
 }
 




[PATCH 5.4 031/142] mlxsw: spectrum: Fix use-after-free of split/unsplit/type_set in case reload fails

2020-06-01 Thread Greg Kroah-Hartman
From: Jiri Pirko 

commit 4340f42f207eacb81e7a6b6bb1e3b6afad9a2e26 upstream.

In case of reload fail, the mlxsw_sp->ports contains a pointer to a
freed memory (either by reload_down() or reload_up() error path).
Fix this by initializing the pointer to NULL and checking it before
dereferencing in split/unsplit/type_set callpaths.

Fixes: 24cc68ad6c46 ("mlxsw: core: Add support for reload")
Reported-by: Danielle Ratson 
Signed-off-by: Jiri Pirko 
Signed-off-by: Ido Schimmel 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c |   14 --
 drivers/net/ethernet/mellanox/mlxsw/switchx2.c |8 
 2 files changed, 20 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3932,6 +3932,7 @@ static void mlxsw_sp_ports_remove(struct
mlxsw_sp_cpu_port_remove(mlxsw_sp);
kfree(mlxsw_sp->port_to_module);
kfree(mlxsw_sp->ports);
+   mlxsw_sp->ports = NULL;
 }
 
 static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
@@ -3986,6 +3987,7 @@ err_cpu_port_create:
kfree(mlxsw_sp->port_to_module);
 err_port_to_module_alloc:
kfree(mlxsw_sp->ports);
+   mlxsw_sp->ports = NULL;
return err;
 }
 
@@ -4040,6 +4042,14 @@ static void mlxsw_sp_port_unsplit_create
}
 }
 
+static struct mlxsw_sp_port *
+mlxsw_sp_port_get_by_local_port(struct mlxsw_sp *mlxsw_sp, u8 local_port)
+{
+   if (mlxsw_sp->ports && mlxsw_sp->ports[local_port])
+   return mlxsw_sp->ports[local_port];
+   return NULL;
+}
+
 static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port,
   unsigned int count,
   struct netlink_ext_ack *extack)
@@ -4058,7 +4068,7 @@ static int mlxsw_sp_port_split(struct ml
local_ports_in_1x = MLXSW_CORE_RES_GET(mlxsw_core, LOCAL_PORTS_IN_1X);
local_ports_in_2x = MLXSW_CORE_RES_GET(mlxsw_core, LOCAL_PORTS_IN_2X);
 
-   mlxsw_sp_port = mlxsw_sp->ports[local_port];
+   mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port);
if (!mlxsw_sp_port) {
dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not 
exist\n",
local_port);
@@ -4136,7 +4146,7 @@ static int mlxsw_sp_port_unsplit(struct
local_ports_in_1x = MLXSW_CORE_RES_GET(mlxsw_core, LOCAL_PORTS_IN_1X);
local_ports_in_2x = MLXSW_CORE_RES_GET(mlxsw_core, LOCAL_PORTS_IN_2X);
 
-   mlxsw_sp_port = mlxsw_sp->ports[local_port];
+   mlxsw_sp_port = mlxsw_sp_port_get_by_local_port(mlxsw_sp, local_port);
if (!mlxsw_sp_port) {
dev_err(mlxsw_sp->bus_info->dev, "Port number \"%d\" does not 
exist\n",
local_port);
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -1258,6 +1258,7 @@ static void mlxsw_sx_ports_remove(struct
if (mlxsw_sx_port_created(mlxsw_sx, i))
mlxsw_sx_port_remove(mlxsw_sx, i);
kfree(mlxsw_sx->ports);
+   mlxsw_sx->ports = NULL;
 }
 
 static int mlxsw_sx_ports_create(struct mlxsw_sx *mlxsw_sx)
@@ -1292,6 +1293,7 @@ err_port_module_info_get:
if (mlxsw_sx_port_created(mlxsw_sx, i))
mlxsw_sx_port_remove(mlxsw_sx, i);
kfree(mlxsw_sx->ports);
+   mlxsw_sx->ports = NULL;
return err;
 }
 
@@ -1375,6 +1377,12 @@ static int mlxsw_sx_port_type_set(struct
u8 module, width;
int err;
 
+   if (!mlxsw_sx->ports || !mlxsw_sx->ports[local_port]) {
+   dev_err(mlxsw_sx->bus_info->dev, "Port number \"%d\" does not 
exist\n",
+   local_port);
+   return -EINVAL;
+   }
+
if (new_type == DEVLINK_PORT_TYPE_AUTO)
return -EOPNOTSUPP;
 




[PATCH 5.4 030/142] net/mlx4_core: fix a memory leak bug.

2020-06-01 Thread Greg Kroah-Hartman
From: Qiushi Wu 

commit febfd9d3c7f74063e8e630b15413ca91b567f963 upstream.

In function mlx4_opreq_action(), pointer "mailbox" is not released,
when mlx4_cmd_box() return and error, causing a memory leak bug.
Fix this issue by going to "out" label, mlx4_free_cmd_mailbox() can
free this pointer.

Fixes: fe6f700d6cbb ("net/mlx4_core: Respond to operation request by firmware")
Signed-off-by: Qiushi Wu 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/mellanox/mlx4/fw.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -2734,7 +2734,7 @@ void mlx4_opreq_action(struct work_struc
if (err) {
mlx4_err(dev, "Failed to retrieve required operation: 
%d\n",
 err);
-   return;
+   goto out;
}
MLX4_GET(modifier, outbox, GET_OP_REQ_MODIFIER_OFFSET);
MLX4_GET(token, outbox, GET_OP_REQ_TOKEN_OFFSET);




[PATCH 4.19 78/95] xfrm: fix a warning in xfrm_policy_insert_list

2020-06-01 Thread Greg Kroah-Hartman
From: Xin Long 

commit ed17b8d377eaf6b4a01d46942b4c647378a79bdd upstream.

This waring can be triggered simply by:

  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 1 mark 0 mask 0x10  #[1]
  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 2 mark 0 mask 0x1   #[2]
  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 2 mark 0 mask 0x10  #[3]

Then dmesg shows:

  [ ] WARNING: CPU: 1 PID: 7265 at net/xfrm/xfrm_policy.c:1548
  [ ] RIP: 0010:xfrm_policy_insert_list+0x2f2/0x1030
  [ ] Call Trace:
  [ ]  xfrm_policy_inexact_insert+0x85/0xe50
  [ ]  xfrm_policy_insert+0x4ba/0x680
  [ ]  xfrm_add_policy+0x246/0x4d0
  [ ]  xfrm_user_rcv_msg+0x331/0x5c0
  [ ]  netlink_rcv_skb+0x121/0x350
  [ ]  xfrm_netlink_rcv+0x66/0x80
  [ ]  netlink_unicast+0x439/0x630
  [ ]  netlink_sendmsg+0x714/0xbf0
  [ ]  sock_sendmsg+0xe2/0x110

The issue was introduced by Commit 7cb8a93968e3 ("xfrm: Allow inserting
policies with matching mark and different priorities"). After that, the
policies [1] and [2] would be able to be added with different priorities.

However, policy [3] will actually match both [1] and [2]. Policy [1]
was matched due to the 1st 'return true' in xfrm_policy_mark_match(),
and policy [2] was matched due to the 2nd 'return true' in there. It
caused WARN_ON() in xfrm_policy_insert_list().

This patch is to fix it by only (the same value and priority) as the
same policy in xfrm_policy_mark_match().

Thanks to Yuehaibing, we could make this fix better.

v1->v2:
  - check policy->mark.v == pol->mark.v only without mask.

Fixes: 7cb8a93968e3 ("xfrm: Allow inserting policies with matching mark and 
different priorities")
Reported-by: Xiumei Mu 
Signed-off-by: Xin Long 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 net/xfrm/xfrm_policy.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -730,12 +730,7 @@ static void xfrm_policy_requeue(struct x
 static bool xfrm_policy_mark_match(struct xfrm_policy *policy,
   struct xfrm_policy *pol)
 {
-   u32 mark = policy->mark.v & policy->mark.m;
-
-   if (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m)
-   return true;
-
-   if ((mark & pol->mark.m) == pol->mark.v &&
+   if (policy->mark.v == pol->mark.v &&
policy->priority == pol->priority)
return true;
 




[PATCH 4.19 80/95] xfrm: fix error in comment

2020-06-01 Thread Greg Kroah-Hartman
From: Antony Antony 

commit 29e4276667e24ee6b91d9f91064d8fda9a210ea1 upstream.

s/xfrm_state_offload/xfrm_user_offload/

Fixes: d77e38e612a ("xfrm: Add an IPsec hardware offloading API")
Signed-off-by: Antony Antony 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 include/uapi/linux/xfrm.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -304,7 +304,7 @@ enum xfrm_attr_type_t {
XFRMA_PROTO,/* __u8 */
XFRMA_ADDRESS_FILTER,   /* struct xfrm_address_filter */
XFRMA_PAD,
-   XFRMA_OFFLOAD_DEV,  /* struct xfrm_state_offload */
+   XFRMA_OFFLOAD_DEV,  /* struct xfrm_user_offload */
XFRMA_SET_MARK, /* __u32 */
XFRMA_SET_MARK_MASK,/* __u32 */
XFRMA_IF_ID,/* __u32 */




[PATCH 4.19 81/95] vti4: eliminated some duplicate code.

2020-06-01 Thread Greg Kroah-Hartman
From: Jeremy Sowden 

commit f981c57ffd2d7cf2dd4b6d6f8fcb3965df42f54c upstream.

The ipip tunnel introduced in commit dd9ee3444014 ("vti4: Fix a ipip
packet processing bug in 'IPCOMP' virtual tunnel") largely duplicated
the existing vti_input and vti_recv functions.  Refactored to
deduplicate the common code.

Signed-off-by: Jeremy Sowden 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 net/ipv4/ip_vti.c |   60 +++---
 1 file changed, 22 insertions(+), 38 deletions(-)

--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -50,7 +50,7 @@ static unsigned int vti_net_id __read_mo
 static int vti_tunnel_init(struct net_device *dev);
 
 static int vti_input(struct sk_buff *skb, int nexthdr, __be32 spi,
-int encap_type)
+int encap_type, bool update_skb_dev)
 {
struct ip_tunnel *tunnel;
const struct iphdr *iph = ip_hdr(skb);
@@ -65,6 +65,9 @@ static int vti_input(struct sk_buff *skb
 
XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = tunnel;
 
+   if (update_skb_dev)
+   skb->dev = tunnel->dev;
+
return xfrm_input(skb, nexthdr, spi, encap_type);
}
 
@@ -74,47 +77,28 @@ drop:
return 0;
 }
 
-static int vti_input_ipip(struct sk_buff *skb, int nexthdr, __be32 spi,
-int encap_type)
+static int vti_input_proto(struct sk_buff *skb, int nexthdr, __be32 spi,
+  int encap_type)
 {
-   struct ip_tunnel *tunnel;
-   const struct iphdr *iph = ip_hdr(skb);
-   struct net *net = dev_net(skb->dev);
-   struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
-
-   tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
- iph->saddr, iph->daddr, 0);
-   if (tunnel) {
-   if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
-   goto drop;
-
-   XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = tunnel;
-
-   skb->dev = tunnel->dev;
-
-   return xfrm_input(skb, nexthdr, spi, encap_type);
-   }
-
-   return -EINVAL;
-drop:
-   kfree_skb(skb);
-   return 0;
+   return vti_input(skb, nexthdr, spi, encap_type, false);
 }
 
-static int vti_rcv(struct sk_buff *skb)
+static int vti_rcv(struct sk_buff *skb, __be32 spi, bool update_skb_dev)
 {
XFRM_SPI_SKB_CB(skb)->family = AF_INET;
XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr);
 
-   return vti_input(skb, ip_hdr(skb)->protocol, 0, 0);
+   return vti_input(skb, ip_hdr(skb)->protocol, spi, 0, update_skb_dev);
 }
 
-static int vti_rcv_ipip(struct sk_buff *skb)
+static int vti_rcv_proto(struct sk_buff *skb)
 {
-   XFRM_SPI_SKB_CB(skb)->family = AF_INET;
-   XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr);
+   return vti_rcv(skb, 0, false);
+}
 
-   return vti_input_ipip(skb, ip_hdr(skb)->protocol, ip_hdr(skb)->saddr, 
0);
+static int vti_rcv_tunnel(struct sk_buff *skb)
+{
+   return vti_rcv(skb, ip_hdr(skb)->saddr, true);
 }
 
 static int vti_rcv_cb(struct sk_buff *skb, int err)
@@ -478,31 +462,31 @@ static void __net_init vti_fb_tunnel_ini
 }
 
 static struct xfrm4_protocol vti_esp4_protocol __read_mostly = {
-   .handler=   vti_rcv,
-   .input_handler  =   vti_input,
+   .handler=   vti_rcv_proto,
+   .input_handler  =   vti_input_proto,
.cb_handler =   vti_rcv_cb,
.err_handler=   vti4_err,
.priority   =   100,
 };
 
 static struct xfrm4_protocol vti_ah4_protocol __read_mostly = {
-   .handler=   vti_rcv,
-   .input_handler  =   vti_input,
+   .handler=   vti_rcv_proto,
+   .input_handler  =   vti_input_proto,
.cb_handler =   vti_rcv_cb,
.err_handler=   vti4_err,
.priority   =   100,
 };
 
 static struct xfrm4_protocol vti_ipcomp4_protocol __read_mostly = {
-   .handler=   vti_rcv,
-   .input_handler  =   vti_input,
+   .handler=   vti_rcv_proto,
+   .input_handler  =   vti_input_proto,
.cb_handler =   vti_rcv_cb,
.err_handler=   vti4_err,
.priority   =   100,
 };
 
 static struct xfrm_tunnel ipip_handler __read_mostly = {
-   .handler=   vti_rcv_ipip,
+   .handler=   vti_rcv_tunnel,
.err_handler=   vti4_err,
.priority   =   0,
 };




[PATCH 4.19 76/95] xfrm: call xfrm_output_gso when inner_protocol is set in xfrm_output

2020-06-01 Thread Greg Kroah-Hartman
From: Xin Long 

commit a204aef9fd77dce1efd9066ca4e44eede99cd858 upstream.

An use-after-free crash can be triggered when sending big packets over
vxlan over esp with esp offload enabled:

  [] BUG: KASAN: use-after-free in ipv6_gso_pull_exthdrs.part.8+0x32c/0x4e0
  [] Call Trace:
  []  dump_stack+0x75/0xa0
  []  kasan_report+0x37/0x50
  []  ipv6_gso_pull_exthdrs.part.8+0x32c/0x4e0
  []  ipv6_gso_segment+0x2c8/0x13c0
  []  skb_mac_gso_segment+0x1cb/0x420
  []  skb_udp_tunnel_segment+0x6b5/0x1c90
  []  inet_gso_segment+0x440/0x1380
  []  skb_mac_gso_segment+0x1cb/0x420
  []  esp4_gso_segment+0xae8/0x1709 [esp4_offload]
  []  inet_gso_segment+0x440/0x1380
  []  skb_mac_gso_segment+0x1cb/0x420
  []  __skb_gso_segment+0x2d7/0x5f0
  []  validate_xmit_skb+0x527/0xb10
  []  __dev_queue_xmit+0x10f8/0x2320 <---
  []  ip_finish_output2+0xa2e/0x1b50
  []  ip_output+0x1a8/0x2f0
  []  xfrm_output_resume+0x110e/0x15f0
  []  __xfrm4_output+0xe1/0x1b0
  []  xfrm4_output+0xa0/0x200
  []  iptunnel_xmit+0x5a7/0x920
  []  vxlan_xmit_one+0x1658/0x37a0 [vxlan]
  []  vxlan_xmit+0x5e4/0x3ec8 [vxlan]
  []  dev_hard_start_xmit+0x125/0x540
  []  __dev_queue_xmit+0x17bd/0x2320  <---
  []  ip6_finish_output2+0xb20/0x1b80
  []  ip6_output+0x1b3/0x390
  []  ip6_xmit+0xb82/0x17e0
  []  inet6_csk_xmit+0x225/0x3d0
  []  __tcp_transmit_skb+0x1763/0x3520
  []  tcp_write_xmit+0xd64/0x5fe0
  []  __tcp_push_pending_frames+0x8c/0x320
  []  tcp_sendmsg_locked+0x2245/0x3500
  []  tcp_sendmsg+0x27/0x40

As on the tx path of vxlan over esp, skb->inner_network_header would be
set on vxlan_xmit() and xfrm4_tunnel_encap_add(), and the later one can
overwrite the former one. It causes skb_udp_tunnel_segment() to use a
wrong skb->inner_network_header, then the issue occurs.

This patch is to fix it by calling xfrm_output_gso() instead when the
inner_protocol is set, in which gso_segment of inner_protocol will be
done first.

While at it, also improve some code around.

Fixes: 7862b4058b9f ("esp: Add gso handlers for esp4 and esp6")
Reported-by: Xiumei Mu 
Signed-off-by: Xin Long 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 net/xfrm/xfrm_output.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -235,18 +235,20 @@ int xfrm_output(struct sock *sk, struct
xfrm_state_hold(x);
 
if (skb_is_gso(skb)) {
-   skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
+   if (skb->inner_protocol)
+   return xfrm_output_gso(net, sk, skb);
 
-   return xfrm_output2(net, sk, skb);
+   skb_shinfo(skb)->gso_type |= SKB_GSO_ESP;
+   goto out;
}
 
if (x->xso.dev && x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM)
goto out;
+   } else {
+   if (skb_is_gso(skb))
+   return xfrm_output_gso(net, sk, skb);
}
 
-   if (skb_is_gso(skb))
-   return xfrm_output_gso(net, sk, skb);
-
if (skb->ip_summed == CHECKSUM_PARTIAL) {
err = skb_checksum_help(skb);
if (err) {




[PATCH 4.19 90/95] qlcnic: fix missing release in qlcnic_83xx_interrupt_test.

2020-06-01 Thread Greg Kroah-Hartman
From: Qiushi Wu 

commit 15c973858903009e995b2037683de29dfe968621 upstream.

In function qlcnic_83xx_interrupt_test(), function
qlcnic_83xx_diag_alloc_res() is not handled by function
qlcnic_83xx_diag_free_res() after a call of the function
qlcnic_alloc_mbx_args() failed. Fix this issue by adding
a jump target "fail_mbx_args", and jump to this new target
when qlcnic_alloc_mbx_args() failed.

Fixes: b6b4316c8b2f ("qlcnic: Handle qlcnic_alloc_mbx_args() failure")
Signed-off-by: Qiushi Wu 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -3651,7 +3651,7 @@ int qlcnic_83xx_interrupt_test(struct ne
ahw->diag_cnt = 0;
ret = qlcnic_alloc_mbx_args(, adapter, QLCNIC_CMD_INTRPT_TEST);
if (ret)
-   goto fail_diag_irq;
+   goto fail_mbx_args;
 
if (adapter->flags & QLCNIC_MSIX_ENABLED)
intrpt_id = ahw->intr_tbl[0].id;
@@ -3681,6 +3681,8 @@ int qlcnic_83xx_interrupt_test(struct ne
 
 done:
qlcnic_free_mbx_args();
+
+fail_mbx_args:
qlcnic_83xx_diag_free_res(netdev, drv_sds_rings);
 
 fail_diag_irq:




[PATCH 5.4 010/142] net: mvpp2: fix RX hashing for non-10G ports

2020-06-01 Thread Greg Kroah-Hartman
From: Russell King 

[ Upstream commit 3138a07ce219acde4c0d7ea0b6d54ba64153328b ]

When rxhash is enabled on any ethernet port except the first in each CP
block, traffic flow is prevented.  The analysis is below:

I've been investigating this afternoon, and what I've found, comparing
a kernel without 895586d5dc32 and with 895586d5dc32 applied is:

- The table programmed into the hardware via mvpp22_rss_fill_table()
  appears to be identical with or without the commit.

- When rxhash is enabled on eth2, mvpp2_rss_port_c2_enable() reports
  that c2.attr[0] and c2.attr[2] are written back containing:

   - with 895586d5dc32, failing:0020 4000
   - without 895586d5dc32, working: 0400 4000

- When disabling rxhash, c2.attr[0] and c2.attr[2] are written back as:

   0400 

The second value represents the MVPP22_CLS_C2_ATTR2_RSS_EN bit, the
first value is the queue number, which comprises two fields. The high
5 bits are 24:29 and the low three are 21:23 inclusive. This comes
from:

   c2.attr[0] = MVPP22_CLS_C2_ATTR0_QHIGH(qh) |
 MVPP22_CLS_C2_ATTR0_QLOW(ql);

So, the working case gives eth2 a queue id of 4.0, or 32 as per
port->first_rxq, and the non-working case a queue id of 0.1, or 1.
The allocation of queue IDs seems to be in mvpp2_port_probe():

if (priv->hw_version == MVPP21)
port->first_rxq = port->id * port->nrxqs;
else
port->first_rxq = port->id * priv->max_port_rxqs;

Where:

if (priv->hw_version == MVPP21)
priv->max_port_rxqs = 8;
else
priv->max_port_rxqs = 32;

Making the port 0 (eth0 / eth1) have port->first_rxq = 0, and port 1
(eth2) be 32. It seems the idea is that the first 32 queues belong to
port 0, the second 32 queues belong to port 1, etc.

mvpp2_rss_port_c2_enable() gets the queue number from it's parameter,
'ctx', which comes from mvpp22_rss_ctx(port, 0). This returns
port->rss_ctx[0].

mvpp22_rss_context_create() is responsible for allocating that, which
it does by looking for an unallocated priv->rss_tables[] pointer. This
table is shared amongst all ports on the CP silicon.

When we write the tables in mvpp22_rss_fill_table(), the RSS table
entry is defined by:

u32 sel = MVPP22_RSS_INDEX_TABLE(rss_ctx) |
  MVPP22_RSS_INDEX_TABLE_ENTRY(i);

where rss_ctx is the context ID (queue number) and i is the index in
the table.

If we look at what is written:

- The first table to be written has "sel" values of ..001f,
  containing values 0..3. This appears to be for eth1. This is table 0,
  RX queue number 0.
- The second table has "sel" values of 0100..011f, and appears
  to be for eth2.  These contain values 0x20..0x23. This is table 1,
  RX queue number 0.
- The third table has "sel" values of 0200..021f, and appears
  to be for eth3.  These contain values 0x40..0x43. This is table 2,
  RX queue number 0.

How do queue numbers translate to the RSS table?  There is another
table - the RXQ2RSS table, indexed by the MVPP22_RSS_INDEX_QUEUE field
of MVPP22_RSS_INDEX and accessed through the MVPP22_RXQ2RSS_TABLE
register. Before 895586d5dc32, it was:

   mvpp2_write(priv, MVPP22_RSS_INDEX,
   MVPP22_RSS_INDEX_QUEUE(port->first_rxq));
   mvpp2_write(priv, MVPP22_RXQ2RSS_TABLE,
   MVPP22_RSS_TABLE_POINTER(port->id));

and after:

   mvpp2_write(priv, MVPP22_RSS_INDEX, MVPP22_RSS_INDEX_QUEUE(ctx));
   mvpp2_write(priv, MVPP22_RXQ2RSS_TABLE, MVPP22_RSS_TABLE_POINTER(ctx));

Before the commit, for eth2, that would've contained '32' for the
index and '1' for the table pointer - mapping queue 32 to table 1.
Remember that this is queue-high.queue-low of 4.0.

After the commit, we appear to map queue 1 to table 1. That again
looks fine on the face of it.

Section 9.3.1 of the A8040 manual seems indicate the reason that the
queue number is separated. queue-low seems to always come from the
classifier, whereas queue-high can be from the ingress physical port
number or the classifier depending on the MVPP2_CLS_SWFWD_PCTRL_REG.

We set the port bit in MVPP2_CLS_SWFWD_PCTRL_REG, meaning that queue-high
comes from the MVPP2_CLS_SWFWD_P2HQ_REG() register... and this seems to
be where our bug comes from.

mvpp2_cls_oversize_rxq_set() sets this up as:

mvpp2_write(port->priv, MVPP2_CLS_SWFWD_P2HQ_REG(port->id),
(port->first_rxq >> MVPP2_CLS_OVERSIZE_RXQ_LOW_BITS));

val = mvpp2_read(port->priv, MVPP2_CLS_SWFWD_PCTRL_REG);
val |= MVPP2_CLS_SWFWD_PCTRL_MASK(port->id);
mvpp2_write(port->priv, MVPP2_CLS_SWFWD_PCTRL_REG, val);

Setting the MVPP2_CLS_SWFWD_PCTRL_MASK bit means that the queue-high
for eth2 is _always_ 4, so only queues 32 through 39 inclusive are
available to eth2. Yet, we're trying to tell the classifier to set
queue-high, which will be ignored, to zero. Hence, the queue-high
field 

vimc: Add color descriptions to test image

2020-06-01 Thread Kaaira Gupta
On Mon, Jun 01, 2020 at 01:36:59PM -0300, Helen Koike wrote:
> 
> 
> On 6/1/20 10:53 AM, Kaaira Gupta wrote:
> > Hi!
> > 
> > Currently there is no method to know if the test image generated by vimc
> > is correct (except for comparing it with a known 'correct' image). So, I
> > wanted to investigate about a possibility to add text to each color bar
> > of the generated pattern. I think currently vivid supports this
> > functionality as an optional control, so can we move it to a common 
> > platform so that both VIVID and VIMC can supoort it?
> > 
> > Thanks,
> > Kaaira
> > 
> 
> If it is useful I don't oppose, but I'm not sure how this is implemented
> in vivid (or if it is in tpg).
> I guess it is easier to judge from an RFC code :)

I am sorry for the confusion. Kieran pointed it out to me that vivid
does not print the values of colors to check if they are right or not.
It prints other useful information. As for vimc we want the order of
test image color to be printed so that it can be checked if the visible
order is correct. 

> 
> Regards,
> Helen


[PATCH 4.19 89/95] xsk: Add overflow check for u64 division, stored into u32

2020-06-01 Thread Greg Kroah-Hartman
From: Björn Töpel 

commit b16a87d0aef7a6be766f6618976dc5ff2c689291 upstream.

The npgs member of struct xdp_umem is an u32 entity, and stores the
number of pages the UMEM consumes. The calculation of npgs

  npgs = size / PAGE_SIZE

can overflow.

To avoid overflow scenarios, the division is now first stored in a
u64, and the result is verified to fit into 32b.

An alternative would be storing the npgs as a u64, however, this
wastes memory and is an unrealisticly large packet area.

Fixes: c0c77d8fb787 ("xsk: add user memory registration support sockopt")
Reported-by: "Minh Bùi Quang" 
Signed-off-by: Björn Töpel 
Signed-off-by: Daniel Borkmann 
Acked-by: Jonathan Lemon 
Link: 
https://lore.kernel.org/bpf/CACtPs=ggvv-_yj6rbpztvnopgi5nhmocctkskyrjhgqhjwf...@mail.gmail.com/
Link: https://lore.kernel.org/bpf/20200525080400.13195-1-bjorn.to...@gmail.com
Signed-off-by: Greg Kroah-Hartman 

---
 net/xdp/xdp_umem.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -258,8 +258,8 @@ static int xdp_umem_account_pages(struct
 static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
 {
u32 chunk_size = mr->chunk_size, headroom = mr->headroom;
+   u64 npgs, addr = mr->addr, size = mr->len;
unsigned int chunks, chunks_per_page;
-   u64 addr = mr->addr, size = mr->len;
int err, i;
 
if (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) {
@@ -285,6 +285,10 @@ static int xdp_umem_reg(struct xdp_umem
if ((addr + size) < addr)
return -EINVAL;
 
+   npgs = div_u64(size, PAGE_SIZE);
+   if (npgs > U32_MAX)
+   return -EINVAL;
+
chunks = (unsigned int)div_u64(size, chunk_size);
if (chunks == 0)
return -EINVAL;
@@ -303,7 +307,7 @@ static int xdp_umem_reg(struct xdp_umem
umem->props.size = size;
umem->headroom = headroom;
umem->chunk_size_nohr = chunk_size - headroom;
-   umem->npgs = size / PAGE_SIZE;
+   umem->npgs = (u32)npgs;
umem->pgs = NULL;
umem->user = NULL;
INIT_LIST_HEAD(>xsk_list);




[PATCH 4.19 74/95] copy_xstate_to_kernel(): dont leave parts of destination uninitialized

2020-06-01 Thread Greg Kroah-Hartman
From: Al Viro 

commit 9e4636545933131de15e1ecd06733538ae939b2f upstream.

copy the corresponding pieces of init_fpstate into the gaps instead.

Cc: sta...@kernel.org
Tested-by: Alexander Potapenko 
Acked-by: Borislav Petkov 
Signed-off-by: Al Viro 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kernel/fpu/xstate.c |   86 ---
 1 file changed, 48 insertions(+), 38 deletions(-)

--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -964,18 +964,31 @@ static inline bool xfeatures_mxcsr_quirk
return true;
 }
 
-/*
- * This is similar to user_regset_copyout(), but will not add offset to
- * the source data pointer or increment pos, count, kbuf, and ubuf.
- */
-static inline void
-__copy_xstate_to_kernel(void *kbuf, const void *data,
-   unsigned int offset, unsigned int size, unsigned int 
size_total)
+static void fill_gap(unsigned to, void **kbuf, unsigned *pos, unsigned *count)
 {
-   if (offset < size_total) {
-   unsigned int copy = min(size, size_total - offset);
+   if (*pos < to) {
+   unsigned size = to - *pos;
+
+   if (size > *count)
+   size = *count;
+   memcpy(*kbuf, (void *)_fpstate.xsave + *pos, size);
+   *kbuf += size;
+   *pos += size;
+   *count -= size;
+   }
+}
 
-   memcpy(kbuf + offset, data, copy);
+static void copy_part(unsigned offset, unsigned size, void *from,
+   void **kbuf, unsigned *pos, unsigned *count)
+{
+   fill_gap(offset, kbuf, pos, count);
+   if (size > *count)
+   size = *count;
+   if (size) {
+   memcpy(*kbuf, from, size);
+   *kbuf += size;
+   *pos += size;
+   *count -= size;
}
 }
 
@@ -988,8 +1001,9 @@ __copy_xstate_to_kernel(void *kbuf, cons
  */
 int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int 
offset_start, unsigned int size_total)
 {
-   unsigned int offset, size;
struct xstate_header header;
+   const unsigned off_mxcsr = offsetof(struct fxregs_state, mxcsr);
+   unsigned count = size_total;
int i;
 
/*
@@ -1005,46 +1019,42 @@ int copy_xstate_to_kernel(void *kbuf, st
header.xfeatures = xsave->header.xfeatures;
header.xfeatures &= ~XFEATURE_MASK_SUPERVISOR;
 
+   if (header.xfeatures & XFEATURE_MASK_FP)
+   copy_part(0, off_mxcsr,
+ >i387, , _start, );
+   if (header.xfeatures & (XFEATURE_MASK_SSE | XFEATURE_MASK_YMM))
+   copy_part(off_mxcsr, MXCSR_AND_FLAGS_SIZE,
+ >i387.mxcsr, , _start, );
+   if (header.xfeatures & XFEATURE_MASK_FP)
+   copy_part(offsetof(struct fxregs_state, st_space), 128,
+ >i387.st_space, , _start, );
+   if (header.xfeatures & XFEATURE_MASK_SSE)
+   copy_part(xstate_offsets[XFEATURE_MASK_SSE], 256,
+ >i387.xmm_space, , _start, );
+   /*
+* Fill xsave->i387.sw_reserved value for ptrace frame:
+*/
+   copy_part(offsetof(struct fxregs_state, sw_reserved), 48,
+ xstate_fx_sw_bytes, , _start, );
/*
 * Copy xregs_state->header:
 */
-   offset = offsetof(struct xregs_state, header);
-   size = sizeof(header);
-
-   __copy_xstate_to_kernel(kbuf, , offset, size, size_total);
+   copy_part(offsetof(struct xregs_state, header), sizeof(header),
+ , , _start, );
 
-   for (i = 0; i < XFEATURE_MAX; i++) {
+   for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
/*
 * Copy only in-use xstates:
 */
if ((header.xfeatures >> i) & 1) {
void *src = __raw_xsave_addr(xsave, 1 << i);
 
-   offset = xstate_offsets[i];
-   size = xstate_sizes[i];
-
-   /* The next component has to fit fully into the output 
buffer: */
-   if (offset + size > size_total)
-   break;
-
-   __copy_xstate_to_kernel(kbuf, src, offset, size, 
size_total);
+   copy_part(xstate_offsets[i], xstate_sizes[i],
+ src, , _start, );
}
 
}
-
-   if (xfeatures_mxcsr_quirk(header.xfeatures)) {
-   offset = offsetof(struct fxregs_state, mxcsr);
-   size = MXCSR_AND_FLAGS_SIZE;
-   __copy_xstate_to_kernel(kbuf, >i387.mxcsr, offset, size, 
size_total);
-   }
-
-   /*
-* Fill xsave->i387.sw_reserved value for ptrace frame:
-*/
-   offset = offsetof(struct fxregs_state, sw_reserved);
-   size = sizeof(xstate_fx_sw_bytes);
-
-   __copy_xstate_to_kernel(kbuf, xstate_fx_sw_bytes, 

[PATCH 4.19 91/95] crypto: chelsio/chtls: properly set tp->lsndtime

2020-06-01 Thread Greg Kroah-Hartman
From: Eric Dumazet 

commit a4976a3ef844c510ae9120290b23e9f3f47d6bce upstream.

TCP tp->lsndtime unit/base is tcp_jiffies32, not tcp_time_stamp()

Fixes: 36bedb3f2e5b ("crypto: chtls - Inline TLS record Tx")
Signed-off-by: Eric Dumazet 
Cc: Ayush Sawal 
Cc: Vinay Kumar Yadav 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/crypto/chelsio/chtls/chtls_io.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/crypto/chelsio/chtls/chtls_io.c
+++ b/drivers/crypto/chelsio/chtls/chtls_io.c
@@ -686,7 +686,7 @@ int chtls_push_frames(struct chtls_sock
make_tx_data_wr(sk, skb, immdlen, len,
credits_needed, completion);
tp->snd_nxt += len;
-   tp->lsndtime = tcp_time_stamp(tp);
+   tp->lsndtime = tcp_jiffies32;
if (completion)
ULP_SKB_CB(skb)->flags &= ~ULPCB_FLAG_NEED_HDR;
} else {




[PATCH 4.19 93/95] Revert "Input: i8042 - add ThinkPad S230u to i8042 nomux list"

2020-06-01 Thread Greg Kroah-Hartman
From: Dmitry Torokhov 

commit f4dec2d6160976b14e54be9c3950ce0f52385741 upstream.

This reverts commit 18931506465a762ffd3f4803d36a18d336a67da9. From Kevin
Locke:

"... nomux only appeared to fix the issue because the controller
continued working after warm reboots. After more thorough testing from
both warm and cold start, I now believe the entry should be added to
i8042_dmi_reset_table rather than i8042_dmi_nomux_table as i8042.reset=1
alone is sufficient to avoid the issue from both states while
i8042.nomux is not."

Signed-off-by: Greg Kroah-Hartman 

---
 drivers/input/serio/i8042-x86ia64io.h |7 ---
 1 file changed, 7 deletions(-)

--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -545,13 +545,6 @@ static const struct dmi_system_id __init
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
},
},
-   {
-   /* Lenovo ThinkPad Twist S230u */
-   .matches = {
-   DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-   DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"),
-   },
-   },
{ }
 };
 




Re: Question: livepatch failed for new fork() task stack unreliable

2020-06-01 Thread Josh Poimboeuf
On Sat, May 30, 2020 at 10:21:19AM +0800, Wangshaobo (bobo) wrote:
> 1) when a user mode task just fork start excuting ret_from_fork() till
> schedule_tail, unwind_next_frame found
> 
> orc->sp_reg is ORC_REG_UNDEFINED but orc->end not equals zero, this time
> arch_stack_walk_reliable()
> 
> terminates it's backtracing loop for unwind_done() return true. then 'if
> (!(task->flags & (PF_KTHREAD | PF_IDLE)))'
> 
> in arch_stack_walk_reliable() true and return -EINVAL after.
> 
> * The stack trace looks like that:
> 
> ret_from_fork
> 
>   -=> UNWIND_HINT_EMPTY
> 
>   -=> schedule_tail /* schedule out */
> 
>   ...
> 
>   -=> UNWIND_HINT_REGS  /*  UNDO */

Yes, makes sense.

> 2) when using call_usermodehelper_exec_async() to create a user mode task,
> ret_from_fork() still not exec whereas
> 
> the task has been scheduled in __schedule(), at this time, orc->sp_reg is
> ORC_REG_UNDEFINED but orc->end equals zero,
> 
> unwind_error() return true and also terminates arch_stack_walk_reliable()'s
> backtracing loop, end up return from
> 
> 'if (unwind_error())' branch.
> 
> * The stack trace looks like that:
> 
> -=> call_usermodehelper_exec
> 
>                  -=> do_exec
> 
>    -=> search_binary_handler
> 
>   -=> load_elf_binary
> 
>     -=> elf_map
> 
>  -=> vm_mmap_pgoff
> 
> -=> down_write_killable
> 
> -=> _cond_resched
> 
>  -=> __schedule   /* scheduled to work */
> 
> -=> ret_from_fork   /* UNDO */

I don't quite follow the stacktrace, but it sounds like the issue is the
same as the first one you originally reported:

> 1) The task was not actually scheduled to excute, at this time
> UNWIND_HINT_EMPTY in ret_from_fork() has not reset unwind_hint, it's
> sp_reg and end field remain default value and end up throwing an error
> in unwind_next_frame() when called by arch_stack_walk_reliable();

Or am I misunderstanding?

And to reiterate, these are not "livepatch failures", right?  Livepatch
doesn't fail when stack_trace_save_tsk_reliable() returns an error.  It
recovers gracefully and tries again later.

-- 
Josh



[PATCH 4.19 95/95] mm/vmalloc.c: dont dereference possible NULL pointer in __vunmap()

2020-06-01 Thread Greg Kroah-Hartman
From: Liviu Dudau 

commit 6ade20327dbb808882888ed8ccded71e93067cf9 upstream.

find_vmap_area() can return a NULL pointer and we're going to
dereference it without checking it first.  Use the existing
find_vm_area() function which does exactly what we want and checks for
the NULL pointer.

Link: http://lkml.kernel.org/r/20181228171009.22269-1-li...@dudau.co.uk
Fixes: f3c01d2f3ade ("mm: vmalloc: avoid racy handling of debugobjects in 
vunmap")
Signed-off-by: Liviu Dudau 
Reviewed-by: Andrew Morton 
Cc: Chintan Pandya 
Cc: Andrey Ryabinin 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 mm/vmalloc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1510,7 +1510,7 @@ static void __vunmap(const void *addr, i
addr))
return;
 
-   area = find_vmap_area((unsigned long)addr)->vm;
+   area = find_vm_area(addr);
if (unlikely(!area)) {
WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n",
addr);




[PATCH 4.19 88/95] bnxt_en: Fix accumulation of bp->net_stats_prev.

2020-06-01 Thread Greg Kroah-Hartman
From: Michael Chan 

commit b8056e8434b037fdab08158fea99ed7bc8ef3a74 upstream.

We have logic to maintain network counters across resets by storing
the counters in bp->net_stats_prev before reset.  But not all resets
will clear the counters.  Certain resets that don't need to change
the number of rings do not clear the counters.  The current logic
accumulates the counters before all resets, causing big jumps in
the counters after some resets, such as ethtool -G.

Fix it by only accumulating the counters during reset if the irq_re_init
parameter is set.  The parameter signifies that all rings and interrupts
will be reset and that means that the counters will also be reset.

Reported-by: Vijayendra Suman 
Fixes: b8875ca356f1 ("bnxt_en: Save ring statistics before reset.")
Signed-off-by: Michael Chan 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7177,7 +7177,7 @@ static void __bnxt_close_nic(struct bnxt
bnxt_free_skbs(bp);
 
/* Save ring stats before shutdown */
-   if (bp->bnapi)
+   if (bp->bnapi && irq_re_init)
bnxt_get_ring_stats(bp, >net_stats_prev);
if (irq_re_init) {
bnxt_free_irq(bp);




[PATCH 4.19 70/95] mmc: core: Fix recursive locking issue in CQE recovery path

2020-06-01 Thread Greg Kroah-Hartman
From: Sarthak Garg 

commit 39a22f73744d5baee30b5f134ae2e30b668b66ed upstream.

Consider the following stack trace

-001|raw_spin_lock_irqsave
-002|mmc_blk_cqe_complete_rq
-003|__blk_mq_complete_request(inline)
-003|blk_mq_complete_request(rq)
-004|mmc_cqe_timed_out(inline)
-004|mmc_mq_timed_out

mmc_mq_timed_out acquires the queue_lock for the first
time. The mmc_blk_cqe_complete_rq function also tries to acquire
the same queue lock resulting in recursive locking where the task
is spinning for the same lock which it has already acquired leading
to watchdog bark.

Fix this issue with the lock only for the required critical section.

Cc: 
Fixes: 1e8e55b67030 ("mmc: block: Add CQE support")
Suggested-by: Sahitya Tummala 
Signed-off-by: Sarthak Garg 
Acked-by: Adrian Hunter 
Link: 
https://lore.kernel.org/r/1588868135-31783-1-git-send-email-vbadi...@codeaurora.org
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/queue.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -108,7 +108,7 @@ static enum blk_eh_timer_return mmc_cqe_
case MMC_ISSUE_DCMD:
if (host->cqe_ops->cqe_timeout(host, mrq, _needed)) {
if (recovery_needed)
-   __mmc_cqe_recovery_notifier(mq);
+   mmc_cqe_recovery_notifier(mrq);
return BLK_EH_RESET_TIMER;
}
/* The request has gone already */
@@ -125,18 +125,13 @@ static enum blk_eh_timer_return mmc_mq_t
struct request_queue *q = req->q;
struct mmc_queue *mq = q->queuedata;
unsigned long flags;
-   int ret;
+   bool ignore_tout;
 
spin_lock_irqsave(q->queue_lock, flags);
-
-   if (mq->recovery_needed || !mq->use_cqe)
-   ret = BLK_EH_RESET_TIMER;
-   else
-   ret = mmc_cqe_timed_out(req);
-
+   ignore_tout = mq->recovery_needed || !mq->use_cqe;
spin_unlock_irqrestore(q->queue_lock, flags);
 
-   return ret;
+   return ignore_tout ? BLK_EH_RESET_TIMER : mmc_cqe_timed_out(req);
 }
 
 static void mmc_mq_recovery_handler(struct work_struct *work)




[PATCH 4.19 52/95] ARM: dts/imx6q-bx50v3: Set display interface clock parents

2020-06-01 Thread Greg Kroah-Hartman
From: Robert Beckett 

[ Upstream commit 665e7c73a7724a393b4ec92d1ae1e029925ef2b7 ]

Avoid LDB and IPU DI clocks both using the same parent. LDB requires
pasthrough clock to avoid breaking timing while IPU DI does not.

Force IPU DI clocks to use IMX6QDL_CLK_PLL2_PFD0_352M as parent
and LDB to use IMX6QDL_CLK_PLL5_VIDEO_DIV.

This fixes an issue where attempting atomic modeset while using
HDMI and display port at the same time causes LDB clock programming
to destroy the programming of HDMI that was done during the same
modeset.

Cc: sta...@vger.kernel.org
Signed-off-by: Robert Beckett 
[Use IMX6QDL_CLK_PLL2_PFD0_352M instead of IMX6QDL_CLK_PLL2_PFD2_396M
 originally chosen by Robert Beckett to avoid affecting eMMC clock
 by DRM atomic updates]
Signed-off-by: Ian Ray 
[Squash Robert's and Ian's commits for bisectability, update patch
 description and add stable tag]
Signed-off-by: Sebastian Reichel 
Signed-off-by: Shawn Guo 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/imx6q-b450v3.dts  |  7 ---
 arch/arm/boot/dts/imx6q-b650v3.dts  |  7 ---
 arch/arm/boot/dts/imx6q-b850v3.dts  | 11 ---
 arch/arm/boot/dts/imx6q-bx50v3.dtsi | 15 +++
 4 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-b450v3.dts 
b/arch/arm/boot/dts/imx6q-b450v3.dts
index 3ec58500e9c2..25bf45659737 100644
--- a/arch/arm/boot/dts/imx6q-b450v3.dts
+++ b/arch/arm/boot/dts/imx6q-b450v3.dts
@@ -65,13 +65,6 @@
};
 };
 
- {
-   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
- < IMX6QDL_CLK_LDB_DI1_SEL>;
-   assigned-clock-parents = < IMX6QDL_CLK_PLL3_USB_OTG>,
-< IMX6QDL_CLK_PLL3_USB_OTG>;
-};
-
  {
status = "okay";
 
diff --git a/arch/arm/boot/dts/imx6q-b650v3.dts 
b/arch/arm/boot/dts/imx6q-b650v3.dts
index 5650a9b11091..0326711a8700 100644
--- a/arch/arm/boot/dts/imx6q-b650v3.dts
+++ b/arch/arm/boot/dts/imx6q-b650v3.dts
@@ -65,13 +65,6 @@
};
 };
 
- {
-   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
- < IMX6QDL_CLK_LDB_DI1_SEL>;
-   assigned-clock-parents = < IMX6QDL_CLK_PLL3_USB_OTG>,
-< IMX6QDL_CLK_PLL3_USB_OTG>;
-};
-
  {
status = "okay";
 
diff --git a/arch/arm/boot/dts/imx6q-b850v3.dts 
b/arch/arm/boot/dts/imx6q-b850v3.dts
index 044a5bebe1c5..612f782ddaaa 100644
--- a/arch/arm/boot/dts/imx6q-b850v3.dts
+++ b/arch/arm/boot/dts/imx6q-b850v3.dts
@@ -53,17 +53,6 @@
};
 };
 
- {
-   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
- < IMX6QDL_CLK_LDB_DI1_SEL>,
- < IMX6QDL_CLK_IPU1_DI0_PRE_SEL>,
- < IMX6QDL_CLK_IPU2_DI0_PRE_SEL>;
-   assigned-clock-parents = < IMX6QDL_CLK_PLL5_VIDEO_DIV>,
-< IMX6QDL_CLK_PLL5_VIDEO_DIV>,
-< IMX6QDL_CLK_PLL2_PFD2_396M>,
-< IMX6QDL_CLK_PLL2_PFD2_396M>;
-};
-
  {
fsl,dual-channel;
status = "okay";
diff --git a/arch/arm/boot/dts/imx6q-bx50v3.dtsi 
b/arch/arm/boot/dts/imx6q-bx50v3.dtsi
index d3cba09be0cb..c1f554348187 100644
--- a/arch/arm/boot/dts/imx6q-bx50v3.dtsi
+++ b/arch/arm/boot/dts/imx6q-bx50v3.dtsi
@@ -391,3 +391,18 @@
#interrupt-cells = <1>;
};
 };
+
+ {
+   assigned-clocks = < IMX6QDL_CLK_LDB_DI0_SEL>,
+ < IMX6QDL_CLK_LDB_DI1_SEL>,
+ < IMX6QDL_CLK_IPU1_DI0_PRE_SEL>,
+ < IMX6QDL_CLK_IPU1_DI1_PRE_SEL>,
+ < IMX6QDL_CLK_IPU2_DI0_PRE_SEL>,
+ < IMX6QDL_CLK_IPU2_DI1_PRE_SEL>;
+   assigned-clock-parents = < IMX6QDL_CLK_PLL5_VIDEO_DIV>,
+< IMX6QDL_CLK_PLL5_VIDEO_DIV>,
+< IMX6QDL_CLK_PLL2_PFD0_352M>,
+< IMX6QDL_CLK_PLL2_PFD0_352M>,
+< IMX6QDL_CLK_PLL2_PFD0_352M>,
+< IMX6QDL_CLK_PLL2_PFD0_352M>;
+};
-- 
2.25.1





[PATCH 4.19 62/95] ALSA: hda/realtek - Add new codec supported for ALC287

2020-06-01 Thread Greg Kroah-Hartman
From: Kailang Yang 

[ Upstream commit 630e36126e420e1756378b3427b42711ce0b9ddd ]

Enable new codec supported for ALC287.

Signed-off-by: Kailang Yang 
Cc: 
Link: https://lore.kernel.org/r/dcf5ce5507104d0589a917cbb71dc...@realtek.com
Signed-off-by: Takashi Iwai 
Signed-off-by: Sasha Levin 
---
 sound/pci/hda/patch_realtek.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 34cda0accbd8..b06f7d52faad 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -387,6 +387,7 @@ static void alc_fill_eapd_coef(struct hda_codec *codec)
case 0x10ec0282:
case 0x10ec0283:
case 0x10ec0286:
+   case 0x10ec0287:
case 0x10ec0288:
case 0x10ec0285:
case 0x10ec0298:
@@ -7840,6 +7841,7 @@ static int patch_alc269(struct hda_codec *codec)
case 0x10ec0215:
case 0x10ec0245:
case 0x10ec0285:
+   case 0x10ec0287:
case 0x10ec0289:
spec->codec_variant = ALC269_TYPE_ALC215;
spec->shutup = alc225_shutup;
@@ -8978,6 +8980,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
+   HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
-- 
2.25.1





Re: [GRUB PATCH RFC 00/18] i386: Intel TXT secure launcher

2020-06-01 Thread Ross Philipson
On 6/1/20 1:56 PM, Daniel P. Smith wrote:
> On 6/1/20 12:51 PM, Andy Lutomirski wrote:
>> On Mon, Jun 1, 2020 at 8:33 AM Daniel P. Smith
>>  wrote:
>>>
>>> On 5/7/20 7:06 AM, Daniel Kiper wrote:
 Hi Łukasz,

 On Tue, May 05, 2020 at 04:38:02PM +0200, Lukasz Hawrylko wrote:
> On Tue, 2020-05-05 at 01:21 +0200, Daniel Kiper wrote:
>>>
>>> ...
>>>
> In OS-MLE table there is a buffer for TPM event log, however I see that
> you are not using it, but instead allocate space somewhere in the

 I think that this part requires more discussion. In my opinion we should
 have this region dynamically allocated because it gives us more 
 flexibility.
 Of course there is a question about the size of this buffer too. I am
 not sure about that because I have not checked yet how many log entries
 are created by the SINIT ACM. Though probably it should not be large...

> memory. I am just wondering if, from security perspective, it will be
> better to use memory from TXT heap for event log, like we do in TBOOT.

 Appendix F, TPM Event Log, has following sentence: There are no
 requirements for event log to be in DMA protected memory – SINIT will
 not enforce it.

 I was thinking about it and it seems to me that the TPM event log does
 not require any special protections. Any changes in it can be quickly
 detected by comparing hashes with the TPM PCRs. Does not it?

>>>
>>> I think it would be beneficial to consider the following in deciding
>>> where the log is placed. There are two areas of attack/manipulation that
>>> need to be considered. The first area is the log contents itself, which
>>> as Daniel has pointed out, the log contents do not really need to be
>>> protected from tampering as that would/should be detected during
>>> verification by the attestor. The second area that we need to consider
>>> is the log descriptors themselves. If these are in an area that can be
>>> manipulated, it is an opportunity for an attacker to attempt to
>>> influence the ACM's execution. For a little perspective, the ACM
>>> executes from CRAM to take the most possible precaution to ensure that
>>> it cannot be tampered with during execution. This is very important
>>> since it runs a CPU mode (ACM Mode) that I would consider to be higher
>>> (or lower depending on how you view it) than SMM. As a result, the txt
>>> heap is also included in what is mapped into CRAM. If the event log is
>>> place in the heap, this ensures that the ACM is not using memory outside
>>> of CRAM during execution. Now as Daniel has pointed out, the down side
>>> to this is that it greatly restricts the log size and can only be
>>> managed by a combination of limiting the number of events and
>>> restricting what content is carried in the event data field.
>>
>> Can you clarify what the actual flow of control is?  If I had to guess, it's:
>>
>> GRUB (or other bootloader) writes log.
>>
>> GRUB transfers control to the ACM.  At this point, GRUB is done
>> running and GRUB code will not run again.
>>
>> ACM validates system configuration and updates TPM state using magic
>> privileged TPM access.
>>
>> ACM transfers control to the shiny new Linux secure launch entry point
>>
>> Maybe this is right, and maybe this is wrong.  But I have some
>> questions about this whole setup.  Is the ACM code going to inspect
>> this log at all?  If so, why?  Who supplies the ACM code?  If the ACM
>> can be attacked by putting its inputs (e.g. this log) in the wrong
>> place in memory, why should this be considered anything other than a
>> bug in the ACM?
> 
> There is a lot behind that, so to get a complete detail of the event
> sequence I would recommend looking at Section Vol. 2D 6.2.3 (pg Vol. 2D
> 6-5/ pdf pg 2531), 6.3 GETSEC[ENTERACCS](pg 6-10 Vol. 2D/pdf pg 2546),
> and 6.3 GETSEC[SENTER](pg Vol. 2D 6-21/pdf pg 2557) in the Intel SDM[1].
> Section 6.2.3 gives a slightly detailed overview. Section
> GETSEC[ENTERACCS] details the requirements/procedures for entering AC
> execution mode and ACRAM (Authenticated CRAM) and section GETSEC[SENTER]
> will detail requirements/procedures for SENTER.
> 
> To answer you additional questions I would say if you look at all the
> work that goes into protecting the ACM execution, why would you want to
> then turn around and have it use memory outside of the protected region.
> On the other hand, you are right, if the Developer's Guide says it
> doesn't need to be protected and someone somehow finds a way to cause a
> failure in the ACM through the use of a log outside of CRAM, then
> rightfully that is a bug in the ACM. This is why I asked about making it
> configurable, paranoid people could set the configuration to use the
> heap and all others could just use an external location.

After thinking about it, it should be easy to make it configurable since
as stated it is up the the pre-launch code to decide where the buffer
is. To do 

[PATCH 4.19 50/95] gpio: exar: Fix bad handling for ida_simple_get error path

2020-06-01 Thread Greg Kroah-Hartman
From: Takashi Iwai 

[ Upstream commit 333830aa149a87cabeb5d30fbcf12eecc8040d2c ]

The commit 7ecced0934e5 ("gpio: exar: add a check for the return value
of ida_simple_get fails") added a goto jump to the common error
handler for ida_simple_get() error, but this is wrong in two ways:
it doesn't set the proper return code and, more badly, it invokes
ida_simple_remove() with a negative index that shall lead to a kernel
panic via BUG_ON().

This patch addresses those two issues.

Fixes: 7ecced0934e5 ("gpio: exar: add a check for the return value of 
ida_simple_get fails")
Cc: 
Signed-off-by: Takashi Iwai 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-exar.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index a09d2f9ebacc..695c19901eff 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -148,8 +148,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
mutex_init(_gpio->lock);
 
index = ida_simple_get(_index, 0, 0, GFP_KERNEL);
-   if (index < 0)
-   goto err_destroy;
+   if (index < 0) {
+   ret = index;
+   goto err_mutex_destroy;
+   }
 
sprintf(exar_gpio->name, "exar_gpio%d", index);
exar_gpio->gpio_chip.label = exar_gpio->name;
@@ -176,6 +178,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
 
 err_destroy:
ida_simple_remove(_index, index);
+err_mutex_destroy:
mutex_destroy(_gpio->lock);
return ret;
 }
-- 
2.25.1





[PATCH 4.19 84/95] netfilter: ipset: Fix subcounter update skip

2020-06-01 Thread Greg Kroah-Hartman
From: Phil Sutter 

commit a164b95ad6055c50612795882f35e0efda1f1390 upstream.

If IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE is set, user requested to not
update counters in sub sets. Therefore IPSET_FLAG_SKIP_COUNTER_UPDATE
must be set, not unset.

Fixes: 6e01781d1c80e ("netfilter: ipset: set match: add support to match the 
counters")
Signed-off-by: Phil Sutter 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Greg Kroah-Hartman 

---
 net/netfilter/ipset/ip_set_list_set.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -63,7 +63,7 @@ list_set_ktest(struct ip_set *set, const
/* Don't lookup sub-counters at all */
opt->cmdflags &= ~IPSET_FLAG_MATCH_COUNTERS;
if (opt->cmdflags & IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE)
-   opt->cmdflags &= ~IPSET_FLAG_SKIP_COUNTER_UPDATE;
+   opt->cmdflags |= IPSET_FLAG_SKIP_COUNTER_UPDATE;
list_for_each_entry_rcu(e, >members, list) {
ret = ip_set_test(e->id, skb, par, opt);
if (ret <= 0)




[PATCH 4.19 38/95] Input: i8042 - add ThinkPad S230u to i8042 nomux list

2020-06-01 Thread Greg Kroah-Hartman
From: Kevin Locke 

[ Upstream commit 18931506465a762ffd3f4803d36a18d336a67da9 ]

On the Lenovo ThinkPad Twist S230u (3347-4HU) with BIOS version
"GDETC1WW (1.81 ) 06/27/2019", whether booted in UEFI or Legacy/CSM mode
the keyboard, Synaptics TouchPad, and TrackPoint either do not function
or stop functioning a few minutes after boot.  This problem has been
noted before, perhaps only occurring on BIOS 1.57 and
later.[1][2][3][4][5]

This model does not have an external PS/2 port, so mux does not appear
to be useful.

Odds of a BIOS fix appear to be low: 1.57 was released over 6 years ago
and although the [BIOS changelog] notes "Fixed an issue of UEFI
touchpad/trackpoint/keyboard/touchscreen" in 1.58, it appears to be
insufficient.

Adding 33474HU to the nomux list avoids the issue on my system.

[1]: https://bugs.launchpad.net/bugs/1210748
[2]: https://bbs.archlinux.org/viewtopic.php?pid=1360425
[3]: https://forums.linuxmint.com/viewtopic.php?f=46=41200
[4]: https://forums.linuxmint.com/viewtopic.php?f=49=157115
[5]: https://forums.lenovo.com/topic/findpost/27/1337119
[BIOS changelog]: https://download.lenovo.com/pccbbs/mobiles/gduj33uc.txt

Signed-off-by: Kevin Locke 
Cc: sta...@vger.kernel.org
Link: 
https://lore.kernel.org/r/feb8a8339a67025dab3850e6377eb6f3a0e782ba.1587400635.git.ke...@kevinlocke.name
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Sasha Levin 
---
 drivers/input/serio/i8042-x86ia64io.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/serio/i8042-x86ia64io.h 
b/drivers/input/serio/i8042-x86ia64io.h
index 0d0f977a2f39..8bf38eded1ef 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -545,6 +545,13 @@ static const struct dmi_system_id __initconst 
i8042_dmi_nomux_table[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
},
},
+   {
+   /* Lenovo ThinkPad Twist S230u */
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"),
+   },
+   },
{ }
 };
 
-- 
2.25.1





[PATCH 4.19 83/95] netfilter: nft_reject_bridge: enable reject with bridge vlan

2020-06-01 Thread Greg Kroah-Hartman
From: Michael Braun 

commit e9c284ec4b41c827f4369973d2792992849e4fa5 upstream.

Currently, using the bridge reject target with tagged packets
results in untagged packets being sent back.

Fix this by mirroring the vlan id as well.

Fixes: 85f5b3086a04 ("netfilter: bridge: add reject support")
Signed-off-by: Michael Braun 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Greg Kroah-Hartman 

---
 net/bridge/netfilter/nft_reject_bridge.c |6 ++
 1 file changed, 6 insertions(+)

--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -34,6 +34,12 @@ static void nft_reject_br_push_etherhdr(
ether_addr_copy(eth->h_dest, eth_hdr(oldskb)->h_source);
eth->h_proto = eth_hdr(oldskb)->h_proto;
skb_pull(nskb, ETH_HLEN);
+
+   if (skb_vlan_tag_present(oldskb)) {
+   u16 vid = skb_vlan_tag_get(oldskb);
+
+   __vlan_hwaccel_put_tag(nskb, oldskb->vlan_proto, vid);
+   }
 }
 
 static int nft_bridge_iphdr_validate(struct sk_buff *skb)




[PATCH 4.19 36/95] samples: bpf: Fix build error

2020-06-01 Thread Greg Kroah-Hartman
From: Matteo Croce 

[ Upstream commit 23ad04669f81f958e9a4121b0266228d2eb3c357 ]

GCC 10 is very strict about symbol clash, and lwt_len_hist_user contains
a symbol which clashes with libbpf:

/usr/bin/ld: samples/bpf/lwt_len_hist_user.o:(.bss+0x0): multiple definition of 
`bpf_log_buf'; samples/bpf/bpf_load.o:(.bss+0x8c0): first defined here
collect2: error: ld returned 1 exit status

bpf_log_buf here seems to be a leftover, so removing it.

Signed-off-by: Matteo Croce 
Signed-off-by: Alexei Starovoitov 
Acked-by: Yonghong Song 
Link: https://lore.kernel.org/bpf/2020053234.80722-1-mcr...@redhat.com
Signed-off-by: Sasha Levin 
---
 samples/bpf/lwt_len_hist_user.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/samples/bpf/lwt_len_hist_user.c b/samples/bpf/lwt_len_hist_user.c
index 587b68b1f8dd..430a4b7e353e 100644
--- a/samples/bpf/lwt_len_hist_user.c
+++ b/samples/bpf/lwt_len_hist_user.c
@@ -15,8 +15,6 @@
 #define MAX_INDEX 64
 #define MAX_STARS 38
 
-char bpf_log_buf[BPF_LOG_BUF_SIZE];
-
 static void stars(char *str, long val, long max, int width)
 {
int i;
-- 
2.25.1





[PATCH 4.19 66/95] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

2020-06-01 Thread Greg Kroah-Hartman
From: Alexander Potapenko 

[ Upstream commit 1d605416fb7175e1adf094251466caa52093b413 ]

KMSAN reported uninitialized data being written to disk when dumping
core.  As a result, several kilobytes of kmalloc memory may be written
to the core file and then read by a non-privileged user.

Reported-by: sam 
Signed-off-by: Alexander Potapenko 
Signed-off-by: Andrew Morton 
Acked-by: Kees Cook 
Cc: Al Viro 
Cc: Alexey Dobriyan 
Cc: 
Link: http://lkml.kernel.org/r/20200419100848.63472-1-gli...@google.com
Link: https://github.com/google/kmsan/issues/76
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index e7fd0b5b9234..975dd0dbc252 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1766,7 +1766,7 @@ static int fill_thread_core_info(struct 
elf_thread_core_info *t,
(!regset->active || regset->active(t->task, regset) > 0)) {
int ret;
size_t size = regset_size(t->task, regset);
-   void *data = kmalloc(size, GFP_KERNEL);
+   void *data = kzalloc(size, GFP_KERNEL);
if (unlikely(!data))
return 0;
ret = regset->get(t->task, regset,
-- 
2.25.1





[PATCH 4.19 71/95] RDMA/core: Fix double destruction of uobject

2020-06-01 Thread Greg Kroah-Hartman
From: Jason Gunthorpe 

commit c85f4abe66bea0b5db8d28d55da760c4fe0a0301 upstream.

Fix use after free when user user space request uobject concurrently for
the same object, within the RCU grace period.

In that case, remove_handle_idr_uobject() is called twice and we will have
an extra put on the uobject which cause use after free.  Fix it by leaving
the uobject write locked after it was removed from the idr.

Call to rdma_lookup_put_uobject with UVERBS_LOOKUP_DESTROY instead of
UVERBS_LOOKUP_WRITE will do the work.

  refcount_t: underflow; use-after-free.
  WARNING: CPU: 0 PID: 1381 at lib/refcount.c:28 
refcount_warn_saturate+0xfe/0x1a0
  Kernel panic - not syncing: panic_on_warn set ...
  CPU: 0 PID: 1381 Comm: syz-executor.0 Not tainted 5.5.0-rc3 #8
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
  Call Trace:
   dump_stack+0x94/0xce
   panic+0x234/0x56f
   __warn+0x1cc/0x1e1
   report_bug+0x200/0x310
   fixup_bug.part.11+0x32/0x80
   do_error_trap+0xd3/0x100
   do_invalid_op+0x31/0x40
   invalid_op+0x1e/0x30
  RIP: 0010:refcount_warn_saturate+0xfe/0x1a0
  Code: 0f 0b eb 9b e8 23 f6 6d ff 80 3d 6c d4 19 03 00 75 8d e8 15 f6 6d ff 48 
c7 c7 c0 02 55 bd c6 05 57 d4 19 03 01 e8 a2 58 49 ff <0f> 0b e9 6e ff ff ff e8 
f6 f5 6d ff 80 3d 42 d4 19 03 00 0f 85 5c
  RSP: 0018:c90002df7b98 EFLAGS: 00010282
  RAX:  RBX: 88810f6a193c RCX: ba649009
  RDX:  RSI: 0008 RDI: 88811b0283cc
  RBP: 0003 R08: ed10236060e3 R09: ed10236060e3
  R10: 0001 R11: ed10236060e2 R12: 88810f6a193c
  R13: c90002df7d60 R14:  R15: 888116ae6a08
   uverbs_uobject_put+0xfd/0x140
   __uobj_perform_destroy+0x3d/0x60
   ib_uverbs_close_xrcd+0x148/0x170
   ib_uverbs_write+0xaa5/0xdf0
   __vfs_write+0x7c/0x100
   vfs_write+0x168/0x4a0
   ksys_write+0xc8/0x200
   do_syscall_64+0x9c/0x390
   entry_SYSCALL_64_after_hwframe+0x44/0xa9
  RIP: 0033:0x465b49
  Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 
c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
  RSP: 002b:7f759d122c58 EFLAGS: 0246 ORIG_RAX: 0001
  RAX: ffda RBX: 0073bfa8 RCX: 00465b49
  RDX: 000c RSI: 2080 RDI: 0003
  RBP: 0003 R08:  R09: 
  R10:  R11: 0246 R12: 7f759d1236bc
  R13: 004ca27c R14: 0070de40 R15: 
  Dumping ftrace buffer:
 (ftrace buffer empty)
  Kernel Offset: 0x3940 from 0x8100 (relocation range: 
0x8000-0xbfff)

Fixes: 7452a3c745a2 ("IB/uverbs: Allow RDMA_REMOVE_DESTROY to work concurrently 
with disassociate")
Link: https://lore.kernel.org/r/20200527135534.482279-1-l...@kernel.org
Signed-off-by: Maor Gottlieb 
Signed-off-by: Leon Romanovsky 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/rdma_core.c |   19 +--
 include/rdma/uverbs_std_types.h |2 +-
 2 files changed, 14 insertions(+), 7 deletions(-)

--- a/drivers/infiniband/core/rdma_core.c
+++ b/drivers/infiniband/core/rdma_core.c
@@ -158,9 +158,9 @@ static int uverbs_destroy_uobject(struct
uobj->context = NULL;
 
/*
-* For DESTROY the usecnt is held write locked, the caller is expected
-* to put it unlock and put the object when done with it. Only DESTROY
-* can remove the IDR handle.
+* For DESTROY the usecnt is not changed, the caller is expected to
+* manage it via uobj_put_destroy(). Only DESTROY can remove the IDR
+* handle.
 */
if (reason != RDMA_REMOVE_DESTROY)
atomic_set(>usecnt, 0);
@@ -192,7 +192,7 @@ static int uverbs_destroy_uobject(struct
 /*
  * This calls uverbs_destroy_uobject() using the RDMA_REMOVE_DESTROY
  * sequence. It should only be used from command callbacks. On success the
- * caller must pair this with rdma_lookup_put_uobject(LOOKUP_WRITE). This
+ * caller must pair this with uobj_put_destroy(). This
  * version requires the caller to have already obtained an
  * LOOKUP_DESTROY uobject kref.
  */
@@ -203,6 +203,13 @@ int uobj_destroy(struct ib_uobject *uobj
 
down_read(>hw_destroy_rwsem);
 
+   /*
+* Once the uobject is destroyed by RDMA_REMOVE_DESTROY then it is left
+* write locked as the callers put it back with UVERBS_LOOKUP_DESTROY.
+* This is because any other concurrent thread can still see the object
+* in the xarray due to RCU. Leaving it locked ensures nothing else will
+* touch it.
+*/
ret = uverbs_try_lock_object(uobj, UVERBS_LOOKUP_WRITE);
if (ret)
goto out_unlock;
@@ -221,7 +228,7 @@ out_unlock:

[PATCH 4.19 68/95] iommu: Fix reference count leak in iommu_group_alloc.

2020-06-01 Thread Greg Kroah-Hartman
From: Qiushi Wu 

[ Upstream commit 7cc31613734c4870ae32f5265d576ef296621343 ]

kobject_init_and_add() takes reference even when it fails.
Thus, when kobject_init_and_add() returns an error,
kobject_put() must be called to properly clean up the kobject.

Fixes: d72e31c93746 ("iommu: IOMMU Groups")
Signed-off-by: Qiushi Wu 
Link: https://lore.kernel.org/r/20200527210020.6522-1-wu000...@umn.edu
Signed-off-by: Joerg Roedel 
Signed-off-by: Sasha Levin 
---
 drivers/iommu/iommu.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -392,7 +392,7 @@ struct iommu_group *iommu_group_alloc(vo
   NULL, "%d", group->id);
if (ret) {
ida_simple_remove(_group_ida, group->id);
-   kfree(group);
+   kobject_put(>kobj);
return ERR_PTR(ret);
}
 




[PATCH 4.19 51/95] IB/qib: Call kobject_put() when kobject_init_and_add() fails

2020-06-01 Thread Greg Kroah-Hartman
From: Kaike Wan 

[ Upstream commit a35cd6447effd5c239b564c80fa109d05ff3d114 ]

When kobject_init_and_add() returns an error in the function
qib_create_port_files(), the function kobject_put() is not called for the
corresponding kobject, which potentially leads to memory leak.

This patch fixes the issue by calling kobject_put() even if
kobject_init_and_add() fails. In addition, the ppd->diagc_kobj is released
along with other kobjects when the sysfs is unregistered.

Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand 
adapters")
Link: 
https://lore.kernel.org/r/20200512031328.189865.48627.st...@awfm-01.aw.intel.com
Cc: 
Suggested-by: Lin Yi 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Dennis Dalessandro 
Reviewed-by: Leon Romanovsky 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/qib/qib_sysfs.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c 
b/drivers/infiniband/hw/qib/qib_sysfs.c
index d831f3e61ae8..2626205780ee 100644
--- a/drivers/infiniband/hw/qib/qib_sysfs.c
+++ b/drivers/infiniband/hw/qib/qib_sysfs.c
@@ -756,7 +756,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping linkcontrol sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail;
+   goto bail_link;
}
kobject_uevent(>pport_kobj, KOBJ_ADD);
 
@@ -766,7 +766,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping sl2vl sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail_link;
+   goto bail_sl;
}
kobject_uevent(>sl2vl_kobj, KOBJ_ADD);
 
@@ -776,7 +776,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping diag_counters sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail_sl;
+   goto bail_diagc;
}
kobject_uevent(>diagc_kobj, KOBJ_ADD);
 
@@ -789,7 +789,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
 "Skipping Congestion Control sysfs info, (err %d) port %u\n",
 ret, port_num);
-   goto bail_diagc;
+   goto bail_cc;
}
 
kobject_uevent(>pport_cc_kobj, KOBJ_ADD);
@@ -871,6 +871,7 @@ void qib_verbs_unregister_sysfs(struct qib_devdata *dd)
_table_bin_attr);
kobject_put(>pport_cc_kobj);
}
+   kobject_put(>diagc_kobj);
kobject_put(>sl2vl_kobj);
kobject_put(>pport_kobj);
}
-- 
2.25.1





[PATCH 4.19 54/95] ARM: dts: bcm: HR2: Fix PPI interrupt types

2020-06-01 Thread Greg Kroah-Hartman
From: Hamish Martin 

[ Upstream commit be0ec060b54f0481fb95d59086c1484a949c903c ]

These error messages are output when booting on a BCM HR2 system:
GIC: PPI11 is secure or misconfigured
GIC: PPI13 is secure or misconfigured

Per ARM documentation these interrupts are triggered on a rising edge.
See ARM Cortex A-9 MPCore Technical Reference Manual, Revision r4p1,
Section 3.3.8 Interrupt Configuration Registers.

The same issue was resolved for NSP systems in commit 5f1aa51c7a1e
("ARM: dts: NSP: Fix PPI interrupt types").

Fixes: b9099ec754b5 ("ARM: dts: Add Broadcom Hurricane 2 DTS include file")
Signed-off-by: Hamish Martin 
Signed-off-by: Florian Fainelli 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/bcm-hr2.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/bcm-hr2.dtsi b/arch/arm/boot/dts/bcm-hr2.dtsi
index e4d49731287f..e35398cc60a0 100644
--- a/arch/arm/boot/dts/bcm-hr2.dtsi
+++ b/arch/arm/boot/dts/bcm-hr2.dtsi
@@ -75,7 +75,7 @@
timer@20200 {
compatible = "arm,cortex-a9-global-timer";
reg = <0x20200 0x100>;
-   interrupts = ;
+   interrupts = ;
clocks = <_clk>;
};
 
@@ -83,7 +83,7 @@
compatible = "arm,cortex-a9-twd-timer";
reg = <0x20600 0x20>;
interrupts = ;
+ IRQ_TYPE_EDGE_RISING)>;
clocks = <_clk>;
};
 
@@ -91,7 +91,7 @@
compatible = "arm,cortex-a9-twd-wdt";
reg = <0x20620 0x20>;
interrupts = ;
+ IRQ_TYPE_EDGE_RISING)>;
clocks = <_clk>;
};
 
-- 
2.25.1





[PATCH 4.19 73/95] x86/dma: Fix max PFN arithmetic overflow on 32 bit systems

2020-06-01 Thread Greg Kroah-Hartman
From: Alexander Dahl 

commit 88743470668ef5eb6b7ba9e0f99888e5999bf172 upstream.

The intermediate result of the old term (4UL * 1024 * 1024 * 1024) is
4 294 967 296 or 0x1 which is no problem on 64 bit systems.
The patch does not change the later overall result of 0x10 for
MAX_DMA32_PFN (after it has been shifted by PAGE_SHIFT). The new
calculation yields the same result, but does not require 64 bit
arithmetic.

On 32 bit systems the old calculation suffers from an arithmetic
overflow in that intermediate term in braces: 4UL aka unsigned long int
is 4 byte wide and an arithmetic overflow happens (the 0x1 does
not fit in 4 bytes), the in braces result is truncated to zero, the
following right shift does not alter that, so MAX_DMA32_PFN evaluates to
0 on 32 bit systems.

That wrong value is a problem in a comparision against MAX_DMA32_PFN in
the init code for swiotlb in pci_swiotlb_detect_4gb() to decide if
swiotlb should be active.  That comparison yields the opposite result,
when compiling on 32 bit systems.

This was not possible before

  1b7e03ef7570 ("x86, NUMA: Enable emulation on 32bit too")

when that MAX_DMA32_PFN was first made visible to x86_32 (and which
landed in v3.0).

In practice this wasn't a problem, unless CONFIG_SWIOTLB is active on
x86-32.

However if one has set CONFIG_IOMMU_INTEL, since

  c5a5dc4cbbf4 ("iommu/vt-d: Don't switch off swiotlb if bounce page is used")

there's a dependency on CONFIG_SWIOTLB, which was not necessarily
active before. That landed in v5.4, where we noticed it in the fli4l
Linux distribution. We have CONFIG_IOMMU_INTEL active on both 32 and 64
bit kernel configs there (I could not find out why, so let's just say
historical reasons).

The effect is at boot time 64 MiB (default size) were allocated for
bounce buffers now, which is a noticeable amount of memory on small
systems like pcengines ALIX 2D3 with 256 MiB memory, which are still
frequently used as home routers.

We noticed this effect when migrating from kernel v4.19 (LTS) to v5.4
(LTS) in fli4l and got that kernel messages for example:

  Linux version 5.4.22 (buildroot@buildroot) (gcc version 7.3.0 (Buildroot 
2018.02.8)) #1 SMP Mon Nov 26 23:40:00 CET 2018
  …
  Memory: 183484K/261756K available (4594K kernel code, 393K rwdata, 1660K 
rodata, 536K init, 456K bss , 78272K reserved, 0K cma-reserved, 0K highmem)
  …
  PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
  software IO TLB: mapped [mem 0x0bb78000-0x0fb78000] (64MB)

The initial analysis and the suggested fix was done by user 'sourcejedi'
at stackoverflow and explicitly marked as GPLv2 for inclusion in the
Linux kernel:

  https://unix.stackexchange.com/a/520525/50007

The new calculation, which does not suffer from that overflow, is the
same as for arch/mips now as suggested by Robin Murphy.

The fix was tested by fli4l users on round about two dozen different
systems, including both 32 and 64 bit archs, bare metal and virtualized
machines.

 [ bp: Massage commit message. ]

Fixes: 1b7e03ef7570 ("x86, NUMA: Enable emulation on 32bit too")
Reported-by: Alan Jenkins 
Suggested-by: Robin Murphy 
Signed-off-by: Alexander Dahl 
Signed-off-by: Borislav Petkov 
Reviewed-by: Greg Kroah-Hartman 
Cc: sta...@vger.kernel.org
Link: https://unix.stackexchange.com/q/520065/50007
Link: https://web.nettworks.org/bugs/browse/FFL-2560
Link: https://lkml.kernel.org/r/20200526175749.20742-1-p...@lespocky.de
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/include/asm/dma.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/include/asm/dma.h
+++ b/arch/x86/include/asm/dma.h
@@ -74,7 +74,7 @@
 #define MAX_DMA_PFN   ((16UL * 1024 * 1024) >> PAGE_SHIFT)
 
 /* 4GB broken PCI/AGP hardware bus master zone */
-#define MAX_DMA32_PFN ((4UL * 1024 * 1024 * 1024) >> PAGE_SHIFT)
+#define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
 
 #ifdef CONFIG_X86_32
 /* The maximum address that we can perform a DMA transfer to on this platform 
*/




[PATCH 4.19 47/95] ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h

2020-06-01 Thread Greg Kroah-Hartman
From: Russell King 

[ Upstream commit 747ffc2fcf969eff9309d7f2d1d61cb8b9e1bb40 ]

Consolidate the user access assembly code to asm/uaccess-asm.h.  This
moves the csdb, check_uaccess, uaccess_mask_range_ptr, uaccess_enable,
uaccess_disable, uaccess_save, uaccess_restore macros, and creates two
new ones for exception entry and exit - uaccess_entry and uaccess_exit.

This makes the uaccess_save and uaccess_restore macros private to
asm/uaccess-asm.h.

Signed-off-by: Russell King 
Signed-off-by: Sasha Levin 
---
 arch/arm/include/asm/assembler.h   |  75 +---
 arch/arm/include/asm/uaccess-asm.h | 106 +
 arch/arm/kernel/entry-armv.S   |  11 +--
 arch/arm/kernel/entry-header.S |   9 +--
 4 files changed, 112 insertions(+), 89 deletions(-)
 create mode 100644 arch/arm/include/asm/uaccess-asm.h

diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 965224d14e6c..1935b580f0e8 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -21,11 +21,11 @@
 #endif
 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #define IOMEM(x)   (x)
 
@@ -447,79 +447,6 @@ THUMB( orr \reg , \reg , #PSR_T_BIT)
.size \name , . - \name
.endm
 
-   .macro  csdb
-#ifdef CONFIG_THUMB2_KERNEL
-   .inst.w 0xf3af8014
-#else
-   .inst   0xe320f014
-#endif
-   .endm
-
-   .macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req
-#ifndef CONFIG_CPU_USE_DOMAINS
-   adds\tmp, \addr, #\size - 1
-   sbcscc  \tmp, \tmp, \limit
-   bcs \bad
-#ifdef CONFIG_CPU_SPECTRE
-   movcs   \addr, #0
-   csdb
-#endif
-#endif
-   .endm
-
-   .macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req
-#ifdef CONFIG_CPU_SPECTRE
-   sub \tmp, \limit, #1
-   subs\tmp, \tmp, \addr   @ tmp = limit - 1 - addr
-   addhs   \tmp, \tmp, #1  @ if (tmp >= 0) {
-   subshs  \tmp, \tmp, \size   @ tmp = limit - (addr + size) }
-   movlo   \addr, #0   @ if (tmp < 0) addr = NULL
-   csdb
-#endif
-   .endm
-
-   .macro  uaccess_disable, tmp, isb=1
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   /*
-* Whenever we re-enter userspace, the domains should always be
-* set appropriately.
-*/
-   mov \tmp, #DACR_UACCESS_DISABLE
-   mcr p15, 0, \tmp, c3, c0, 0 @ Set domain register
-   .if \isb
-   instr_sync
-   .endif
-#endif
-   .endm
-
-   .macro  uaccess_enable, tmp, isb=1
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   /*
-* Whenever we re-enter userspace, the domains should always be
-* set appropriately.
-*/
-   mov \tmp, #DACR_UACCESS_ENABLE
-   mcr p15, 0, \tmp, c3, c0, 0
-   .if \isb
-   instr_sync
-   .endif
-#endif
-   .endm
-
-   .macro  uaccess_save, tmp
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   mrc p15, 0, \tmp, c3, c0, 0
-   str \tmp, [sp, #SVC_DACR]
-#endif
-   .endm
-
-   .macro  uaccess_restore
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   ldr r0, [sp, #SVC_DACR]
-   mcr p15, 0, r0, c3, c0, 0
-#endif
-   .endm
-
.irpc,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo
.macro  ret\c, reg
 #if __LINUX_ARM_ARCH__ < 6
diff --git a/arch/arm/include/asm/uaccess-asm.h 
b/arch/arm/include/asm/uaccess-asm.h
new file mode 100644
index ..d475e3e8145d
--- /dev/null
+++ b/arch/arm/include/asm/uaccess-asm.h
@@ -0,0 +1,106 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_UACCESS_ASM_H__
+#define __ASM_UACCESS_ASM_H__
+
+#include 
+#include 
+#include 
+#include 
+
+   .macro  csdb
+#ifdef CONFIG_THUMB2_KERNEL
+   .inst.w 0xf3af8014
+#else
+   .inst   0xe320f014
+#endif
+   .endm
+
+   .macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req
+#ifndef CONFIG_CPU_USE_DOMAINS
+   adds\tmp, \addr, #\size - 1
+   sbcscc  \tmp, \tmp, \limit
+   bcs \bad
+#ifdef CONFIG_CPU_SPECTRE
+   movcs   \addr, #0
+   csdb
+#endif
+#endif
+   .endm
+
+   .macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req
+#ifdef CONFIG_CPU_SPECTRE
+   sub \tmp, \limit, #1
+   subs\tmp, \tmp, \addr   @ tmp = limit - 1 - addr
+   addhs   \tmp, \tmp, #1  @ if (tmp >= 0) {
+   subshs  \tmp, \tmp, \size   @ tmp = limit - (addr + size) }
+   movlo   \addr, #0   @ if (tmp < 0) addr = NULL
+   csdb
+#endif
+   .endm
+
+   .macro  uaccess_disable, tmp, isb=1
+#ifdef CONFIG_CPU_SW_DOMAIN_PAN
+   /*
+* Whenever we re-enter userspace, the domains should always be
+* set appropriately.
+*/
+   mov \tmp, #DACR_UACCESS_DISABLE
+   mcr p15, 0, \tmp, c3, c0, 0 @ Set domain register
+   .if \isb
+   

[PATCH 4.19 42/95] Input: i8042 - add ThinkPad S230u to i8042 reset list

2020-06-01 Thread Greg Kroah-Hartman
From: Kevin Locke 

[ Upstream commit 2712c91a54a1058d55c284152b4d93c979b67be6 ]

On the Lenovo ThinkPad Twist S230u (3347-4HU) with BIOS version
"GDETC1WW (1.81 ) 06/27/2019", the keyboard, Synaptics TouchPad, and
TrackPoint either do not function or stop functioning a few minutes
after boot.  This problem has been noted before, perhaps only occurring
with BIOS 1.57 and later.[1][2][3][4][5]

Odds of a BIOS fix appear to be low: 1.57 was released over 6 years ago
and although the [BIOS changelog] notes "Fixed an issue of UEFI
touchpad/trackpoint/keyboard/touchscreen" in 1.58, it appears to be
insufficient.

Setting i8042.reset=1 or adding 33474HU to the reset list avoids the
issue on my system from either warm or cold boot.

[1]: https://bugs.launchpad.net/bugs/1210748
[2]: https://bbs.archlinux.org/viewtopic.php?pid=1360425
[3]: https://forums.linuxmint.com/viewtopic.php?f=46=41200
[4]: https://forums.linuxmint.com/viewtopic.php?f=49=157115
[5]: https://forums.lenovo.com/topic/findpost/27/1337119
[BIOS changelog]: https://download.lenovo.com/pccbbs/mobiles/gduj33uc.txt

Signed-off-by: Kevin Locke 
Cc: sta...@vger.kernel.org
Link: 
https://lore.kernel.org/r/94f384b0f75f90f71425d7dce7ac82c59ddb87a8.1587702636.git.ke...@kevinlocke.name
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Sasha Levin 
---
 drivers/input/serio/i8042-x86ia64io.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/input/serio/i8042-x86ia64io.h 
b/drivers/input/serio/i8042-x86ia64io.h
index 8bf38eded1ef..ad357f79c7d6 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -673,6 +673,13 @@ static const struct dmi_system_id __initconst 
i8042_dmi_reset_table[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"),
},
},
+   {
+   /* Lenovo ThinkPad Twist S230u */
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"),
+   },
+   },
{ }
 };
 
-- 
2.25.1





[PATCH 4.19 41/95] Input: dlink-dir685-touchkeys - fix a typo in driver name

2020-06-01 Thread Greg Kroah-Hartman
From: Christophe JAILLET 

[ Upstream commit 38347374ae3f1ec4df56dd688bd603a64e79a0ed ]

According to the file name and Kconfig, a 'k' is missing in this driver
name. It should be "dlink-dir685-touchkeys".

Fixes: 131b3de7016b ("Input: add D-Link DIR-685 touchkeys driver")
Signed-off-by: Christophe JAILLET 
Reviewed-by: Linus Walleij 
Link: 
https://lore.kernel.org/r/20200412213937.5287-1-christophe.jail...@wanadoo.fr
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Sasha Levin 
---
 drivers/input/keyboard/dlink-dir685-touchkeys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/dlink-dir685-touchkeys.c 
b/drivers/input/keyboard/dlink-dir685-touchkeys.c
index 88e321b76397..6fe4062e3ac2 100644
--- a/drivers/input/keyboard/dlink-dir685-touchkeys.c
+++ b/drivers/input/keyboard/dlink-dir685-touchkeys.c
@@ -142,7 +142,7 @@ MODULE_DEVICE_TABLE(of, dir685_tk_of_match);
 
 static struct i2c_driver dir685_tk_i2c_driver = {
.driver = {
-   .name   = "dlin-dir685-touchkeys",
+   .name   = "dlink-dir685-touchkeys",
.of_match_table = of_match_ptr(dir685_tk_of_match),
},
.probe  = dir685_tk_probe,
-- 
2.25.1





[PATCH 4.19 48/95] ARM: uaccess: integrate uaccess_save and uaccess_restore

2020-06-01 Thread Greg Kroah-Hartman
From: Russell King 

[ Upstream commit 8ede890b0bcebe8c760aacfe20e934d98c3dc6aa ]

Integrate uaccess_save / uaccess_restore macros into the new
uaccess_entry / uaccess_exit macros respectively.

Signed-off-by: Russell King 
Signed-off-by: Sasha Levin 
---
 arch/arm/include/asm/uaccess-asm.h | 30 +-
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/arm/include/asm/uaccess-asm.h 
b/arch/arm/include/asm/uaccess-asm.h
index d475e3e8145d..e46468b91eaa 100644
--- a/arch/arm/include/asm/uaccess-asm.h
+++ b/arch/arm/include/asm/uaccess-asm.h
@@ -67,30 +67,23 @@
 #endif
.endm
 
-   .macro  uaccess_save, tmp
 #ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   mrc p15, 0, \tmp, c3, c0, 0
-   str \tmp, [sp, #SVC_DACR]
-#endif
-   .endm
-
-   .macro  uaccess_restore
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   ldr r0, [sp, #SVC_DACR]
-   mcr p15, 0, r0, c3, c0, 0
+#define DACR(x...) x
+#else
+#define DACR(x...)
 #endif
-   .endm
 
/*
 * Save the address limit on entry to a privileged exception and
 * if using PAN, save and disable usermode access.
 */
.macro  uaccess_entry, tsk, tmp0, tmp1, tmp2, disable
-   ldr \tmp0, [\tsk, #TI_ADDR_LIMIT]
-   mov \tmp1, #TASK_SIZE
-   str \tmp1, [\tsk, #TI_ADDR_LIMIT]
-   str \tmp0, [sp, #SVC_ADDR_LIMIT]
-   uaccess_save \tmp0
+   ldr \tmp1, [\tsk, #TI_ADDR_LIMIT]
+   mov \tmp2, #TASK_SIZE
+   str \tmp2, [\tsk, #TI_ADDR_LIMIT]
+ DACR( mrc p15, 0, \tmp0, c3, c0, 0)
+ DACR( str \tmp0, [sp, #SVC_DACR])
+   str \tmp1, [sp, #SVC_ADDR_LIMIT]
.if \disable
uaccess_disable \tmp0
.endif
@@ -99,8 +92,11 @@
/* Restore the user access state previously saved by uaccess_entry */
.macro  uaccess_exit, tsk, tmp0, tmp1
ldr \tmp1, [sp, #SVC_ADDR_LIMIT]
-   uaccess_restore
+ DACR( ldr \tmp0, [sp, #SVC_DACR])
str \tmp1, [\tsk, #TI_ADDR_LIMIT]
+ DACR( mcr p15, 0, \tmp0, c3, c0, 0)
.endm
 
+#undef DACR
+
 #endif /* __ASM_UACCESS_ASM_H__ */
-- 
2.25.1





[PATCH 4.19 03/95] net: dsa: mt7530: fix roaming from DSA user ports

2020-06-01 Thread Greg Kroah-Hartman
From: DENG Qingfang 

[ Upstream commit 5e5502e012b8129e11be616acb0f9c34bc8f8adb ]

When a client moves from a DSA user port to a software port in a bridge,
it cannot reach any other clients that connected to the DSA user ports.
That is because SA learning on the CPU port is disabled, so the switch
ignores the client's frames from the CPU port and still thinks it is at
the user port.

Fix it by enabling SA learning on the CPU port.

To prevent the switch from learning from flooding frames from the CPU
port, set skb->offload_fwd_mark to 1 for unicast and broadcast frames,
and let the switch flood them instead of trapping to the CPU port.
Multicast frames still need to be trapped to the CPU port for snooping,
so set the SA_DIS bit of the MTK tag to 1 when transmitting those frames
to disable SA learning.

Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 
switch")
Signed-off-by: DENG Qingfang 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/dsa/mt7530.c |9 ++---
 drivers/net/dsa/mt7530.h |1 +
 net/dsa/tag_mtk.c|   15 +++
 3 files changed, 18 insertions(+), 7 deletions(-)

--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -685,11 +685,8 @@ mt7530_cpu_port_enable(struct mt7530_pri
/* Setup the MAC by default for the cpu port */
mt7530_write(priv, MT7530_PMCR_P(port), PMCR_CPUP_LINK);
 
-   /* Disable auto learning on the cpu port */
-   mt7530_set(priv, MT7530_PSC_P(port), SA_DIS);
-
-   /* Unknown unicast frame fordwarding to the cpu port */
-   mt7530_set(priv, MT7530_MFC, UNU_FFP(BIT(port)));
+   /* Unknown multicast frame forwarding to the cpu port */
+   mt7530_rmw(priv, MT7530_MFC, UNM_FFP_MASK, UNM_FFP(BIT(port)));
 
/* CPU port gets connected to all user ports of
 * the switch
@@ -1288,8 +1285,6 @@ mt7530_setup(struct dsa_switch *ds)
/* Enable and reset MIB counters */
mt7530_mib_reset(ds);
 
-   mt7530_clear(priv, MT7530_MFC, UNU_FFP_MASK);
-
for (i = 0; i < MT7530_NUM_PORTS; i++) {
/* Disable forwarding by default on all ports */
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -34,6 +34,7 @@
 #define MT7530_MFC 0x10
 #define  BC_FFP(x) (((x) & 0xff) << 24)
 #define  UNM_FFP(x)(((x) & 0xff) << 16)
+#define  UNM_FFP_MASK  UNM_FFP(~0)
 #define  UNU_FFP(x)(((x) & 0xff) << 8)
 #define  UNU_FFP_MASK  UNU_FFP(~0)
 
--- a/net/dsa/tag_mtk.c
+++ b/net/dsa/tag_mtk.c
@@ -22,6 +22,7 @@
 #define MTK_HDR_XMIT_TAGGED_TPID_8100  1
 #define MTK_HDR_RECV_SOURCE_PORT_MASK  GENMASK(2, 0)
 #define MTK_HDR_XMIT_DP_BIT_MASK   GENMASK(5, 0)
+#define MTK_HDR_XMIT_SA_DISBIT(6)
 
 static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb,
struct net_device *dev)
@@ -29,6 +30,9 @@ static struct sk_buff *mtk_tag_xmit(stru
struct dsa_port *dp = dsa_slave_to_port(dev);
u8 *mtk_tag;
bool is_vlan_skb = true;
+   unsigned char *dest = eth_hdr(skb)->h_dest;
+   bool is_multicast_skb = is_multicast_ether_addr(dest) &&
+   !is_broadcast_ether_addr(dest);
 
/* Build the special tag after the MAC Source Address. If VLAN header
 * is present, it's required that VLAN header and special tag is
@@ -54,6 +58,10 @@ static struct sk_buff *mtk_tag_xmit(stru
 MTK_HDR_XMIT_UNTAGGED;
mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK;
 
+   /* Disable SA learning for multicast frames */
+   if (unlikely(is_multicast_skb))
+   mtk_tag[1] |= MTK_HDR_XMIT_SA_DIS;
+
/* Tag control information is kept for 802.1Q */
if (!is_vlan_skb) {
mtk_tag[2] = 0;
@@ -68,6 +76,9 @@ static struct sk_buff *mtk_tag_rcv(struc
 {
int port;
__be16 *phdr, hdr;
+   unsigned char *dest = eth_hdr(skb)->h_dest;
+   bool is_multicast_skb = is_multicast_ether_addr(dest) &&
+   !is_broadcast_ether_addr(dest);
 
if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
return NULL;
@@ -93,6 +104,10 @@ static struct sk_buff *mtk_tag_rcv(struc
if (!skb->dev)
return NULL;
 
+   /* Only unicast or broadcast frames are offloaded */
+   if (likely(!is_multicast_skb))
+   skb->offload_fwd_mark = 1;
+
return skb;
 }
 




[PATCH 4.19 24/95] gpio: tegra: mask GPIO IRQs during IRQ shutdown

2020-06-01 Thread Greg Kroah-Hartman
From: Stephen Warren 

[ Upstream commit 0cf253eed5d2bdf7bb3152457b38f39b012955f7 ]

The driver currently leaves GPIO IRQs unmasked even when the GPIO IRQ
client has released the GPIO IRQ. This allows the HW to raise IRQs, and
SW to process them, after shutdown. Fix this by masking the IRQ when it's
shut down. This is usually taken care of by the irqchip core, but since
this driver has a custom irq_shutdown implementation, it must do this
explicitly itself.

Signed-off-by: Stephen Warren 
Link: https://lore.kernel.org/r/20200427232605.11608-1-swar...@wwwdotorg.org
Signed-off-by: Linus Walleij 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-tegra.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 47dbd19751d0..57903501821e 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -357,6 +357,7 @@ static void tegra_gpio_irq_shutdown(struct irq_data *d)
struct tegra_gpio_info *tgi = bank->tgi;
unsigned int gpio = d->hwirq;
 
+   tegra_gpio_irq_mask(d);
gpiochip_unlock_as_irq(>gc, gpio);
 }
 
-- 
2.25.1





[PATCH 4.19 46/95] ARM: 8843/1: use unified assembler in headers

2020-06-01 Thread Greg Kroah-Hartman
From: Stefan Agner 

[ Upstream commit c001899a5d6c2d7a0f3b75b2307ddef137fb46a6 ]

Use unified assembler syntax (UAL) in headers. Divided syntax is
considered deprecated. This will also allow to build the kernel
using LLVM's integrated assembler.

Signed-off-by: Stefan Agner 
Acked-by: Nicolas Pitre 
Signed-off-by: Russell King 
Signed-off-by: Sasha Levin 
---
 arch/arm/include/asm/assembler.h | 12 ++--
 arch/arm/include/asm/vfpmacros.h |  8 
 arch/arm/lib/bitops.h|  8 
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 88286dd483ff..965224d14e6c 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -374,9 +374,9 @@ THUMB(  orr \reg , \reg , #PSR_T_BIT)
.macro  usraccoff, instr, reg, ptr, inc, off, cond, abort, t=TUSER()
 :
.if \inc == 1
-   \instr\cond\()b\()\t\().w \reg, [\ptr, #\off]
+   \instr\()b\t\cond\().w \reg, [\ptr, #\off]
.elseif \inc == 4
-   \instr\cond\()\t\().w \reg, [\ptr, #\off]
+   \instr\t\cond\().w \reg, [\ptr, #\off]
.else
.error  "Unsupported inc macro argument"
.endif
@@ -415,9 +415,9 @@ THUMB(  orr \reg , \reg , #PSR_T_BIT)
.rept   \rept
 :
.if \inc == 1
-   \instr\cond\()b\()\t \reg, [\ptr], #\inc
+   \instr\()b\t\cond \reg, [\ptr], #\inc
.elseif \inc == 4
-   \instr\cond\()\t \reg, [\ptr], #\inc
+   \instr\t\cond \reg, [\ptr], #\inc
.else
.error  "Unsupported inc macro argument"
.endif
@@ -458,7 +458,7 @@ THUMB(  orr \reg , \reg , #PSR_T_BIT)
.macro check_uaccess, addr:req, size:req, limit:req, tmp:req, bad:req
 #ifndef CONFIG_CPU_USE_DOMAINS
adds\tmp, \addr, #\size - 1
-   sbcccs  \tmp, \tmp, \limit
+   sbcscc  \tmp, \tmp, \limit
bcs \bad
 #ifdef CONFIG_CPU_SPECTRE
movcs   \addr, #0
@@ -472,7 +472,7 @@ THUMB(  orr \reg , \reg , #PSR_T_BIT)
sub \tmp, \limit, #1
subs\tmp, \tmp, \addr   @ tmp = limit - 1 - addr
addhs   \tmp, \tmp, #1  @ if (tmp >= 0) {
-   subhss  \tmp, \tmp, \size   @ tmp = limit - (addr + size) }
+   subshs  \tmp, \tmp, \size   @ tmp = limit - (addr + size) }
movlo   \addr, #0   @ if (tmp < 0) addr = NULL
csdb
 #endif
diff --git a/arch/arm/include/asm/vfpmacros.h b/arch/arm/include/asm/vfpmacros.h
index ef5dfedacd8d..628c336e8e3b 100644
--- a/arch/arm/include/asm/vfpmacros.h
+++ b/arch/arm/include/asm/vfpmacros.h
@@ -29,13 +29,13 @@
ldr \tmp, =elf_hwcap@ may not have MVFR regs
ldr \tmp, [\tmp, #0]
tst \tmp, #HWCAP_VFPD32
-   ldcnel  p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
+   ldclne  p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
addeq   \base, \base, #32*4 @ step over unused register 
space
 #else
VFPFMRX \tmp, MVFR0 @ Media and VFP Feature 
Register 0
and \tmp, \tmp, #MVFR0_A_SIMD_MASK  @ A_SIMD field
cmp \tmp, #2@ 32 x 64bit registers?
-   ldceql  p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
+   ldcleq  p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
addne   \base, \base, #32*4 @ step over unused register 
space
 #endif
 #endif
@@ -53,13 +53,13 @@
ldr \tmp, =elf_hwcap@ may not have MVFR regs
ldr \tmp, [\tmp, #0]
tst \tmp, #HWCAP_VFPD32
-   stcnel  p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
+   stclne  p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
addeq   \base, \base, #32*4 @ step over unused register 
space
 #else
VFPFMRX \tmp, MVFR0 @ Media and VFP Feature 
Register 0
and \tmp, \tmp, #MVFR0_A_SIMD_MASK  @ A_SIMD field
cmp \tmp, #2@ 32 x 64bit registers?
-   stceql  p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
+   stcleq  p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
addne   \base, \base, #32*4 @ step over unused register 
space
 #endif
 #endif
diff --git a/arch/arm/lib/bitops.h b/arch/arm/lib/bitops.h
index 93cddab73072..95bd35991288 100644
--- a/arch/arm/lib/bitops.h
+++ b/arch/arm/lib/bitops.h
@@ -7,7 +7,7 @@
 ENTRY( \name   )
 UNWIND(.fnstart)
andsip, r1, #3
-   strneb  r1, [ip]@ assert word-aligned
+   strbne  r1, [ip]@ assert word-aligned
mov r2, #1
and r3, r0, #31 @ Get bit offset
mov 

[PATCH 4.19 21/95] arm64: dts: rockchip: swap interrupts interrupt-names rk3399 gpu node

2020-06-01 Thread Greg Kroah-Hartman
From: Johan Jonker 

[ Upstream commit c604fd810bda667bdc20b2c041917baa7803e0fb ]

Dts files with Rockchip rk3399 'gpu' nodes were manually verified.
In order to automate this process arm,mali-midgard.txt
has been converted to yaml. In the new setup dtbs_check with
arm,mali-midgard.yaml expects interrupts and interrupt-names values
in the same order. Fix this for rk3399.

make ARCH=arm64 dtbs_check
DT_SCHEMA_FILES=Documentation/devicetree/bindings/gpu/
arm,mali-midgard.yaml

Signed-off-by: Johan Jonker 
Link: https://lore.kernel.org/r/20200425143837.18706-1-jbx6...@gmail.com
Signed-off-by: Heiko Stuebner 
Signed-off-by: Sasha Levin 
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 451f00a631c4..f14e8c5c41ac 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1817,10 +1817,10 @@
gpu: gpu@ff9a {
compatible = "rockchip,rk3399-mali", "arm,mali-t860";
reg = <0x0 0xff9a 0x0 0x1>;
-   interrupts = ,
-,
-;
-   interrupt-names = "gpu", "job", "mmu";
+   interrupts = ,
+,
+;
+   interrupt-names = "job", "mmu", "gpu";
clocks = < ACLK_GPU>;
power-domains = < RK3399_PD_GPU>;
status = "disabled";
-- 
2.25.1





[PATCH 4.19 26/95] net: microchip: encx24j600: add missed kthread_stop

2020-06-01 Thread Greg Kroah-Hartman
From: Chuhong Yuan 

[ Upstream commit ff8ce319e9c25e920d994cc35236f0bb32dfc8f3 ]

This driver calls kthread_run() in probe, but forgets to call
kthread_stop() in probe failure and remove.
Add the missed kthread_stop() to fix it.

Signed-off-by: Chuhong Yuan 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/microchip/encx24j600.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/encx24j600.c 
b/drivers/net/ethernet/microchip/encx24j600.c
index f831238d9793..84b6ad76f5bc 100644
--- a/drivers/net/ethernet/microchip/encx24j600.c
+++ b/drivers/net/ethernet/microchip/encx24j600.c
@@ -1075,7 +1075,7 @@ static int encx24j600_spi_probe(struct spi_device *spi)
if (unlikely(ret)) {
netif_err(priv, probe, ndev, "Error %d initializing card 
encx24j600 card\n",
  ret);
-   goto out_free;
+   goto out_stop;
}
 
eidled = encx24j600_read_reg(priv, EIDLED);
@@ -1093,6 +1093,8 @@ static int encx24j600_spi_probe(struct spi_device *spi)
 
 out_unregister:
unregister_netdev(priv->ndev);
+out_stop:
+   kthread_stop(priv->kworker_task);
 out_free:
free_netdev(ndev);
 
@@ -1105,6 +1107,7 @@ static int encx24j600_spi_remove(struct spi_device *spi)
struct encx24j600_priv *priv = dev_get_drvdata(>dev);
 
unregister_netdev(priv->ndev);
+   kthread_stop(priv->kworker_task);
 
free_netdev(priv->ndev);
 
-- 
2.25.1





[PATCH 4.19 06/95] net: ipip: fix wrong address family in init error path

2020-06-01 Thread Greg Kroah-Hartman
From: Vadim Fedorenko 

[ Upstream commit 57ebc8f08504f176eb0f25b3e0fde517dec61a4f ]

In case of error with MPLS support the code is misusing AF_INET
instead of AF_MPLS.

Fixes: 1b69e7e6c4da ("ipip: support MPLS over IPv4")
Signed-off-by: Vadim Fedorenko 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ipv4/ipip.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -704,7 +704,7 @@ out:
 
 rtnl_link_failed:
 #if IS_ENABLED(CONFIG_MPLS)
-   xfrm4_tunnel_deregister(_handler, AF_INET);
+   xfrm4_tunnel_deregister(_handler, AF_MPLS);
 xfrm_tunnel_mplsip_failed:
 
 #endif




[PATCH 4.19 31/95] usb: gadget: legacy: fix redundant initialization warnings

2020-06-01 Thread Greg Kroah-Hartman
From: Masahiro Yamada 

[ Upstream commit d13cce757954fa663c69845611957396843ed87a ]

Fix the following cppcheck warnings:

drivers/usb/gadget/legacy/inode.c:1364:8: style: Redundant initialization for 
'value'. The initialized value is overwritten$
 value = -EOPNOTSUPP;
   ^
drivers/usb/gadget/legacy/inode.c:1331:15: note: value is initialized
 intvalue = -EOPNOTSUPP;
  ^
drivers/usb/gadget/legacy/inode.c:1364:8: note: value is overwritten
 value = -EOPNOTSUPP;
   ^
drivers/usb/gadget/legacy/inode.c:1817:8: style: Redundant initialization for 
'value'. The initialized value is overwritten$
 value = -EINVAL;
   ^
drivers/usb/gadget/legacy/inode.c:1787:18: note: value is initialized
 ssize_t   value = len, length = len;
 ^
drivers/usb/gadget/legacy/inode.c:1817:8: note: value is overwritten
 value = -EINVAL;
   ^
Acked-by: Alan Stern 
Reported-by: kbuild test robot 
Signed-off-by: Masahiro Yamada 
Signed-off-by: Felipe Balbi 

Signed-off-by: Sasha Levin 
---
 drivers/usb/gadget/legacy/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/legacy/inode.c 
b/drivers/usb/gadget/legacy/inode.c
index 37ca0e669bd8..25d417ad9000 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1360,7 +1360,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
 
req->buf = dev->rbuf;
req->context = NULL;
-   value = -EOPNOTSUPP;
switch (ctrl->bRequest) {
 
case USB_REQ_GET_DESCRIPTOR:
@@ -1783,7 +1782,7 @@ static ssize_t
 dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 {
struct dev_data *dev = fd->private_data;
-   ssize_t value = len, length = len;
+   ssize_t value, length = len;
unsignedtotal;
u32 tag;
char*kbuf;
-- 
2.25.1





[PATCH 4.19 00/95] 4.19.126-rc1 review

2020-06-01 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.126 release.
There are 95 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Wed, 03 Jun 2020 17:38:19 +.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.126-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.19.126-rc1

Liviu Dudau 
mm/vmalloc.c: don't dereference possible NULL pointer in __vunmap()

Pablo Neira Ayuso 
netfilter: nf_conntrack_pptp: fix compilation warning with W=1 build

Dmitry Torokhov 
Revert "Input: i8042 - add ThinkPad S230u to i8042 nomux list"

Qiushi Wu 
bonding: Fix reference count leak in bond_sysfs_slave_add.

Eric Dumazet 
crypto: chelsio/chtls: properly set tp->lsndtime

Qiushi Wu 
qlcnic: fix missing release in qlcnic_83xx_interrupt_test.

Björn Töpel 
xsk: Add overflow check for u64 division, stored into u32

Michael Chan 
bnxt_en: Fix accumulation of bp->net_stats_prev.

Xin Long 
esp6: get the right proto for transport mode in esp6_gso_encap

Pablo Neira Ayuso 
netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code

Pablo Neira Ayuso 
netfilter: nfnetlink_cthelper: unbreak userspace helper support

Phil Sutter 
netfilter: ipset: Fix subcounter update skip

Michael Braun 
netfilter: nft_reject_bridge: enable reject with bridge vlan

Xin Long 
ip_vti: receive ipip packet by calling ip_tunnel_rcv

Jeremy Sowden 
vti4: eliminated some duplicate code.

Antony Antony 
xfrm: fix error in comment

Xin Long 
xfrm: fix a NULL-ptr deref in xfrm_local_error

Xin Long 
xfrm: fix a warning in xfrm_policy_insert_list

Nicolas Dichtel 
xfrm interface: fix oops when deleting a x-netns interface

Xin Long 
xfrm: call xfrm_output_gso when inner_protocol is set in xfrm_output

Xin Long 
xfrm: allow to accept packets with ipv6 NEXTHDR_HOP in xfrm_input

Al Viro 
copy_xstate_to_kernel(): don't leave parts of destination uninitialized

Alexander Dahl 
x86/dma: Fix max PFN arithmetic overflow on 32 bit systems

Linus Lüssing 
mac80211: mesh: fix discovery timer re-arming issue / crash

Jason Gunthorpe 
RDMA/core: Fix double destruction of uobject

Sarthak Garg 
mmc: core: Fix recursive locking issue in CQE recovery path

Helge Deller 
parisc: Fix kernel panic in mem_init()

Qiushi Wu 
iommu: Fix reference count leak in iommu_group_alloc.

Arnd Bergmann 
include/asm-generic/topology.h: guard cpumask_of_node() macro argument

Alexander Potapenko 
fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

Konstantin Khlebnikov 
mm: remove VM_BUG_ON(PageSlab()) from page_mapcount()

Valentine Fatiev 
IB/ipoib: Fix double free of skb in case of multicast traffic in CM mode

Jerry Lee 
libceph: ignore pool overlay and cache logic on redirects

Kailang Yang 
ALSA: hda/realtek - Add new codec supported for ALC287

Takashi Iwai 
ALSA: usb-audio: Quirks for Gigabyte TRX40 Aorus Master onboard audio

Eric W. Biederman 
exec: Always set cap_ambient in cap_bprm_set_creds

Chris Chiu 
ALSA: usb-audio: mixer: volume quirk for ESS Technology Asus USB DAC

Takashi Iwai 
ALSA: hda/realtek - Add a model for Thinkpad T570 without DAC workaround

Changming Liu 
ALSA: hwdep: fix a left shifting 1 by 31 UB bug

Qiushi Wu 
RDMA/pvrdma: Fix missing pci disable in pvrdma_pci_probe()

Peng Hao 
mmc: block: Fix use-after-free issue for rpmb

Hamish Martin 
ARM: dts: bcm: HR2: Fix PPI interrupt types

Vincent Stehlé 
ARM: dts: bcm2835-rpi-zero-w: Fix led polarity

Robert Beckett 
ARM: dts/imx6q-bx50v3: Set display interface clock parents

Kaike Wan 
IB/qib: Call kobject_put() when kobject_init_and_add() fails

Takashi Iwai 
gpio: exar: Fix bad handling for ida_simple_get error path

Russell King 
ARM: uaccess: fix DACR mismatch with nested exceptions

Russell King 
ARM: uaccess: integrate uaccess_save and uaccess_restore

Russell King 
ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h

Stefan Agner 
ARM: 8843/1: use unified assembler in headers

Łukasz Stelmach 
ARM: 8970/1: decompressor: increase tag size

Wei Yongjun 
Input: synaptics-rmi4 - fix error return code in rmi_driver_probe()

Evan Green 
Input: synaptics-rmi4 - really fix attn_data use-after-free

Kevin Locke 
Input: i8042 - add ThinkPad S230u to i8042 reset list

Christophe JAILLET 
Input: dlink-dir685-touchkeys - fix a typo in driver name

Łukasz Patron 
Input: xpad - add 

[PATCH 4.19 05/95] net: inet_csk: Fix so_reuseport bind-address cache in tb->fast*

2020-06-01 Thread Greg Kroah-Hartman
From: Martin KaFai Lau 

[ Upstream commit 88d7fcfa3b1fe670f0412b95be785aafca63352b ]

The commit 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport 
sk")
added a bind-address cache in tb->fast*.  The tb->fast* caches the address
of a sk which has successfully been binded with SO_REUSEPORT ON.  The idea
is to avoid the expensive conflict search in inet_csk_bind_conflict().

There is an issue with wildcard matching where sk_reuseport_match() should
have returned false but it is currently returning true.  It ends up
hiding bind conflict.  For example,

bind("[::1]:443"); /* without SO_REUSEPORT. Succeed. */
bind("[::2]:443"); /* withSO_REUSEPORT. Succeed. */
bind("[::]:443");  /* withSO_REUSEPORT. Still Succeed where it shouldn't */

The last bind("[::]:443") with SO_REUSEPORT on should have failed because
it should have a conflict with the very first bind("[::1]:443") which
has SO_REUSEPORT off.  However, the address "[::2]" is cached in
tb->fast* in the second bind. In the last bind, the sk_reuseport_match()
returns true because the binding sk's wildcard addr "[::]" matches with
the "[::2]" cached in tb->fast*.

The correct bind conflict is reported by removing the second
bind such that tb->fast* cache is not involved and forces the
bind("[::]:443") to go through the inet_csk_bind_conflict():

bind("[::1]:443"); /* without SO_REUSEPORT. Succeed. */
bind("[::]:443");  /* withSO_REUSEPORT. -EADDRINUSE */

The expected behavior for sk_reuseport_match() is, it should only allow
the "cached" tb->fast* address to be used as a wildcard match but not
the address of the binding sk.  To do that, the current
"bool match_wildcard" arg is split into
"bool match_sk1_wildcard" and "bool match_sk2_wildcard".

This change only affects the sk_reuseport_match() which is only
used by inet_csk (e.g. TCP).
The other use cases are calling inet_rcv_saddr_equal() and
this patch makes it pass the same "match_wildcard" arg twice to
the "ipv[46]_rcv_saddr_equal(..., match_wildcard, match_wildcard)".

Cc: Josef Bacik 
Fixes: 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport sk")
Signed-off-by: Martin KaFai Lau 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ipv4/inet_connection_sock.c |   43 ++--
 1 file changed, 24 insertions(+), 19 deletions(-)

--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -28,17 +28,19 @@
 #include 
 
 #if IS_ENABLED(CONFIG_IPV6)
-/* match_wildcard == true:  IPV6_ADDR_ANY equals to any IPv6 addresses if IPv6
- *  only, and any IPv4 addresses if not IPv6 only
- * match_wildcard == false: addresses must be exactly the same, i.e.
- *  IPV6_ADDR_ANY only equals to IPV6_ADDR_ANY,
- *  and 0.0.0.0 equals to 0.0.0.0 only
+/* match_sk*_wildcard == true:  IPV6_ADDR_ANY equals to any IPv6 addresses
+ * if IPv6 only, and any IPv4 addresses
+ * if not IPv6 only
+ * match_sk*_wildcard == false: addresses must be exactly the same, i.e.
+ * IPV6_ADDR_ANY only equals to IPV6_ADDR_ANY,
+ * and 0.0.0.0 equals to 0.0.0.0 only
  */
 static bool ipv6_rcv_saddr_equal(const struct in6_addr *sk1_rcv_saddr6,
 const struct in6_addr *sk2_rcv_saddr6,
 __be32 sk1_rcv_saddr, __be32 sk2_rcv_saddr,
 bool sk1_ipv6only, bool sk2_ipv6only,
-bool match_wildcard)
+bool match_sk1_wildcard,
+bool match_sk2_wildcard)
 {
int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : 
IPV6_ADDR_MAPPED;
@@ -48,8 +50,8 @@ static bool ipv6_rcv_saddr_equal(const s
if (!sk2_ipv6only) {
if (sk1_rcv_saddr == sk2_rcv_saddr)
return true;
-   if (!sk1_rcv_saddr || !sk2_rcv_saddr)
-   return match_wildcard;
+   return (match_sk1_wildcard && !sk1_rcv_saddr) ||
+   (match_sk2_wildcard && !sk2_rcv_saddr);
}
return false;
}
@@ -57,11 +59,11 @@ static bool ipv6_rcv_saddr_equal(const s
if (addr_type == IPV6_ADDR_ANY && addr_type2 == IPV6_ADDR_ANY)
return true;
 
-   if (addr_type2 == IPV6_ADDR_ANY && match_wildcard &&
+   if (addr_type2 == IPV6_ADDR_ANY && match_sk2_wildcard &&
!(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
return true;
 
-   if (addr_type == IPV6_ADDR_ANY && match_wildcard &&
+   if (addr_type == IPV6_ADDR_ANY && match_sk1_wildcard &&
!(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))

[PATCH 4.19 25/95] ALSA: usb-audio: add mapping for ASRock TRX40 Creator

2020-06-01 Thread Greg Kroah-Hartman
From: Andrew Oakley 

[ Upstream commit da7a8f1a8fc3e14c6dcc52b4098bddb8f20390be ]

This is another TRX40 based motherboard with ALC1220-VB USB-audio
that requires a static mapping table.

This motherboard also has a PCI device which advertises no codecs.  The
PCI ID is 1022:1487 and PCI SSID is 1022:d102.  As this is using the AMD
vendor ID, don't blacklist for now in case other boards have a working
audio device with the same ssid.

alsa-info.sh report for this board:
http://alsa-project.org/db/?f=0a742f89066527497b77ce16bca486daccf8a70c

Signed-off-by: Andrew Oakley 
Link: https://lore.kernel.org/r/20200503141639.35519-1-and...@adoakley.name
Signed-off-by: Takashi Iwai 
Signed-off-by: Sasha Levin 
---
 sound/usb/mixer_maps.c   | 5 +
 sound/usb/quirks-table.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
index 1689e4f242df..d7a8b23b335b 100644
--- a/sound/usb/mixer_maps.c
+++ b/sound/usb/mixer_maps.c
@@ -543,6 +543,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
.map = trx40_mobo_map,
.connector_map = trx40_mobo_connector_map,
},
+   {   /* Asrock TRX40 Creator */
+   .id = USB_ID(0x26ce, 0x0a01),
+   .map = trx40_mobo_map,
+   .connector_map = trx40_mobo_connector_map,
+   },
{ 0 } /* terminator */
 };
 
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 774aeedde071..4f8a2b98e090 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -3412,6 +3412,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
 ALC1220_VB_DESKTOP(0x0414, 0xa002), /* Gigabyte TRX40 Aorus Pro WiFi */
 ALC1220_VB_DESKTOP(0x0db0, 0x0d64), /* MSI TRX40 Creator */
 ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */
+ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
 #undef ALC1220_VB_DESKTOP
 
 #undef USB_DEVICE_VENDOR_SPEC
-- 
2.25.1





[PATCH 4.19 08/95] net: qrtr: Fix passing invalid reference to qrtr_local_enqueue()

2020-06-01 Thread Greg Kroah-Hartman
From: Manivannan Sadhasivam 

[ Upstream commit d28ea1fbbf437054ef339afec241019f2c4e2bb6 ]

Once the traversal of the list is completed with list_for_each_entry(),
the iterator (node) will point to an invalid object. So passing this to
qrtr_local_enqueue() which is outside of the iterator block is erroneous
eventhough the object is not used.

So fix this by passing NULL to qrtr_local_enqueue().

Fixes: bdabad3e363d ("net: Add Qualcomm IPC router")
Reported-by: kbuild test robot 
Reported-by: Julia Lawall 
Signed-off-by: Manivannan Sadhasivam 
Reviewed-by: Bjorn Andersson 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/qrtr/qrtr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -718,7 +718,7 @@ static int qrtr_bcast_enqueue(struct qrt
}
mutex_unlock(_node_lock);
 
-   qrtr_local_enqueue(node, skb, type, from, to);
+   qrtr_local_enqueue(NULL, skb, type, from, to);
 
return 0;
 }




[PATCH 4.19 19/95] ARM: dts: rockchip: fix phy nodename for rk3228-evb

2020-06-01 Thread Greg Kroah-Hartman
From: Johan Jonker 

[ Upstream commit 287e0d538fcec2f6e8eb1e565bf0749f3b90186d ]

A test with the command below gives for example this error:

arch/arm/boot/dts/rk3228-evb.dt.yaml: phy@0:
'#phy-cells' is a required property

The phy nodename is normally used by a phy-handle.
This node is however compatible with
"ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22"
which is just been added to 'ethernet-phy.yaml'.
So change nodename to 'ethernet-phy' for which '#phy-cells'
is not a required property

make ARCH=arm dtbs_check
DT_SCHEMA_FILES=~/.local/lib/python3.5/site-packages/dtschema/schemas/
phy/phy-provider.yaml

Signed-off-by: Johan Jonker 
Signed-off-by: Heiko Stuebner 
Link: https://lore.kernel.org/r/20200416170321.4216-1-jbx6...@gmail.com
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/rk3228-evb.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
index 5670b33fd1bd..aed879db6c15 100644
--- a/arch/arm/boot/dts/rk3228-evb.dts
+++ b/arch/arm/boot/dts/rk3228-evb.dts
@@ -46,7 +46,7 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   phy: phy@0 {
+   phy: ethernet-phy@0 {
compatible = "ethernet-phy-id1234.d400", 
"ethernet-phy-ieee802.3-c22";
reg = <0>;
clocks = < SCLK_MAC_PHY>;
-- 
2.25.1





[PATCH 4.19 39/95] Input: evdev - call input_flush_device() on release(), not flush()

2020-06-01 Thread Greg Kroah-Hartman
From: Brendan Shanks 

[ Upstream commit 09264098ff153f60866039d60b31d39b66f55a31 ]

input_flush_device() should only be called once the struct file is being
released and no open descriptors remain, but evdev_flush() was calling
it whenever a file descriptor was closed.

This caused uploaded force-feedback effects to be erased when a process
did a dup()/close() on the event FD, called system(), etc.

Call input_flush_device() from evdev_release() instead.

Reported-by: Mathieu Maret 
Signed-off-by: Brendan Shanks 
Link: https://lore.kernel.org/r/20200421231003.7935-1-bsha...@codeweavers.com
Cc: sta...@vger.kernel.org
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Sasha Levin 
---
 drivers/input/evdev.c | 19 ---
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 4263e905cafb..3362dcb3ec0e 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -348,20 +348,6 @@ static int evdev_fasync(int fd, struct file *file, int on)
return fasync_helper(fd, file, on, >fasync);
 }
 
-static int evdev_flush(struct file *file, fl_owner_t id)
-{
-   struct evdev_client *client = file->private_data;
-   struct evdev *evdev = client->evdev;
-
-   mutex_lock(>mutex);
-
-   if (evdev->exist && !client->revoked)
-   input_flush_device(>handle, file);
-
-   mutex_unlock(>mutex);
-   return 0;
-}
-
 static void evdev_free(struct device *dev)
 {
struct evdev *evdev = container_of(dev, struct evdev, dev);
@@ -475,6 +461,10 @@ static int evdev_release(struct inode *inode, struct file 
*file)
unsigned int i;
 
mutex_lock(>mutex);
+
+   if (evdev->exist && !client->revoked)
+   input_flush_device(>handle, file);
+
evdev_ungrab(evdev, client);
mutex_unlock(>mutex);
 
@@ -1336,7 +1326,6 @@ static const struct file_operations evdev_fops = {
.compat_ioctl   = evdev_ioctl_compat,
 #endif
.fasync = evdev_fasync,
-   .flush  = evdev_flush,
.llseek = no_llseek,
 };
 
-- 
2.25.1





[PATCH 4.19 23/95] ARM: dts: rockchip: fix pinctrl sub nodename for spi in rk322x.dtsi

2020-06-01 Thread Greg Kroah-Hartman
From: Johan Jonker 

[ Upstream commit 855bdca1781c79eb661f89c8944c4a719ce720e8 ]

A test with the command below gives these errors:

arch/arm/boot/dts/rk3229-evb.dt.yaml: spi-0:
'#address-cells' is a required property
arch/arm/boot/dts/rk3229-evb.dt.yaml: spi-1:
'#address-cells' is a required property
arch/arm/boot/dts/rk3229-xms6.dt.yaml: spi-0:
'#address-cells' is a required property
arch/arm/boot/dts/rk3229-xms6.dt.yaml: spi-1:
'#address-cells' is a required property

The $nodename pattern for spi nodes is
"^spi(@.*|-[0-9a-f])*$". To prevent warnings rename
'spi-0' and 'spi-1' pinctrl sub nodenames to
'spi0' and 'spi1' in 'rk322x.dtsi'.

make ARCH=arm dtbs_check
DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/spi-controller.yaml

Signed-off-by: Johan Jonker 
Link: https://lore.kernel.org/r/20200424123923.8192-1-jbx6...@gmail.com
Signed-off-by: Heiko Stuebner 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/rk322x.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index bada942ef38d..2aa74267ae51 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -944,7 +944,7 @@
};
};
 
-   spi-0 {
+   spi0 {
spi0_clk: spi0-clk {
rockchip,pins = <0 9 RK_FUNC_2 _pull_up>;
};
@@ -962,7 +962,7 @@
};
};
 
-   spi-1 {
+   spi1 {
spi1_clk: spi1-clk {
rockchip,pins = <0 23 RK_FUNC_2 _pull_up>;
};
-- 
2.25.1





[PATCH 4.19 07/95] net/mlx5: Add command entry handling completion

2020-06-01 Thread Greg Kroah-Hartman
From: Moshe Shemesh 

[ Upstream commit 17d00e839d3b592da9659c1977d45f85b77f986a ]

When FW response to commands is very slow and all command entries in
use are waiting for completion we can have a race where commands can get
timeout before they get out of the queue and handled. Timeout
completion on uninitialized command will cause releasing command's
buffers before accessing it for initialization and then we will get NULL
pointer exception while trying access it. It may also cause releasing
buffers of another command since we may have timeout completion before
even allocating entry index for this command.
Add entry handling completion to avoid this race.

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Moshe Shemesh 
Signed-off-by: Eran Ben Elisha 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c |   14 ++
 include/linux/mlx5/driver.h   |1 +
 2 files changed, 15 insertions(+)

--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -835,6 +835,7 @@ static void cmd_work_handler(struct work
int alloc_ret;
int cmd_mode;
 
+   complete(>handling);
sem = ent->page_queue ? >pages_sem : >sem;
down(sem);
if (!ent->page_queue) {
@@ -953,6 +954,11 @@ static int wait_func(struct mlx5_core_de
struct mlx5_cmd *cmd = >cmd;
int err;
 
+   if (!wait_for_completion_timeout(>handling, timeout) &&
+   cancel_work_sync(>work)) {
+   ent->ret = -ECANCELED;
+   goto out_err;
+   }
if (cmd->mode == CMD_MODE_POLLING || ent->polling) {
wait_for_completion(>done);
} else if (!wait_for_completion_timeout(>done, timeout)) {
@@ -960,12 +966,17 @@ static int wait_func(struct mlx5_core_de
mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
}
 
+out_err:
err = ent->ret;
 
if (err == -ETIMEDOUT) {
mlx5_core_warn(dev, "%s(0x%x) timeout. Will cause a leak of a 
command resource\n",
   mlx5_command_str(msg_to_opcode(ent->in)),
   msg_to_opcode(ent->in));
+   } else if (err == -ECANCELED) {
+   mlx5_core_warn(dev, "%s(0x%x) canceled on out of queue 
timeout.\n",
+  mlx5_command_str(msg_to_opcode(ent->in)),
+  msg_to_opcode(ent->in));
}
mlx5_core_dbg(dev, "err %d, delivery status %s(%d)\n",
  err, deliv_status_to_str(ent->status), ent->status);
@@ -1001,6 +1012,7 @@ static int mlx5_cmd_invoke(struct mlx5_c
ent->token = token;
ent->polling = force_polling;
 
+   init_completion(>handling);
if (!callback)
init_completion(>done);
 
@@ -1020,6 +1032,8 @@ static int mlx5_cmd_invoke(struct mlx5_c
err = wait_func(dev, ent);
if (err == -ETIMEDOUT)
goto out;
+   if (err == -ECANCELED)
+   goto out_free;
 
ds = ent->ts2 - ent->ts1;
op = MLX5_GET(mbox_in, in->first.data, opcode);
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -902,6 +902,7 @@ struct mlx5_cmd_work_ent {
struct delayed_work cb_timeout_work;
void   *context;
int idx;
+   struct completion   handling;
struct completion   done;
struct mlx5_cmd*cmd;
struct work_struct  work;




[PATCH 4.14 66/77] netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code

2020-06-01 Thread Greg Kroah-Hartman
From: Pablo Neira Ayuso 

commit 4c559f15efcc43b996f4da528cd7f9483aaca36d upstream.

Dan Carpenter says: "Smatch complains that the value for "cmd" comes
from the network and can't be trusted."

Add pptp_msg_name() helper function that checks for the array boundary.

Fixes: f09943fefe6b ("[NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port")
Reported-by: Dan Carpenter 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/netfilter/nf_conntrack_pptp.h |2 
 net/ipv4/netfilter/nf_nat_pptp.c|7 ---
 net/netfilter/nf_conntrack_pptp.c   |   62 +++-
 3 files changed, 38 insertions(+), 33 deletions(-)

--- a/include/linux/netfilter/nf_conntrack_pptp.h
+++ b/include/linux/netfilter/nf_conntrack_pptp.h
@@ -5,7 +5,7 @@
 
 #include 
 
-extern const char *const pptp_msg_name[];
+extern const char *const pptp_msg_name(u_int16_t msg);
 
 /* state of the control session */
 enum pptp_ctrlsess_state {
--- a/net/ipv4/netfilter/nf_nat_pptp.c
+++ b/net/ipv4/netfilter/nf_nat_pptp.c
@@ -165,8 +165,7 @@ pptp_outbound_pkt(struct sk_buff *skb,
break;
default:
pr_debug("unknown outbound packet 0x%04x:%s\n", msg,
-msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] :
-  pptp_msg_name[0]);
+pptp_msg_name(msg));
/* fall through */
case PPTP_SET_LINK_INFO:
/* only need to NAT in case PAC is behind NAT box */
@@ -267,9 +266,7 @@ pptp_inbound_pkt(struct sk_buff *skb,
pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID);
break;
default:
-   pr_debug("unknown inbound packet %s\n",
-msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] :
-  pptp_msg_name[0]);
+   pr_debug("unknown inbound packet %s\n", pptp_msg_name(msg));
/* fall through */
case PPTP_START_SESSION_REQUEST:
case PPTP_START_SESSION_REPLY:
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -71,24 +71,32 @@ EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expec
 
 #if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
 /* PptpControlMessageType names */
-const char *const pptp_msg_name[] = {
-   "UNKNOWN_MESSAGE",
-   "START_SESSION_REQUEST",
-   "START_SESSION_REPLY",
-   "STOP_SESSION_REQUEST",
-   "STOP_SESSION_REPLY",
-   "ECHO_REQUEST",
-   "ECHO_REPLY",
-   "OUT_CALL_REQUEST",
-   "OUT_CALL_REPLY",
-   "IN_CALL_REQUEST",
-   "IN_CALL_REPLY",
-   "IN_CALL_CONNECT",
-   "CALL_CLEAR_REQUEST",
-   "CALL_DISCONNECT_NOTIFY",
-   "WAN_ERROR_NOTIFY",
-   "SET_LINK_INFO"
+static const char *const pptp_msg_name_array[PPTP_MSG_MAX + 1] = {
+   [0] = "UNKNOWN_MESSAGE",
+   [PPTP_START_SESSION_REQUEST]= "START_SESSION_REQUEST",
+   [PPTP_START_SESSION_REPLY]  = "START_SESSION_REPLY",
+   [PPTP_STOP_SESSION_REQUEST] = "STOP_SESSION_REQUEST",
+   [PPTP_STOP_SESSION_REPLY]   = "STOP_SESSION_REPLY",
+   [PPTP_ECHO_REQUEST] = "ECHO_REQUEST",
+   [PPTP_ECHO_REPLY]   = "ECHO_REPLY",
+   [PPTP_OUT_CALL_REQUEST] = "OUT_CALL_REQUEST",
+   [PPTP_OUT_CALL_REPLY]   = "OUT_CALL_REPLY",
+   [PPTP_IN_CALL_REQUEST]  = "IN_CALL_REQUEST",
+   [PPTP_IN_CALL_REPLY]= "IN_CALL_REPLY",
+   [PPTP_IN_CALL_CONNECT]  = "IN_CALL_CONNECT",
+   [PPTP_CALL_CLEAR_REQUEST]   = "CALL_CLEAR_REQUEST",
+   [PPTP_CALL_DISCONNECT_NOTIFY]   = "CALL_DISCONNECT_NOTIFY",
+   [PPTP_WAN_ERROR_NOTIFY] = "WAN_ERROR_NOTIFY",
+   [PPTP_SET_LINK_INFO]= "SET_LINK_INFO"
 };
+
+const char *const pptp_msg_name(u_int16_t msg)
+{
+   if (msg > PPTP_MSG_MAX)
+   return pptp_msg_name_array[0];
+
+   return pptp_msg_name_array[msg];
+}
 EXPORT_SYMBOL(pptp_msg_name);
 #endif
 
@@ -275,7 +283,7 @@ pptp_inbound_pkt(struct sk_buff *skb, un
typeof(nf_nat_pptp_hook_inbound) nf_nat_pptp_inbound;
 
msg = ntohs(ctlh->messageType);
-   pr_debug("inbound control message %s\n", pptp_msg_name[msg]);
+   pr_debug("inbound control message %s\n", pptp_msg_name(msg));
 
switch (msg) {
case PPTP_START_SESSION_REPLY:
@@ -310,7 +318,7 @@ pptp_inbound_pkt(struct sk_buff *skb, un
pcid = pptpReq->ocack.peersCallID;
if (info->pns_call_id != pcid)
goto invalid;
-   pr_debug("%s, CID=%X, PCID=%X\n", pptp_msg_name[msg],
+   pr_debug("%s, CID=%X, PCID=%X\n", pptp_msg_name(msg),
 ntohs(cid), ntohs(pcid));
 
if (pptpReq->ocack.resultCode == PPTP_OUTCALL_CONNECT) {
@@ -327,7 +335,7 @@ pptp_inbound_pkt(struct sk_buff 

[PATCH 4.19 14/95] net/mlx5e: Update netdev txq on completions during closure

2020-06-01 Thread Greg Kroah-Hartman
From: Moshe Shemesh 

[ Upstream commit 5e911e2c06bd8c17df29147a5e2d4b17fafda024 ]

On sq closure when we free its descriptors, we should also update netdev
txq on completions which would not arrive. Otherwise if we reopen sqs
and attach them back, for example on fw fatal recovery flow, we may get
tx timeout.

Fixes: 29429f3300a3 ("net/mlx5e: Timeout if SQ doesn't flush during close")
Signed-off-by: Moshe Shemesh 
Reviewed-by: Tariq Toukan 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -595,8 +595,9 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *c
 void mlx5e_free_txqsq_descs(struct mlx5e_txqsq *sq)
 {
struct mlx5e_tx_wqe_info *wi;
+   u32 nbytes = 0;
+   u16 ci, npkts = 0;
struct sk_buff *skb;
-   u16 ci;
int i;
 
while (sq->cc != sq->pc) {
@@ -617,8 +618,11 @@ void mlx5e_free_txqsq_descs(struct mlx5e
}
 
dev_kfree_skb_any(skb);
+   npkts++;
+   nbytes += wi->num_bytes;
sq->cc += wi->num_wqebbs;
}
+   netdev_tx_completed_queue(sq->txq, npkts, nbytes);
 }
 
 #ifdef CONFIG_MLX5_CORE_IPOIB




[PATCH 4.14 68/77] qlcnic: fix missing release in qlcnic_83xx_interrupt_test.

2020-06-01 Thread Greg Kroah-Hartman
From: Qiushi Wu 

commit 15c973858903009e995b2037683de29dfe968621 upstream.

In function qlcnic_83xx_interrupt_test(), function
qlcnic_83xx_diag_alloc_res() is not handled by function
qlcnic_83xx_diag_free_res() after a call of the function
qlcnic_alloc_mbx_args() failed. Fix this issue by adding
a jump target "fail_mbx_args", and jump to this new target
when qlcnic_alloc_mbx_args() failed.

Fixes: b6b4316c8b2f ("qlcnic: Handle qlcnic_alloc_mbx_args() failure")
Signed-off-by: Qiushi Wu 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -3650,7 +3650,7 @@ int qlcnic_83xx_interrupt_test(struct ne
ahw->diag_cnt = 0;
ret = qlcnic_alloc_mbx_args(, adapter, QLCNIC_CMD_INTRPT_TEST);
if (ret)
-   goto fail_diag_irq;
+   goto fail_mbx_args;
 
if (adapter->flags & QLCNIC_MSIX_ENABLED)
intrpt_id = ahw->intr_tbl[0].id;
@@ -3680,6 +3680,8 @@ int qlcnic_83xx_interrupt_test(struct ne
 
 done:
qlcnic_free_mbx_args();
+
+fail_mbx_args:
qlcnic_83xx_diag_free_res(netdev, drv_sds_rings);
 
 fail_diag_irq:




[PATCH 4.19 16/95] net: sun: fix missing release regions in cas_init_one().

2020-06-01 Thread Greg Kroah-Hartman
From: Qiushi Wu 

commit 5a730153984dd13f82ffae93d7170d76eba204e9 upstream.

In cas_init_one(), "pdev" is requested by "pci_request_regions", but it
was not released after a call of the function “pci_write_config_byte”
failed. Thus replace the jump target “err_write_cacheline” by
"err_out_free_res".

Fixes: 1f26dac32057 ("[NET]: Add Sun Cassini driver.")
Signed-off-by: Qiushi Wu 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/sun/cassini.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -4971,7 +4971,7 @@ static int cas_init_one(struct pci_dev *
  cas_cacheline_size)) {
dev_err(>dev, "Could not set PCI cache "
   "line size\n");
-   goto err_write_cacheline;
+   goto err_out_free_res;
}
}
 #endif
@@ -5144,7 +5144,6 @@ err_out_iounmap:
 err_out_free_res:
pci_release_regions(pdev);
 
-err_write_cacheline:
/* Try to restore it in case the error occurred after we
 * set it.
 */




[PATCH 4.14 65/77] netfilter: nfnetlink_cthelper: unbreak userspace helper support

2020-06-01 Thread Greg Kroah-Hartman
From: Pablo Neira Ayuso 

commit 703acd70f2496537457186211c2f03e792409e68 upstream.

Restore helper data size initialization and fix memcopy of the helper
data size.

Fixes: 157eb5dc ("netfilter: nfnetlink_cthelper: reject too large userspace 
allocation requests")
Reviewed-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Greg Kroah-Hartman 

---
 net/netfilter/nfnetlink_cthelper.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -106,7 +106,7 @@ nfnl_cthelper_from_nlattr(struct nlattr
if (help->helper->data_len == 0)
return -EINVAL;
 
-   nla_memcpy(help->data, nla_data(attr), sizeof(help->data));
+   nla_memcpy(help->data, attr, sizeof(help->data));
return 0;
 }
 
@@ -240,6 +240,7 @@ nfnl_cthelper_create(const struct nlattr
ret = -ENOMEM;
goto err2;
}
+   helper->data_len = size;
 
helper->flags |= NF_CT_HELPER_F_USERSPACE;
memcpy(>tuple, tuple, sizeof(struct nf_conntrack_tuple));




[PATCH 4.19 13/95] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed

2020-06-01 Thread Greg Kroah-Hartman
From: "Jere Lepp�nen" 

[ Upstream commit d3e8e4c11870413789f029a71e72ae6e971fe678 ]

Commit bdf6fa52f01b ("sctp: handle association restarts when the
socket is closed.") starts shutdown when an association is restarted,
if in SHUTDOWN-PENDING state and the socket is closed. However, the
rationale stated in that commit applies also when in SHUTDOWN-SENT
state - we don't want to move an association to ESTABLISHED state when
the socket has been closed, because that results in an association
that is unreachable from user space.

The problem scenario:

1.  Client crashes and/or restarts.

2.  Server (using one-to-one socket) calls close(). SHUTDOWN is lost.

3.  Client reconnects using the same addresses and ports.

4.  Server's association is restarted. The association and the socket
move to ESTABLISHED state, even though the server process has
closed its descriptor.

Also, after step 4 when the server process exits, some resources are
leaked in an attempt to release the underlying inet sock structure in
ESTABLISHED state:

IPv4: Attempt to release TCP socket in state 1 377288c7

Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if
an association is restarted in SHUTDOWN-SENT state and the socket is
closed, then start shutdown and don't move the association or the
socket to ESTABLISHED state.

Fixes: bdf6fa52f01b ("sctp: handle association restarts when the socket is 
closed.")
Signed-off-by: Jere Leppänen 
Acked-by: Marcelo Ricardo Leitner 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/sctp/sm_statefuns.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1871,12 +1871,13 @@ static enum sctp_disposition sctp_sf_do_
/* Update the content of current association. */
sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
-   if (sctp_state(asoc, SHUTDOWN_PENDING) &&
+   if ((sctp_state(asoc, SHUTDOWN_PENDING) ||
+sctp_state(asoc, SHUTDOWN_SENT)) &&
(sctp_sstate(asoc->base.sk, CLOSING) ||
 sock_flag(asoc->base.sk, SOCK_DEAD))) {
-   /* if were currently in SHUTDOWN_PENDING, but the socket
-* has been closed by user, don't transition to ESTABLISHED.
-* Instead trigger SHUTDOWN bundled with COOKIE_ACK.
+   /* If the socket has been closed by user, don't
+* transition to ESTABLISHED. Instead trigger SHUTDOWN
+* bundled with COOKIE_ACK.
 */
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
return sctp_sf_do_9_2_start_shutdown(net, ep, asoc,




[PATCH 4.14 74/77] rxrpc: Fix transport sockopts to get IPv4 errors on an IPv6 socket

2020-06-01 Thread Greg Kroah-Hartman
From: David Howells 

commit 37a675e768d7606fe8a53e0c459c9b53e121ac20 upstream.

It seems that enabling IPV6_RECVERR on an IPv6 socket doesn't also turn on
IP_RECVERR, so neither local errors nor ICMP-transported remote errors from
IPv4 peer addresses are returned to the AF_RXRPC protocol.

Make the sockopt setting code in rxrpc_open_socket() fall through from the
AF_INET6 case to the AF_INET case to turn on all the AF_INET options too in
the AF_INET6 case.

Fixes: f2aeed3a591f ("rxrpc: Fix error reception on AF_INET6 sockets")
Signed-off-by: David Howells 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 net/rxrpc/local_object.c |   23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -134,10 +134,10 @@ static int rxrpc_open_socket(struct rxrp
}
 
switch (local->srx.transport.family) {
-   case AF_INET:
-   /* we want to receive ICMP errors */
+   case AF_INET6:
+   /* we want to receive ICMPv6 errors */
opt = 1;
-   ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR,
+   ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_RECVERR,
(char *) , sizeof(opt));
if (ret < 0) {
_debug("setsockopt failed");
@@ -145,19 +145,22 @@ static int rxrpc_open_socket(struct rxrp
}
 
/* we want to set the don't fragment bit */
-   opt = IP_PMTUDISC_DO;
-   ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER,
+   opt = IPV6_PMTUDISC_DO;
+   ret = kernel_setsockopt(local->socket, SOL_IPV6, 
IPV6_MTU_DISCOVER,
(char *) , sizeof(opt));
if (ret < 0) {
_debug("setsockopt failed");
goto error;
}
-   break;
 
-   case AF_INET6:
+   /* Fall through and set IPv4 options too otherwise we don't get
+* errors from IPv4 packets sent through the IPv6 socket.
+*/
+
+   case AF_INET:
/* we want to receive ICMP errors */
opt = 1;
-   ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_RECVERR,
+   ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR,
(char *) , sizeof(opt));
if (ret < 0) {
_debug("setsockopt failed");
@@ -165,8 +168,8 @@ static int rxrpc_open_socket(struct rxrp
}
 
/* we want to set the don't fragment bit */
-   opt = IPV6_PMTUDISC_DO;
-   ret = kernel_setsockopt(local->socket, SOL_IPV6, 
IPV6_MTU_DISCOVER,
+   opt = IP_PMTUDISC_DO;
+   ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER,
(char *) , sizeof(opt));
if (ret < 0) {
_debug("setsockopt failed");




[PATCH 4.14 77/77] net: hns: Fixes the missing put_device in positive leg for roce reset

2020-06-01 Thread Greg Kroah-Hartman
From: Salil Mehta 

commit 4d96e13ee9cd1f7f801e8c7f4b12f09d1da4a5d8 upstream.

This patch fixes the missing device reference release-after-use in
the positive leg of the roce reset API of the HNS DSAF.

Fixes: c969c6e7ab8c ("net: hns: Fix object reference leaks in 
hns_dsaf_roce_reset()")
Reported-by: John Garry 
Signed-off-by: Salil Mehta 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -3142,6 +3142,9 @@ int hns_dsaf_roce_reset(struct fwnode_ha
dsaf_set_bit(credit, DSAF_SBM_ROCEE_CFG_CRD_EN_B, 1);
dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit);
}
+
+   put_device(>dev);
+
return 0;
 }
 EXPORT_SYMBOL(hns_dsaf_roce_reset);




[PATCH 4.14 72/77] mm/vmalloc.c: dont dereference possible NULL pointer in __vunmap()

2020-06-01 Thread Greg Kroah-Hartman
From: Liviu Dudau 

commit 6ade20327dbb808882888ed8ccded71e93067cf9 upstream.

find_vmap_area() can return a NULL pointer and we're going to
dereference it without checking it first.  Use the existing
find_vm_area() function which does exactly what we want and checks for
the NULL pointer.

Link: http://lkml.kernel.org/r/20181228171009.22269-1-li...@dudau.co.uk
Fixes: f3c01d2f3ade ("mm: vmalloc: avoid racy handling of debugobjects in 
vunmap")
Signed-off-by: Liviu Dudau 
Reviewed-by: Andrew Morton 
Cc: Chintan Pandya 
Cc: Andrey Ryabinin 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 mm/vmalloc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1524,7 +1524,7 @@ static void __vunmap(const void *addr, i
addr))
return;
 
-   area = find_vmap_area((unsigned long)addr)->vm;
+   area = find_vm_area(addr);
if (unlikely(!area)) {
WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n",
addr);




[PATCH 4.14 73/77] sc16is7xx: move label err_spi to correct section

2020-06-01 Thread Greg Kroah-Hartman
From: Guoqing Jiang 

commit e00164a0f000de893944981f41a568c981aca658 upstream.

err_spi is used when SERIAL_SC16IS7XX_SPI is enabled, so make
the label only available under SERIAL_SC16IS7XX_SPI option.
Otherwise, the below warning appears.

drivers/tty/serial/sc16is7xx.c:1523:1: warning: label ‘err_spi’ defined but not 
used [-Wunused-label]
 err_spi:
  ^~~

Signed-off-by: Guoqing Jiang 
Fixes: ac0cdb3d9901 ("sc16is7xx: missing unregister/delete driver on error in 
sc16is7xx_init()")
Signed-off-by: Arnd Bergmann 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/tty/serial/sc16is7xx.c |2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1524,10 +1524,12 @@ static int __init sc16is7xx_init(void)
 #endif
return ret;
 
+#ifdef CONFIG_SERIAL_SC16IS7XX_SPI
 err_spi:
 #ifdef CONFIG_SERIAL_SC16IS7XX_I2C
i2c_del_driver(_i2c_uart_driver);
 #endif
+#endif
 err_i2c:
uart_unregister_driver(_uart);
return ret;




[PATCH 4.14 71/77] netfilter: nf_conntrack_pptp: fix compilation warning with W=1 build

2020-06-01 Thread Greg Kroah-Hartman
From: Pablo Neira Ayuso 

commit 4946ea5c1237036155c3b3a24f049fd5f849f8f6 upstream.

>> include/linux/netfilter/nf_conntrack_pptp.h:13:20: warning: 'const' type 
>> qualifier on return type has no effect [-Wignored-qualifiers]
extern const char *const pptp_msg_name(u_int16_t msg);
^~

Reported-by: kbuild test robot 
Fixes: 4c559f15efcc ("netfilter: nf_conntrack_pptp: prevent buffer overflows in 
debug code")
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/netfilter/nf_conntrack_pptp.h |2 +-
 net/netfilter/nf_conntrack_pptp.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/include/linux/netfilter/nf_conntrack_pptp.h
+++ b/include/linux/netfilter/nf_conntrack_pptp.h
@@ -5,7 +5,7 @@
 
 #include 
 
-extern const char *const pptp_msg_name(u_int16_t msg);
+const char *pptp_msg_name(u_int16_t msg);
 
 /* state of the control session */
 enum pptp_ctrlsess_state {
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -90,7 +90,7 @@ static const char *const pptp_msg_name_a
[PPTP_SET_LINK_INFO]= "SET_LINK_INFO"
 };
 
-const char *const pptp_msg_name(u_int16_t msg)
+const char *pptp_msg_name(u_int16_t msg)
 {
if (msg > PPTP_MSG_MAX)
return pptp_msg_name_array[0];




[PATCH 4.14 76/77] net: hns: fix unsigned comparison to less than zero

2020-06-01 Thread Greg Kroah-Hartman
From: Colin Ian King 

commit ea401685a20b5d631957f024bda86e1f6118eb20 upstream.

Currently mskid is unsigned and hence comparisons with negative
error return values are always false. Fix this by making mskid an
int.

Fixes: f058e46855dc ("net: hns: fix ICMP6 neighbor solicitation messages 
discard problem")
Addresses-Coverity: ("Operands don't affect result")
Signed-off-by: Colin Ian King 
Reviewed-by: Mukesh Ojha 
Signed-off-by: David S. Miller 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -2770,7 +2770,7 @@ static void set_promisc_tcam_enable(stru
struct hns_mac_cb *mac_cb;
u8 addr[ETH_ALEN] = {0};
u8 port_num;
-   u16 mskid;
+   int mskid;
 
/* promisc use vague table match with vlanid = 0 & macaddr = 0 */
hns_dsaf_set_mac_key(dsaf_dev, _key, 0x00, port, addr);




[PATCH 4.14 50/77] include/asm-generic/topology.h: guard cpumask_of_node() macro argument

2020-06-01 Thread Greg Kroah-Hartman
From: Arnd Bergmann 

[ Upstream commit 4377748c7b5187c3342a60fa2ceb60c8a57a8488 ]

drivers/hwmon/amd_energy.c:195:15: error: invalid operands to binary expression 
('void' and 'int')
(channel - data->nr_cpus));
~^
include/asm-generic/topology.h:51:42: note: expanded from macro 
'cpumask_of_node'
#define cpumask_of_node(node)   ((void)node, cpu_online_mask)
   ^~~~
include/linux/cpumask.h:618:72: note: expanded from macro 'cpumask_first_and'
 #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
   ^

Fixes: f0b848ce6fe9 ("cpumask: Introduce cpumask_of_{node,pcibus} to replace 
{node,pcibus}_to_cpumask")
Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")
Signed-off-by: Arnd Bergmann 
Signed-off-by: Andrew Morton 
Acked-by: Guenter Roeck 
Link: http://lkml.kernel.org/r/20200527134623.930247-1-a...@arndb.de
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 include/asm-generic/topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index 5d2add1a6c96..864fcfa1df41 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -51,7 +51,7 @@
   #ifdef CONFIG_NEED_MULTIPLE_NODES
 #define cpumask_of_node(node)  ((node) == 0 ? cpu_online_mask : 
cpu_none_mask)
   #else
-#define cpumask_of_node(node)  ((void)node, cpu_online_mask)
+#define cpumask_of_node(node)  ((void)(node), cpu_online_mask)
   #endif
 #endif
 #ifndef pcibus_to_node
-- 
2.25.1





[PATCH 4.14 37/77] IB/qib: Call kobject_put() when kobject_init_and_add() fails

2020-06-01 Thread Greg Kroah-Hartman
From: Kaike Wan 

[ Upstream commit a35cd6447effd5c239b564c80fa109d05ff3d114 ]

When kobject_init_and_add() returns an error in the function
qib_create_port_files(), the function kobject_put() is not called for the
corresponding kobject, which potentially leads to memory leak.

This patch fixes the issue by calling kobject_put() even if
kobject_init_and_add() fails. In addition, the ppd->diagc_kobj is released
along with other kobjects when the sysfs is unregistered.

Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand 
adapters")
Link: 
https://lore.kernel.org/r/20200512031328.189865.48627.st...@awfm-01.aw.intel.com
Cc: 
Suggested-by: Lin Yi 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Dennis Dalessandro 
Reviewed-by: Leon Romanovsky 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/qib/qib_sysfs.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c 
b/drivers/infiniband/hw/qib/qib_sysfs.c
index d831f3e61ae8..2626205780ee 100644
--- a/drivers/infiniband/hw/qib/qib_sysfs.c
+++ b/drivers/infiniband/hw/qib/qib_sysfs.c
@@ -756,7 +756,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping linkcontrol sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail;
+   goto bail_link;
}
kobject_uevent(>pport_kobj, KOBJ_ADD);
 
@@ -766,7 +766,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping sl2vl sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail_link;
+   goto bail_sl;
}
kobject_uevent(>sl2vl_kobj, KOBJ_ADD);
 
@@ -776,7 +776,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping diag_counters sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail_sl;
+   goto bail_diagc;
}
kobject_uevent(>diagc_kobj, KOBJ_ADD);
 
@@ -789,7 +789,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
 "Skipping Congestion Control sysfs info, (err %d) port %u\n",
 ret, port_num);
-   goto bail_diagc;
+   goto bail_cc;
}
 
kobject_uevent(>pport_cc_kobj, KOBJ_ADD);
@@ -871,6 +871,7 @@ void qib_verbs_unregister_sysfs(struct qib_devdata *dd)
_table_bin_attr);
kobject_put(>pport_cc_kobj);
}
+   kobject_put(>diagc_kobj);
kobject_put(>sl2vl_kobj);
kobject_put(>pport_kobj);
}
-- 
2.25.1





[PATCH 4.14 60/77] xfrm: fix error in comment

2020-06-01 Thread Greg Kroah-Hartman
From: Antony Antony 

commit 29e4276667e24ee6b91d9f91064d8fda9a210ea1 upstream.

s/xfrm_state_offload/xfrm_user_offload/

Fixes: d77e38e612a ("xfrm: Add an IPsec hardware offloading API")
Signed-off-by: Antony Antony 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 include/uapi/linux/xfrm.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -304,7 +304,7 @@ enum xfrm_attr_type_t {
XFRMA_PROTO,/* __u8 */
XFRMA_ADDRESS_FILTER,   /* struct xfrm_address_filter */
XFRMA_PAD,
-   XFRMA_OFFLOAD_DEV,  /* struct xfrm_state_offload */
+   XFRMA_OFFLOAD_DEV,  /* struct xfrm_user_offload */
XFRMA_OUTPUT_MARK,  /* __u32 */
__XFRMA_MAX
 




[PATCH 4.14 23/77] samples: bpf: Fix build error

2020-06-01 Thread Greg Kroah-Hartman
From: Matteo Croce 

[ Upstream commit 23ad04669f81f958e9a4121b0266228d2eb3c357 ]

GCC 10 is very strict about symbol clash, and lwt_len_hist_user contains
a symbol which clashes with libbpf:

/usr/bin/ld: samples/bpf/lwt_len_hist_user.o:(.bss+0x0): multiple definition of 
`bpf_log_buf'; samples/bpf/bpf_load.o:(.bss+0x8c0): first defined here
collect2: error: ld returned 1 exit status

bpf_log_buf here seems to be a leftover, so removing it.

Signed-off-by: Matteo Croce 
Signed-off-by: Alexei Starovoitov 
Acked-by: Yonghong Song 
Link: https://lore.kernel.org/bpf/2020053234.80722-1-mcr...@redhat.com
Signed-off-by: Sasha Levin 
---
 samples/bpf/lwt_len_hist_user.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/samples/bpf/lwt_len_hist_user.c b/samples/bpf/lwt_len_hist_user.c
index 7fcb94c09112..965108527a4f 100644
--- a/samples/bpf/lwt_len_hist_user.c
+++ b/samples/bpf/lwt_len_hist_user.c
@@ -15,8 +15,6 @@
 #define MAX_INDEX 64
 #define MAX_STARS 38
 
-char bpf_log_buf[BPF_LOG_BUF_SIZE];
-
 static void stars(char *str, long val, long max, int width)
 {
int i;
-- 
2.25.1





[PATCH 4.14 21/77] net: freescale: select CONFIG_FIXED_PHY where needed

2020-06-01 Thread Greg Kroah-Hartman
From: Arnd Bergmann 

[ Upstream commit 99352c79af3e5f2e4724abf37fa5a2a3299b1c81 ]

I ran into a randconfig build failure with CONFIG_FIXED_PHY=m
and CONFIG_GIANFAR=y:

x86_64-linux-ld: drivers/net/ethernet/freescale/gianfar.o:(.rodata+0x418): 
undefined reference to `fixed_phy_change_carrier'

It seems the same thing can happen with dpaa and ucc_geth, so change
all three to do an explicit 'select FIXED_PHY'.

The fixed-phy driver actually has an alternative stub function that
theoretically allows building network drivers when fixed-phy is
disabled, but I don't see how that would help here, as the drivers
presumably would not work then.

Signed-off-by: Arnd Bergmann 
Acked-by: Florian Fainelli 
Signed-off-by: Jakub Kicinski 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/freescale/Kconfig  | 2 ++
 drivers/net/ethernet/freescale/dpaa/Kconfig | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/freescale/Kconfig 
b/drivers/net/ethernet/freescale/Kconfig
index 6e490fd2345d..71f0640200bc 100644
--- a/drivers/net/ethernet/freescale/Kconfig
+++ b/drivers/net/ethernet/freescale/Kconfig
@@ -76,6 +76,7 @@ config UCC_GETH
depends on QUICC_ENGINE
select FSL_PQ_MDIO
select PHYLIB
+   select FIXED_PHY
---help---
  This driver supports the Gigabit Ethernet mode of the QUICC Engine,
  which is available on some Freescale SOCs.
@@ -89,6 +90,7 @@ config GIANFAR
depends on HAS_DMA
select FSL_PQ_MDIO
select PHYLIB
+   select FIXED_PHY
select CRC32
---help---
  This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
diff --git a/drivers/net/ethernet/freescale/dpaa/Kconfig 
b/drivers/net/ethernet/freescale/dpaa/Kconfig
index a654736237a9..8fec41e57178 100644
--- a/drivers/net/ethernet/freescale/dpaa/Kconfig
+++ b/drivers/net/ethernet/freescale/dpaa/Kconfig
@@ -2,6 +2,7 @@ menuconfig FSL_DPAA_ETH
tristate "DPAA Ethernet"
depends on FSL_DPAA && FSL_FMAN
select PHYLIB
+   select FIXED_PHY
select FSL_FMAN_MAC
---help---
  Data Path Acceleration Architecture Ethernet driver,
-- 
2.25.1





[PATCH 4.14 20/77] usb: gadget: legacy: fix redundant initialization warnings

2020-06-01 Thread Greg Kroah-Hartman
From: Masahiro Yamada 

[ Upstream commit d13cce757954fa663c69845611957396843ed87a ]

Fix the following cppcheck warnings:

drivers/usb/gadget/legacy/inode.c:1364:8: style: Redundant initialization for 
'value'. The initialized value is overwritten$
 value = -EOPNOTSUPP;
   ^
drivers/usb/gadget/legacy/inode.c:1331:15: note: value is initialized
 intvalue = -EOPNOTSUPP;
  ^
drivers/usb/gadget/legacy/inode.c:1364:8: note: value is overwritten
 value = -EOPNOTSUPP;
   ^
drivers/usb/gadget/legacy/inode.c:1817:8: style: Redundant initialization for 
'value'. The initialized value is overwritten$
 value = -EINVAL;
   ^
drivers/usb/gadget/legacy/inode.c:1787:18: note: value is initialized
 ssize_t   value = len, length = len;
 ^
drivers/usb/gadget/legacy/inode.c:1817:8: note: value is overwritten
 value = -EINVAL;
   ^
Acked-by: Alan Stern 
Reported-by: kbuild test robot 
Signed-off-by: Masahiro Yamada 
Signed-off-by: Felipe Balbi 

Signed-off-by: Sasha Levin 
---
 drivers/usb/gadget/legacy/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/legacy/inode.c 
b/drivers/usb/gadget/legacy/inode.c
index 5c28bee327e1..e431a8bc3a9d 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1364,7 +1364,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
 
req->buf = dev->rbuf;
req->context = NULL;
-   value = -EOPNOTSUPP;
switch (ctrl->bRequest) {
 
case USB_REQ_GET_DESCRIPTOR:
@@ -1788,7 +1787,7 @@ static ssize_t
 dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 {
struct dev_data *dev = fd->private_data;
-   ssize_t value = len, length = len;
+   ssize_t value, length = len;
unsignedtotal;
u32 tag;
char*kbuf;
-- 
2.25.1





[PATCH 4.14 19/77] cachefiles: Fix race between read_waiter and read_copier involving op->to_do

2020-06-01 Thread Greg Kroah-Hartman
From: Lei Xue 

[ Upstream commit 7bb0c5338436dae953622470d52689265867f032 ]

There is a potential race in fscache operation enqueuing for reading and
copying multiple pages from cachefiles to netfs.  The problem can be seen
easily on a heavy loaded system (for example many processes reading files
continually on an NFS share covered by fscache triggered this problem within
a few minutes).

The race is due to cachefiles_read_waiter() adding the op to the monitor
to_do list and then then drop the object->work_lock spinlock before
completing fscache_enqueue_operation().  Once the lock is dropped,
cachefiles_read_copier() grabs the op, completes processing it, and
makes it through fscache_retrieval_complete() which sets the op->state to
the final state of FSCACHE_OP_ST_COMPLETE(4).  When cachefiles_read_waiter()
finally gets through the remainder of fscache_enqueue_operation()
it sees the invalid state, and hits the ASSERTCMP and the following
oops is seen:
[ 2259.612361] FS-Cache:
[ 2259.614785] FS-Cache: Assertion failed
[ 2259.618639] FS-Cache: 4 == 5 is false
[ 2259.622456] [ cut here ]
[ 2259.627190] kernel BUG at fs/fscache/operation.c:70!
...
[ 2259.791675] RIP: 0010:[]  [] 
fscache_enqueue_operation+0xff/0x170 [fscache]
[ 2259.802059] RSP: :a0263d543be0  EFLAGS: 00010046
[ 2259.807521] RAX: 0019 RBX: a01a4d390480 RCX: 0006
[ 2259.814847] RDX:  RSI: 0046 RDI: a0263d553890
[ 2259.822176] RBP: a0263d543be8 R08:  R09: a0263c2d8708
[ 2259.829502] R10: 1e7f R11:  R12: a01a4d390480
[ 2259.844483] R13: 9fa9546c5920 R14: a0263d543c80 R15: a0293ff9bf10
[ 2259.859554] FS:  7f4b6efbd700() GS:a0263d54() 
knlGS:
[ 2259.875571] CS:  0010 DS:  ES:  CR0: 80050033
[ 2259.889117] CR2: 7f49e1624ff0 CR3: 012b38b38000 CR4: 007607e0
[ 2259.904015] DR0:  DR1:  DR2: 
[ 2259.918764] DR3:  DR6: fffe0ff0 DR7: 0400
[ 2259.933449] PKRU: 5554
[ 2259.943654] Call Trace:
[ 2259.953592]  
[ 2259.955577]  [] cachefiles_read_waiter+0x92/0xf0 
[cachefiles]
[ 2259.978039]  [] __wake_up_common+0x82/0x120
[ 2259.991392]  [] __wake_up_common_lock+0x83/0xc0
[ 2260.004930]  [] ? task_rq_unlock+0x20/0x20
[ 2260.017863]  [] __wake_up+0x13/0x20
[ 2260.030230]  [] __wake_up_bit+0x50/0x70
[ 2260.042535]  [] unlock_page+0x2b/0x30
[ 2260.054495]  [] page_endio+0x29/0x90
[ 2260.066184]  [] mpage_end_io+0x51/0x80

CPU1
cachefiles_read_waiter()
 20 static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode,
 21   int sync, void *_key)
 22 {
...
 61 spin_lock(>work_lock);
 62 list_add_tail(>op_link, >to_do);
 63 spin_unlock(>work_lock);

 64
 65 fscache_enqueue_retrieval(op);
182 static inline void fscache_enqueue_retrieval(struct fscache_retrieval *op)
183 {
184 fscache_enqueue_operation(>op);
185 }
 58 void fscache_enqueue_operation(struct fscache_operation *op)
 59 {
 60 struct fscache_cookie *cookie = op->object->cookie;
 61
 62 _enter("{OBJ%x OP%x,%u}",
 63op->object->debug_id, op->debug_id, atomic_read(>usage));
 64
 65 ASSERT(list_empty(>pend_link));
 66 ASSERT(op->processor != NULL);
 67 ASSERT(fscache_object_is_available(op->object));
 68 ASSERTCMP(atomic_read(>usage), >, 0);


CPU2
cachefiles_read_copier()
168 while (!list_empty(>to_do)) {
...
202 fscache_end_io(op, monitor->netfs_page, error);
203 put_page(monitor->netfs_page);
204 fscache_retrieval_complete(op, 1);

CPU1
 58 void fscache_enqueue_operation(struct fscache_operation *op)
 59 {
...
 69 ASSERTIFCMP(op->state != FSCACHE_OP_ST_IN_PROGRESS,
 70 op->state, ==,  FSCACHE_OP_ST_CANCELLED);

Signed-off-by: Lei Xue 
Signed-off-by: Dave Wysochanski 
Signed-off-by: David Howells 
Signed-off-by: Sasha Levin 
---
 fs/cachefiles/rdwr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
index 5e9176ec0d3a..c073a0f680fd 100644
--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -64,9 +64,9 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, 
unsigned mode,
object = container_of(op->op.object, struct cachefiles_object, fscache);
spin_lock(>work_lock);
list_add_tail(>op_link, >to_do);
+   fscache_enqueue_retrieval(op);
spin_unlock(>work_lock);
 
-   fscache_enqueue_retrieval(op);
fscache_put_retrieval(op);
return 0;
 }
-- 
2.25.1





[PATCH 4.14 58/77] xfrm: fix a warning in xfrm_policy_insert_list

2020-06-01 Thread Greg Kroah-Hartman
From: Xin Long 

commit ed17b8d377eaf6b4a01d46942b4c647378a79bdd upstream.

This waring can be triggered simply by:

  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 1 mark 0 mask 0x10  #[1]
  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 2 mark 0 mask 0x1   #[2]
  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 2 mark 0 mask 0x10  #[3]

Then dmesg shows:

  [ ] WARNING: CPU: 1 PID: 7265 at net/xfrm/xfrm_policy.c:1548
  [ ] RIP: 0010:xfrm_policy_insert_list+0x2f2/0x1030
  [ ] Call Trace:
  [ ]  xfrm_policy_inexact_insert+0x85/0xe50
  [ ]  xfrm_policy_insert+0x4ba/0x680
  [ ]  xfrm_add_policy+0x246/0x4d0
  [ ]  xfrm_user_rcv_msg+0x331/0x5c0
  [ ]  netlink_rcv_skb+0x121/0x350
  [ ]  xfrm_netlink_rcv+0x66/0x80
  [ ]  netlink_unicast+0x439/0x630
  [ ]  netlink_sendmsg+0x714/0xbf0
  [ ]  sock_sendmsg+0xe2/0x110

The issue was introduced by Commit 7cb8a93968e3 ("xfrm: Allow inserting
policies with matching mark and different priorities"). After that, the
policies [1] and [2] would be able to be added with different priorities.

However, policy [3] will actually match both [1] and [2]. Policy [1]
was matched due to the 1st 'return true' in xfrm_policy_mark_match(),
and policy [2] was matched due to the 2nd 'return true' in there. It
caused WARN_ON() in xfrm_policy_insert_list().

This patch is to fix it by only (the same value and priority) as the
same policy in xfrm_policy_mark_match().

Thanks to Yuehaibing, we could make this fix better.

v1->v2:
  - check policy->mark.v == pol->mark.v only without mask.

Fixes: 7cb8a93968e3 ("xfrm: Allow inserting policies with matching mark and 
different priorities")
Reported-by: Xiumei Mu 
Signed-off-by: Xin Long 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 net/xfrm/xfrm_policy.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -722,12 +722,7 @@ static void xfrm_policy_requeue(struct x
 static bool xfrm_policy_mark_match(struct xfrm_policy *policy,
   struct xfrm_policy *pol)
 {
-   u32 mark = policy->mark.v & policy->mark.m;
-
-   if (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m)
-   return true;
-
-   if ((mark & pol->mark.m) == pol->mark.v &&
+   if (policy->mark.v == pol->mark.v &&
policy->priority == pol->priority)
return true;
 




[PATCH 4.14 48/77] mm: remove VM_BUG_ON(PageSlab()) from page_mapcount()

2020-06-01 Thread Greg Kroah-Hartman
From: Konstantin Khlebnikov 

[ Upstream commit 6988f31d558aa8c744464a7f6d91d34ada48ad12 ]

Replace superfluous VM_BUG_ON() with comment about correct usage.

Technically reverts commit 1d148e218a0d ("mm: add VM_BUG_ON_PAGE() to
page_mapcount()"), but context lines have changed.

Function isolate_migratepages_block() runs some checks out of lru_lock
when choose pages for migration.  After checking PageLRU() it checks
extra page references by comparing page_count() and page_mapcount().
Between these two checks page could be removed from lru, freed and taken
by slab.

As a result this race triggers VM_BUG_ON(PageSlab()) in page_mapcount().
Race window is tiny.  For certain workload this happens around once a
year.

page:ea0105ca9380 count:1 mapcount:0 mapping:88ff7712c180 index:0x0 
compound_mapcount: 0
flags: 0x5008100(slab|head)
raw: 05008100 dead0100 dead0200 88ff7712c180
raw:  80200020 0001 
page dumped because: VM_BUG_ON_PAGE(PageSlab(page))
[ cut here ]
kernel BUG at ./include/linux/mm.h:628!
invalid opcode:  [#1] SMP NOPTI
CPU: 77 PID: 504 Comm: kcompactd1 Tainted: GW 4.19.109-27 #1
Hardware name: Yandex T175-N41-Y3N/MY81-EX0-Y3N, BIOS R05 06/20/2019
RIP: 0010:isolate_migratepages_block+0x986/0x9b0

The code in isolate_migratepages_block() was added in commit
119d6d59dcc0 ("mm, compaction: avoid isolating pinned pages") before
adding VM_BUG_ON into page_mapcount().

This race has been predicted in 2015 by Vlastimil Babka (see link
below).

[a...@linux-foundation.org: comment tweaks, per Hugh]
Fixes: 1d148e218a0d ("mm: add VM_BUG_ON_PAGE() to page_mapcount()")
Signed-off-by: Konstantin Khlebnikov 
Signed-off-by: Andrew Morton 
Acked-by: Hugh Dickins 
Acked-by: Kirill A. Shutemov 
Acked-by: Vlastimil Babka 
Cc: David Rientjes 
Cc: 
Link: 
http://lkml.kernel.org/r/159032779896.957378.7852761411265662220.stgit@buzz
Link: https://lore.kernel.org/lkml/557710e1.6060...@suse.cz/
Link: 
https://lore.kernel.org/linux-mm/158937872515.474360.5066096871639561424.stgit@buzz/T/
 (v1)
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 include/linux/mm.h | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 858ce84ac7c5..6f852d5fbada 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -549,6 +549,11 @@ static inline void *kvmalloc_array(size_t n, size_t size, 
gfp_t flags)
 
 extern void kvfree(const void *addr);
 
+/*
+ * Mapcount of compound page as a whole, does not include mapped sub-pages.
+ *
+ * Must be called only for compound pages or any their tail sub-pages.
+ */
 static inline int compound_mapcount(struct page *page)
 {
VM_BUG_ON_PAGE(!PageCompound(page), page);
@@ -568,10 +573,16 @@ static inline void page_mapcount_reset(struct page *page)
 
 int __page_mapcount(struct page *page);
 
+/*
+ * Mapcount of 0-order page; when compound sub-page, includes
+ * compound_mapcount().
+ *
+ * Result is undefined for pages which cannot be mapped into userspace.
+ * For example SLAB or special types of pages. See function page_has_type().
+ * They use this place in struct page differently.
+ */
 static inline int page_mapcount(struct page *page)
 {
-   VM_BUG_ON_PAGE(PageSlab(page), page);
-
if (unlikely(PageCompound(page)))
return __page_mapcount(page);
return atomic_read(>_mapcount) + 1;
-- 
2.25.1





[PATCH 4.14 56/77] xfrm: allow to accept packets with ipv6 NEXTHDR_HOP in xfrm_input

2020-06-01 Thread Greg Kroah-Hartman
From: Xin Long 

commit afcaf61be9d1dbdee5ec186d1dcc67b6b692180f upstream.

For beet mode, when it's ipv6 inner address with nexthdrs set,
the packet format might be:


| outer  | | dest | |  |  ESP| ESP |
| IP hdr | ESP | opts.| TCP | Data | Trailer | ICV |


The nexthdr from ESP could be NEXTHDR_HOP(0), so it should
continue processing the packet when nexthdr returns 0 in
xfrm_input(). Otherwise, when ipv6 nexthdr is set, the
packet will be dropped.

I don't see any error cases that nexthdr may return 0. So
fix it by removing the check for nexthdr == 0.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xin Long 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 net/xfrm/xfrm_input.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -402,7 +402,7 @@ resume:
dev_put(skb->dev);
 
spin_lock(>lock);
-   if (nexthdr <= 0) {
+   if (nexthdr < 0) {
if (nexthdr == -EBADMSG) {
xfrm_audit_state_icvfail(x, skb,
 x->type->proto);




[PATCH 4.14 40/77] ARM: dts: bcm2835-rpi-zero-w: Fix led polarity

2020-06-01 Thread Greg Kroah-Hartman
From: Vincent Stehlé 

[ Upstream commit 58bb90ab415562eededb932455046924e65df342 ]

The status "ACT" led on the Raspberry Pi Zero W is on when GPIO 47 is low.

This has been verified on a board and somewhat confirmed by both the GPIO
name ("STATUS_LED_N") and the reduced schematics [1].

[1]: 
https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/rpi_SCH_ZeroW_1p1_reduced.pdf

Fixes: 2c7c040c73e9 ("ARM: dts: bcm2835: Add Raspberry Pi Zero W")
Signed-off-by: Vincent Stehlé 
Cc: Stefan Wahren 
Cc: Florian Fainelli 
Tested-by: Stefan Wahren 
Signed-off-by: Florian Fainelli 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/bcm2835-rpi-zero-w.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts 
b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
index e5f2cca86f04..120776d45441 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
@@ -25,7 +25,7 @@
 
leds {
act {
-   gpios = < 47 GPIO_ACTIVE_HIGH>;
+   gpios = < 47 GPIO_ACTIVE_LOW>;
};
};
 
-- 
2.25.1





[PATCH 4.14 49/77] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

2020-06-01 Thread Greg Kroah-Hartman
From: Alexander Potapenko 

[ Upstream commit 1d605416fb7175e1adf094251466caa52093b413 ]

KMSAN reported uninitialized data being written to disk when dumping
core.  As a result, several kilobytes of kmalloc memory may be written
to the core file and then read by a non-privileged user.

Reported-by: sam 
Signed-off-by: Alexander Potapenko 
Signed-off-by: Andrew Morton 
Acked-by: Kees Cook 
Cc: Al Viro 
Cc: Alexey Dobriyan 
Cc: 
Link: http://lkml.kernel.org/r/20200419100848.63472-1-gli...@google.com
Link: https://github.com/google/kmsan/issues/76
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 166846a40078..2c433c95adb5 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1740,7 +1740,7 @@ static int fill_thread_core_info(struct 
elf_thread_core_info *t,
(!regset->active || regset->active(t->task, regset) > 0)) {
int ret;
size_t size = regset->n * regset->size;
-   void *data = kmalloc(size, GFP_KERNEL);
+   void *data = kzalloc(size, GFP_KERNEL);
if (unlikely(!data))
return 0;
ret = regset->get(t->task, regset,
-- 
2.25.1





[PATCH 4.14 45/77] exec: Always set cap_ambient in cap_bprm_set_creds

2020-06-01 Thread Greg Kroah-Hartman
From: Eric W. Biederman 

[ Upstream commit a4ae32c71fe90794127b32d26d7ad795813b502e ]

An invariant of cap_bprm_set_creds is that every field in the new cred
structure that cap_bprm_set_creds might set, needs to be set every
time to ensure the fields does not get a stale value.

The field cap_ambient is not set every time cap_bprm_set_creds is
called, which means that if there is a suid or sgid script with an
interpreter that has neither the suid nor the sgid bits set the
interpreter should be able to accept ambient credentials.
Unfortuantely because cap_ambient is not reset to it's original value
the interpreter can not accept ambient credentials.

Given that the ambient capability set is expected to be controlled by
the caller, I don't think this is particularly serious.  But it is
definitely worth fixing so the code works correctly.

I have tested to verify my reading of the code is correct and the
interpreter of a sgid can receive ambient capabilities with this
change and cannot receive ambient capabilities without this change.

Cc: sta...@vger.kernel.org
Cc: Andy Lutomirski 
Fixes: 58319057b784 ("capabilities: ambient capabilities")
Signed-off-by: "Eric W. Biederman" 
Signed-off-by: Sasha Levin 
---
 security/commoncap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/security/commoncap.c b/security/commoncap.c
index ae26ef006988..ac031fa39190 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -711,6 +711,7 @@ int cap_bprm_set_creds(struct linux_binprm *bprm)
int ret;
kuid_t root_uid;
 
+   new->cap_ambient = old->cap_ambient;
if (WARN_ON(!cap_ambient_invariant_ok(old)))
return -EPERM;
 
-- 
2.25.1





[PATCH 4.14 01/77] ax25: fix setsockopt(SO_BINDTODEVICE)

2020-06-01 Thread Greg Kroah-Hartman
From: Eric Dumazet 

[ Upstream commit 687775cec056b38a4c8f3291e0dd7a9145f7b667 ]

syzbot was able to trigger this trace [1], probably by using
a zero optlen.

While we are at it, cap optlen to IFNAMSIZ - 1 instead of IFNAMSIZ.

[1]
BUG: KMSAN: uninit-value in strnlen+0xf9/0x170 lib/string.c:569
CPU: 0 PID: 8807 Comm: syz-executor483 Not tainted 5.7.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1c9/0x220 lib/dump_stack.c:118
 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121
 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215
 strnlen+0xf9/0x170 lib/string.c:569
 dev_name_hash net/core/dev.c:207 [inline]
 netdev_name_node_lookup net/core/dev.c:277 [inline]
 __dev_get_by_name+0x75/0x2b0 net/core/dev.c:778
 ax25_setsockopt+0xfa3/0x1170 net/ax25/af_ax25.c:654
 __compat_sys_setsockopt+0x4ed/0x910 net/compat.c:403
 __do_compat_sys_setsockopt net/compat.c:413 [inline]
 __se_compat_sys_setsockopt+0xdd/0x100 net/compat.c:410
 __ia32_compat_sys_setsockopt+0x62/0x80 net/compat.c:410
 do_syscall_32_irqs_on arch/x86/entry/common.c:339 [inline]
 do_fast_syscall_32+0x3bf/0x6d0 arch/x86/entry/common.c:398
 entry_SYSENTER_compat+0x68/0x77 arch/x86/entry/entry_64_compat.S:139
RIP: 0023:0xf7f57dd9
Code: 90 e8 0b 00 00 00 f3 90 0f ae e8 eb f9 8d 74 26 00 89 3c 24 c3 90 90 90 
90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 
eb 0d 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 002b:ffae8c1c EFLAGS: 0217 ORIG_RAX: 016e
RAX: ffda RBX: 0003 RCX: 0101
RDX: 0019 RSI: 2000 RDI: 0004
RBP: 0012 R08:  R09: 
R10:  R11:  R12: 
R13:  R14:  R15: 

Local variable devname@ax25_setsockopt created at:
 ax25_setsockopt+0xe6/0x1170 net/ax25/af_ax25.c:536
 ax25_setsockopt+0xe6/0x1170 net/ax25/af_ax25.c:536

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet 
Reported-by: syzbot 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ax25/af_ax25.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -639,8 +639,10 @@ static int ax25_setsockopt(struct socket
break;
 
case SO_BINDTODEVICE:
-   if (optlen > IFNAMSIZ)
-   optlen = IFNAMSIZ;
+   if (optlen > IFNAMSIZ - 1)
+   optlen = IFNAMSIZ - 1;
+
+   memset(devname, 0, sizeof(devname));
 
if (copy_from_user(devname, optval, optlen)) {
res = -EFAULT;




[PATCH 4.9 43/61] mac80211: mesh: fix discovery timer re-arming issue / crash

2020-06-01 Thread Greg Kroah-Hartman
From: Linus Lüssing 

commit e2d4a80f93fcfaf72e2e20daf6a28e39c3b90677 upstream.

On a non-forwarding 802.11s link between two fairly busy
neighboring nodes (iperf with -P 16 at ~850MBit/s TCP;
1733.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 4), so with
frequent PREQ retries, usually after around 30-40 seconds the
following crash would occur:

[ 1110.822428] Unable to handle kernel read from unreadable memory at virtual 
address 
[ 1110.830786] Mem abort info:
[ 1110.833573]   Exception class = IABT (current EL), IL = 32 bits
[ 1110.839494]   SET = 0, FnV = 0
[ 1110.842546]   EA = 0, S1PTW = 0
[ 1110.845678] user pgtable: 4k pages, 48-bit VAs, pgd = 800076386000
[ 1110.852204] [] *pgd=f6322003, *pud=f62de003, 
*pmd=
[ 1110.861167] Internal error: Oops: 8604 [#1] PREEMPT SMP
[ 1110.866730] Modules linked in: pppoe ppp_async batman_adv ath10k_pci 
ath10k_core ath pppox ppp_generic nf_conntrack_ipv6 mac80211 iptable_nat 
ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat 
xt_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS 
xt_REDIRECT xt_LOG xt_FLOWOFFLOAD slhc nf_reject_ipv4 nf_nat_redirect 
nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 
nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 
nf_conntrack_rtcache nf_conntrack iptable_mangle iptable_filter ip_tables 
crc_ccitt compat nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter 
ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 usb_storage xhci_plat_hcd 
xhci_pci xhci_hcd dwc3 usbcore usb_common
[ 1110.932190] Process swapper/3 (pid: 0, stack limit = 0x090c8000)
[ 1110.938884] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.14.162 #0
[ 1110.944965] Hardware name: LS1043A RGW Board (DT)
[ 1110.949658] task: 8000787a81c0 task.stack: 090c8000
[ 1110.955568] PC is at 0x0
[ 1110.958097] LR is at call_timer_fn.isra.27+0x24/0x78
[ 1110.963055] pc : [<>] lr : [] pstate: 
00400145
[ 1110.970440] sp : 0801be10
[ 1110.973744] x29: 0801be10 x28: 08bf7018
[ 1110.979047] x27: 08bf87c8 x26: 08c160c0
[ 1110.984352] x25:  x24: 
[ 1110.989657] x23: dead0200 x22: 
[ 1110.994959] x21:  x20: 0101
[ .000262] x19: 8000787a81c0 x18: 
[ .005565] x17: 089167b0 x16: 0058
[ .010868] x15: 089167b0 x14: 
[ .016172] x13: 08916788 x12: 0040
[ .021475] x11: 80007fda9af0 x10: 0001
[ .026777] x9 : 0801bea0 x8 : 0004
[ .032080] x7 :  x6 : 80007fda9aa8
[ .037383] x5 : 0801bea0 x4 : 0010
[ .042685] x3 : 0801be98 x2 : 0614
[ .047988] x1 :  x0 : 
[ .053290] Call trace:
[ .055728] Exception stack(0x0801bcd0 to 0x0801be10)
[ .062158] bcc0:    

[ .069978] bce0: 0614 0801be98 0010 
0801bea0
[ .077798] bd00: 80007fda9aa8  0004 
0801bea0
[ .085618] bd20: 0001 80007fda9af0 0040 
08916788
[ .093437] bd40:  089167b0 0058 
089167b0
[ .101256] bd60:  8000787a81c0 0101 

[ .109075] bd80:  dead0200  

[ .116895] bda0: 08c160c0 08bf87c8 08bf7018 
0801be10
[ .124715] bdc0: 080ff29c 0801be10  
00400145
[ .132534] bde0: 8000787a81c0 0801bde8  
01029eb19be8
[ .140353] be00: 0801be10 
[ .145220] [<  (null)>]   (null)
[ .149917] [] run_timer_softirq+0x184/0x398
[ .155741] [] __do_softirq+0x100/0x1fc
[ .161130] [] irq_exit+0x80/0xd8
[ .166002] [] __handle_domain_irq+0x88/0xb0
[ .171825] [] gic_handle_irq+0x68/0xb0
[ .177213] Exception stack(0x090cbe30 to 0x090cbf70)
[ .183642] be20:   0020 

[ .191461] be40: 0001  8000771af000 

[ .199281] be60: 08c95180  08c19360 
090cbef0
[ .207101] be80: 0810 0400 0098 

[ .214920] bea0: 0001 089167b0  
089167b0
[ .222740] bec0:  08c198e8 08bf7018 
08c19000
[ .230559] bee0:   8000787a81c0 
08018000
[ .238380] bf00: 

[PATCH 4.14 12/77] ARM: dts: rockchip: fix phy nodename for rk3228-evb

2020-06-01 Thread Greg Kroah-Hartman
From: Johan Jonker 

[ Upstream commit 287e0d538fcec2f6e8eb1e565bf0749f3b90186d ]

A test with the command below gives for example this error:

arch/arm/boot/dts/rk3228-evb.dt.yaml: phy@0:
'#phy-cells' is a required property

The phy nodename is normally used by a phy-handle.
This node is however compatible with
"ethernet-phy-id1234.d400", "ethernet-phy-ieee802.3-c22"
which is just been added to 'ethernet-phy.yaml'.
So change nodename to 'ethernet-phy' for which '#phy-cells'
is not a required property

make ARCH=arm dtbs_check
DT_SCHEMA_FILES=~/.local/lib/python3.5/site-packages/dtschema/schemas/
phy/phy-provider.yaml

Signed-off-by: Johan Jonker 
Signed-off-by: Heiko Stuebner 
Link: https://lore.kernel.org/r/20200416170321.4216-1-jbx6...@gmail.com
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/rk3228-evb.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
index 1be9daacc4f9..b69c842d8306 100644
--- a/arch/arm/boot/dts/rk3228-evb.dts
+++ b/arch/arm/boot/dts/rk3228-evb.dts
@@ -84,7 +84,7 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   phy: phy@0 {
+   phy: ethernet-phy@0 {
compatible = "ethernet-phy-id1234.d400", 
"ethernet-phy-ieee802.3-c22";
reg = <0>;
clocks = < SCLK_MAC_PHY>;
-- 
2.25.1





[PATCH 4.14 28/77] Input: dlink-dir685-touchkeys - fix a typo in driver name

2020-06-01 Thread Greg Kroah-Hartman
From: Christophe JAILLET 

[ Upstream commit 38347374ae3f1ec4df56dd688bd603a64e79a0ed ]

According to the file name and Kconfig, a 'k' is missing in this driver
name. It should be "dlink-dir685-touchkeys".

Fixes: 131b3de7016b ("Input: add D-Link DIR-685 touchkeys driver")
Signed-off-by: Christophe JAILLET 
Reviewed-by: Linus Walleij 
Link: 
https://lore.kernel.org/r/20200412213937.5287-1-christophe.jail...@wanadoo.fr
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Sasha Levin 
---
 drivers/input/keyboard/dlink-dir685-touchkeys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/dlink-dir685-touchkeys.c 
b/drivers/input/keyboard/dlink-dir685-touchkeys.c
index 88e321b76397..6fe4062e3ac2 100644
--- a/drivers/input/keyboard/dlink-dir685-touchkeys.c
+++ b/drivers/input/keyboard/dlink-dir685-touchkeys.c
@@ -142,7 +142,7 @@ MODULE_DEVICE_TABLE(of, dir685_tk_of_match);
 
 static struct i2c_driver dir685_tk_i2c_driver = {
.driver = {
-   .name   = "dlin-dir685-touchkeys",
+   .name   = "dlink-dir685-touchkeys",
.of_match_table = of_match_ptr(dir685_tk_of_match),
},
.probe  = dir685_tk_probe,
-- 
2.25.1





[PATCH 4.14 36/77] gpio: exar: Fix bad handling for ida_simple_get error path

2020-06-01 Thread Greg Kroah-Hartman
From: Takashi Iwai 

[ Upstream commit 333830aa149a87cabeb5d30fbcf12eecc8040d2c ]

The commit 7ecced0934e5 ("gpio: exar: add a check for the return value
of ida_simple_get fails") added a goto jump to the common error
handler for ida_simple_get() error, but this is wrong in two ways:
it doesn't set the proper return code and, more badly, it invokes
ida_simple_remove() with a negative index that shall lead to a kernel
panic via BUG_ON().

This patch addresses those two issues.

Fixes: 7ecced0934e5 ("gpio: exar: add a check for the return value of 
ida_simple_get fails")
Cc: 
Signed-off-by: Takashi Iwai 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-exar.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index a09d2f9ebacc..695c19901eff 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -148,8 +148,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
mutex_init(_gpio->lock);
 
index = ida_simple_get(_index, 0, 0, GFP_KERNEL);
-   if (index < 0)
-   goto err_destroy;
+   if (index < 0) {
+   ret = index;
+   goto err_mutex_destroy;
+   }
 
sprintf(exar_gpio->name, "exar_gpio%d", index);
exar_gpio->gpio_chip.label = exar_gpio->name;
@@ -176,6 +178,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
 
 err_destroy:
ida_simple_remove(_index, index);
+err_mutex_destroy:
mutex_destroy(_gpio->lock);
return ret;
 }
-- 
2.25.1





[PATCH 4.14 15/77] gpio: tegra: mask GPIO IRQs during IRQ shutdown

2020-06-01 Thread Greg Kroah-Hartman
From: Stephen Warren 

[ Upstream commit 0cf253eed5d2bdf7bb3152457b38f39b012955f7 ]

The driver currently leaves GPIO IRQs unmasked even when the GPIO IRQ
client has released the GPIO IRQ. This allows the HW to raise IRQs, and
SW to process them, after shutdown. Fix this by masking the IRQ when it's
shut down. This is usually taken care of by the irqchip core, but since
this driver has a custom irq_shutdown implementation, it must do this
explicitly itself.

Signed-off-by: Stephen Warren 
Link: https://lore.kernel.org/r/20200427232605.11608-1-swar...@wwwdotorg.org
Signed-off-by: Linus Walleij 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-tegra.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 1eb857e2f62f..dd801f5d5253 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -356,6 +356,7 @@ static void tegra_gpio_irq_shutdown(struct irq_data *d)
struct tegra_gpio_info *tgi = bank->tgi;
unsigned int gpio = d->hwirq;
 
+   tegra_gpio_irq_mask(d);
gpiochip_unlock_as_irq(>gc, gpio);
 }
 
-- 
2.25.1





[PATCH 4.14 14/77] ARM: dts: rockchip: fix pinctrl sub nodename for spi in rk322x.dtsi

2020-06-01 Thread Greg Kroah-Hartman
From: Johan Jonker 

[ Upstream commit 855bdca1781c79eb661f89c8944c4a719ce720e8 ]

A test with the command below gives these errors:

arch/arm/boot/dts/rk3229-evb.dt.yaml: spi-0:
'#address-cells' is a required property
arch/arm/boot/dts/rk3229-evb.dt.yaml: spi-1:
'#address-cells' is a required property
arch/arm/boot/dts/rk3229-xms6.dt.yaml: spi-0:
'#address-cells' is a required property
arch/arm/boot/dts/rk3229-xms6.dt.yaml: spi-1:
'#address-cells' is a required property

The $nodename pattern for spi nodes is
"^spi(@.*|-[0-9a-f])*$". To prevent warnings rename
'spi-0' and 'spi-1' pinctrl sub nodenames to
'spi0' and 'spi1' in 'rk322x.dtsi'.

make ARCH=arm dtbs_check
DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/spi-controller.yaml

Signed-off-by: Johan Jonker 
Link: https://lore.kernel.org/r/20200424123923.8192-1-jbx6...@gmail.com
Signed-off-by: Heiko Stuebner 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/rk322x.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/rk322x.dtsi b/arch/arm/boot/dts/rk322x.dtsi
index f59f7cc62be6..0c60dbc4b46a 100644
--- a/arch/arm/boot/dts/rk322x.dtsi
+++ b/arch/arm/boot/dts/rk322x.dtsi
@@ -950,7 +950,7 @@
};
};
 
-   spi-0 {
+   spi0 {
spi0_clk: spi0-clk {
rockchip,pins = <0 9 RK_FUNC_2 _pull_up>;
};
@@ -968,7 +968,7 @@
};
};
 
-   spi-1 {
+   spi1 {
spi1_clk: spi1-clk {
rockchip,pins = <0 23 RK_FUNC_2 _pull_up>;
};
-- 
2.25.1





[PATCH 4.14 30/77] Input: synaptics-rmi4 - really fix attn_data use-after-free

2020-06-01 Thread Greg Kroah-Hartman
From: Evan Green 

[ Upstream commit d5a5e5b5fa7b86c05bf073acc0ba98fa280174ec ]

Fix a use-after-free noticed by running with KASAN enabled. If
rmi_irq_fn() is run twice in a row, then rmi_f11_attention() (among
others) will end up reading from drvdata->attn_data.data, which was
freed and left dangling in rmi_irq_fn().

Commit 55edde9fff1a ("Input: synaptics-rmi4 - prevent UAF reported by
KASAN") correctly identified and analyzed this bug. However the attempted
fix only NULLed out a local variable, missing the fact that
drvdata->attn_data is a struct, not a pointer.

NULL out the correct pointer in the driver data to prevent the attention
functions from copying from it.

Fixes: 55edde9fff1a ("Input: synaptics-rmi4 - prevent UAF reported by KASAN")
Fixes: b908d3cd812a ("Input: synaptics-rmi4 - allow to add attention data")
Signed-off-by: Evan Green 
Cc: sta...@vger.kernel.org
Link: 
https://lore.kernel.org/r/20200427145537.1.Ic8f898e0147b2c005ee7b20f1aebdef1e7eb@changeid
Signed-off-by: Dmitry Torokhov 
Signed-off-by: Sasha Levin 
---
 drivers/input/rmi4/rmi_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 997ccae7ee05..633fd0d660c1 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -232,7 +232,7 @@ static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
 
if (count) {
kfree(attn_data.data);
-   attn_data.data = NULL;
+   drvdata->attn_data.data = NULL;
}
 
if (!kfifo_is_empty(>attn_fifo))
-- 
2.25.1





[PATCH 4.14 34/77] ARM: uaccess: integrate uaccess_save and uaccess_restore

2020-06-01 Thread Greg Kroah-Hartman
From: Russell King 

[ Upstream commit 8ede890b0bcebe8c760aacfe20e934d98c3dc6aa ]

Integrate uaccess_save / uaccess_restore macros into the new
uaccess_entry / uaccess_exit macros respectively.

Signed-off-by: Russell King 
Signed-off-by: Sasha Levin 
---
 arch/arm/include/asm/uaccess-asm.h | 30 +-
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/arm/include/asm/uaccess-asm.h 
b/arch/arm/include/asm/uaccess-asm.h
index d475e3e8145d..e46468b91eaa 100644
--- a/arch/arm/include/asm/uaccess-asm.h
+++ b/arch/arm/include/asm/uaccess-asm.h
@@ -67,30 +67,23 @@
 #endif
.endm
 
-   .macro  uaccess_save, tmp
 #ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   mrc p15, 0, \tmp, c3, c0, 0
-   str \tmp, [sp, #SVC_DACR]
-#endif
-   .endm
-
-   .macro  uaccess_restore
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-   ldr r0, [sp, #SVC_DACR]
-   mcr p15, 0, r0, c3, c0, 0
+#define DACR(x...) x
+#else
+#define DACR(x...)
 #endif
-   .endm
 
/*
 * Save the address limit on entry to a privileged exception and
 * if using PAN, save and disable usermode access.
 */
.macro  uaccess_entry, tsk, tmp0, tmp1, tmp2, disable
-   ldr \tmp0, [\tsk, #TI_ADDR_LIMIT]
-   mov \tmp1, #TASK_SIZE
-   str \tmp1, [\tsk, #TI_ADDR_LIMIT]
-   str \tmp0, [sp, #SVC_ADDR_LIMIT]
-   uaccess_save \tmp0
+   ldr \tmp1, [\tsk, #TI_ADDR_LIMIT]
+   mov \tmp2, #TASK_SIZE
+   str \tmp2, [\tsk, #TI_ADDR_LIMIT]
+ DACR( mrc p15, 0, \tmp0, c3, c0, 0)
+ DACR( str \tmp0, [sp, #SVC_DACR])
+   str \tmp1, [sp, #SVC_ADDR_LIMIT]
.if \disable
uaccess_disable \tmp0
.endif
@@ -99,8 +92,11 @@
/* Restore the user access state previously saved by uaccess_entry */
.macro  uaccess_exit, tsk, tmp0, tmp1
ldr \tmp1, [sp, #SVC_ADDR_LIMIT]
-   uaccess_restore
+ DACR( ldr \tmp0, [sp, #SVC_DACR])
str \tmp1, [\tsk, #TI_ADDR_LIMIT]
+ DACR( mcr p15, 0, \tmp0, c3, c0, 0)
.endm
 
+#undef DACR
+
 #endif /* __ASM_UACCESS_ASM_H__ */
-- 
2.25.1





[PATCH 4.9 08/61] net/mlx5: Add command entry handling completion

2020-06-01 Thread Greg Kroah-Hartman
From: Moshe Shemesh 

[ Upstream commit 17d00e839d3b592da9659c1977d45f85b77f986a ]

When FW response to commands is very slow and all command entries in
use are waiting for completion we can have a race where commands can get
timeout before they get out of the queue and handled. Timeout
completion on uninitialized command will cause releasing command's
buffers before accessing it for initialization and then we will get NULL
pointer exception while trying access it. It may also cause releasing
buffers of another command since we may have timeout completion before
even allocating entry index for this command.
Add entry handling completion to avoid this race.

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Moshe Shemesh 
Signed-off-by: Eran Ben Elisha 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c |   15 +++
 include/linux/mlx5/driver.h   |1 +
 2 files changed, 16 insertions(+)

--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -786,6 +786,7 @@ static void cmd_work_handler(struct work
int alloc_ret;
int cmd_mode;
 
+   complete(>handling);
sem = ent->page_queue ? >pages_sem : >sem;
down(sem);
if (!ent->page_queue) {
@@ -904,6 +905,12 @@ static int wait_func(struct mlx5_core_de
struct mlx5_cmd *cmd = >cmd;
int err;
 
+   if (!wait_for_completion_timeout(>handling, timeout) &&
+   cancel_work_sync(>work)) {
+   ent->ret = -ECANCELED;
+   goto out_err;
+   }
+
if (cmd->mode == CMD_MODE_POLLING) {
wait_for_completion(>done);
} else if (!wait_for_completion_timeout(>done, timeout)) {
@@ -911,12 +918,17 @@ static int wait_func(struct mlx5_core_de
mlx5_cmd_comp_handler(dev, 1UL << ent->idx, true);
}
 
+out_err:
err = ent->ret;
 
if (err == -ETIMEDOUT) {
mlx5_core_warn(dev, "%s(0x%x) timeout. Will cause a leak of a 
command resource\n",
   mlx5_command_str(msg_to_opcode(ent->in)),
   msg_to_opcode(ent->in));
+   } else if (err == -ECANCELED) {
+   mlx5_core_warn(dev, "%s(0x%x) canceled on out of queue 
timeout.\n",
+  mlx5_command_str(msg_to_opcode(ent->in)),
+  msg_to_opcode(ent->in));
}
mlx5_core_dbg(dev, "err %d, delivery status %s(%d)\n",
  err, deliv_status_to_str(ent->status), ent->status);
@@ -951,6 +963,7 @@ static int mlx5_cmd_invoke(struct mlx5_c
 
ent->token = token;
 
+   init_completion(>handling);
if (!callback)
init_completion(>done);
 
@@ -970,6 +983,8 @@ static int mlx5_cmd_invoke(struct mlx5_c
err = wait_func(dev, ent);
if (err == -ETIMEDOUT)
goto out;
+   if (err == -ECANCELED)
+   goto out_free;
 
ds = ent->ts2 - ent->ts1;
op = MLX5_GET(mbox_in, in->first.data, opcode);
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -656,6 +656,7 @@ struct mlx5_cmd_work_ent {
struct delayed_work cb_timeout_work;
void   *context;
int idx;
+   struct completion   handling;
struct completion   done;
struct mlx5_cmd*cmd;
struct work_struct  work;




[PATCH 4.9 44/61] x86/dma: Fix max PFN arithmetic overflow on 32 bit systems

2020-06-01 Thread Greg Kroah-Hartman
From: Alexander Dahl 

commit 88743470668ef5eb6b7ba9e0f99888e5999bf172 upstream.

The intermediate result of the old term (4UL * 1024 * 1024 * 1024) is
4 294 967 296 or 0x1 which is no problem on 64 bit systems.
The patch does not change the later overall result of 0x10 for
MAX_DMA32_PFN (after it has been shifted by PAGE_SHIFT). The new
calculation yields the same result, but does not require 64 bit
arithmetic.

On 32 bit systems the old calculation suffers from an arithmetic
overflow in that intermediate term in braces: 4UL aka unsigned long int
is 4 byte wide and an arithmetic overflow happens (the 0x1 does
not fit in 4 bytes), the in braces result is truncated to zero, the
following right shift does not alter that, so MAX_DMA32_PFN evaluates to
0 on 32 bit systems.

That wrong value is a problem in a comparision against MAX_DMA32_PFN in
the init code for swiotlb in pci_swiotlb_detect_4gb() to decide if
swiotlb should be active.  That comparison yields the opposite result,
when compiling on 32 bit systems.

This was not possible before

  1b7e03ef7570 ("x86, NUMA: Enable emulation on 32bit too")

when that MAX_DMA32_PFN was first made visible to x86_32 (and which
landed in v3.0).

In practice this wasn't a problem, unless CONFIG_SWIOTLB is active on
x86-32.

However if one has set CONFIG_IOMMU_INTEL, since

  c5a5dc4cbbf4 ("iommu/vt-d: Don't switch off swiotlb if bounce page is used")

there's a dependency on CONFIG_SWIOTLB, which was not necessarily
active before. That landed in v5.4, where we noticed it in the fli4l
Linux distribution. We have CONFIG_IOMMU_INTEL active on both 32 and 64
bit kernel configs there (I could not find out why, so let's just say
historical reasons).

The effect is at boot time 64 MiB (default size) were allocated for
bounce buffers now, which is a noticeable amount of memory on small
systems like pcengines ALIX 2D3 with 256 MiB memory, which are still
frequently used as home routers.

We noticed this effect when migrating from kernel v4.19 (LTS) to v5.4
(LTS) in fli4l and got that kernel messages for example:

  Linux version 5.4.22 (buildroot@buildroot) (gcc version 7.3.0 (Buildroot 
2018.02.8)) #1 SMP Mon Nov 26 23:40:00 CET 2018
  …
  Memory: 183484K/261756K available (4594K kernel code, 393K rwdata, 1660K 
rodata, 536K init, 456K bss , 78272K reserved, 0K cma-reserved, 0K highmem)
  …
  PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
  software IO TLB: mapped [mem 0x0bb78000-0x0fb78000] (64MB)

The initial analysis and the suggested fix was done by user 'sourcejedi'
at stackoverflow and explicitly marked as GPLv2 for inclusion in the
Linux kernel:

  https://unix.stackexchange.com/a/520525/50007

The new calculation, which does not suffer from that overflow, is the
same as for arch/mips now as suggested by Robin Murphy.

The fix was tested by fli4l users on round about two dozen different
systems, including both 32 and 64 bit archs, bare metal and virtualized
machines.

 [ bp: Massage commit message. ]

Fixes: 1b7e03ef7570 ("x86, NUMA: Enable emulation on 32bit too")
Reported-by: Alan Jenkins 
Suggested-by: Robin Murphy 
Signed-off-by: Alexander Dahl 
Signed-off-by: Borislav Petkov 
Reviewed-by: Greg Kroah-Hartman 
Cc: sta...@vger.kernel.org
Link: https://unix.stackexchange.com/q/520065/50007
Link: https://web.nettworks.org/bugs/browse/FFL-2560
Link: https://lkml.kernel.org/r/20200526175749.20742-1-p...@lespocky.de
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/include/asm/dma.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/include/asm/dma.h
+++ b/arch/x86/include/asm/dma.h
@@ -73,7 +73,7 @@
 #define MAX_DMA_PFN   ((16UL * 1024 * 1024) >> PAGE_SHIFT)
 
 /* 4GB broken PCI/AGP hardware bus master zone */
-#define MAX_DMA32_PFN ((4UL * 1024 * 1024 * 1024) >> PAGE_SHIFT)
+#define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
 
 #ifdef CONFIG_X86_32
 /* The maximum address that we can perform a DMA transfer to on this platform 
*/




[PATCH 4.9 57/61] genirq/generic_pending: Do not lose pending affinity update

2020-06-01 Thread Greg Kroah-Hartman
From: Thomas Gleixner 

commit a33a5d2d16cb84bea8d5f5510f3a41aa48b5c467 upstream.

The generic pending interrupt mechanism moves interrupts from the interrupt
handler on the original target CPU to the new destination CPU. This is
required for x86 and ia64 due to the way the interrupt delivery and
acknowledge works if the interrupts are not remapped.

However that update can fail for various reasons. Some of them are valid
reasons to discard the pending update, but the case, when the previous move
has not been fully cleaned up is not a legit reason to fail.

Check the return value of irq_do_set_affinity() for -EBUSY, which indicates
a pending cleanup, and rearm the pending move in the irq dexcriptor so it's
tried again when the next interrupt arrives.

Fixes: 996c591227d9 ("x86/irq: Plug vector cleanup race")
Signed-off-by: Thomas Gleixner 
Tested-by: Song Liu 
Cc: Joerg Roedel 
Cc: Peter Zijlstra 
Cc: Song Liu 
Cc: Dmitry Safonov <0x7f454...@gmail.com>
Cc: sta...@vger.kernel.org
Cc: Mike Travis 
Cc: Borislav Petkov 
Cc: Tariq Toukan 
Cc: Guenter Roeck 
Link: https://lkml.kernel.org/r/20180604162224.386544...@linutronix.de
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/irq/migration.c |   24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -7,17 +7,18 @@
 void irq_move_masked_irq(struct irq_data *idata)
 {
struct irq_desc *desc = irq_data_to_desc(idata);
-   struct irq_chip *chip = desc->irq_data.chip;
+   struct irq_data *data = >irq_data;
+   struct irq_chip *chip = data->chip;
 
-   if (likely(!irqd_is_setaffinity_pending(>irq_data)))
+   if (likely(!irqd_is_setaffinity_pending(data)))
return;
 
-   irqd_clr_move_pending(>irq_data);
+   irqd_clr_move_pending(data);
 
/*
 * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
 */
-   if (irqd_is_per_cpu(>irq_data)) {
+   if (irqd_is_per_cpu(data)) {
WARN_ON(1);
return;
}
@@ -42,9 +43,20 @@ void irq_move_masked_irq(struct irq_data
 * For correct operation this depends on the caller
 * masking the irqs.
 */
-   if (cpumask_any_and(desc->pending_mask, cpu_online_mask) < nr_cpu_ids)
-   irq_do_set_affinity(>irq_data, desc->pending_mask, false);
+   if (cpumask_any_and(desc->pending_mask, cpu_online_mask) < nr_cpu_ids) {
+   int ret;
 
+   ret = irq_do_set_affinity(data, desc->pending_mask, false);
+   /*
+* If the there is a cleanup pending in the underlying
+* vector management, reschedule the move for the next
+* interrupt. Leave desc->pending_mask intact.
+*/
+   if (ret == -EBUSY) {
+   irqd_set_move_pending(data);
+   return;
+   }
+   }
cpumask_clear(desc->pending_mask);
 }
 




[PATCH 4.9 06/61] net/mlx5e: Update netdev txq on completions during closure

2020-06-01 Thread Greg Kroah-Hartman
From: Moshe Shemesh 

[ Upstream commit 5e911e2c06bd8c17df29147a5e2d4b17fafda024 ]

On sq closure when we free its descriptors, we should also update netdev
txq on completions which would not arrive. Otherwise if we reopen sqs
and attach them back, for example on fw fatal recovery flow, we may get
tx timeout.

Fixes: 29429f3300a3 ("net/mlx5e: Timeout if SQ doesn't flush during close")
Signed-off-by: Moshe Shemesh 
Reviewed-by: Tariq Toukan 
Signed-off-by: Saeed Mahameed 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -499,8 +499,9 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *c
 static void mlx5e_free_txq_sq_descs(struct mlx5e_sq *sq)
 {
struct mlx5e_tx_wqe_info *wi;
+   u32 nbytes = 0;
+   u16 ci, npkts = 0;
struct sk_buff *skb;
-   u16 ci;
int i;
 
while (sq->cc != sq->pc) {
@@ -521,8 +522,11 @@ static void mlx5e_free_txq_sq_descs(stru
}
 
dev_kfree_skb_any(skb);
+   npkts++;
+   nbytes += wi->num_bytes;
sq->cc += wi->num_wqebbs;
}
+   netdev_tx_completed_queue(sq->txq, npkts, nbytes);
 }
 
 static void mlx5e_free_xdp_sq_descs(struct mlx5e_sq *sq)




[PATCH 4.9 53/61] qlcnic: fix missing release in qlcnic_83xx_interrupt_test.

2020-06-01 Thread Greg Kroah-Hartman
From: Qiushi Wu 

commit 15c973858903009e995b2037683de29dfe968621 upstream.

In function qlcnic_83xx_interrupt_test(), function
qlcnic_83xx_diag_alloc_res() is not handled by function
qlcnic_83xx_diag_free_res() after a call of the function
qlcnic_alloc_mbx_args() failed. Fix this issue by adding
a jump target "fail_mbx_args", and jump to this new target
when qlcnic_alloc_mbx_args() failed.

Fixes: b6b4316c8b2f ("qlcnic: Handle qlcnic_alloc_mbx_args() failure")
Signed-off-by: Qiushi Wu 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -3610,7 +3610,7 @@ int qlcnic_83xx_interrupt_test(struct ne
ahw->diag_cnt = 0;
ret = qlcnic_alloc_mbx_args(, adapter, QLCNIC_CMD_INTRPT_TEST);
if (ret)
-   goto fail_diag_irq;
+   goto fail_mbx_args;
 
if (adapter->flags & QLCNIC_MSIX_ENABLED)
intrpt_id = ahw->intr_tbl[0].id;
@@ -3640,6 +3640,8 @@ int qlcnic_83xx_interrupt_test(struct ne
 
 done:
qlcnic_free_mbx_args();
+
+fail_mbx_args:
qlcnic_83xx_diag_free_res(netdev, drv_sds_rings);
 
 fail_diag_irq:




[PATCH 4.9 52/61] netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code

2020-06-01 Thread Greg Kroah-Hartman
From: Pablo Neira Ayuso 

commit 4c559f15efcc43b996f4da528cd7f9483aaca36d upstream.

Dan Carpenter says: "Smatch complains that the value for "cmd" comes
from the network and can't be trusted."

Add pptp_msg_name() helper function that checks for the array boundary.

Fixes: f09943fefe6b ("[NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port")
Reported-by: Dan Carpenter 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/netfilter/nf_conntrack_pptp.h |2 
 net/ipv4/netfilter/nf_nat_pptp.c|7 ---
 net/netfilter/nf_conntrack_pptp.c   |   62 +++-
 3 files changed, 38 insertions(+), 33 deletions(-)

--- a/include/linux/netfilter/nf_conntrack_pptp.h
+++ b/include/linux/netfilter/nf_conntrack_pptp.h
@@ -4,7 +4,7 @@
 
 #include 
 
-extern const char *const pptp_msg_name[];
+extern const char *const pptp_msg_name(u_int16_t msg);
 
 /* state of the control session */
 enum pptp_ctrlsess_state {
--- a/net/ipv4/netfilter/nf_nat_pptp.c
+++ b/net/ipv4/netfilter/nf_nat_pptp.c
@@ -156,8 +156,7 @@ pptp_outbound_pkt(struct sk_buff *skb,
break;
default:
pr_debug("unknown outbound packet 0x%04x:%s\n", msg,
-msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] :
-  pptp_msg_name[0]);
+pptp_msg_name(msg));
/* fall through */
case PPTP_SET_LINK_INFO:
/* only need to NAT in case PAC is behind NAT box */
@@ -250,9 +249,7 @@ pptp_inbound_pkt(struct sk_buff *skb,
pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID);
break;
default:
-   pr_debug("unknown inbound packet %s\n",
-msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] :
-  pptp_msg_name[0]);
+   pr_debug("unknown inbound packet %s\n", pptp_msg_name(msg));
/* fall through */
case PPTP_START_SESSION_REQUEST:
case PPTP_START_SESSION_REPLY:
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -71,24 +71,32 @@ EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expec
 
 #if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
 /* PptpControlMessageType names */
-const char *const pptp_msg_name[] = {
-   "UNKNOWN_MESSAGE",
-   "START_SESSION_REQUEST",
-   "START_SESSION_REPLY",
-   "STOP_SESSION_REQUEST",
-   "STOP_SESSION_REPLY",
-   "ECHO_REQUEST",
-   "ECHO_REPLY",
-   "OUT_CALL_REQUEST",
-   "OUT_CALL_REPLY",
-   "IN_CALL_REQUEST",
-   "IN_CALL_REPLY",
-   "IN_CALL_CONNECT",
-   "CALL_CLEAR_REQUEST",
-   "CALL_DISCONNECT_NOTIFY",
-   "WAN_ERROR_NOTIFY",
-   "SET_LINK_INFO"
+static const char *const pptp_msg_name_array[PPTP_MSG_MAX + 1] = {
+   [0] = "UNKNOWN_MESSAGE",
+   [PPTP_START_SESSION_REQUEST]= "START_SESSION_REQUEST",
+   [PPTP_START_SESSION_REPLY]  = "START_SESSION_REPLY",
+   [PPTP_STOP_SESSION_REQUEST] = "STOP_SESSION_REQUEST",
+   [PPTP_STOP_SESSION_REPLY]   = "STOP_SESSION_REPLY",
+   [PPTP_ECHO_REQUEST] = "ECHO_REQUEST",
+   [PPTP_ECHO_REPLY]   = "ECHO_REPLY",
+   [PPTP_OUT_CALL_REQUEST] = "OUT_CALL_REQUEST",
+   [PPTP_OUT_CALL_REPLY]   = "OUT_CALL_REPLY",
+   [PPTP_IN_CALL_REQUEST]  = "IN_CALL_REQUEST",
+   [PPTP_IN_CALL_REPLY]= "IN_CALL_REPLY",
+   [PPTP_IN_CALL_CONNECT]  = "IN_CALL_CONNECT",
+   [PPTP_CALL_CLEAR_REQUEST]   = "CALL_CLEAR_REQUEST",
+   [PPTP_CALL_DISCONNECT_NOTIFY]   = "CALL_DISCONNECT_NOTIFY",
+   [PPTP_WAN_ERROR_NOTIFY] = "WAN_ERROR_NOTIFY",
+   [PPTP_SET_LINK_INFO]= "SET_LINK_INFO"
 };
+
+const char *const pptp_msg_name(u_int16_t msg)
+{
+   if (msg > PPTP_MSG_MAX)
+   return pptp_msg_name_array[0];
+
+   return pptp_msg_name_array[msg];
+}
 EXPORT_SYMBOL(pptp_msg_name);
 #endif
 
@@ -277,7 +285,7 @@ pptp_inbound_pkt(struct sk_buff *skb, un
typeof(nf_nat_pptp_hook_inbound) nf_nat_pptp_inbound;
 
msg = ntohs(ctlh->messageType);
-   pr_debug("inbound control message %s\n", pptp_msg_name[msg]);
+   pr_debug("inbound control message %s\n", pptp_msg_name(msg));
 
switch (msg) {
case PPTP_START_SESSION_REPLY:
@@ -312,7 +320,7 @@ pptp_inbound_pkt(struct sk_buff *skb, un
pcid = pptpReq->ocack.peersCallID;
if (info->pns_call_id != pcid)
goto invalid;
-   pr_debug("%s, CID=%X, PCID=%X\n", pptp_msg_name[msg],
+   pr_debug("%s, CID=%X, PCID=%X\n", pptp_msg_name(msg),
 ntohs(cid), ntohs(pcid));
 
if (pptpReq->ocack.resultCode == PPTP_OUTCALL_CONNECT) {
@@ -329,7 +337,7 @@ pptp_inbound_pkt(struct sk_buff 

[PATCH 4.9 46/61] xfrm: fix a warning in xfrm_policy_insert_list

2020-06-01 Thread Greg Kroah-Hartman
From: Xin Long 

commit ed17b8d377eaf6b4a01d46942b4c647378a79bdd upstream.

This waring can be triggered simply by:

  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 1 mark 0 mask 0x10  #[1]
  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 2 mark 0 mask 0x1   #[2]
  # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
priority 2 mark 0 mask 0x10  #[3]

Then dmesg shows:

  [ ] WARNING: CPU: 1 PID: 7265 at net/xfrm/xfrm_policy.c:1548
  [ ] RIP: 0010:xfrm_policy_insert_list+0x2f2/0x1030
  [ ] Call Trace:
  [ ]  xfrm_policy_inexact_insert+0x85/0xe50
  [ ]  xfrm_policy_insert+0x4ba/0x680
  [ ]  xfrm_add_policy+0x246/0x4d0
  [ ]  xfrm_user_rcv_msg+0x331/0x5c0
  [ ]  netlink_rcv_skb+0x121/0x350
  [ ]  xfrm_netlink_rcv+0x66/0x80
  [ ]  netlink_unicast+0x439/0x630
  [ ]  netlink_sendmsg+0x714/0xbf0
  [ ]  sock_sendmsg+0xe2/0x110

The issue was introduced by Commit 7cb8a93968e3 ("xfrm: Allow inserting
policies with matching mark and different priorities"). After that, the
policies [1] and [2] would be able to be added with different priorities.

However, policy [3] will actually match both [1] and [2]. Policy [1]
was matched due to the 1st 'return true' in xfrm_policy_mark_match(),
and policy [2] was matched due to the 2nd 'return true' in there. It
caused WARN_ON() in xfrm_policy_insert_list().

This patch is to fix it by only (the same value and priority) as the
same policy in xfrm_policy_mark_match().

Thanks to Yuehaibing, we could make this fix better.

v1->v2:
  - check policy->mark.v == pol->mark.v only without mask.

Fixes: 7cb8a93968e3 ("xfrm: Allow inserting policies with matching mark and 
different priorities")
Reported-by: Xiumei Mu 
Signed-off-by: Xin Long 
Signed-off-by: Steffen Klassert 
Signed-off-by: Greg Kroah-Hartman 

---
 net/xfrm/xfrm_policy.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -757,12 +757,7 @@ static void xfrm_policy_requeue(struct x
 static bool xfrm_policy_mark_match(struct xfrm_policy *policy,
   struct xfrm_policy *pol)
 {
-   u32 mark = policy->mark.v & policy->mark.m;
-
-   if (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m)
-   return true;
-
-   if ((mark & pol->mark.m) == pol->mark.v &&
+   if (policy->mark.v == pol->mark.v &&
policy->priority == pol->priority)
return true;
 




[PATCH 4.9 05/61] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed

2020-06-01 Thread Greg Kroah-Hartman
From: "Jere Lepp�nen" 

[ Upstream commit d3e8e4c11870413789f029a71e72ae6e971fe678 ]

Commit bdf6fa52f01b ("sctp: handle association restarts when the
socket is closed.") starts shutdown when an association is restarted,
if in SHUTDOWN-PENDING state and the socket is closed. However, the
rationale stated in that commit applies also when in SHUTDOWN-SENT
state - we don't want to move an association to ESTABLISHED state when
the socket has been closed, because that results in an association
that is unreachable from user space.

The problem scenario:

1.  Client crashes and/or restarts.

2.  Server (using one-to-one socket) calls close(). SHUTDOWN is lost.

3.  Client reconnects using the same addresses and ports.

4.  Server's association is restarted. The association and the socket
move to ESTABLISHED state, even though the server process has
closed its descriptor.

Also, after step 4 when the server process exits, some resources are
leaked in an attempt to release the underlying inet sock structure in
ESTABLISHED state:

IPv4: Attempt to release TCP socket in state 1 377288c7

Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if
an association is restarted in SHUTDOWN-SENT state and the socket is
closed, then start shutdown and don't move the association or the
socket to ESTABLISHED state.

Fixes: bdf6fa52f01b ("sctp: handle association restarts when the socket is 
closed.")
Signed-off-by: Jere Leppänen 
Acked-by: Marcelo Ricardo Leitner 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/sctp/sm_statefuns.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1793,12 +1793,13 @@ static sctp_disposition_t sctp_sf_do_dup
/* Update the content of current association. */
sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
-   if (sctp_state(asoc, SHUTDOWN_PENDING) &&
+   if ((sctp_state(asoc, SHUTDOWN_PENDING) ||
+sctp_state(asoc, SHUTDOWN_SENT)) &&
(sctp_sstate(asoc->base.sk, CLOSING) ||
 sock_flag(asoc->base.sk, SOCK_DEAD))) {
-   /* if were currently in SHUTDOWN_PENDING, but the socket
-* has been closed by user, don't transition to ESTABLISHED.
-* Instead trigger SHUTDOWN bundled with COOKIE_ACK.
+   /* If the socket has been closed by user, don't
+* transition to ESTABLISHED. Instead trigger SHUTDOWN
+* bundled with COOKIE_ACK.
 */
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
return sctp_sf_do_9_2_start_shutdown(net, ep, asoc,




[PATCH 4.9 39/61] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()

2020-06-01 Thread Greg Kroah-Hartman
From: Alexander Potapenko 

[ Upstream commit 1d605416fb7175e1adf094251466caa52093b413 ]

KMSAN reported uninitialized data being written to disk when dumping
core.  As a result, several kilobytes of kmalloc memory may be written
to the core file and then read by a non-privileged user.

Reported-by: sam 
Signed-off-by: Alexander Potapenko 
Signed-off-by: Andrew Morton 
Acked-by: Kees Cook 
Cc: Al Viro 
Cc: Alexey Dobriyan 
Cc: 
Link: http://lkml.kernel.org/r/20200419100848.63472-1-gli...@google.com
Link: https://github.com/google/kmsan/issues/76
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 fs/binfmt_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index e78553d51837..73cd7482c1fa 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1721,7 +1721,7 @@ static int fill_thread_core_info(struct 
elf_thread_core_info *t,
(!regset->active || regset->active(t->task, regset) > 0)) {
int ret;
size_t size = regset->n * regset->size;
-   void *data = kmalloc(size, GFP_KERNEL);
+   void *data = kzalloc(size, GFP_KERNEL);
if (unlikely(!data))
return 0;
ret = regset->get(t->task, regset,
-- 
2.25.1





[PATCH 4.9 04/61] net sched: fix reporting the first-time use timestamp

2020-06-01 Thread Greg Kroah-Hartman
From: Roman Mashak 

[ Upstream commit b15e62631c5f19fea9895f7632dae9c1b27fe0cd ]

When a new action is installed, firstuse field of 'tcf_t' is explicitly set
to 0. Value of zero means "new action, not yet used"; as a packet hits the
action, 'firstuse' is stamped with the current jiffies value.

tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.

Fixes: 48d8ee1694dd ("net sched actions: aggregate dumping of actions timeinfo")
Cc: Jamal Hadi Salim 
Signed-off-by: Roman Mashak 
Acked-by: Jamal Hadi Salim 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 include/net/act_api.h |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -94,7 +94,8 @@ static inline void tcf_tm_dump(struct tc
 {
dtm->install = jiffies_to_clock_t(jiffies - stm->install);
dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse);
-   dtm->firstuse = jiffies_to_clock_t(jiffies - stm->firstuse);
+   dtm->firstuse = stm->firstuse ?
+   jiffies_to_clock_t(jiffies - stm->firstuse) : 0;
dtm->expires = jiffies_to_clock_t(stm->expires);
 }
 




[PATCH 4.9 40/61] include/asm-generic/topology.h: guard cpumask_of_node() macro argument

2020-06-01 Thread Greg Kroah-Hartman
From: Arnd Bergmann 

[ Upstream commit 4377748c7b5187c3342a60fa2ceb60c8a57a8488 ]

drivers/hwmon/amd_energy.c:195:15: error: invalid operands to binary expression 
('void' and 'int')
(channel - data->nr_cpus));
~^
include/asm-generic/topology.h:51:42: note: expanded from macro 
'cpumask_of_node'
#define cpumask_of_node(node)   ((void)node, cpu_online_mask)
   ^~~~
include/linux/cpumask.h:618:72: note: expanded from macro 'cpumask_first_and'
 #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
   ^

Fixes: f0b848ce6fe9 ("cpumask: Introduce cpumask_of_{node,pcibus} to replace 
{node,pcibus}_to_cpumask")
Fixes: 8abee9566b7e ("hwmon: Add amd_energy driver to report energy counters")
Signed-off-by: Arnd Bergmann 
Signed-off-by: Andrew Morton 
Acked-by: Guenter Roeck 
Link: http://lkml.kernel.org/r/20200527134623.930247-1-a...@arndb.de
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 include/asm-generic/topology.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index 5d2add1a6c96..864fcfa1df41 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -51,7 +51,7 @@
   #ifdef CONFIG_NEED_MULTIPLE_NODES
 #define cpumask_of_node(node)  ((node) == 0 ? cpu_online_mask : 
cpu_none_mask)
   #else
-#define cpumask_of_node(node)  ((void)node, cpu_online_mask)
+#define cpumask_of_node(node)  ((void)(node), cpu_online_mask)
   #endif
 #endif
 #ifndef pcibus_to_node
-- 
2.25.1





[PATCH 4.9 37/61] libceph: ignore pool overlay and cache logic on redirects

2020-06-01 Thread Greg Kroah-Hartman
From: Jerry Lee 

[ Upstream commit 890bd0f8997ae6ac0a367dd5146154a3963306dd ]

OSD client should ignore cache/overlay flag if got redirect reply.
Otherwise, the client hangs when the cache tier is in forward mode.

[ idryomov: Redirects are effectively deprecated and no longer
  used or tested.  The original tiering modes based on redirects
  are inherently flawed because redirects can race and reorder,
  potentially resulting in data corruption.  The new proxy and
  readproxy tiering modes should be used instead of forward and
  readforward.  Still marking for stable as obviously correct,
  though. ]

Cc: sta...@vger.kernel.org
URL: https://tracker.ceph.com/issues/23296
URL: https://tracker.ceph.com/issues/36406
Signed-off-by: Jerry Lee 
Reviewed-by: Ilya Dryomov 
Signed-off-by: Ilya Dryomov 
Signed-off-by: Sasha Levin 
---
 net/ceph/osd_client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 70ccb0716fc5..4fd679b30b19 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2879,7 +2879,9 @@ static void handle_reply(struct ceph_osd *osd, struct 
ceph_msg *msg)
 * supported.
 */
req->r_t.target_oloc.pool = m.redirect.oloc.pool;
-   req->r_flags |= CEPH_OSD_FLAG_REDIRECTED;
+   req->r_flags |= CEPH_OSD_FLAG_REDIRECTED |
+   CEPH_OSD_FLAG_IGNORE_OVERLAY |
+   CEPH_OSD_FLAG_IGNORE_CACHE;
req->r_tid = 0;
__submit_request(req, false);
goto out_unlock_osdc;
-- 
2.25.1





[PATCH 4.9 30/61] IB/qib: Call kobject_put() when kobject_init_and_add() fails

2020-06-01 Thread Greg Kroah-Hartman
From: Kaike Wan 

[ Upstream commit a35cd6447effd5c239b564c80fa109d05ff3d114 ]

When kobject_init_and_add() returns an error in the function
qib_create_port_files(), the function kobject_put() is not called for the
corresponding kobject, which potentially leads to memory leak.

This patch fixes the issue by calling kobject_put() even if
kobject_init_and_add() fails. In addition, the ppd->diagc_kobj is released
along with other kobjects when the sysfs is unregistered.

Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand 
adapters")
Link: 
https://lore.kernel.org/r/20200512031328.189865.48627.st...@awfm-01.aw.intel.com
Cc: 
Suggested-by: Lin Yi 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Dennis Dalessandro 
Reviewed-by: Leon Romanovsky 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/qib/qib_sysfs.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c 
b/drivers/infiniband/hw/qib/qib_sysfs.c
index 8ce0f6eef89e..b9d653afff8b 100644
--- a/drivers/infiniband/hw/qib/qib_sysfs.c
+++ b/drivers/infiniband/hw/qib/qib_sysfs.c
@@ -756,7 +756,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping linkcontrol sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail;
+   goto bail_link;
}
kobject_uevent(>pport_kobj, KOBJ_ADD);
 
@@ -766,7 +766,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping sl2vl sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail_link;
+   goto bail_sl;
}
kobject_uevent(>sl2vl_kobj, KOBJ_ADD);
 
@@ -776,7 +776,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
"Skipping diag_counters sysfs info, (err %d) port %u\n",
ret, port_num);
-   goto bail_sl;
+   goto bail_diagc;
}
kobject_uevent(>diagc_kobj, KOBJ_ADD);
 
@@ -789,7 +789,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 
port_num,
qib_dev_err(dd,
 "Skipping Congestion Control sysfs info, (err %d) port %u\n",
 ret, port_num);
-   goto bail_diagc;
+   goto bail_cc;
}
 
kobject_uevent(>pport_cc_kobj, KOBJ_ADD);
@@ -871,6 +871,7 @@ void qib_verbs_unregister_sysfs(struct qib_devdata *dd)
_table_bin_attr);
kobject_put(>pport_cc_kobj);
}
+   kobject_put(>diagc_kobj);
kobject_put(>sl2vl_kobj);
kobject_put(>pport_kobj);
}
-- 
2.25.1





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