--- /dev/null
+From 7f0a4b40d6f1b7294662341c8e1b48184d08dd14 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 28 Apr 2021 14:39:41 +0800
+Subject: cfg80211: call cfg80211_leave_ocb when switching away from OCB
+
+From: Du Cheng <ducheng2@gmail.com>
+
+[ Upstream commit a64b6a25dd9f984ed05fade603a00e2eae787d2f ]
+
+If the userland switches back-and-forth between NL80211_IFTYPE_OCB and
+NL80211_IFTYPE_ADHOC via send_msg(NL80211_CMD_SET_INTERFACE), there is a
+chance where the cleanup cfg80211_leave_ocb() is not called. This leads
+to initialization of in-use memory (e.g. init u.ibss while in-use by
+u.ocb) due to a shared struct/union within ieee80211_sub_if_data:
+
+struct ieee80211_sub_if_data {
+ ...
+ union {
+ struct ieee80211_if_ap ap;
+ struct ieee80211_if_vlan vlan;
+ struct ieee80211_if_managed mgd;
+ struct ieee80211_if_ibss ibss; // <- shares address
+ struct ieee80211_if_mesh mesh;
+ struct ieee80211_if_ocb ocb; // <- shares address
+ struct ieee80211_if_mntr mntr;
+ struct ieee80211_if_nan nan;
+ } u;
+ ...
+}
+
+Therefore add handling of otype == NL80211_IFTYPE_OCB, during
+cfg80211_change_iface() to perform cleanup when leaving OCB mode.
+
+link to syzkaller bug:
+https://syzkaller.appspot.com/bug?id=0612dbfa595bf4b9b680ff7b4948257b8e3732d5
+
+Reported-by: syzbot+105896fac213f26056f9@syzkaller.appspotmail.com
+Signed-off-by: Du Cheng <ducheng2@gmail.com>
+Link: https://lore.kernel.org/r/20210428063941.105161-1-ducheng2@gmail.com
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/wireless/util.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/net/wireless/util.c b/net/wireless/util.c
+index 4eae6ad32851..f0247eab5bc9 100644
+--- a/net/wireless/util.c
++++ b/net/wireless/util.c
+@@ -1006,6 +1006,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
+ case NL80211_IFTYPE_MESH_POINT:
+ /* mesh should be handled? */
+ break;
++ case NL80211_IFTYPE_OCB:
++ cfg80211_leave_ocb(rdev, dev);
++ break;
+ default:
+ break;
+ }
+--
+2.30.2
+
--- /dev/null
+From 4efc0f1cadc32952a08fc9b693e700bdbb5af46f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 May 2021 21:26:41 +0200
+Subject: dmaengine: mediatek: do not issue a new desc if one is still current
+
+From: Guillaume Ranquet <granquet@baylibre.com>
+
+[ Upstream commit 2537b40b0a4f61d2c83900744fe89b09076be9c6 ]
+
+Avoid issuing a new desc if one is still being processed as this can
+lead to some desc never being marked as completed.
+
+Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
+
+Link: https://lore.kernel.org/r/20210513192642.29446-3-granquet@baylibre.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/mediatek/mtk-uart-apdma.c | 20 ++++++++++++--------
+ 1 file changed, 12 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
+index 311d7c236d27..e420e9f72b3d 100644
+--- a/drivers/dma/mediatek/mtk-uart-apdma.c
++++ b/drivers/dma/mediatek/mtk-uart-apdma.c
+@@ -204,14 +204,9 @@ static void mtk_uart_apdma_start_rx(struct mtk_chan *c)
+
+ static void mtk_uart_apdma_tx_handler(struct mtk_chan *c)
+ {
+- struct mtk_uart_apdma_desc *d = c->desc;
+-
+ mtk_uart_apdma_write(c, VFF_INT_FLAG, VFF_TX_INT_CLR_B);
+ mtk_uart_apdma_write(c, VFF_INT_EN, VFF_INT_EN_CLR_B);
+ mtk_uart_apdma_write(c, VFF_EN, VFF_EN_CLR_B);
+-
+- list_del(&d->vd.node);
+- vchan_cookie_complete(&d->vd);
+ }
+
+ static void mtk_uart_apdma_rx_handler(struct mtk_chan *c)
+@@ -242,9 +237,17 @@ static void mtk_uart_apdma_rx_handler(struct mtk_chan *c)
+
+ c->rx_status = d->avail_len - cnt;
+ mtk_uart_apdma_write(c, VFF_RPT, wg);
++}
+
+- list_del(&d->vd.node);
+- vchan_cookie_complete(&d->vd);
++static void mtk_uart_apdma_chan_complete_handler(struct mtk_chan *c)
++{
++ struct mtk_uart_apdma_desc *d = c->desc;
++
++ if (d) {
++ list_del(&d->vd.node);
++ vchan_cookie_complete(&d->vd);
++ c->desc = NULL;
++ }
+ }
+
+ static irqreturn_t mtk_uart_apdma_irq_handler(int irq, void *dev_id)
+@@ -258,6 +261,7 @@ static irqreturn_t mtk_uart_apdma_irq_handler(int irq, void *dev_id)
+ mtk_uart_apdma_rx_handler(c);
+ else if (c->dir == DMA_MEM_TO_DEV)
+ mtk_uart_apdma_tx_handler(c);
++ mtk_uart_apdma_chan_complete_handler(c);
+ spin_unlock_irqrestore(&c->vc.lock, flags);
+
+ return IRQ_HANDLED;
+@@ -363,7 +367,7 @@ static void mtk_uart_apdma_issue_pending(struct dma_chan *chan)
+ unsigned long flags;
+
+ spin_lock_irqsave(&c->vc.lock, flags);
+- if (vchan_issue_pending(&c->vc)) {
++ if (vchan_issue_pending(&c->vc) && !c->desc) {
+ vd = vchan_next_desc(&c->vc);
+ c->desc = to_mtk_uart_apdma_desc(&vd->tx);
+
+--
+2.30.2
+
--- /dev/null
+From 8ef918dad7ca53c3e9ecaddcc93330ac25dc31ba Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 May 2021 21:26:40 +0200
+Subject: dmaengine: mediatek: free the proper desc in desc_free handler
+
+From: Guillaume Ranquet <granquet@baylibre.com>
+
+[ Upstream commit 0a2ff58f9f8f95526ecb0ccd7517fefceb96f661 ]
+
+The desc_free handler assumed that the desc we want to free was always
+ the current one associated with the channel.
+
+This is seldom the case and this is causing use after free crashes in
+ multiple places (tx/rx/terminate...).
+
+ BUG: KASAN: use-after-free in mtk_uart_apdma_rx_handler+0x120/0x304
+
+ Call trace:
+ dump_backtrace+0x0/0x1b0
+ show_stack+0x24/0x34
+ dump_stack+0xe0/0x150
+ print_address_description+0x8c/0x55c
+ __kasan_report+0x1b8/0x218
+ kasan_report+0x14/0x20
+ __asan_load4+0x98/0x9c
+ mtk_uart_apdma_rx_handler+0x120/0x304
+ mtk_uart_apdma_irq_handler+0x50/0x80
+ __handle_irq_event_percpu+0xe0/0x210
+ handle_irq_event+0x8c/0x184
+ handle_fasteoi_irq+0x1d8/0x3ac
+ __handle_domain_irq+0xb0/0x110
+ gic_handle_irq+0x50/0xb8
+ el0_irq_naked+0x60/0x6c
+
+ Allocated by task 3541:
+ __kasan_kmalloc+0xf0/0x1b0
+ kasan_kmalloc+0x10/0x1c
+ kmem_cache_alloc_trace+0x90/0x2dc
+ mtk_uart_apdma_prep_slave_sg+0x6c/0x1a0
+ mtk8250_dma_rx_complete+0x220/0x2e4
+ vchan_complete+0x290/0x340
+ tasklet_action_common+0x220/0x298
+ tasklet_action+0x28/0x34
+ __do_softirq+0x158/0x35c
+
+ Freed by task 3541:
+ __kasan_slab_free+0x154/0x224
+ kasan_slab_free+0x14/0x24
+ slab_free_freelist_hook+0xf8/0x15c
+ kfree+0xb4/0x278
+ mtk_uart_apdma_desc_free+0x34/0x44
+ vchan_complete+0x1bc/0x340
+ tasklet_action_common+0x220/0x298
+ tasklet_action+0x28/0x34
+ __do_softirq+0x158/0x35c
+
+ The buggy address belongs to the object at ffff000063606800
+ which belongs to the cache kmalloc-256 of size 256
+ The buggy address is located 176 bytes inside of
+ 256-byte region [ffff000063606800, ffff000063606900)
+ The buggy address belongs to the page:
+ page:fffffe00016d8180 refcount:1 mapcount:0 mapping:ffff00000302f600 index:0x0 compound_mapcount: 0
+ flags: 0xffff00000010200(slab|head)
+ raw: 0ffff00000010200 dead000000000100 dead000000000122 ffff00000302f600
+ raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
+ page dumped because: kasan: bad access detected
+
+Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
+
+Link: https://lore.kernel.org/r/20210513192642.29446-2-granquet@baylibre.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/mediatek/mtk-uart-apdma.c | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
+index f40051d6aecb..311d7c236d27 100644
+--- a/drivers/dma/mediatek/mtk-uart-apdma.c
++++ b/drivers/dma/mediatek/mtk-uart-apdma.c
+@@ -131,10 +131,7 @@ static unsigned int mtk_uart_apdma_read(struct mtk_chan *c, unsigned int reg)
+
+ static void mtk_uart_apdma_desc_free(struct virt_dma_desc *vd)
+ {
+- struct dma_chan *chan = vd->tx.chan;
+- struct mtk_chan *c = to_mtk_uart_apdma_chan(chan);
+-
+- kfree(c->desc);
++ kfree(container_of(vd, struct mtk_uart_apdma_desc, vd));
+ }
+
+ static void mtk_uart_apdma_start_tx(struct mtk_chan *c)
+--
+2.30.2
+
--- /dev/null
+From 9aad82119abe754ea06a283598a5c753628aaf05 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 May 2021 21:26:42 +0200
+Subject: dmaengine: mediatek: use GFP_NOWAIT instead of GFP_ATOMIC in prep_dma
+
+From: Guillaume Ranquet <granquet@baylibre.com>
+
+[ Upstream commit 9041575348b21ade1fb74d790f1aac85d68198c7 ]
+
+As recommended by the doc in:
+Documentation/drivers-api/dmaengine/provider.rst
+
+Use GFP_NOWAIT to not deplete the emergency pool.
+
+Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
+
+Link: https://lore.kernel.org/r/20210513192642.29446-4-granquet@baylibre.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/mediatek/mtk-uart-apdma.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
+index e420e9f72b3d..9c0ea13ca788 100644
+--- a/drivers/dma/mediatek/mtk-uart-apdma.c
++++ b/drivers/dma/mediatek/mtk-uart-apdma.c
+@@ -349,7 +349,7 @@ static struct dma_async_tx_descriptor *mtk_uart_apdma_prep_slave_sg
+ return NULL;
+
+ /* Now allocate and setup the descriptor */
+- d = kzalloc(sizeof(*d), GFP_ATOMIC);
++ d = kzalloc(sizeof(*d), GFP_NOWAIT);
+ if (!d)
+ return NULL;
+
+--
+2.30.2
+
--- /dev/null
+From 50ea589ed60c750ad127df4824a708a7eceae5ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 31 May 2021 14:36:03 +0800
+Subject: dmaengine: rcar-dmac: Fix PM reference leak in rcar_dmac_probe()
+
+From: Zou Wei <zou_wei@huawei.com>
+
+[ Upstream commit dea8464ddf553803382efb753b6727dbf3931d06 ]
+
+pm_runtime_get_sync will increment pm usage counter even it failed.
+Forgetting to putting operation will result in reference leak here.
+Fix it by replacing it with pm_runtime_resume_and_get to keep usage
+counter balanced.
+
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Zou Wei <zou_wei@huawei.com>
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Link: https://lore.kernel.org/r/1622442963-54095-1-git-send-email-zou_wei@huawei.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/sh/rcar-dmac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
+index 3993ab65c62c..89eb9ea25814 100644
+--- a/drivers/dma/sh/rcar-dmac.c
++++ b/drivers/dma/sh/rcar-dmac.c
+@@ -1855,7 +1855,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
+
+ /* Enable runtime PM and initialize the device. */
+ pm_runtime_enable(&pdev->dev);
+- ret = pm_runtime_get_sync(&pdev->dev);
++ ret = pm_runtime_resume_and_get(&pdev->dev);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "runtime PM get sync failed (%d)\n", ret);
+ return ret;
+--
+2.30.2
+
--- /dev/null
+From e59cf82564d1d629fc8f0e49737d998c5ce775bc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 May 2021 16:18:26 +0800
+Subject: dmaengine: zynqmp_dma: Fix PM reference leak in
+ zynqmp_dma_alloc_chan_resourc()
+
+From: Yu Kuai <yukuai3@huawei.com>
+
+[ Upstream commit 8982d48af36d2562c0f904736b0fc80efc9f2532 ]
+
+pm_runtime_get_sync will increment pm usage counter even it failed.
+Forgetting to putting operation will result in reference leak here.
+Fix it by replacing it with pm_runtime_resume_and_get to keep usage
+counter balanced.
+
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Yu Kuai <yukuai3@huawei.com>
+Link: https://lore.kernel.org/r/20210517081826.1564698-4-yukuai3@huawei.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/xilinx/zynqmp_dma.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
+index d47749a35863..84009c5e0f33 100644
+--- a/drivers/dma/xilinx/zynqmp_dma.c
++++ b/drivers/dma/xilinx/zynqmp_dma.c
+@@ -467,7 +467,7 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
+ struct zynqmp_dma_desc_sw *desc;
+ int i, ret;
+
+- ret = pm_runtime_get_sync(chan->dev);
++ ret = pm_runtime_resume_and_get(chan->dev);
+ if (ret < 0)
+ return ret;
+
+--
+2.30.2
+
--- /dev/null
+From 2c9703ca3b4ff3cd428267a76af3970e9d3d42d9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 10 Jun 2021 07:44:11 -0700
+Subject: inet: annotate date races around sk->sk_txhash
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit b71eaed8c04f72a919a9c44e83e4ee254e69e7f3 ]
+
+UDP sendmsg() path can be lockless, it is possible for another
+thread to re-connect an change sk->sk_txhash under us.
+
+There is no serious impact, but we can use READ_ONCE()/WRITE_ONCE()
+pair to document the race.
+
+BUG: KCSAN: data-race in __ip4_datagram_connect / skb_set_owner_w
+
+write to 0xffff88813397920c of 4 bytes by task 30997 on cpu 1:
+ sk_set_txhash include/net/sock.h:1937 [inline]
+ __ip4_datagram_connect+0x69e/0x710 net/ipv4/datagram.c:75
+ __ip6_datagram_connect+0x551/0x840 net/ipv6/datagram.c:189
+ ip6_datagram_connect+0x2a/0x40 net/ipv6/datagram.c:272
+ inet_dgram_connect+0xfd/0x180 net/ipv4/af_inet.c:580
+ __sys_connect_file net/socket.c:1837 [inline]
+ __sys_connect+0x245/0x280 net/socket.c:1854
+ __do_sys_connect net/socket.c:1864 [inline]
+ __se_sys_connect net/socket.c:1861 [inline]
+ __x64_sys_connect+0x3d/0x50 net/socket.c:1861
+ do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+read to 0xffff88813397920c of 4 bytes by task 31039 on cpu 0:
+ skb_set_hash_from_sk include/net/sock.h:2211 [inline]
+ skb_set_owner_w+0x118/0x220 net/core/sock.c:2101
+ sock_alloc_send_pskb+0x452/0x4e0 net/core/sock.c:2359
+ sock_alloc_send_skb+0x2d/0x40 net/core/sock.c:2373
+ __ip6_append_data+0x1743/0x21a0 net/ipv6/ip6_output.c:1621
+ ip6_make_skb+0x258/0x420 net/ipv6/ip6_output.c:1983
+ udpv6_sendmsg+0x160a/0x16b0 net/ipv6/udp.c:1527
+ inet6_sendmsg+0x5f/0x80 net/ipv6/af_inet6.c:642
+ sock_sendmsg_nosec net/socket.c:654 [inline]
+ sock_sendmsg net/socket.c:674 [inline]
+ ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
+ ___sys_sendmsg net/socket.c:2404 [inline]
+ __sys_sendmmsg+0x315/0x4b0 net/socket.c:2490
+ __do_sys_sendmmsg net/socket.c:2519 [inline]
+ __se_sys_sendmmsg net/socket.c:2516 [inline]
+ __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2516
+ do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+value changed: 0xbca3c43d -> 0xfdb309e0
+
+Reported by Kernel Concurrency Sanitizer on:
+CPU: 0 PID: 31039 Comm: syz-executor.2 Not tainted 5.13.0-rc3-syzkaller #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
+
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/sock.h | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/include/net/sock.h b/include/net/sock.h
+index a0728f24ecc5..d3dd89b6e2cb 100644
+--- a/include/net/sock.h
++++ b/include/net/sock.h
+@@ -1860,7 +1860,8 @@ static inline u32 net_tx_rndhash(void)
+
+ static inline void sk_set_txhash(struct sock *sk)
+ {
+- sk->sk_txhash = net_tx_rndhash();
++ /* This pairs with READ_ONCE() in skb_set_hash_from_sk() */
++ WRITE_ONCE(sk->sk_txhash, net_tx_rndhash());
+ }
+
+ static inline void sk_rethink_txhash(struct sock *sk)
+@@ -2125,9 +2126,12 @@ static inline void sock_poll_wait(struct file *filp, struct socket *sock,
+
+ static inline void skb_set_hash_from_sk(struct sk_buff *skb, struct sock *sk)
+ {
+- if (sk->sk_txhash) {
++ /* This pairs with WRITE_ONCE() in sk_set_txhash() */
++ u32 txhash = READ_ONCE(sk->sk_txhash);
++
++ if (txhash) {
+ skb->l4_hash = 1;
+- skb->hash = sk->sk_txhash;
++ skb->hash = txhash;
+ }
+ }
+
+--
+2.30.2
+
--- /dev/null
+From 1df7816124bbfff7cf6c41008135fe3585ce4b29 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Jun 2021 16:04:43 +0100
+Subject: KVM: selftests: Fix kvm_check_cap() assertion
+
+From: Fuad Tabba <tabba@google.com>
+
+[ Upstream commit d8ac05ea13d789d5491a5920d70a05659015441d ]
+
+KVM_CHECK_EXTENSION ioctl can return any negative value on error,
+and not necessarily -1. Change the assertion to reflect that.
+
+Signed-off-by: Fuad Tabba <tabba@google.com>
+Message-Id: <20210615150443.1183365-1-tabba@google.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/kvm/lib/kvm_util.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
+index 41cf45416060..38de88e5ffbb 100644
+--- a/tools/testing/selftests/kvm/lib/kvm_util.c
++++ b/tools/testing/selftests/kvm/lib/kvm_util.c
+@@ -54,7 +54,7 @@ int kvm_check_cap(long cap)
+ exit(KSFT_SKIP);
+
+ ret = ioctl(kvm_fd, KVM_CHECK_EXTENSION, cap);
+- TEST_ASSERT(ret != -1, "KVM_CHECK_EXTENSION IOCTL failed,\n"
++ TEST_ASSERT(ret >= 0, "KVM_CHECK_EXTENSION IOCTL failed,\n"
+ " rc: %i errno: %i", ret, errno);
+
+ close(kvm_fd);
+--
+2.30.2
+
--- /dev/null
+From 73e720bc0b1bbcf92d44800d368c356e8f43f611 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 9 Jun 2021 16:13:06 +0200
+Subject: mac80211: drop multicast fragments
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit a9799541ca34652d9996e45f80e8e03144c12949 ]
+
+These are not permitted by the spec, just drop them.
+
+Link: https://lore.kernel.org/r/20210609161305.23def022b750.Ibd6dd3cdce573dae262fcdc47f8ac52b883a9c50@changeid
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/mac80211/rx.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
+index 3d7a5c5e586a..670d84e54db7 100644
+--- a/net/mac80211/rx.c
++++ b/net/mac80211/rx.c
+@@ -2200,17 +2200,15 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
+ sc = le16_to_cpu(hdr->seq_ctrl);
+ frag = sc & IEEE80211_SCTL_FRAG;
+
+- if (is_multicast_ether_addr(hdr->addr1)) {
+- I802_DEBUG_INC(rx->local->dot11MulticastReceivedFrameCount);
+- goto out_no_led;
+- }
+-
+ if (rx->sta)
+ cache = &rx->sta->frags;
+
+ if (likely(!ieee80211_has_morefrags(fc) && frag == 0))
+ goto out;
+
++ if (is_multicast_ether_addr(hdr->addr1))
++ return RX_DROP_MONITOR;
++
+ I802_DEBUG_INC(rx->local->rx_handlers_fragments);
+
+ if (skb_linearize(rx->skb))
+@@ -2336,7 +2334,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
+
+ out:
+ ieee80211_led_rx(rx->local);
+- out_no_led:
+ if (rx->sta)
+ rx->sta->rx_stats.packets++;
+ return RX_CONTINUE;
+--
+2.30.2
+
--- /dev/null
+From fc167b8f9d7be3d0bd88718b37b85b858406745e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 May 2021 16:47:17 +0200
+Subject: mac80211: remove warning in ieee80211_get_sband()
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit 0ee4d55534f82a0624701d0bb9fc2304d4529086 ]
+
+Syzbot reports that it's possible to hit this from userspace,
+by trying to add a station before any other connection setup
+has been done. Instead of trying to catch this in some other
+way simply remove the warning, that will appropriately reject
+the call from userspace.
+
+Reported-by: syzbot+7716dbc401d9a437890d@syzkaller.appspotmail.com
+Link: https://lore.kernel.org/r/20210517164715.f537da276d17.Id05f40ec8761d6a8cc2df87f1aa09c651988a586@changeid
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/mac80211/ieee80211_i.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
+index a7933279a80b..e574fbf6745a 100644
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -1420,7 +1420,7 @@ ieee80211_get_sband(struct ieee80211_sub_if_data *sdata)
+ rcu_read_lock();
+ chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+
+- if (WARN_ON_ONCE(!chanctx_conf)) {
++ if (!chanctx_conf) {
+ rcu_read_unlock();
+ return NULL;
+ }
+--
+2.30.2
+
--- /dev/null
+From 80a0a185cf6e08401068ed2b77ebbdfa1f765a22 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 May 2021 17:04:31 +0200
+Subject: mac80211_hwsim: drop pending frames on stop
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit bd18de517923903a177508fc8813f44e717b1c00 ]
+
+Syzbot reports that we may be able to get into a situation where
+mac80211 has pending ACK frames on shutdown with hwsim. It appears
+that the reason for this is that syzbot uses the wmediumd hooks to
+intercept/injection frames, and may shut down hwsim, removing the
+radio(s), while frames are pending in the air simulation.
+
+Clean out the pending queue when the interface is stopped, after
+this the frames can't be reported back to mac80211 properly anyway.
+
+Reported-by: syzbot+a063bbf0b15737362592@syzkaller.appspotmail.com
+Link: https://lore.kernel.org/r/20210517170429.b0f85ab0eda1.Ie42a6ec6b940c971f3441286aeaaae2fe368e29a@changeid
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/mac80211_hwsim.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
+index c48c68090d76..1033513d3d9d 100644
+--- a/drivers/net/wireless/mac80211_hwsim.c
++++ b/drivers/net/wireless/mac80211_hwsim.c
+@@ -1458,8 +1458,13 @@ static int mac80211_hwsim_start(struct ieee80211_hw *hw)
+ static void mac80211_hwsim_stop(struct ieee80211_hw *hw)
+ {
+ struct mac80211_hwsim_data *data = hw->priv;
++
+ data->started = false;
+ hrtimer_cancel(&data->beacon_timer);
++
++ while (!skb_queue_empty(&data->pending))
++ ieee80211_free_txskb(hw, skb_dequeue(&data->pending));
++
+ wiphy_dbg(hw->wiphy, "%s\n", __func__);
+ }
+
+--
+2.30.2
+
--- /dev/null
+From e0a8381ba96fb4784d104b01644d9f596d45cb18 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 12 Jun 2021 17:51:22 +0300
+Subject: net: caif: fix memory leak in ldisc_open
+
+From: Pavel Skripkin <paskripkin@gmail.com>
+
+[ Upstream commit 58af3d3d54e87bfc1f936e16c04ade3369d34011 ]
+
+Syzbot reported memory leak in tty_init_dev().
+The problem was in unputted tty in ldisc_open()
+
+static int ldisc_open(struct tty_struct *tty)
+{
+...
+ ser->tty = tty_kref_get(tty);
+...
+ result = register_netdevice(dev);
+ if (result) {
+ rtnl_unlock();
+ free_netdev(dev);
+ return -ENODEV;
+ }
+...
+}
+
+Ser pointer is netdev private_data, so after free_netdev()
+this pointer goes away with unputted tty reference. So, fix
+it by adding tty_kref_put() before freeing netdev.
+
+Reported-and-tested-by: syzbot+f303e045423e617d2cad@syzkaller.appspotmail.com
+Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/caif/caif_serial.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
+index 0f2bee59a82b..0bc7f6518fb3 100644
+--- a/drivers/net/caif/caif_serial.c
++++ b/drivers/net/caif/caif_serial.c
+@@ -351,6 +351,7 @@ static int ldisc_open(struct tty_struct *tty)
+ rtnl_lock();
+ result = register_netdevice(dev);
+ if (result) {
++ tty_kref_put(tty);
+ rtnl_unlock();
+ free_netdev(dev);
+ return -ENODEV;
+--
+2.30.2
+
--- /dev/null
+From 76f6f7178e927edd137f299d1b80edd4589f1326 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 9 Jun 2021 03:34:25 +0100
+Subject: net: ethtool: clear heap allocations for ethtool function
+
+From: Austin Kim <austindh.kim@gmail.com>
+
+[ Upstream commit 80ec82e3d2c1fab42eeb730aaa7985494a963d3f ]
+
+Several ethtool functions leave heap uncleared (potentially) by
+drivers. This will leave the unused portion of heap unchanged and
+might copy the full contents back to userspace.
+
+Signed-off-by: Austin Kim <austindh.kim@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/ethtool.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/net/core/ethtool.c b/net/core/ethtool.c
+index 76506975d59a..cbd1885f2459 100644
+--- a/net/core/ethtool.c
++++ b/net/core/ethtool.c
+@@ -1508,7 +1508,7 @@ static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
+ if (eeprom.offset + eeprom.len > total_len)
+ return -EINVAL;
+
+- data = kmalloc(PAGE_SIZE, GFP_USER);
++ data = kzalloc(PAGE_SIZE, GFP_USER);
+ if (!data)
+ return -ENOMEM;
+
+@@ -1573,7 +1573,7 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
+ if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
+ return -EINVAL;
+
+- data = kmalloc(PAGE_SIZE, GFP_USER);
++ data = kzalloc(PAGE_SIZE, GFP_USER);
+ if (!data)
+ return -ENOMEM;
+
+@@ -1764,7 +1764,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
+ return -EFAULT;
+
+ test.len = test_len;
+- data = kmalloc_array(test_len, sizeof(u64), GFP_USER);
++ data = kcalloc(test_len, sizeof(u64), GFP_USER);
+ if (!data)
+ return -ENOMEM;
+
+@@ -2295,7 +2295,7 @@ static int ethtool_get_tunable(struct net_device *dev, void __user *useraddr)
+ ret = ethtool_tunable_valid(&tuna);
+ if (ret)
+ return ret;
+- data = kmalloc(tuna.len, GFP_USER);
++ data = kzalloc(tuna.len, GFP_USER);
+ if (!data)
+ return -ENOMEM;
+ ret = ops->get_tunable(dev, &tuna, data);
+@@ -2481,7 +2481,7 @@ static int get_phy_tunable(struct net_device *dev, void __user *useraddr)
+ ret = ethtool_phy_tunable_valid(&tuna);
+ if (ret)
+ return ret;
+- data = kmalloc(tuna.len, GFP_USER);
++ data = kzalloc(tuna.len, GFP_USER);
+ if (!data)
+ return -ENOMEM;
+ mutex_lock(&phydev->lock);
+--
+2.30.2
+
--- /dev/null
+From e7a05bf63f74e0f6cbc79ecfa894ec6dbacc5e6c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 8 Jun 2021 09:53:15 +0800
+Subject: net: ipv4: Remove unneed BUG() function
+
+From: Zheng Yongjun <zhengyongjun3@huawei.com>
+
+[ Upstream commit 5ac6b198d7e312bd10ebe7d58c64690dc59cc49a ]
+
+When 'nla_parse_nested_deprecated' failed, it's no need to
+BUG() here, return -EINVAL is ok.
+
+Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/devinet.c | 2 +-
+ net/ipv6/addrconf.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
+index a27d034c85cc..603a3495afa6 100644
+--- a/net/ipv4/devinet.c
++++ b/net/ipv4/devinet.c
+@@ -1989,7 +1989,7 @@ static int inet_set_link_af(struct net_device *dev, const struct nlattr *nla)
+ return -EAFNOSUPPORT;
+
+ if (nla_parse_nested_deprecated(tb, IFLA_INET_MAX, nla, NULL, NULL) < 0)
+- BUG();
++ return -EINVAL;
+
+ if (tb[IFLA_INET_CONF]) {
+ nla_for_each_nested(a, tb[IFLA_INET_CONF], rem)
+diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
+index 52feab2baeee..366c3792b860 100644
+--- a/net/ipv6/addrconf.c
++++ b/net/ipv6/addrconf.c
+@@ -5761,7 +5761,7 @@ static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
+ return -EAFNOSUPPORT;
+
+ if (nla_parse_nested_deprecated(tb, IFLA_INET6_MAX, nla, NULL, NULL) < 0)
+- BUG();
++ return -EINVAL;
+
+ if (tb[IFLA_INET6_TOKEN]) {
+ err = inet6_set_iftoken(idev, nla_data(tb[IFLA_INET6_TOKEN]));
+--
+2.30.2
+
--- /dev/null
+From 863b0e71ccb22ede17bb430d1ff811a9954fddf7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Jun 2021 12:52:28 +0200
+Subject: net: ll_temac: Add memory-barriers for TX BD access
+
+From: Esben Haabendal <esben@geanix.com>
+
+[ Upstream commit 28d9fab458b16bcd83f9dd07ede3d585c3e1a69e ]
+
+Add a couple of memory-barriers to ensure correct ordering of read/write
+access to TX BDs.
+
+In xmit_done, we should ensure that reading the additional BD fields are
+only done after STS_CTRL_APP0_CMPLT bit is set.
+
+When xmit_done marks the BD as free by setting APP0=0, we need to ensure
+that the other BD fields are reset first, so we avoid racing with the xmit
+path, which writes to the same fields.
+
+Finally, making sure to read APP0 of next BD after the current BD, ensures
+that we see all available buffers.
+
+Signed-off-by: Esben Haabendal <esben@geanix.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/xilinx/ll_temac_main.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
+index 9b55fbdc3a7c..d3d9f7046913 100644
+--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
+@@ -770,12 +770,15 @@ static void temac_start_xmit_done(struct net_device *ndev)
+ stat = be32_to_cpu(cur_p->app0);
+
+ while (stat & STS_CTRL_APP0_CMPLT) {
++ /* Make sure that the other fields are read after bd is
++ * released by dma
++ */
++ rmb();
+ dma_unmap_single(ndev->dev.parent, be32_to_cpu(cur_p->phys),
+ be32_to_cpu(cur_p->len), DMA_TO_DEVICE);
+ skb = (struct sk_buff *)ptr_from_txbd(cur_p);
+ if (skb)
+ dev_consume_skb_irq(skb);
+- cur_p->app0 = 0;
+ cur_p->app1 = 0;
+ cur_p->app2 = 0;
+ cur_p->app3 = 0;
+@@ -784,6 +787,12 @@ static void temac_start_xmit_done(struct net_device *ndev)
+ ndev->stats.tx_packets++;
+ ndev->stats.tx_bytes += be32_to_cpu(cur_p->len);
+
++ /* app0 must be visible last, as it is used to flag
++ * availability of the bd
++ */
++ smp_mb();
++ cur_p->app0 = 0;
++
+ lp->tx_bd_ci++;
+ if (lp->tx_bd_ci >= TX_BD_NUM)
+ lp->tx_bd_ci = 0;
+@@ -810,6 +819,9 @@ static inline int temac_check_tx_bd_space(struct temac_local *lp, int num_frag)
+ if (cur_p->app0)
+ return NETDEV_TX_BUSY;
+
++ /* Make sure to read next bd app0 after this one */
++ rmb();
++
+ tail++;
+ if (tail >= TX_BD_NUM)
+ tail = 0;
+--
+2.30.2
+
--- /dev/null
+From 8e3a617f8a2124afb7bb07a8779683797dd839bc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Jun 2021 12:52:38 +0200
+Subject: net: ll_temac: Avoid ndo_start_xmit returning NETDEV_TX_BUSY
+
+From: Esben Haabendal <esben@geanix.com>
+
+[ Upstream commit f6396341194234e9b01cd7538bc2c6ac4501ab14 ]
+
+As documented in Documentation/networking/driver.rst, the ndo_start_xmit
+method must not return NETDEV_TX_BUSY under any normal circumstances, and
+as recommended, we simply stop the tx queue in advance, when there is a
+risk that the next xmit would cause a NETDEV_TX_BUSY return.
+
+Signed-off-by: Esben Haabendal <esben@geanix.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/xilinx/ll_temac_main.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
+index d3d9f7046913..9a7af7dda70d 100644
+--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
+@@ -939,6 +939,11 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+ wmb();
+ lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
+
++ if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {
++ netdev_info(ndev, "%s -> netif_stop_queue\n", __func__);
++ netif_stop_queue(ndev);
++ }
++
+ return NETDEV_TX_OK;
+ }
+
+--
+2.30.2
+
--- /dev/null
+From f4cced6d94d584a27dc7edd45560a7feb4c59e84 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Jun 2021 06:42:01 -0700
+Subject: net/packet: annotate accesses to po->bind
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit c7d2ef5dd4b03ed0ee1d13bc0c55f9cf62d49bd6 ]
+
+tpacket_snd(), packet_snd(), packet_getname() and packet_seq_show()
+can read po->num without holding a lock. This means other threads
+can change po->num at the same time.
+
+KCSAN complained about this known fact [1]
+Add READ_ONCE()/WRITE_ONCE() to address the issue.
+
+[1] BUG: KCSAN: data-race in packet_do_bind / packet_sendmsg
+
+write to 0xffff888131a0dcc0 of 2 bytes by task 24714 on cpu 0:
+ packet_do_bind+0x3ab/0x7e0 net/packet/af_packet.c:3181
+ packet_bind+0xc3/0xd0 net/packet/af_packet.c:3255
+ __sys_bind+0x200/0x290 net/socket.c:1637
+ __do_sys_bind net/socket.c:1648 [inline]
+ __se_sys_bind net/socket.c:1646 [inline]
+ __x64_sys_bind+0x3d/0x50 net/socket.c:1646
+ do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+read to 0xffff888131a0dcc0 of 2 bytes by task 24719 on cpu 1:
+ packet_snd net/packet/af_packet.c:2899 [inline]
+ packet_sendmsg+0x317/0x3570 net/packet/af_packet.c:3040
+ sock_sendmsg_nosec net/socket.c:654 [inline]
+ sock_sendmsg net/socket.c:674 [inline]
+ ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
+ ___sys_sendmsg net/socket.c:2404 [inline]
+ __sys_sendmsg+0x1ed/0x270 net/socket.c:2433
+ __do_sys_sendmsg net/socket.c:2442 [inline]
+ __se_sys_sendmsg net/socket.c:2440 [inline]
+ __x64_sys_sendmsg+0x42/0x50 net/socket.c:2440
+ do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+value changed: 0x0000 -> 0x1200
+
+Reported by Kernel Concurrency Sanitizer on:
+CPU: 1 PID: 24719 Comm: syz-executor.5 Not tainted 5.13.0-rc4-syzkaller #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
+
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/packet/af_packet.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
+index fbc2d4dfddf0..e582799d4e85 100644
+--- a/net/packet/af_packet.c
++++ b/net/packet/af_packet.c
+@@ -2656,7 +2656,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
+ }
+ if (likely(saddr == NULL)) {
+ dev = packet_cached_dev_get(po);
+- proto = po->num;
++ proto = READ_ONCE(po->num);
+ } else {
+ err = -EINVAL;
+ if (msg->msg_namelen < sizeof(struct sockaddr_ll))
+@@ -2869,7 +2869,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
+
+ if (likely(saddr == NULL)) {
+ dev = packet_cached_dev_get(po);
+- proto = po->num;
++ proto = READ_ONCE(po->num);
+ } else {
+ err = -EINVAL;
+ if (msg->msg_namelen < sizeof(struct sockaddr_ll))
+@@ -3141,7 +3141,7 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
+ /* prevents packet_notifier() from calling
+ * register_prot_hook()
+ */
+- po->num = 0;
++ WRITE_ONCE(po->num, 0);
+ __unregister_prot_hook(sk, true);
+ rcu_read_lock();
+ dev_curr = po->prot_hook.dev;
+@@ -3151,7 +3151,7 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
+ }
+
+ BUG_ON(po->running);
+- po->num = proto;
++ WRITE_ONCE(po->num, proto);
+ po->prot_hook.type = proto;
+
+ if (unlikely(unlisted)) {
+@@ -3496,7 +3496,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
+
+ sll->sll_family = AF_PACKET;
+ sll->sll_ifindex = po->ifindex;
+- sll->sll_protocol = po->num;
++ sll->sll_protocol = READ_ONCE(po->num);
+ sll->sll_pkttype = 0;
+ rcu_read_lock();
+ dev = dev_get_by_index_rcu(sock_net(sk), po->ifindex);
+@@ -4405,7 +4405,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
+ was_running = po->running;
+ num = po->num;
+ if (was_running) {
+- po->num = 0;
++ WRITE_ONCE(po->num, 0);
+ __unregister_prot_hook(sk, false);
+ }
+ spin_unlock(&po->bind_lock);
+@@ -4440,7 +4440,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
+
+ spin_lock(&po->bind_lock);
+ if (was_running) {
+- po->num = num;
++ WRITE_ONCE(po->num, num);
+ register_prot_hook(sk);
+ }
+ spin_unlock(&po->bind_lock);
+@@ -4613,7 +4613,7 @@ static int packet_seq_show(struct seq_file *seq, void *v)
+ s,
+ refcount_read(&s->sk_refcnt),
+ s->sk_type,
+- ntohs(po->num),
++ ntohs(READ_ONCE(po->num)),
+ po->ifindex,
+ po->running,
+ atomic_read(&s->sk_rmem_alloc),
+--
+2.30.2
+
--- /dev/null
+From 4ee4774c056a42de0f3bb7dfc78c9b27570e28b5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Jun 2021 06:42:02 -0700
+Subject: net/packet: annotate accesses to po->ifindex
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit e032f7c9c7cefffcfb79b9fc16c53011d2d9d11f ]
+
+Like prior patch, we need to annotate lockless accesses to po->ifindex
+For instance, packet_getname() is reading po->ifindex (twice) while
+another thread is able to change po->ifindex.
+
+KCSAN reported:
+
+BUG: KCSAN: data-race in packet_do_bind / packet_getname
+
+write to 0xffff888143ce3cbc of 4 bytes by task 25573 on cpu 1:
+ packet_do_bind+0x420/0x7e0 net/packet/af_packet.c:3191
+ packet_bind+0xc3/0xd0 net/packet/af_packet.c:3255
+ __sys_bind+0x200/0x290 net/socket.c:1637
+ __do_sys_bind net/socket.c:1648 [inline]
+ __se_sys_bind net/socket.c:1646 [inline]
+ __x64_sys_bind+0x3d/0x50 net/socket.c:1646
+ do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+read to 0xffff888143ce3cbc of 4 bytes by task 25578 on cpu 0:
+ packet_getname+0x5b/0x1a0 net/packet/af_packet.c:3525
+ __sys_getsockname+0x10e/0x1a0 net/socket.c:1887
+ __do_sys_getsockname net/socket.c:1902 [inline]
+ __se_sys_getsockname net/socket.c:1899 [inline]
+ __x64_sys_getsockname+0x3e/0x50 net/socket.c:1899
+ do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+
+value changed: 0x00000000 -> 0x00000001
+
+Reported by Kernel Concurrency Sanitizer on:
+CPU: 0 PID: 25578 Comm: syz-executor.5 Not tainted 5.13.0-rc6-syzkaller #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
+
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/packet/af_packet.c | 16 +++++++++-------
+ 1 file changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
+index e582799d4e85..0ffbf3d17911 100644
+--- a/net/packet/af_packet.c
++++ b/net/packet/af_packet.c
+@@ -3157,11 +3157,11 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
+ if (unlikely(unlisted)) {
+ dev_put(dev);
+ po->prot_hook.dev = NULL;
+- po->ifindex = -1;
++ WRITE_ONCE(po->ifindex, -1);
+ packet_cached_dev_reset(po);
+ } else {
+ po->prot_hook.dev = dev;
+- po->ifindex = dev ? dev->ifindex : 0;
++ WRITE_ONCE(po->ifindex, dev ? dev->ifindex : 0);
+ packet_cached_dev_assign(po, dev);
+ }
+ }
+@@ -3475,7 +3475,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
+ uaddr->sa_family = AF_PACKET;
+ memset(uaddr->sa_data, 0, sizeof(uaddr->sa_data));
+ rcu_read_lock();
+- dev = dev_get_by_index_rcu(sock_net(sk), pkt_sk(sk)->ifindex);
++ dev = dev_get_by_index_rcu(sock_net(sk), READ_ONCE(pkt_sk(sk)->ifindex));
+ if (dev)
+ strlcpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
+ rcu_read_unlock();
+@@ -3490,16 +3490,18 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
+ struct sock *sk = sock->sk;
+ struct packet_sock *po = pkt_sk(sk);
+ DECLARE_SOCKADDR(struct sockaddr_ll *, sll, uaddr);
++ int ifindex;
+
+ if (peer)
+ return -EOPNOTSUPP;
+
++ ifindex = READ_ONCE(po->ifindex);
+ sll->sll_family = AF_PACKET;
+- sll->sll_ifindex = po->ifindex;
++ sll->sll_ifindex = ifindex;
+ sll->sll_protocol = READ_ONCE(po->num);
+ sll->sll_pkttype = 0;
+ rcu_read_lock();
+- dev = dev_get_by_index_rcu(sock_net(sk), po->ifindex);
++ dev = dev_get_by_index_rcu(sock_net(sk), ifindex);
+ if (dev) {
+ sll->sll_hatype = dev->type;
+ sll->sll_halen = dev->addr_len;
+@@ -4099,7 +4101,7 @@ static int packet_notifier(struct notifier_block *this,
+ }
+ if (msg == NETDEV_UNREGISTER) {
+ packet_cached_dev_reset(po);
+- po->ifindex = -1;
++ WRITE_ONCE(po->ifindex, -1);
+ if (po->prot_hook.dev)
+ dev_put(po->prot_hook.dev);
+ po->prot_hook.dev = NULL;
+@@ -4614,7 +4616,7 @@ static int packet_seq_show(struct seq_file *seq, void *v)
+ refcount_read(&s->sk_refcnt),
+ s->sk_type,
+ ntohs(READ_ONCE(po->num)),
+- po->ifindex,
++ READ_ONCE(po->ifindex),
+ po->running,
+ atomic_read(&s->sk_rmem_alloc),
+ from_kuid_munged(seq_user_ns(seq), sock_i_uid(s)),
+--
+2.30.2
+
--- /dev/null
+From eec5f47a56c9e870593fabcb3259f2fd7ec182f3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 9 Jun 2021 19:43:42 -0500
+Subject: net: phy: dp83867: perform soft reset and retain established link
+
+From: Praneeth Bajjuri <praneeth@ti.com>
+
+[ Upstream commit da9ef50f545f86ffe6ff786174d26500c4db737a ]
+
+Current logic is performing hard reset and causing the programmed
+registers to be wiped out.
+
+as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
+8.6.26 Control Register (CTRL)
+
+do SW_RESTART to perform a reset not including the registers,
+If performed when link is already present,
+it will drop the link and trigger re-auto negotiation.
+
+Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
+Signed-off-by: Geet Modi <geet.modi@ti.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/phy/dp83867.c | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
+index 31a559513362..87c0cdbf262a 100644
+--- a/drivers/net/phy/dp83867.c
++++ b/drivers/net/phy/dp83867.c
+@@ -468,16 +468,12 @@ static int dp83867_phy_reset(struct phy_device *phydev)
+ {
+ int err;
+
+- err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET);
++ err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESTART);
+ if (err < 0)
+ return err;
+
+ usleep_range(10, 20);
+
+- /* After reset FORCE_LINK_GOOD bit is set. Although the
+- * default value should be unset. Disable FORCE_LINK_GOOD
+- * for the phy to work properly.
+- */
+ return phy_modify(phydev, MII_DP83867_PHYCTRL,
+ DP83867_PHYCR_FORCE_LINK_GOOD, 0);
+ }
+--
+2.30.2
+
--- /dev/null
+From b41f88403fa6c49e5b89d6b078895e2a8bdea1fe Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 17 Jun 2021 10:09:53 -0700
+Subject: net: qed: Fix memcpy() overflow of qed_dcbx_params()
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit 1c200f832e14420fa770193f9871f4ce2df00d07 ]
+
+The source (&dcbx_info->operational.params) and dest
+(&p_hwfn->p_dcbx_info->set.config.params) are both struct qed_dcbx_params
+(560 bytes), not struct qed_dcbx_admin_params (564 bytes), which is used
+as the memcpy() size.
+
+However it seems that struct qed_dcbx_operational_params
+(dcbx_info->operational)'s layout matches struct qed_dcbx_admin_params
+(p_hwfn->p_dcbx_info->set.config)'s 4 byte difference (3 padding, 1 byte
+for "valid").
+
+On the assumption that the size is wrong (rather than the source structure
+type), adjust the memcpy() size argument to be 4 bytes smaller and add
+a BUILD_BUG_ON() to validate any changes to the structure sizes.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+index 5c6a276f69ac..426b8098c50e 100644
+--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
++++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+@@ -1293,9 +1293,11 @@ int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn,
+ p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_STATIC;
+
+ p_hwfn->p_dcbx_info->set.enabled = dcbx_info->operational.enabled;
++ BUILD_BUG_ON(sizeof(dcbx_info->operational.params) !=
++ sizeof(p_hwfn->p_dcbx_info->set.config.params));
+ memcpy(&p_hwfn->p_dcbx_info->set.config.params,
+ &dcbx_info->operational.params,
+- sizeof(struct qed_dcbx_admin_params));
++ sizeof(p_hwfn->p_dcbx_info->set.config.params));
+ p_hwfn->p_dcbx_info->set.config.valid = true;
+
+ memcpy(params, &p_hwfn->p_dcbx_info->set, sizeof(struct qed_dcbx_set));
+--
+2.30.2
+
--- /dev/null
+From 37568299aa30f9e60db4d948d529c8bfe043100c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 11 Jun 2021 17:48:23 -0400
+Subject: PCI: Add AMD RS690 quirk to enable 64-bit DMA
+
+From: Mikel Rychliski <mikel@mikelr.com>
+
+[ Upstream commit cacf994a91d3a55c0c2f853d6429cd7b86113915 ]
+
+Although the AMD RS690 chipset has 64-bit DMA support, BIOS implementations
+sometimes fail to configure the memory limit registers correctly.
+
+The Acer F690GVM mainboard uses this chipset and a Marvell 88E8056 NIC. The
+sky2 driver programs the NIC to use 64-bit DMA, which will not work:
+
+ sky2 0000:02:00.0: error interrupt status=0x8
+ sky2 0000:02:00.0 eth0: tx timeout
+ sky2 0000:02:00.0 eth0: transmit ring 0 .. 22 report=0 done=0
+
+Other drivers required by this mainboard either don't support 64-bit DMA,
+or have it disabled using driver specific quirks. For example, the ahci
+driver has quirks to enable or disable 64-bit DMA depending on the BIOS
+version (see ahci_sb600_enable_64bit() in ahci.c). This ahci quirk matches
+against the SB600 SATA controller, but the real issue is almost certainly
+with the RS690 PCI host that it was commonly attached to.
+
+To avoid this issue in all drivers with 64-bit DMA support, fix the
+configuration of the PCI host. If the kernel is aware of physical memory
+above 4GB, but the BIOS never configured the PCI host with this
+information, update the registers with our values.
+
+[bhelgaas: drop PCI_DEVICE_ID_ATI_RS690 definition]
+Link: https://lore.kernel.org/r/20210611214823.4898-1-mikel@mikelr.com
+Signed-off-by: Mikel Rychliski <mikel@mikelr.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/pci/fixup.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 44 insertions(+)
+
+diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
+index 0c67a5a94de3..76959a7d88c8 100644
+--- a/arch/x86/pci/fixup.c
++++ b/arch/x86/pci/fixup.c
+@@ -779,4 +779,48 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1571, pci_amd_enable_64bit_bar);
+ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x15b1, pci_amd_enable_64bit_bar);
+ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1601, pci_amd_enable_64bit_bar);
+
++#define RS690_LOWER_TOP_OF_DRAM2 0x30
++#define RS690_LOWER_TOP_OF_DRAM2_VALID 0x1
++#define RS690_UPPER_TOP_OF_DRAM2 0x31
++#define RS690_HTIU_NB_INDEX 0xA8
++#define RS690_HTIU_NB_INDEX_WR_ENABLE 0x100
++#define RS690_HTIU_NB_DATA 0xAC
++
++/*
++ * Some BIOS implementations support RAM above 4GB, but do not configure the
++ * PCI host to respond to bus master accesses for these addresses. These
++ * implementations set the TOP_OF_DRAM_SLOT1 register correctly, so PCI DMA
++ * works as expected for addresses below 4GB.
++ *
++ * Reference: "AMD RS690 ASIC Family Register Reference Guide" (pg. 2-57)
++ * https://www.amd.com/system/files/TechDocs/43372_rs690_rrg_3.00o.pdf
++ */
++static void rs690_fix_64bit_dma(struct pci_dev *pdev)
++{
++ u32 val = 0;
++ phys_addr_t top_of_dram = __pa(high_memory - 1) + 1;
++
++ if (top_of_dram <= (1ULL << 32))
++ return;
++
++ pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX,
++ RS690_LOWER_TOP_OF_DRAM2);
++ pci_read_config_dword(pdev, RS690_HTIU_NB_DATA, &val);
++
++ if (val)
++ return;
++
++ pci_info(pdev, "Adjusting top of DRAM to %pa for 64-bit DMA support\n", &top_of_dram);
++
++ pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX,
++ RS690_UPPER_TOP_OF_DRAM2 | RS690_HTIU_NB_INDEX_WR_ENABLE);
++ pci_write_config_dword(pdev, RS690_HTIU_NB_DATA, top_of_dram >> 32);
++
++ pci_write_config_dword(pdev, RS690_HTIU_NB_INDEX,
++ RS690_LOWER_TOP_OF_DRAM2 | RS690_HTIU_NB_INDEX_WR_ENABLE);
++ pci_write_config_dword(pdev, RS690_HTIU_NB_DATA,
++ top_of_dram | RS690_LOWER_TOP_OF_DRAM2_VALID);
++}
++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7910, rs690_fix_64bit_dma);
++
+ #endif
+--
+2.30.2
+
--- /dev/null
+From 98e948a97eeb72061654c47f71596e270e51208c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 10 Jun 2021 09:41:36 +0800
+Subject: ping: Check return value of function 'ping_queue_rcv_skb'
+
+From: Zheng Yongjun <zhengyongjun3@huawei.com>
+
+[ Upstream commit 9d44fa3e50cc91691896934d106c86e4027e61ca ]
+
+Function 'ping_queue_rcv_skb' not always return success, which will
+also return fail. If not check the wrong return value of it, lead to function
+`ping_rcv` return success.
+
+Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/ping.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
+index df6fbefe44d4..1c3d5d3702a1 100644
+--- a/net/ipv4/ping.c
++++ b/net/ipv4/ping.c
+@@ -963,6 +963,7 @@ bool ping_rcv(struct sk_buff *skb)
+ struct sock *sk;
+ struct net *net = dev_net(skb->dev);
+ struct icmphdr *icmph = icmp_hdr(skb);
++ bool rc = false;
+
+ /* We assume the packet has already been checked by icmp_rcv */
+
+@@ -977,14 +978,15 @@ bool ping_rcv(struct sk_buff *skb)
+ struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
+
+ pr_debug("rcv on socket %p\n", sk);
+- if (skb2)
+- ping_queue_rcv_skb(sk, skb2);
++ if (skb2 && !ping_queue_rcv_skb(sk, skb2))
++ rc = true;
+ sock_put(sk);
+- return true;
+ }
+- pr_debug("no socket, dropping\n");
+
+- return false;
++ if (!rc)
++ pr_debug("no socket, dropping\n");
++
++ return rc;
+ }
+ EXPORT_SYMBOL_GPL(ping_rcv);
+
+--
+2.30.2
+
--- /dev/null
+From af5cffabf88088602820d46774df5248d494ac36 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Jun 2021 12:53:03 -0700
+Subject: r8152: Avoid memcpy() over-reading of ETH_SS_STATS
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit 99718abdc00e86e4f286dd836408e2834886c16e ]
+
+In preparation for FORTIFY_SOURCE performing compile-time and run-time
+field bounds checking for memcpy(), memmove(), and memset(), avoid
+intentionally reading across neighboring array fields.
+
+The memcpy() is copying the entire structure, not just the first array.
+Adjust the source argument so the compiler can do appropriate bounds
+checking.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/usb/r8152.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
+index f6d643ecaf39..24d124633037 100644
+--- a/drivers/net/usb/r8152.c
++++ b/drivers/net/usb/r8152.c
+@@ -5065,7 +5065,7 @@ static void rtl8152_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+ {
+ switch (stringset) {
+ case ETH_SS_STATS:
+- memcpy(data, *rtl8152_gstrings, sizeof(rtl8152_gstrings));
++ memcpy(data, rtl8152_gstrings, sizeof(rtl8152_gstrings));
+ break;
+ }
+ }
+--
+2.30.2
+
--- /dev/null
+From 12dca532142b70b254a0a40a643d5d05de08e809 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Jun 2021 12:53:59 -0700
+Subject: r8169: Avoid memcpy() over-reading of ETH_SS_STATS
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit da5ac772cfe2a03058b0accfac03fad60c46c24d ]
+
+In preparation for FORTIFY_SOURCE performing compile-time and run-time
+field bounds checking for memcpy(), memmove(), and memset(), avoid
+intentionally reading across neighboring array fields.
+
+The memcpy() is copying the entire structure, not just the first array.
+Adjust the source argument so the compiler can do appropriate bounds
+checking.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/realtek/r8169_main.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
+index 8ff178fc2670..661202e85412 100644
+--- a/drivers/net/ethernet/realtek/r8169_main.c
++++ b/drivers/net/ethernet/realtek/r8169_main.c
+@@ -1801,7 +1801,7 @@ static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data)
+ {
+ switch(stringset) {
+ case ETH_SS_STATS:
+- memcpy(data, *rtl8169_gstrings, sizeof(rtl8169_gstrings));
++ memcpy(data, rtl8169_gstrings, sizeof(rtl8169_gstrings));
+ break;
+ }
+ }
+--
+2.30.2
+
--- /dev/null
+From f36155aa3ea77730c71edb8fc6bdf99a822be4ca Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Jun 2021 23:41:26 +0800
+Subject: recordmcount: Correct st_shndx handling
+
+From: Peter Zijlstra <peterz@infradead.org>
+
+[ Upstream commit fb780761e7bd9f2e94f5b9a296ead6b35b944206 ]
+
+One should only use st_shndx when >SHN_UNDEF and <SHN_LORESERVE. When
+SHN_XINDEX, then use .symtab_shndx. Otherwise use 0.
+
+This handles the case: st_shndx >= SHN_LORESERVE && st_shndx != SHN_XINDEX.
+
+Link: https://lore.kernel.org/lkml/20210607023839.26387-1-mark-pk.tsai@mediatek.com/
+Link: https://lkml.kernel.org/r/20210616154126.2794-1-mark-pk.tsai@mediatek.com
+
+Reported-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
+Tested-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+[handle endianness of sym->st_shndx]
+Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ scripts/recordmcount.h | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
+index f9b19524da11..1e9baa5c4fc6 100644
+--- a/scripts/recordmcount.h
++++ b/scripts/recordmcount.h
+@@ -192,15 +192,20 @@ static unsigned int get_symindex(Elf_Sym const *sym, Elf32_Word const *symtab,
+ Elf32_Word const *symtab_shndx)
+ {
+ unsigned long offset;
++ unsigned short shndx = w2(sym->st_shndx);
+ int index;
+
+- if (sym->st_shndx != SHN_XINDEX)
+- return w2(sym->st_shndx);
++ if (shndx > SHN_UNDEF && shndx < SHN_LORESERVE)
++ return shndx;
+
+- offset = (unsigned long)sym - (unsigned long)symtab;
+- index = offset / sizeof(*sym);
++ if (shndx == SHN_XINDEX) {
++ offset = (unsigned long)sym - (unsigned long)symtab;
++ index = offset / sizeof(*sym);
+
+- return w(symtab_shndx[index]);
++ return w(symtab_shndx[index]);
++ }
++
++ return 0;
+ }
+
+ static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0)
+--
+2.30.2
+
mips-generic-update-node-names-to-avoid-unit-addresses.patch
spi-spi-nxp-fspi-move-the-register-operation-after-t.patch
revert-pci-pm-do-not-read-power-state-in-pci_enable_.patch
+dmaengine-zynqmp_dma-fix-pm-reference-leak-in-zynqmp.patch
+mac80211-remove-warning-in-ieee80211_get_sband.patch
+mac80211_hwsim-drop-pending-frames-on-stop.patch
+cfg80211-call-cfg80211_leave_ocb-when-switching-away.patch
+dmaengine-rcar-dmac-fix-pm-reference-leak-in-rcar_dm.patch
+dmaengine-mediatek-free-the-proper-desc-in-desc_free.patch
+dmaengine-mediatek-do-not-issue-a-new-desc-if-one-is.patch
+dmaengine-mediatek-use-gfp_nowait-instead-of-gfp_ato.patch
+net-ipv4-remove-unneed-bug-function.patch
+mac80211-drop-multicast-fragments.patch
+net-ethtool-clear-heap-allocations-for-ethtool-funct.patch
+ping-check-return-value-of-function-ping_queue_rcv_s.patch
+inet-annotate-date-races-around-sk-sk_txhash.patch
+net-phy-dp83867-perform-soft-reset-and-retain-establ.patch
+net-caif-fix-memory-leak-in-ldisc_open.patch
+net-packet-annotate-accesses-to-po-bind.patch
+net-packet-annotate-accesses-to-po-ifindex.patch
+r8152-avoid-memcpy-over-reading-of-eth_ss_stats.patch
+sh_eth-avoid-memcpy-over-reading-of-eth_ss_stats.patch
+r8169-avoid-memcpy-over-reading-of-eth_ss_stats.patch
+kvm-selftests-fix-kvm_check_cap-assertion.patch
+net-qed-fix-memcpy-overflow-of-qed_dcbx_params.patch
+recordmcount-correct-st_shndx-handling.patch
+pci-add-amd-rs690-quirk-to-enable-64-bit-dma.patch
+net-ll_temac-add-memory-barriers-for-tx-bd-access.patch
+net-ll_temac-avoid-ndo_start_xmit-returning-netdev_t.patch
--- /dev/null
+From 19f83ba2e4282dc3dead56217ce48880ddd46f9d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Jun 2021 12:53:33 -0700
+Subject: sh_eth: Avoid memcpy() over-reading of ETH_SS_STATS
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit 224004fbb033600715dbd626bceec10bfd9c58bc ]
+
+In preparation for FORTIFY_SOURCE performing compile-time and run-time
+field bounds checking for memcpy(), memmove(), and memset(), avoid
+intentionally reading across neighboring array fields.
+
+The memcpy() is copying the entire structure, not just the first array.
+Adjust the source argument so the compiler can do appropriate bounds
+checking.
+
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/renesas/sh_eth.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
+index a042f4607b0d..931a44fe7afe 100644
+--- a/drivers/net/ethernet/renesas/sh_eth.c
++++ b/drivers/net/ethernet/renesas/sh_eth.c
+@@ -2322,7 +2322,7 @@ static void sh_eth_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
+ {
+ switch (stringset) {
+ case ETH_SS_STATS:
+- memcpy(data, *sh_eth_gstrings_stats,
++ memcpy(data, sh_eth_gstrings_stats,
+ sizeof(sh_eth_gstrings_stats));
+ break;
+ }
+--
+2.30.2
+