]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.14
authorSasha Levin <sashal@kernel.org>
Sun, 24 Jul 2022 03:30:03 +0000 (23:30 -0400)
committerSasha Levin <sashal@kernel.org>
Sun, 24 Jul 2022 03:30:03 +0000 (23:30 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
14 files changed:
queue-4.14/be2net-fix-buffer-overflow-in-be_get_module_eeprom.patch [new file with mode: 0644]
queue-4.14/i2c-cadence-change-large-transfer-count-reset-logic-.patch [new file with mode: 0644]
queue-4.14/igmp-fix-a-data-race-around-sysctl_igmp_max_membersh.patch [new file with mode: 0644]
queue-4.14/igmp-fix-data-races-around-sysctl_igmp_llm_reports.patch [new file with mode: 0644]
queue-4.14/ip-fix-a-data-race-around-sysctl_fwmark_reflect.patch [new file with mode: 0644]
queue-4.14/net-stmmac-fix-dma-queue-left-shift-overflow-issue.patch [new file with mode: 0644]
queue-4.14/perf-core-fix-data-race-between-perf_event_set_outpu.patch [new file with mode: 0644]
queue-4.14/power-reset-arm-versatile-fix-refcount-leak-in-versa.patch [new file with mode: 0644]
queue-4.14/series
queue-4.14/tcp-dccp-fix-a-data-race-around-sysctl_tcp_fwmark_ac.patch [new file with mode: 0644]
queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_notsent_lowat.patch [new file with mode: 0644]
queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_probe_interval.patch [new file with mode: 0644]
queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_probe_threshol.patch [new file with mode: 0644]
queue-4.14/xfrm-xfrm_policy-fix-a-possible-double-xfrm_pols_put.patch [new file with mode: 0644]

diff --git a/queue-4.14/be2net-fix-buffer-overflow-in-be_get_module_eeprom.patch b/queue-4.14/be2net-fix-buffer-overflow-in-be_get_module_eeprom.patch
new file mode 100644 (file)
index 0000000..94d80cd
--- /dev/null
@@ -0,0 +1,144 @@
+From ae5eee131787d3a9252fe7d2ba220e57aea28a9c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 16 Jul 2022 11:51:34 +0300
+Subject: be2net: Fix buffer overflow in be_get_module_eeprom
+
+From: Hristo Venev <hristo@venev.name>
+
+[ Upstream commit d7241f679a59cfe27f92cb5c6272cb429fb1f7ec ]
+
+be_cmd_read_port_transceiver_data assumes that it is given a buffer that
+is at least PAGE_DATA_LEN long, or twice that if the module supports SFF
+8472. However, this is not always the case.
+
+Fix this by passing the desired offset and length to
+be_cmd_read_port_transceiver_data so that we only copy the bytes once.
+
+Fixes: e36edd9d26cf ("be2net: add ethtool "-m" option support")
+Signed-off-by: Hristo Venev <hristo@venev.name>
+Link: https://lore.kernel.org/r/20220716085134.6095-1-hristo@venev.name
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/emulex/benet/be_cmds.c   | 10 +++---
+ drivers/net/ethernet/emulex/benet/be_cmds.h   |  2 +-
+ .../net/ethernet/emulex/benet/be_ethtool.c    | 31 ++++++++++++-------
+ 3 files changed, 25 insertions(+), 18 deletions(-)
+
+diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
+index 1589a568bfe0..7ea2e5dbacd5 100644
+--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
++++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
+@@ -2291,7 +2291,7 @@ int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state)
+ /* Uses sync mcc */
+ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
+-                                    u8 page_num, u8 *data)
++                                    u8 page_num, u32 off, u32 len, u8 *data)
+ {
+       struct be_dma_mem cmd;
+       struct be_mcc_wrb *wrb;
+@@ -2325,10 +2325,10 @@ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
+       req->port = cpu_to_le32(adapter->hba_port_num);
+       req->page_num = cpu_to_le32(page_num);
+       status = be_mcc_notify_wait(adapter);
+-      if (!status) {
++      if (!status && len > 0) {
+               struct be_cmd_resp_port_type *resp = cmd.va;
+-              memcpy(data, resp->page_data, PAGE_DATA_LEN);
++              memcpy(data, resp->page_data + off, len);
+       }
+ err:
+       mutex_unlock(&adapter->mcc_lock);
+@@ -2419,7 +2419,7 @@ int be_cmd_query_cable_type(struct be_adapter *adapter)
+       int status;
+       status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
+-                                                 page_data);
++                                                 0, PAGE_DATA_LEN, page_data);
+       if (!status) {
+               switch (adapter->phy.interface_type) {
+               case PHY_TYPE_QSFP:
+@@ -2444,7 +2444,7 @@ int be_cmd_query_sfp_info(struct be_adapter *adapter)
+       int status;
+       status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
+-                                                 page_data);
++                                                 0, PAGE_DATA_LEN, page_data);
+       if (!status) {
+               strlcpy(adapter->phy.vendor_name, page_data +
+                       SFP_VENDOR_NAME_OFFSET, SFP_VENDOR_NAME_LEN - 1);
+diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
+index 09da2d82c2f0..8af11a5e49fe 100644
+--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
++++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
+@@ -2431,7 +2431,7 @@ int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon,
+ int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num,
+                           u32 *state);
+ int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
+-                                    u8 page_num, u8 *data);
++                                    u8 page_num, u32 off, u32 len, u8 *data);
+ int be_cmd_query_cable_type(struct be_adapter *adapter);
+ int be_cmd_query_sfp_info(struct be_adapter *adapter);
+ int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
+diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
+index f66b246acaea..d0d96fa71084 100644
+--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
++++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
+@@ -1340,7 +1340,7 @@ static int be_get_module_info(struct net_device *netdev,
+               return -EOPNOTSUPP;
+       status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
+-                                                 page_data);
++                                                 0, PAGE_DATA_LEN, page_data);
+       if (!status) {
+               if (!page_data[SFP_PLUS_SFF_8472_COMP]) {
+                       modinfo->type = ETH_MODULE_SFF_8079;
+@@ -1358,25 +1358,32 @@ static int be_get_module_eeprom(struct net_device *netdev,
+ {
+       struct be_adapter *adapter = netdev_priv(netdev);
+       int status;
++      u32 begin, end;
+       if (!check_privilege(adapter, MAX_PRIVILEGES))
+               return -EOPNOTSUPP;
+-      status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
+-                                                 data);
+-      if (status)
+-              goto err;
++      begin = eeprom->offset;
++      end = eeprom->offset + eeprom->len;
++
++      if (begin < PAGE_DATA_LEN) {
++              status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, begin,
++                                                         min_t(u32, end, PAGE_DATA_LEN) - begin,
++                                                         data);
++              if (status)
++                      goto err;
++
++              data += PAGE_DATA_LEN - begin;
++              begin = PAGE_DATA_LEN;
++      }
+-      if (eeprom->offset + eeprom->len > PAGE_DATA_LEN) {
+-              status = be_cmd_read_port_transceiver_data(adapter,
+-                                                         TR_PAGE_A2,
+-                                                         data +
+-                                                         PAGE_DATA_LEN);
++      if (end > PAGE_DATA_LEN) {
++              status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A2,
++                                                         begin - PAGE_DATA_LEN,
++                                                         end - begin, data);
+               if (status)
+                       goto err;
+       }
+-      if (eeprom->offset)
+-              memcpy(data, data + eeprom->offset, eeprom->len);
+ err:
+       return be_cmd_status(status);
+ }
+-- 
+2.35.1
+
diff --git a/queue-4.14/i2c-cadence-change-large-transfer-count-reset-logic-.patch b/queue-4.14/i2c-cadence-change-large-transfer-count-reset-logic-.patch
new file mode 100644 (file)
index 0000000..695804c
--- /dev/null
@@ -0,0 +1,111 @@
+From be3e8e1248c9846370eef5917cae91b4d6c5893e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 14 Jun 2022 17:29:19 -0600
+Subject: i2c: cadence: Change large transfer count reset logic to be
+ unconditional
+
+From: Robert Hancock <robert.hancock@calian.com>
+
+[ Upstream commit 4ca8ca873d454635c20d508261bfc0081af75cf8 ]
+
+Problems were observed on the Xilinx ZynqMP platform with large I2C reads.
+When a read of 277 bytes was performed, the controller NAKed the transfer
+after only 252 bytes were transferred and returned an ENXIO error on the
+transfer.
+
+There is some code in cdns_i2c_master_isr to handle this case by resetting
+the transfer count in the controller before it reaches 0, to allow larger
+transfers to work, but it was conditional on the CDNS_I2C_BROKEN_HOLD_BIT
+quirk being set on the controller, and ZynqMP uses the r1p14 version of
+the core where this quirk is not being set. The requirement to do this to
+support larger reads seems like an inherently required workaround due to
+the core only having an 8-bit transfer size register, so it does not
+appear that this should be conditional on the broken HOLD bit quirk which
+is used elsewhere in the driver.
+
+Remove the dependency on the CDNS_I2C_BROKEN_HOLD_BIT for this transfer
+size reset logic to fix this problem.
+
+Fixes: 63cab195bf49 ("i2c: removed work arounds in i2c driver for Zynq Ultrascale+ MPSoC")
+Signed-off-by: Robert Hancock <robert.hancock@calian.com>
+Reviewed-by: Shubhrajyoti Datta <Shubhrajyoti.datta@amd.com>
+Acked-by: Michal Simek <michal.simek@amd.com>
+Signed-off-by: Wolfram Sang <wsa@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/i2c/busses/i2c-cadence.c | 30 +++++-------------------------
+ 1 file changed, 5 insertions(+), 25 deletions(-)
+
+diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
+index 273f57e277b3..512c61d31fe5 100644
+--- a/drivers/i2c/busses/i2c-cadence.c
++++ b/drivers/i2c/busses/i2c-cadence.c
+@@ -203,9 +203,9 @@ static inline bool cdns_is_holdquirk(struct cdns_i2c *id, bool hold_wrkaround)
+  */
+ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
+ {
+-      unsigned int isr_status, avail_bytes, updatetx;
++      unsigned int isr_status, avail_bytes;
+       unsigned int bytes_to_send;
+-      bool hold_quirk;
++      bool updatetx;
+       struct cdns_i2c *id = ptr;
+       /* Signal completion only after everything is updated */
+       int done_flag = 0;
+@@ -224,11 +224,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
+        * Check if transfer size register needs to be updated again for a
+        * large data receive operation.
+        */
+-      updatetx = 0;
+-      if (id->recv_count > id->curr_recv_count)
+-              updatetx = 1;
+-
+-      hold_quirk = (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT) && updatetx;
++      updatetx = id->recv_count > id->curr_recv_count;
+       /* When receiving, handle data interrupt and completion interrupt */
+       if (id->p_recv_buf &&
+@@ -251,7 +247,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
+                       id->recv_count--;
+                       id->curr_recv_count--;
+-                      if (cdns_is_holdquirk(id, hold_quirk))
++                      if (cdns_is_holdquirk(id, updatetx))
+                               break;
+               }
+@@ -262,7 +258,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
+                * maintain transfer size non-zero while performing a large
+                * receive operation.
+                */
+-              if (cdns_is_holdquirk(id, hold_quirk)) {
++              if (cdns_is_holdquirk(id, updatetx)) {
+                       /* wait while fifo is full */
+                       while (cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET) !=
+                              (id->curr_recv_count - CDNS_I2C_FIFO_DEPTH))
+@@ -284,22 +280,6 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
+                                                 CDNS_I2C_XFER_SIZE_OFFSET);
+                               id->curr_recv_count = id->recv_count;
+                       }
+-              } else if (id->recv_count && !hold_quirk &&
+-                                              !id->curr_recv_count) {
+-
+-                      /* Set the slave address in address register*/
+-                      cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
+-                                              CDNS_I2C_ADDR_OFFSET);
+-
+-                      if (id->recv_count > CDNS_I2C_TRANSFER_SIZE) {
+-                              cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
+-                                              CDNS_I2C_XFER_SIZE_OFFSET);
+-                              id->curr_recv_count = CDNS_I2C_TRANSFER_SIZE;
+-                      } else {
+-                              cdns_i2c_writereg(id->recv_count,
+-                                              CDNS_I2C_XFER_SIZE_OFFSET);
+-                              id->curr_recv_count = id->recv_count;
+-                      }
+               }
+               /* Clear hold (if not repeated start) and signal completion */
+-- 
+2.35.1
+
diff --git a/queue-4.14/igmp-fix-a-data-race-around-sysctl_igmp_max_membersh.patch b/queue-4.14/igmp-fix-a-data-race-around-sysctl_igmp_max_membersh.patch
new file mode 100644 (file)
index 0000000..6f18791
--- /dev/null
@@ -0,0 +1,36 @@
+From 4c357e5059ffd57aef216ed13cd49b1469f46177 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Jul 2022 10:17:42 -0700
+Subject: igmp: Fix a data-race around sysctl_igmp_max_memberships.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 6305d821e3b9b5379d348528e5b5faf316383bc2 ]
+
+While reading sysctl_igmp_max_memberships, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its reader.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/igmp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
+index 4b3875acc876..fd2c634eeee4 100644
+--- a/net/ipv4/igmp.c
++++ b/net/ipv4/igmp.c
+@@ -2179,7 +2179,7 @@ int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr)
+               count++;
+       }
+       err = -ENOBUFS;
+-      if (count >= net->ipv4.sysctl_igmp_max_memberships)
++      if (count >= READ_ONCE(net->ipv4.sysctl_igmp_max_memberships))
+               goto done;
+       iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);
+       if (!iml)
+-- 
+2.35.1
+
diff --git a/queue-4.14/igmp-fix-data-races-around-sysctl_igmp_llm_reports.patch b/queue-4.14/igmp-fix-data-races-around-sysctl_igmp_llm_reports.patch
new file mode 100644 (file)
index 0000000..c932fe8
--- /dev/null
@@ -0,0 +1,110 @@
+From 5db56d181d01f1e3ca076e632c61547306eb9707 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Jul 2022 10:17:41 -0700
+Subject: igmp: Fix data-races around sysctl_igmp_llm_reports.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit f6da2267e71106474fbc0943dc24928b9cb79119 ]
+
+While reading sysctl_igmp_llm_reports, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its readers.
+
+This test can be packed into a helper, so such changes will be in the
+follow-up series after net is merged into net-next.
+
+  if (ipv4_is_local_multicast(pmc->multiaddr) &&
+      !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+
+Fixes: df2cf4a78e48 ("IGMP: Inhibit reports for local multicast groups")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/igmp.c | 21 +++++++++++++--------
+ 1 file changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
+index 16255dd0abf4..4b3875acc876 100644
+--- a/net/ipv4/igmp.c
++++ b/net/ipv4/igmp.c
+@@ -474,7 +474,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
+       if (pmc->multiaddr == IGMP_ALL_HOSTS)
+               return skb;
+-      if (ipv4_is_local_multicast(pmc->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)
++      if (ipv4_is_local_multicast(pmc->multiaddr) &&
++          !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+               return skb;
+       mtu = READ_ONCE(dev->mtu);
+@@ -600,7 +601,7 @@ static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc)
+                       if (pmc->multiaddr == IGMP_ALL_HOSTS)
+                               continue;
+                       if (ipv4_is_local_multicast(pmc->multiaddr) &&
+-                           !net->ipv4.sysctl_igmp_llm_reports)
++                          !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+                               continue;
+                       spin_lock_bh(&pmc->lock);
+                       if (pmc->sfcount[MCAST_EXCLUDE])
+@@ -743,7 +744,8 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
+       if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
+               return igmpv3_send_report(in_dev, pmc);
+-      if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports)
++      if (ipv4_is_local_multicast(group) &&
++          !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+               return 0;
+       if (type == IGMP_HOST_LEAVE_MESSAGE)
+@@ -921,7 +923,8 @@ static bool igmp_heard_report(struct in_device *in_dev, __be32 group)
+       if (group == IGMP_ALL_HOSTS)
+               return false;
+-      if (ipv4_is_local_multicast(group) && !net->ipv4.sysctl_igmp_llm_reports)
++      if (ipv4_is_local_multicast(group) &&
++          !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+               return false;
+       rcu_read_lock();
+@@ -1031,7 +1034,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
+               if (im->multiaddr == IGMP_ALL_HOSTS)
+                       continue;
+               if (ipv4_is_local_multicast(im->multiaddr) &&
+-                  !net->ipv4.sysctl_igmp_llm_reports)
++                  !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+                       continue;
+               spin_lock_bh(&im->lock);
+               if (im->tm_running)
+@@ -1280,7 +1283,8 @@ static void igmp_group_dropped(struct ip_mc_list *im)
+ #ifdef CONFIG_IP_MULTICAST
+       if (im->multiaddr == IGMP_ALL_HOSTS)
+               return;
+-      if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)
++      if (ipv4_is_local_multicast(im->multiaddr) &&
++          !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+               return;
+       reporter = im->reporter;
+@@ -1317,7 +1321,8 @@ static void igmp_group_added(struct ip_mc_list *im)
+ #ifdef CONFIG_IP_MULTICAST
+       if (im->multiaddr == IGMP_ALL_HOSTS)
+               return;
+-      if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports)
++      if (ipv4_is_local_multicast(im->multiaddr) &&
++          !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+               return;
+       if (in_dev->dead)
+@@ -1629,7 +1634,7 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev)
+               if (im->multiaddr == IGMP_ALL_HOSTS)
+                       continue;
+               if (ipv4_is_local_multicast(im->multiaddr) &&
+-                  !net->ipv4.sysctl_igmp_llm_reports)
++                  !READ_ONCE(net->ipv4.sysctl_igmp_llm_reports))
+                       continue;
+               /* a failover is happening and switches
+-- 
+2.35.1
+
diff --git a/queue-4.14/ip-fix-a-data-race-around-sysctl_fwmark_reflect.patch b/queue-4.14/ip-fix-a-data-race-around-sysctl_fwmark_reflect.patch
new file mode 100644 (file)
index 0000000..2bcb1d3
--- /dev/null
@@ -0,0 +1,36 @@
+From e9fcaa5c0be70f987fe1b8673840a8aabca1da7e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Jul 2022 13:51:57 -0700
+Subject: ip: Fix a data-race around sysctl_fwmark_reflect.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 85d0b4dbd74b95cc492b1f4e34497d3f894f5d9a ]
+
+While reading sysctl_fwmark_reflect, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its reader.
+
+Fixes: e110861f8609 ("net: add a sysctl to reflect the fwmark on replies")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/ip.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/net/ip.h b/include/net/ip.h
+index 4aff48d6ba91..2a92a5f4f9b3 100644
+--- a/include/net/ip.h
++++ b/include/net/ip.h
+@@ -305,7 +305,7 @@ void ipfrag_init(void);
+ void ip_static_sysctl_init(void);
+ #define IP4_REPLY_MARK(net, mark) \
+-      ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0)
++      (READ_ONCE((net)->ipv4.sysctl_fwmark_reflect) ? (mark) : 0)
+ static inline bool ip_is_fragment(const struct iphdr *iph)
+ {
+-- 
+2.35.1
+
diff --git a/queue-4.14/net-stmmac-fix-dma-queue-left-shift-overflow-issue.patch b/queue-4.14/net-stmmac-fix-dma-queue-left-shift-overflow-issue.patch
new file mode 100644 (file)
index 0000000..f538811
--- /dev/null
@@ -0,0 +1,82 @@
+From 33528578282de072c19f18d698758b8a1c78df04 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Jul 2022 15:47:01 +0800
+Subject: net: stmmac: fix dma queue left shift overflow issue
+
+From: Junxiao Chang <junxiao.chang@intel.com>
+
+[ Upstream commit 613b065ca32e90209024ec4a6bb5ca887ee70980 ]
+
+When queue number is > 4, left shift overflows due to 32 bits
+integer variable. Mask calculation is wrong for MTL_RXQ_DMA_MAP1.
+
+If CONFIG_UBSAN is enabled, kernel dumps below warning:
+[   10.363842] ==================================================================
+[   10.363882] UBSAN: shift-out-of-bounds in /build/linux-intel-iotg-5.15-8e6Tf4/
+linux-intel-iotg-5.15-5.15.0/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c:224:12
+[   10.363929] shift exponent 40 is too large for 32-bit type 'unsigned int'
+[   10.363953] CPU: 1 PID: 599 Comm: NetworkManager Not tainted 5.15.0-1003-intel-iotg
+[   10.363956] Hardware name: ADLINK Technology Inc. LEC-EL/LEC-EL, BIOS 0.15.11 12/22/2021
+[   10.363958] Call Trace:
+[   10.363960]  <TASK>
+[   10.363963]  dump_stack_lvl+0x4a/0x5f
+[   10.363971]  dump_stack+0x10/0x12
+[   10.363974]  ubsan_epilogue+0x9/0x45
+[   10.363976]  __ubsan_handle_shift_out_of_bounds.cold+0x61/0x10e
+[   10.363979]  ? wake_up_klogd+0x4a/0x50
+[   10.363983]  ? vprintk_emit+0x8f/0x240
+[   10.363986]  dwmac4_map_mtl_dma.cold+0x42/0x91 [stmmac]
+[   10.364001]  stmmac_mtl_configuration+0x1ce/0x7a0 [stmmac]
+[   10.364009]  ? dwmac410_dma_init_channel+0x70/0x70 [stmmac]
+[   10.364020]  stmmac_hw_setup.cold+0xf/0xb14 [stmmac]
+[   10.364030]  ? page_pool_alloc_pages+0x4d/0x70
+[   10.364034]  ? stmmac_clear_tx_descriptors+0x6e/0xe0 [stmmac]
+[   10.364042]  stmmac_open+0x39e/0x920 [stmmac]
+[   10.364050]  __dev_open+0xf0/0x1a0
+[   10.364054]  __dev_change_flags+0x188/0x1f0
+[   10.364057]  dev_change_flags+0x26/0x60
+[   10.364059]  do_setlink+0x908/0xc40
+[   10.364062]  ? do_setlink+0xb10/0xc40
+[   10.364064]  ? __nla_validate_parse+0x4c/0x1a0
+[   10.364068]  __rtnl_newlink+0x597/0xa10
+[   10.364072]  ? __nla_reserve+0x41/0x50
+[   10.364074]  ? __kmalloc_node_track_caller+0x1d0/0x4d0
+[   10.364079]  ? pskb_expand_head+0x75/0x310
+[   10.364082]  ? nla_reserve_64bit+0x21/0x40
+[   10.364086]  ? skb_free_head+0x65/0x80
+[   10.364089]  ? security_sock_rcv_skb+0x2c/0x50
+[   10.364094]  ? __cond_resched+0x19/0x30
+[   10.364097]  ? kmem_cache_alloc_trace+0x15a/0x420
+[   10.364100]  rtnl_newlink+0x49/0x70
+
+This change fixes MTL_RXQ_DMA_MAP1 mask issue and channel/queue
+mapping warning.
+
+Fixes: d43042f4da3e ("net: stmmac: mapping mtl rx to dma channel")
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=216195
+Reported-by: Cedric Wassenaar <cedric@bytespeed.nl>
+Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+index e5566c121525..9b12bb3b7781 100644
+--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+@@ -217,6 +217,9 @@ static void dwmac4_map_mtl_dma(struct mac_device_info *hw, u32 queue, u32 chan)
+       if (queue == 0 || queue == 4) {
+               value &= ~MTL_RXQ_DMA_Q04MDMACH_MASK;
+               value |= MTL_RXQ_DMA_Q04MDMACH(chan);
++      } else if (queue > 4) {
++              value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4);
++              value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4);
+       } else {
+               value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue);
+               value |= MTL_RXQ_DMA_QXMDMACH(chan, queue);
+-- 
+2.35.1
+
diff --git a/queue-4.14/perf-core-fix-data-race-between-perf_event_set_outpu.patch b/queue-4.14/perf-core-fix-data-race-between-perf_event_set_outpu.patch
new file mode 100644 (file)
index 0000000..4172cb9
--- /dev/null
@@ -0,0 +1,167 @@
+From 7cefff30f64ac35905379a9ab51bbef4acfd3e0c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 5 Jul 2022 15:07:26 +0200
+Subject: perf/core: Fix data race between perf_event_set_output() and
+ perf_mmap_close()
+
+From: Peter Zijlstra <peterz@infradead.org>
+
+[ Upstream commit 68e3c69803dada336893640110cb87221bb01dcf ]
+
+Yang Jihing reported a race between perf_event_set_output() and
+perf_mmap_close():
+
+       CPU1                                    CPU2
+
+       perf_mmap_close(e2)
+         if (atomic_dec_and_test(&e2->rb->mmap_count)) // 1 - > 0
+           detach_rest = true
+
+                                               ioctl(e1, IOC_SET_OUTPUT, e2)
+                                                 perf_event_set_output(e1, e2)
+
+         ...
+         list_for_each_entry_rcu(e, &e2->rb->event_list, rb_entry)
+           ring_buffer_attach(e, NULL);
+           // e1 isn't yet added and
+           // therefore not detached
+
+                                                   ring_buffer_attach(e1, e2->rb)
+                                                     list_add_rcu(&e1->rb_entry,
+                                                                  &e2->rb->event_list)
+
+After this; e1 is attached to an unmapped rb and a subsequent
+perf_mmap() will loop forever more:
+
+       again:
+               mutex_lock(&e->mmap_mutex);
+               if (event->rb) {
+                       ...
+                       if (!atomic_inc_not_zero(&e->rb->mmap_count)) {
+                               ...
+                               mutex_unlock(&e->mmap_mutex);
+                               goto again;
+                       }
+               }
+
+The loop in perf_mmap_close() holds e2->mmap_mutex, while the attach
+in perf_event_set_output() holds e1->mmap_mutex. As such there is no
+serialization to avoid this race.
+
+Change perf_event_set_output() to take both e1->mmap_mutex and
+e2->mmap_mutex to alleviate that problem. Additionally, have the loop
+in perf_mmap() detach the rb directly, this avoids having to wait for
+the concurrent perf_mmap_close() to get around to doing it to make
+progress.
+
+Fixes: 9bb5d40cd93c ("perf: Fix mmap() accounting hole")
+Reported-by: Yang Jihong <yangjihong1@huawei.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Tested-by: Yang Jihong <yangjihong1@huawei.com>
+Link: https://lkml.kernel.org/r/YsQ3jm2GR38SW7uD@worktop.programming.kicks-ass.net
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/events/core.c | 45 ++++++++++++++++++++++++++++++--------------
+ 1 file changed, 31 insertions(+), 14 deletions(-)
+
+diff --git a/kernel/events/core.c b/kernel/events/core.c
+index 93e21e319d70..2ad8acff03db 100644
+--- a/kernel/events/core.c
++++ b/kernel/events/core.c
+@@ -5429,10 +5429,10 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
+               if (!atomic_inc_not_zero(&event->rb->mmap_count)) {
+                       /*
+-                       * Raced against perf_mmap_close() through
+-                       * perf_event_set_output(). Try again, hope for better
+-                       * luck.
++                       * Raced against perf_mmap_close(); remove the
++                       * event and try again.
+                        */
++                      ring_buffer_attach(event, NULL);
+                       mutex_unlock(&event->mmap_mutex);
+                       goto again;
+               }
+@@ -9859,14 +9859,25 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
+       goto out;
+ }
++static void mutex_lock_double(struct mutex *a, struct mutex *b)
++{
++      if (b < a)
++              swap(a, b);
++
++      mutex_lock(a);
++      mutex_lock_nested(b, SINGLE_DEPTH_NESTING);
++}
++
+ static int
+ perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
+ {
+       struct ring_buffer *rb = NULL;
+       int ret = -EINVAL;
+-      if (!output_event)
++      if (!output_event) {
++              mutex_lock(&event->mmap_mutex);
+               goto set;
++      }
+       /* don't allow circular references */
+       if (event == output_event)
+@@ -9904,8 +9915,15 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
+           event->pmu != output_event->pmu)
+               goto out;
++      /*
++       * Hold both mmap_mutex to serialize against perf_mmap_close().  Since
++       * output_event is already on rb->event_list, and the list iteration
++       * restarts after every removal, it is guaranteed this new event is
++       * observed *OR* if output_event is already removed, it's guaranteed we
++       * observe !rb->mmap_count.
++       */
++      mutex_lock_double(&event->mmap_mutex, &output_event->mmap_mutex);
+ set:
+-      mutex_lock(&event->mmap_mutex);
+       /* Can't redirect output if we've got an active mmap() */
+       if (atomic_read(&event->mmap_count))
+               goto unlock;
+@@ -9915,6 +9933,12 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
+               rb = ring_buffer_get(output_event);
+               if (!rb)
+                       goto unlock;
++
++              /* did we race against perf_mmap_close() */
++              if (!atomic_read(&rb->mmap_count)) {
++                      ring_buffer_put(rb);
++                      goto unlock;
++              }
+       }
+       ring_buffer_attach(event, rb);
+@@ -9922,20 +9946,13 @@ perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
+       ret = 0;
+ unlock:
+       mutex_unlock(&event->mmap_mutex);
++      if (output_event)
++              mutex_unlock(&output_event->mmap_mutex);
+ out:
+       return ret;
+ }
+-static void mutex_lock_double(struct mutex *a, struct mutex *b)
+-{
+-      if (b < a)
+-              swap(a, b);
+-
+-      mutex_lock(a);
+-      mutex_lock_nested(b, SINGLE_DEPTH_NESTING);
+-}
+-
+ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)
+ {
+       bool nmi_safe = false;
+-- 
+2.35.1
+
diff --git a/queue-4.14/power-reset-arm-versatile-fix-refcount-leak-in-versa.patch b/queue-4.14/power-reset-arm-versatile-fix-refcount-leak-in-versa.patch
new file mode 100644 (file)
index 0000000..bdbba2f
--- /dev/null
@@ -0,0 +1,38 @@
+From c31831f9c54f779592674ab3674b920f1c71fce0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 May 2022 18:10:09 +0400
+Subject: power/reset: arm-versatile: Fix refcount leak in
+ versatile_reboot_probe
+
+From: Miaoqian Lin <linmq006@gmail.com>
+
+[ Upstream commit 80192eff64eee9b3bc0594a47381937b94b9d65a ]
+
+of_find_matching_node_and_match() returns a node pointer with refcount
+incremented, we should use of_node_put() on it when not need anymore.
+Add missing of_node_put() to avoid refcount leak.
+
+Fixes: 0e545f57b708 ("power: reset: driver for the Versatile syscon reboot")
+Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
+Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/power/reset/arm-versatile-reboot.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/power/reset/arm-versatile-reboot.c b/drivers/power/reset/arm-versatile-reboot.c
+index 06d34ab47df5..8022c782f6ff 100644
+--- a/drivers/power/reset/arm-versatile-reboot.c
++++ b/drivers/power/reset/arm-versatile-reboot.c
+@@ -150,6 +150,7 @@ static int __init versatile_reboot_probe(void)
+       versatile_reboot_type = (enum versatile_reboot)reboot_id->data;
+       syscon_regmap = syscon_node_to_regmap(np);
++      of_node_put(np);
+       if (IS_ERR(syscon_regmap))
+               return PTR_ERR(syscon_regmap);
+-- 
+2.35.1
+
index fa65cd0902c837a611cce121494439426cb3dd71..7f4a07eb9bc844e9f3c8e54f91da01dfe4df3f4a 100644 (file)
@@ -1 +1,14 @@
 xen-gntdev-ignore-failure-to-unmap-invalid_grant_handle.patch
+xfrm-xfrm_policy-fix-a-possible-double-xfrm_pols_put.patch
+power-reset-arm-versatile-fix-refcount-leak-in-versa.patch
+perf-core-fix-data-race-between-perf_event_set_outpu.patch
+ip-fix-a-data-race-around-sysctl_fwmark_reflect.patch
+tcp-dccp-fix-a-data-race-around-sysctl_tcp_fwmark_ac.patch
+tcp-fix-a-data-race-around-sysctl_tcp_probe_threshol.patch
+tcp-fix-a-data-race-around-sysctl_tcp_probe_interval.patch
+i2c-cadence-change-large-transfer-count-reset-logic-.patch
+net-stmmac-fix-dma-queue-left-shift-overflow-issue.patch
+igmp-fix-data-races-around-sysctl_igmp_llm_reports.patch
+igmp-fix-a-data-race-around-sysctl_igmp_max_membersh.patch
+tcp-fix-a-data-race-around-sysctl_tcp_notsent_lowat.patch
+be2net-fix-buffer-overflow-in-be_get_module_eeprom.patch
diff --git a/queue-4.14/tcp-dccp-fix-a-data-race-around-sysctl_tcp_fwmark_ac.patch b/queue-4.14/tcp-dccp-fix-a-data-race-around-sysctl_tcp_fwmark_ac.patch
new file mode 100644 (file)
index 0000000..a83db8b
--- /dev/null
@@ -0,0 +1,37 @@
+From 1b5dae12b5545b8768bdcc46160f59885ba3c747 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Jul 2022 13:51:58 -0700
+Subject: tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 1a0008f9df59451d0a17806c1ee1a19857032fa8 ]
+
+While reading sysctl_tcp_fwmark_accept, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its reader.
+
+Fixes: 84f39b08d786 ("net: support marking accepting TCP sockets")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/inet_sock.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
+index 16a1492a5bd3..f279d72273f6 100644
+--- a/include/net/inet_sock.h
++++ b/include/net/inet_sock.h
+@@ -110,7 +110,8 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
+ static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)
+ {
+-      if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)
++      if (!sk->sk_mark &&
++          READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept))
+               return skb->mark;
+       return sk->sk_mark;
+-- 
+2.35.1
+
diff --git a/queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_notsent_lowat.patch b/queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_notsent_lowat.patch
new file mode 100644 (file)
index 0000000..460e0b9
--- /dev/null
@@ -0,0 +1,36 @@
+From b6135a3b1dbeeb2f38639da8403152967ab58c23 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 15 Jul 2022 10:17:51 -0700
+Subject: tcp: Fix a data-race around sysctl_tcp_notsent_lowat.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 55be873695ed8912eb77ff46d1d1cadf028bd0f3 ]
+
+While reading sysctl_tcp_notsent_lowat, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its reader.
+
+Fixes: c9bee3b7fdec ("tcp: TCP_NOTSENT_LOWAT socket option")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/tcp.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/net/tcp.h b/include/net/tcp.h
+index 181db7dab176..5e719f9d60fd 100644
+--- a/include/net/tcp.h
++++ b/include/net/tcp.h
+@@ -1882,7 +1882,7 @@ void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr, __be32 daddr);
+ static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp)
+ {
+       struct net *net = sock_net((struct sock *)tp);
+-      return tp->notsent_lowat ?: net->ipv4.sysctl_tcp_notsent_lowat;
++      return tp->notsent_lowat ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat);
+ }
+ static inline bool tcp_stream_memory_free(const struct sock *sk)
+-- 
+2.35.1
+
diff --git a/queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_probe_interval.patch b/queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_probe_interval.patch
new file mode 100644 (file)
index 0000000..232df63
--- /dev/null
@@ -0,0 +1,36 @@
+From f545065f6188c67f3d93139045cd4a1bb43f2602 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Jul 2022 13:52:05 -0700
+Subject: tcp: Fix a data-race around sysctl_tcp_probe_interval.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 2a85388f1d94a9f8b5a529118a2c5eaa0520d85c ]
+
+While reading sysctl_tcp_probe_interval, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its reader.
+
+Fixes: 05cbc0db03e8 ("ipv4: Create probe timer for tcp PMTU as per RFC4821")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/tcp_output.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
+index 8ac23e8439c3..5e9b7dfd9d2d 100644
+--- a/net/ipv4/tcp_output.c
++++ b/net/ipv4/tcp_output.c
+@@ -2005,7 +2005,7 @@ static inline void tcp_mtu_check_reprobe(struct sock *sk)
+       u32 interval;
+       s32 delta;
+-      interval = net->ipv4.sysctl_tcp_probe_interval;
++      interval = READ_ONCE(net->ipv4.sysctl_tcp_probe_interval);
+       delta = tcp_jiffies32 - icsk->icsk_mtup.probe_timestamp;
+       if (unlikely(delta >= interval * HZ)) {
+               int mss = tcp_current_mss(sk);
+-- 
+2.35.1
+
diff --git a/queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_probe_threshol.patch b/queue-4.14/tcp-fix-a-data-race-around-sysctl_tcp_probe_threshol.patch
new file mode 100644 (file)
index 0000000..f98db01
--- /dev/null
@@ -0,0 +1,36 @@
+From d006462ce89212ffb08465fe3a09be0de0090809 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Jul 2022 13:52:04 -0700
+Subject: tcp: Fix a data-race around sysctl_tcp_probe_threshold.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 92c0aa4175474483d6cf373314343d4e624e882a ]
+
+While reading sysctl_tcp_probe_threshold, it can be changed concurrently.
+Thus, we need to add READ_ONCE() to its reader.
+
+Fixes: 6b58e0a5f32d ("ipv4: Use binary search to choose tcp PMTU probe_size")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/tcp_output.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
+index a231993c81c4..8ac23e8439c3 100644
+--- a/net/ipv4/tcp_output.c
++++ b/net/ipv4/tcp_output.c
+@@ -2087,7 +2087,7 @@ static int tcp_mtu_probe(struct sock *sk)
+        * probing process by not resetting search range to its orignal.
+        */
+       if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high) ||
+-              interval < net->ipv4.sysctl_tcp_probe_threshold) {
++          interval < READ_ONCE(net->ipv4.sysctl_tcp_probe_threshold)) {
+               /* Check whether enough time has elaplased for
+                * another round of probing.
+                */
+-- 
+2.35.1
+
diff --git a/queue-4.14/xfrm-xfrm_policy-fix-a-possible-double-xfrm_pols_put.patch b/queue-4.14/xfrm-xfrm_policy-fix-a-possible-double-xfrm_pols_put.patch
new file mode 100644 (file)
index 0000000..d8fc0f2
--- /dev/null
@@ -0,0 +1,58 @@
+From f041fdd8cad09466b5623d6fd1d916de1284b59d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Jun 2022 14:46:25 +0800
+Subject: xfrm: xfrm_policy: fix a possible double xfrm_pols_put() in
+ xfrm_bundle_lookup()
+
+From: Hangyu Hua <hbh25y@gmail.com>
+
+[ Upstream commit f85daf0e725358be78dfd208dea5fd665d8cb901 ]
+
+xfrm_policy_lookup() will call xfrm_pol_hold_rcu() to get a refcount of
+pols[0]. This refcount can be dropped in xfrm_expand_policies() when
+xfrm_expand_policies() return error. pols[0]'s refcount is balanced in
+here. But xfrm_bundle_lookup() will also call xfrm_pols_put() with
+num_pols == 1 to drop this refcount when xfrm_expand_policies() return
+error.
+
+This patch also fix an illegal address access. pols[0] will save a error
+point when xfrm_policy_lookup fails. This lead to xfrm_pols_put to resolve
+an illegal address in xfrm_bundle_lookup's error path.
+
+Fix these by setting num_pols = 0 in xfrm_expand_policies()'s error path.
+
+Fixes: 80c802f3073e ("xfrm: cache bundles instead of policies for outgoing flows")
+Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
+Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/xfrm/xfrm_policy.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
+index d87121d61a2b..e1840f70c0ff 100644
+--- a/net/xfrm/xfrm_policy.c
++++ b/net/xfrm/xfrm_policy.c
+@@ -1673,8 +1673,10 @@ static int xfrm_expand_policies(const struct flowi *fl, u16 family,
+               *num_xfrms = 0;
+               return 0;
+       }
+-      if (IS_ERR(pols[0]))
++      if (IS_ERR(pols[0])) {
++              *num_pols = 0;
+               return PTR_ERR(pols[0]);
++      }
+       *num_xfrms = pols[0]->xfrm_nr;
+@@ -1688,6 +1690,7 @@ static int xfrm_expand_policies(const struct flowi *fl, u16 family,
+               if (pols[1]) {
+                       if (IS_ERR(pols[1])) {
+                               xfrm_pols_put(pols, *num_pols);
++                              *num_pols = 0;
+                               return PTR_ERR(pols[1]);
+                       }
+                       (*num_pols)++;
+-- 
+2.35.1
+