]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.10
authorSasha Levin <sashal@kernel.org>
Mon, 5 Jun 2023 11:26:31 +0000 (07:26 -0400)
committerSasha Levin <sashal@kernel.org>
Mon, 5 Jun 2023 11:26:31 +0000 (07:26 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
76 files changed:
queue-5.10/af_packet-do-not-use-read_once-in-packet_bind.patch [new file with mode: 0644]
queue-5.10/af_packet-fix-data-races-of-pkt_sk-sk-num.patch [new file with mode: 0644]
queue-5.10/alsa-hda-glenfly-add-hd-audio-pci-ids-and-hdmi-codec.patch [new file with mode: 0644]
queue-5.10/alsa-oss-avoid-missing-prototype-warnings.patch [new file with mode: 0644]
queue-5.10/amd-xgbe-fix-the-false-linkup-in-xgbe_phy_status.patch [new file with mode: 0644]
queue-5.10/arm-9295-1-unwind-fix-unwind-abort-for-uleb128-case.patch [new file with mode: 0644]
queue-5.10/arm-dts-stm32-add-pin-map-for-can-controller-on-stm3.patch [new file with mode: 0644]
queue-5.10/arm64-mm-mark-private-vm_fault_x-defines-as-vm_fault.patch [new file with mode: 0644]
queue-5.10/asoc-dt-bindings-adjust-sound-dai-cells-on-ti-s-sing.patch [new file with mode: 0644]
queue-5.10/asoc-dwc-limit-the-number-of-overrun-messages.patch [new file with mode: 0644]
queue-5.10/asoc-ssm2602-add-workaround-for-playback-distortions.patch [new file with mode: 0644]
queue-5.10/atm-hide-unused-procfs-functions.patch [new file with mode: 0644]
queue-5.10/block-rnbd-replace-req_op_flush-with-req_op_write.patch [new file with mode: 0644]
queue-5.10/btrfs-abort-transaction-when-sibling-keys-check-fail.patch [new file with mode: 0644]
queue-5.10/dmaengine-at_xdmac-fix-concurrency-over-chan-s-compl.patch [new file with mode: 0644]
queue-5.10/dmaengine-at_xdmac-fix-potential-oops-in-at_xdmac_pr.patch [new file with mode: 0644]
queue-5.10/dmaengine-at_xdmac-fix-race-for-the-tx-desc-callback.patch [new file with mode: 0644]
queue-5.10/dmaengine-at_xdmac-move-the-free-desc-to-the-tail-of.patch [new file with mode: 0644]
queue-5.10/dmaengine-pl330-rename-_start-to-prevent-build-error.patch [new file with mode: 0644]
queue-5.10/drm-msm-be-more-shouty-if-per-process-pgtables-aren-.patch [new file with mode: 0644]
queue-5.10/fbdev-modedb-add-1920x1080-at-60-hz-video-mode.patch [new file with mode: 0644]
queue-5.10/fbdev-stifb-fix-info-entry-in-sti_struct-on-error-pa.patch [new file with mode: 0644]
queue-5.10/gfs2-don-t-deref-jdesc-in-evict.patch [new file with mode: 0644]
queue-5.10/iommu-amd-don-t-block-updates-to-gatag-if-guest-mode.patch [new file with mode: 0644]
queue-5.10/iommu-rockchip-fix-unwind-goto-issue.patch [new file with mode: 0644]
queue-5.10/mailbox-mailbox-test-fix-a-locking-issue-in-mbox_tes.patch [new file with mode: 0644]
queue-5.10/mailbox-mailbox-test-fix-potential-double-free-in-mb.patch [new file with mode: 0644]
queue-5.10/media-dvb-core-fix-kernel-warning-for-blocking-opera.patch [new file with mode: 0644]
queue-5.10/media-dvb-core-fix-use-after-free-due-on-race-condit.patch [new file with mode: 0644]
queue-5.10/media-dvb-core-fix-use-after-free-due-to-race-condit.patch [new file with mode: 0644]
queue-5.10/media-dvb-usb-az6027-fix-three-null-ptr-deref-in-az6.patch [new file with mode: 0644]
queue-5.10/media-dvb-usb-digitv-fix-null-ptr-deref-in-digitv_i2.patch [new file with mode: 0644]
queue-5.10/media-dvb-usb-dw2102-fix-uninit-value-in-su3000_read.patch [new file with mode: 0644]
queue-5.10/media-dvb-usb-v2-ce6230-fix-null-ptr-deref-in-ce6230.patch [new file with mode: 0644]
queue-5.10/media-dvb-usb-v2-ec168-fix-null-ptr-deref-in-ec168_i.patch [new file with mode: 0644]
queue-5.10/media-dvb-usb-v2-rtl28xxu-fix-null-ptr-deref-in-rtl2.patch [new file with mode: 0644]
queue-5.10/media-dvb_ca_en50221-fix-a-size-write-bug.patch [new file with mode: 0644]
queue-5.10/media-dvb_demux-fix-a-bug-for-the-continuity-counter.patch [new file with mode: 0644]
queue-5.10/media-mn88443x-fix-config_of-error-by-drop-of_match_.patch [new file with mode: 0644]
queue-5.10/media-netup_unidvb-fix-irq-init-by-register-it-at-th.patch [new file with mode: 0644]
queue-5.10/media-rcar-vin-select-correct-interrupt-mode-for-v4l.patch [new file with mode: 0644]
queue-5.10/media-ttusb-dec-fix-memory-leak-in-ttusb_dec_exit_dv.patch [new file with mode: 0644]
queue-5.10/mtd-rawnand-ingenic-fix-empty-stub-helper-definition.patch [new file with mode: 0644]
queue-5.10/mtd-rawnand-marvell-don-t-set-the-nand-frequency-sel.patch [new file with mode: 0644]
queue-5.10/mtd-rawnand-marvell-ensure-timing-values-are-written.patch [new file with mode: 0644]
queue-5.10/nbd-fix-debugfs_create_dir-error-checking.patch [new file with mode: 0644]
queue-5.10/net-dsa-mv88e6xxx-increase-wait-after-reset-deactiva.patch [new file with mode: 0644]
queue-5.10/net-mlx5-fw_tracer-fix-event-handling.patch [new file with mode: 0644]
queue-5.10/net-mlx5-read-embedded-cpu-after-init-bit-cleared.patch [new file with mode: 0644]
queue-5.10/net-netlink-fix-netlink_list_memberships-length-repo.patch [new file with mode: 0644]
queue-5.10/net-sched-fix-null-pointer-dereference-in-mq_attach.patch [new file with mode: 0644]
queue-5.10/net-sched-flower-fix-possible-oob-write-in-fl_set_ge.patch [new file with mode: 0644]
queue-5.10/net-sched-prohibit-regrafting-ingress-or-clsact-qdis.patch [new file with mode: 0644]
queue-5.10/net-sched-reserve-tc_h_ingress-tc_h_clsact-for-ingre.patch [new file with mode: 0644]
queue-5.10/net-sched-sch_clsact-only-create-under-tc_h_clsact.patch [new file with mode: 0644]
queue-5.10/net-sched-sch_ingress-only-create-under-tc_h_ingress.patch [new file with mode: 0644]
queue-5.10/netfilter-conntrack-define-variables-exp_nat_nla_pol.patch [new file with mode: 0644]
queue-5.10/netrom-fix-info-leak-in-nr_write_internal.patch [new file with mode: 0644]
queue-5.10/rdma-bnxt_re-code-refactor-while-populating-user-mrs.patch [new file with mode: 0644]
queue-5.10/rdma-bnxt_re-fix-a-possible-memory-leak.patch [new file with mode: 0644]
queue-5.10/rdma-bnxt_re-fix-return-value-of-bnxt_re_process_raw.patch [new file with mode: 0644]
queue-5.10/rdma-bnxt_re-fix-the-page_size-used-during-the-mr-cr.patch [new file with mode: 0644]
queue-5.10/rdma-efa-fix-unsupported-page-sizes-in-device.patch [new file with mode: 0644]
queue-5.10/s390-pkey-zeroize-key-blobs.patch [new file with mode: 0644]
queue-5.10/scsi-core-decrease-scsi_device-s-iorequest_cnt-if-di.patch [new file with mode: 0644]
queue-5.10/series
queue-5.10/sock-expose-so_timestamp-options-for-mptcp.patch [new file with mode: 0644]
queue-5.10/sock-expose-so_timestamping-options-for-mptcp.patch [new file with mode: 0644]
queue-5.10/tcp-deny-tcp_disconnect-when-threads-are-waiting.patch [new file with mode: 0644]
queue-5.10/tcp-remove-sk_-tr-x_skb_cache.patch [new file with mode: 0644]
queue-5.10/tcp-return-user_mss-for-tcp_maxseg-in-close-listen-s.patch [new file with mode: 0644]
queue-5.10/udp6-fix-race-condition-in-udp6_sendmsg-connect.patch [new file with mode: 0644]
queue-5.10/watchdog-menz069_wdt-fix-watchdog-initialisation.patch [new file with mode: 0644]
queue-5.10/wifi-b43-fix-incorrect-__packed-annotation.patch [new file with mode: 0644]
queue-5.10/wifi-rtl8xxxu-fix-authentication-timeout-due-to-inco.patch [new file with mode: 0644]
queue-5.10/xfrm-check-if_id-in-inbound-policy-secpath-match.patch [new file with mode: 0644]

diff --git a/queue-5.10/af_packet-do-not-use-read_once-in-packet_bind.patch b/queue-5.10/af_packet-do-not-use-read_once-in-packet_bind.patch
new file mode 100644 (file)
index 0000000..fbbf836
--- /dev/null
@@ -0,0 +1,64 @@
+From 4b249e73d6a5942e03992d41c1fd8b553ac0d199 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 26 May 2023 15:43:42 +0000
+Subject: af_packet: do not use READ_ONCE() in packet_bind()
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 6ffc57ea004234d9373c57b204fd10370a69f392 ]
+
+A recent patch added READ_ONCE() in packet_bind() and packet_bind_spkt()
+
+This is better handled by reading pkt_sk(sk)->num later
+in packet_do_bind() while appropriate lock is held.
+
+READ_ONCE() in writers are often an evidence of something being wrong.
+
+Fixes: 822b5a1c17df ("af_packet: Fix data-races of pkt_sk(sk)->num.")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reviewed-by: Willem de Bruijn <willemb@google.com>
+Reviewed-by: Jiri Pirko <jiri@nvidia.com>
+Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Link: https://lore.kernel.org/r/20230526154342.2533026-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/packet/af_packet.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
+index 542d5285e99e9..c7129616dd530 100644
+--- a/net/packet/af_packet.c
++++ b/net/packet/af_packet.c
+@@ -3157,6 +3157,9 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,
+       lock_sock(sk);
+       spin_lock(&po->bind_lock);
++      if (!proto)
++              proto = po->num;
++
+       rcu_read_lock();
+       if (po->fanout) {
+@@ -3259,7 +3262,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,
+       memcpy(name, uaddr->sa_data, sizeof(uaddr->sa_data));
+       name[sizeof(uaddr->sa_data)] = 0;
+-      return packet_do_bind(sk, name, 0, READ_ONCE(pkt_sk(sk)->num));
++      return packet_do_bind(sk, name, 0, 0);
+ }
+ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
+@@ -3276,8 +3279,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
+       if (sll->sll_family != AF_PACKET)
+               return -EINVAL;
+-      return packet_do_bind(sk, NULL, sll->sll_ifindex,
+-                            sll->sll_protocol ? : READ_ONCE(pkt_sk(sk)->num));
++      return packet_do_bind(sk, NULL, sll->sll_ifindex, sll->sll_protocol);
+ }
+ static struct proto packet_proto = {
+-- 
+2.39.2
+
diff --git a/queue-5.10/af_packet-fix-data-races-of-pkt_sk-sk-num.patch b/queue-5.10/af_packet-fix-data-races-of-pkt_sk-sk-num.patch
new file mode 100644 (file)
index 0000000..eee71a7
--- /dev/null
@@ -0,0 +1,98 @@
+From afc28d4b0a39ee5e489d6eb2f8e109b81dd5cf9c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 24 May 2023 16:29:34 -0700
+Subject: af_packet: Fix data-races of pkt_sk(sk)->num.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 822b5a1c17df7e338b9f05d1cfe5764e37c7f74f ]
+
+syzkaller found a data race of pkt_sk(sk)->num.
+
+The value is changed under lock_sock() and po->bind_lock, so we
+need READ_ONCE() to access pkt_sk(sk)->num without these locks in
+packet_bind_spkt(), packet_bind(), and sk_diag_fill().
+
+Note that WRITE_ONCE() is already added by commit c7d2ef5dd4b0
+("net/packet: annotate accesses to po->bind").
+
+BUG: KCSAN: data-race in packet_bind / packet_do_bind
+
+write (marked) to 0xffff88802ffd1cee of 2 bytes by task 7322 on cpu 0:
+ packet_do_bind+0x446/0x640 net/packet/af_packet.c:3236
+ packet_bind+0x99/0xe0 net/packet/af_packet.c:3321
+ __sys_bind+0x19b/0x1e0 net/socket.c:1803
+ __do_sys_bind net/socket.c:1814 [inline]
+ __se_sys_bind net/socket.c:1812 [inline]
+ __x64_sys_bind+0x40/0x50 net/socket.c:1812
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x72/0xdc
+
+read to 0xffff88802ffd1cee of 2 bytes by task 7318 on cpu 1:
+ packet_bind+0xbf/0xe0 net/packet/af_packet.c:3322
+ __sys_bind+0x19b/0x1e0 net/socket.c:1803
+ __do_sys_bind net/socket.c:1814 [inline]
+ __se_sys_bind net/socket.c:1812 [inline]
+ __x64_sys_bind+0x40/0x50 net/socket.c:1812
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x72/0xdc
+
+value changed: 0x0300 -> 0x0000
+
+Reported by Kernel Concurrency Sanitizer on:
+CPU: 1 PID: 7318 Comm: syz-executor.4 Not tainted 6.3.0-13380-g7fddb5b5300c #4
+Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
+
+Fixes: 96ec6327144e ("packet: Diag core and basic socket info dumping")
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Reported-by: syzkaller <syzkaller@googlegroups.com>
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Reviewed-by: Willem de Bruijn <willemb@google.com>
+Link: https://lore.kernel.org/r/20230524232934.50950-1-kuniyu@amazon.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/packet/af_packet.c | 4 ++--
+ net/packet/diag.c      | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
+index 3c05414cd3f83..542d5285e99e9 100644
+--- a/net/packet/af_packet.c
++++ b/net/packet/af_packet.c
+@@ -3259,7 +3259,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,
+       memcpy(name, uaddr->sa_data, sizeof(uaddr->sa_data));
+       name[sizeof(uaddr->sa_data)] = 0;
+-      return packet_do_bind(sk, name, 0, pkt_sk(sk)->num);
++      return packet_do_bind(sk, name, 0, READ_ONCE(pkt_sk(sk)->num));
+ }
+ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
+@@ -3277,7 +3277,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
+               return -EINVAL;
+       return packet_do_bind(sk, NULL, sll->sll_ifindex,
+-                            sll->sll_protocol ? : pkt_sk(sk)->num);
++                            sll->sll_protocol ? : READ_ONCE(pkt_sk(sk)->num));
+ }
+ static struct proto packet_proto = {
+diff --git a/net/packet/diag.c b/net/packet/diag.c
+index d704c7bf51b20..a68a84574c739 100644
+--- a/net/packet/diag.c
++++ b/net/packet/diag.c
+@@ -143,7 +143,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
+       rp = nlmsg_data(nlh);
+       rp->pdiag_family = AF_PACKET;
+       rp->pdiag_type = sk->sk_type;
+-      rp->pdiag_num = ntohs(po->num);
++      rp->pdiag_num = ntohs(READ_ONCE(po->num));
+       rp->pdiag_ino = sk_ino;
+       sock_diag_save_cookie(sk, rp->pdiag_cookie);
+-- 
+2.39.2
+
diff --git a/queue-5.10/alsa-hda-glenfly-add-hd-audio-pci-ids-and-hdmi-codec.patch b/queue-5.10/alsa-hda-glenfly-add-hd-audio-pci-ids-and-hdmi-codec.patch
new file mode 100644 (file)
index 0000000..27fabe5
--- /dev/null
@@ -0,0 +1,145 @@
+From 316e8c757ec50e4e5450ebebd3b89d69d423d63d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 26 Apr 2023 09:30:59 +0800
+Subject: ALSA: hda: Glenfly: add HD Audio PCI IDs and HDMI Codec Vendor IDs.
+
+From: jasontao <jasontao@glenfly.com>
+
+[ Upstream commit c51e431052e2eacfb23fbf6b39bc6c8770d9827a ]
+
+Add a set of HD Audio PCI IDS, and the HDMI codec vendor IDs for
+Glenfly Gpus.
+
+- In default_bdl_pos_adj, set bdl to 128 as Glenfly Gpus have hardware
+limitation, need to increase hdac interrupt interval.
+- In azx_first_init, enable polling mode for Glenfly Gpu. When the codec
+complete the command, it sends interrupt and writes response entries to
+memory, howerver, the write requests sometimes are not actually
+synchronized to memory when driver handle hdac interrupt on Glenfly Gpus.
+If the RIRB status is not updated in the interrupt handler,
+azx_rirb_get_response keeps trying to recevie a response from rirb until
+1s timeout. Enabling polling mode for Glenfly Gpu can fix the issue.
+- In patch_gf_hdmi, set Glenlfy Gpu Codec's no_sticky_stream as it need
+driver to do actual clean-ups for the linked codec when switch from one
+codec to another.
+
+Signed-off-by: jasontao <jasontao@glenfly.com>
+Signed-off-by: Reaper Li <reaperlioc@glenfly.com>
+Link: https://lore.kernel.org/r/20230426013059.4329-1-reaperlioc@glenfly.com
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/pci/hda/hda_intel.c  | 21 +++++++++++++++++++++
+ sound/pci/hda/patch_hdmi.c | 22 ++++++++++++++++++++++
+ 2 files changed, 43 insertions(+)
+
+diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
+index de1fe604905f3..1f641712233ef 100644
+--- a/sound/pci/hda/hda_intel.c
++++ b/sound/pci/hda/hda_intel.c
+@@ -264,6 +264,7 @@ enum {
+       AZX_DRIVER_ATI,
+       AZX_DRIVER_ATIHDMI,
+       AZX_DRIVER_ATIHDMI_NS,
++      AZX_DRIVER_GFHDMI,
+       AZX_DRIVER_VIA,
+       AZX_DRIVER_SIS,
+       AZX_DRIVER_ULI,
+@@ -386,6 +387,7 @@ static const char * const driver_short_names[] = {
+       [AZX_DRIVER_ATI] = "HDA ATI SB",
+       [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
+       [AZX_DRIVER_ATIHDMI_NS] = "HDA ATI HDMI",
++      [AZX_DRIVER_GFHDMI] = "HDA GF HDMI",
+       [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
+       [AZX_DRIVER_SIS] = "HDA SIS966",
+       [AZX_DRIVER_ULI] = "HDA ULI M5461",
+@@ -1783,6 +1785,12 @@ static int default_bdl_pos_adj(struct azx *chip)
+       }
+       switch (chip->driver_type) {
++      /*
++       * increase the bdl size for Glenfly Gpus for hardware
++       * limitation on hdac interrupt interval
++       */
++      case AZX_DRIVER_GFHDMI:
++              return 128;
+       case AZX_DRIVER_ICH:
+       case AZX_DRIVER_PCH:
+               return 1;
+@@ -1902,6 +1910,12 @@ static int azx_first_init(struct azx *chip)
+               pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);
+       }
+ #endif
++      /*
++       * Fix response write request not synced to memory when handle
++       * hdac interrupt on Glenfly Gpus
++       */
++      if (chip->driver_type == AZX_DRIVER_GFHDMI)
++              bus->polling_mode = 1;
+       err = pci_request_regions(pci, "ICH HD audio");
+       if (err < 0)
+@@ -2011,6 +2025,7 @@ static int azx_first_init(struct azx *chip)
+                       chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
+                       chip->capture_streams = ATIHDMI_NUM_CAPTURE;
+                       break;
++              case AZX_DRIVER_GFHDMI:
+               case AZX_DRIVER_GENERIC:
+               default:
+                       chip->playback_streams = ICH6_NUM_PLAYBACK;
+@@ -2756,6 +2771,12 @@ static const struct pci_device_id azx_ids[] = {
+       { PCI_DEVICE(0x1002, 0xab38),
+         .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS |
+         AZX_DCAPS_PM_RUNTIME },
++      /* GLENFLY */
++      { PCI_DEVICE(0x6766, PCI_ANY_ID),
++        .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
++        .class_mask = 0xffffff,
++        .driver_data = AZX_DRIVER_GFHDMI | AZX_DCAPS_POSFIX_LPIB |
++        AZX_DCAPS_NO_MSI | AZX_DCAPS_NO_64BIT },
+       /* VIA VT8251/VT8237A */
+       { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
+       /* VIA GFX VT7122/VX900 */
+diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
+index e4366fea9e274..c19afe4861949 100644
+--- a/sound/pci/hda/patch_hdmi.c
++++ b/sound/pci/hda/patch_hdmi.c
+@@ -4287,6 +4287,22 @@ static int patch_via_hdmi(struct hda_codec *codec)
+       return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID);
+ }
++static int patch_gf_hdmi(struct hda_codec *codec)
++{
++      int err;
++
++      err = patch_generic_hdmi(codec);
++      if (err)
++              return err;
++
++      /*
++       * Glenfly GPUs have two codecs, stream switches from one codec to
++       * another, need to do actual clean-ups in codec_cleanup_stream
++       */
++      codec->no_sticky_stream = 1;
++      return 0;
++}
++
+ /*
+  * patch entries
+  */
+@@ -4381,6 +4397,12 @@ HDA_CODEC_ENTRY(0x10de00a6, "GPU a6 HDMI/DP",   patch_nvhdmi),
+ HDA_CODEC_ENTRY(0x10de00a7, "GPU a7 HDMI/DP", patch_nvhdmi),
+ HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI",     patch_nvhdmi_2ch),
+ HDA_CODEC_ENTRY(0x10de8067, "MCP67/68 HDMI",  patch_nvhdmi_2ch),
++HDA_CODEC_ENTRY(0x67663d82, "Arise 82 HDMI/DP",       patch_gf_hdmi),
++HDA_CODEC_ENTRY(0x67663d83, "Arise 83 HDMI/DP",       patch_gf_hdmi),
++HDA_CODEC_ENTRY(0x67663d84, "Arise 84 HDMI/DP",       patch_gf_hdmi),
++HDA_CODEC_ENTRY(0x67663d85, "Arise 85 HDMI/DP",       patch_gf_hdmi),
++HDA_CODEC_ENTRY(0x67663d86, "Arise 86 HDMI/DP",       patch_gf_hdmi),
++HDA_CODEC_ENTRY(0x67663d87, "Arise 87 HDMI/DP",       patch_gf_hdmi),
+ HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP",  patch_via_hdmi),
+ HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP",  patch_via_hdmi),
+ HDA_CODEC_ENTRY(0x11069f84, "VX11 HDMI/DP",   patch_generic_hdmi),
+-- 
+2.39.2
+
diff --git a/queue-5.10/alsa-oss-avoid-missing-prototype-warnings.patch b/queue-5.10/alsa-oss-avoid-missing-prototype-warnings.patch
new file mode 100644 (file)
index 0000000..487d610
--- /dev/null
@@ -0,0 +1,64 @@
+From 6c767eeed2aa8b6ead1709c9c033d41d7f1b6ed0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 May 2023 21:50:42 +0200
+Subject: ALSA: oss: avoid missing-prototype warnings
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit 040b5a046a9e18098580d3ccd029e2318fca7859 ]
+
+Two functions are defined and used in pcm_oss.c but also optionally
+used from io.c, with an optional prototype. If CONFIG_SND_PCM_OSS_PLUGINS
+is disabled, this causes a warning as the functions are not static
+and have no prototype:
+
+sound/core/oss/pcm_oss.c:1235:19: error: no previous prototype for 'snd_pcm_oss_write3' [-Werror=missing-prototypes]
+sound/core/oss/pcm_oss.c:1266:19: error: no previous prototype for 'snd_pcm_oss_read3' [-Werror=missing-prototypes]
+
+Avoid this by making the prototypes unconditional.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Link: https://lore.kernel.org/r/20230516195046.550584-2-arnd@kernel.org
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/core/oss/pcm_plugin.h | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
+index 46e273bd4a786..50a6b50f5db4c 100644
+--- a/sound/core/oss/pcm_plugin.h
++++ b/sound/core/oss/pcm_plugin.h
+@@ -141,6 +141,14 @@ int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
+ void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size);
+ void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr);
++#else
++
++static inline snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size) { return drv_size; }
++static inline snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size) { return clt_size; }
++static inline int snd_pcm_plug_slave_format(int format, const struct snd_mask *format_mask) { return format; }
++
++#endif
++
+ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream,
+                                    const char *ptr, snd_pcm_uframes_t size,
+                                    int in_kernel);
+@@ -151,14 +159,6 @@ snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream,
+ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,
+                                    void **bufs, snd_pcm_uframes_t frames);
+-#else
+-
+-static inline snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size) { return drv_size; }
+-static inline snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size) { return clt_size; }
+-static inline int snd_pcm_plug_slave_format(int format, const struct snd_mask *format_mask) { return format; }
+-
+-#endif
+-
+ #ifdef PLUGIN_DEBUG
+ #define pdprintf(fmt, args...) printk(KERN_DEBUG "plugin: " fmt, ##args)
+ #else
+-- 
+2.39.2
+
diff --git a/queue-5.10/amd-xgbe-fix-the-false-linkup-in-xgbe_phy_status.patch b/queue-5.10/amd-xgbe-fix-the-false-linkup-in-xgbe_phy_status.patch
new file mode 100644 (file)
index 0000000..276d816
--- /dev/null
@@ -0,0 +1,71 @@
+From ccba6d0e6853f95d126956e3fd7cb1496c583ac6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 May 2023 23:56:12 +0530
+Subject: amd-xgbe: fix the false linkup in xgbe_phy_status
+
+From: Raju Rangoju <Raju.Rangoju@amd.com>
+
+[ Upstream commit dc362e20cd6ab7a93d1b09669730c406f0910c35 ]
+
+In the event of a change in XGBE mode, the current auto-negotiation
+needs to be reset and the AN cycle needs to be re-triggerred. However,
+the current code ignores the return value of xgbe_set_mode(), leading to
+false information as the link is declared without checking the status
+register.
+
+Fix this by propagating the mode switch status information to
+xgbe_phy_status().
+
+Fixes: e57f7a3feaef ("amd-xgbe: Prepare for working with more than one type of phy")
+Co-developed-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
+Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
+Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
+index 43fdd111235a6..ca7372369b3e6 100644
+--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
++++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
+@@ -1312,7 +1312,7 @@ static enum xgbe_mode xgbe_phy_status_aneg(struct xgbe_prv_data *pdata)
+       return pdata->phy_if.phy_impl.an_outcome(pdata);
+ }
+-static void xgbe_phy_status_result(struct xgbe_prv_data *pdata)
++static bool xgbe_phy_status_result(struct xgbe_prv_data *pdata)
+ {
+       struct ethtool_link_ksettings *lks = &pdata->phy.lks;
+       enum xgbe_mode mode;
+@@ -1347,8 +1347,13 @@ static void xgbe_phy_status_result(struct xgbe_prv_data *pdata)
+       pdata->phy.duplex = DUPLEX_FULL;
+-      if (xgbe_set_mode(pdata, mode) && pdata->an_again)
++      if (!xgbe_set_mode(pdata, mode))
++              return false;
++
++      if (pdata->an_again)
+               xgbe_phy_reconfig_aneg(pdata);
++
++      return true;
+ }
+ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
+@@ -1378,7 +1383,8 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata)
+                       return;
+               }
+-              xgbe_phy_status_result(pdata);
++              if (xgbe_phy_status_result(pdata))
++                      return;
+               if (test_bit(XGBE_LINK_INIT, &pdata->dev_state))
+                       clear_bit(XGBE_LINK_INIT, &pdata->dev_state);
+-- 
+2.39.2
+
diff --git a/queue-5.10/arm-9295-1-unwind-fix-unwind-abort-for-uleb128-case.patch b/queue-5.10/arm-9295-1-unwind-fix-unwind-abort-for-uleb128-case.patch
new file mode 100644 (file)
index 0000000..998542d
--- /dev/null
@@ -0,0 +1,93 @@
+From d6627b3edaeb88ebdc3c0311acf6e3f12af7a390 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 Apr 2023 10:17:07 +0100
+Subject: ARM: 9295/1: unwind:fix unwind abort for uleb128 case
+
+From: Haibo Li <haibo.li@mediatek.com>
+
+[ Upstream commit fa3eeb638de0c1a9d2d860e5b48259facdd65176 ]
+
+When unwind instruction is 0xb2,the subsequent instructions
+are uleb128 bytes.
+For now,it uses only the first uleb128 byte in code.
+
+For vsp increments of 0x204~0x400,use one uleb128 byte like below:
+0xc06a00e4 <unwind_test_work>: 0x80b27fac
+  Compact model index: 0
+  0xb2 0x7f vsp = vsp + 1024
+  0xac      pop {r4, r5, r6, r7, r8, r14}
+
+For vsp increments larger than 0x400,use two uleb128 bytes like below:
+0xc06a00e4 <unwind_test_work>: @0xc0cc9e0c
+  Compact model index: 1
+  0xb2 0x81 0x01 vsp = vsp + 1032
+  0xac      pop {r4, r5, r6, r7, r8, r14}
+The unwind works well since the decoded uleb128 byte is also 0x81.
+
+For vsp increments larger than 0x600,use two uleb128 bytes like below:
+0xc06a00e4 <unwind_test_work>: @0xc0cc9e0c
+  Compact model index: 1
+  0xb2 0x81 0x02 vsp = vsp + 1544
+  0xac      pop {r4, r5, r6, r7, r8, r14}
+In this case,the decoded uleb128 result is 0x101(vsp=0x204+(0x101<<2)).
+While the uleb128 used in code is 0x81(vsp=0x204+(0x81<<2)).
+The unwind aborts at this frame since it gets incorrect vsp.
+
+To fix this,add uleb128 decode to cover all the above case.
+
+Signed-off-by: Haibo Li <haibo.li@mediatek.com>
+Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
+Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
+Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/kernel/unwind.c | 25 ++++++++++++++++++++++++-
+ 1 file changed, 24 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c
+index d2bd0df2318d6..7e90f17a0676c 100644
+--- a/arch/arm/kernel/unwind.c
++++ b/arch/arm/kernel/unwind.c
+@@ -300,6 +300,29 @@ static int unwind_exec_pop_subset_r0_to_r3(struct unwind_ctrl_block *ctrl,
+       return URC_OK;
+ }
++static unsigned long unwind_decode_uleb128(struct unwind_ctrl_block *ctrl)
++{
++      unsigned long bytes = 0;
++      unsigned long insn;
++      unsigned long result = 0;
++
++      /*
++       * unwind_get_byte() will advance `ctrl` one instruction at a time, so
++       * loop until we get an instruction byte where bit 7 is not set.
++       *
++       * Note: This decodes a maximum of 4 bytes to output 28 bits data where
++       * max is 0xfffffff: that will cover a vsp increment of 1073742336, hence
++       * it is sufficient for unwinding the stack.
++       */
++      do {
++              insn = unwind_get_byte(ctrl);
++              result |= (insn & 0x7f) << (bytes * 7);
++              bytes++;
++      } while (!!(insn & 0x80) && (bytes != sizeof(result)));
++
++      return result;
++}
++
+ /*
+  * Execute the current unwind instruction.
+  */
+@@ -353,7 +376,7 @@ static int unwind_exec_insn(struct unwind_ctrl_block *ctrl)
+               if (ret)
+                       goto error;
+       } else if (insn == 0xb2) {
+-              unsigned long uleb128 = unwind_get_byte(ctrl);
++              unsigned long uleb128 = unwind_decode_uleb128(ctrl);
+               ctrl->vrs[SP] += 0x204 + (uleb128 << 2);
+       } else {
+-- 
+2.39.2
+
diff --git a/queue-5.10/arm-dts-stm32-add-pin-map-for-can-controller-on-stm3.patch b/queue-5.10/arm-dts-stm32-add-pin-map-for-can-controller-on-stm3.patch
new file mode 100644 (file)
index 0000000..50c7936
--- /dev/null
@@ -0,0 +1,115 @@
+From e1c93e92c8fe556a98d31298c2b748c1dea91b77 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 27 Apr 2023 22:45:38 +0200
+Subject: ARM: dts: stm32: add pin map for CAN controller on stm32f7
+
+From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
+
+[ Upstream commit 011644249686f2675e142519cd59e81e04cfc231 ]
+
+Add pin configurations for using CAN controller on stm32f7.
+
+Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
+Link: https://lore.kernel.org/all/20230427204540.3126234-4-dario.binacchi@amarulasolutions.com
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/stm32f7-pinctrl.dtsi | 82 ++++++++++++++++++++++++++
+ 1 file changed, 82 insertions(+)
+
+diff --git a/arch/arm/boot/dts/stm32f7-pinctrl.dtsi b/arch/arm/boot/dts/stm32f7-pinctrl.dtsi
+index fe4cfda72a476..4e1b8b3359e21 100644
+--- a/arch/arm/boot/dts/stm32f7-pinctrl.dtsi
++++ b/arch/arm/boot/dts/stm32f7-pinctrl.dtsi
+@@ -284,6 +284,88 @@
+                                       slew-rate = <2>;
+                               };
+                       };
++
++                      can1_pins_a: can1-0 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('A', 12, AF9)>; /* CAN1_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('A', 11, AF9)>; /* CAN1_RX */
++                                      bias-pull-up;
++                              };
++                      };
++
++                      can1_pins_b: can1-1 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('B', 9, AF9)>; /* CAN1_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('B', 8, AF9)>; /* CAN1_RX */
++                                      bias-pull-up;
++                              };
++                      };
++
++                      can1_pins_c: can1-2 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('D', 1, AF9)>; /* CAN1_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('D', 0, AF9)>; /* CAN1_RX */
++                                      bias-pull-up;
++
++                              };
++                      };
++
++                      can1_pins_d: can1-3 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('H', 13, AF9)>; /* CAN1_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('H', 14, AF9)>; /* CAN1_RX */
++                                      bias-pull-up;
++
++                              };
++                      };
++
++                      can2_pins_a: can2-0 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('B', 6, AF9)>; /* CAN2_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('B', 5, AF9)>; /* CAN2_RX */
++                                      bias-pull-up;
++                              };
++                      };
++
++                      can2_pins_b: can2-1 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('B', 13, AF9)>; /* CAN2_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('B', 12, AF9)>; /* CAN2_RX */
++                                      bias-pull-up;
++                              };
++                      };
++
++                      can3_pins_a: can3-0 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('A', 15, AF11)>; /* CAN3_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('A', 8, AF11)>; /* CAN3_RX */
++                                      bias-pull-up;
++                              };
++                      };
++
++                      can3_pins_b: can3-1 {
++                              pins1 {
++                                      pinmux = <STM32_PINMUX('B', 4, AF11)>;  /* CAN3_TX */
++                              };
++                              pins2 {
++                                      pinmux = <STM32_PINMUX('B', 3, AF11)>; /* CAN3_RX */
++                                      bias-pull-up;
++                              };
++                      };
+               };
+       };
+ };
+-- 
+2.39.2
+
diff --git a/queue-5.10/arm64-mm-mark-private-vm_fault_x-defines-as-vm_fault.patch b/queue-5.10/arm64-mm-mark-private-vm_fault_x-defines-as-vm_fault.patch
new file mode 100644 (file)
index 0000000..761c8d8
--- /dev/null
@@ -0,0 +1,54 @@
+From cd8b43c279ad5b4054dede50f58eac0b4329ad0a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 2 May 2023 23:19:06 +0800
+Subject: arm64/mm: mark private VM_FAULT_X defines as vm_fault_t
+
+From: Min-Hua Chen <minhuadotchen@gmail.com>
+
+[ Upstream commit d91d580878064b880f3574ac35b98d8b70ee8620 ]
+
+This patch fixes several sparse warnings for fault.c:
+
+arch/arm64/mm/fault.c:493:24: sparse: warning: incorrect type in return expression (different base types)
+arch/arm64/mm/fault.c:493:24: sparse:    expected restricted vm_fault_t
+arch/arm64/mm/fault.c:493:24: sparse:    got int
+arch/arm64/mm/fault.c:501:32: sparse: warning: incorrect type in return expression (different base types)
+arch/arm64/mm/fault.c:501:32: sparse:    expected restricted vm_fault_t
+arch/arm64/mm/fault.c:501:32: sparse:    got int
+arch/arm64/mm/fault.c:503:32: sparse: warning: incorrect type in return expression (different base types)
+arch/arm64/mm/fault.c:503:32: sparse:    expected restricted vm_fault_t
+arch/arm64/mm/fault.c:503:32: sparse:    got int
+arch/arm64/mm/fault.c:511:24: sparse: warning: incorrect type in return expression (different base types)
+arch/arm64/mm/fault.c:511:24: sparse:    expected restricted vm_fault_t
+arch/arm64/mm/fault.c:511:24: sparse:    got int
+arch/arm64/mm/fault.c:670:13: sparse: warning: restricted vm_fault_t degrades to integer
+arch/arm64/mm/fault.c:670:13: sparse: warning: restricted vm_fault_t degrades to integer
+arch/arm64/mm/fault.c:713:39: sparse: warning: restricted vm_fault_t degrades to integer
+
+Reported-by: kernel test robot <lkp@intel.com>
+Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
+Link: https://lore.kernel.org/r/20230502151909.128810-1-minhuadotchen@gmail.com
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm64/mm/fault.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
+index 2be856731e817..d8baedd160de0 100644
+--- a/arch/arm64/mm/fault.c
++++ b/arch/arm64/mm/fault.c
+@@ -402,8 +402,8 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
+       }
+ }
+-#define VM_FAULT_BADMAP               0x010000
+-#define VM_FAULT_BADACCESS    0x020000
++#define VM_FAULT_BADMAP               ((__force vm_fault_t)0x010000)
++#define VM_FAULT_BADACCESS    ((__force vm_fault_t)0x020000)
+ static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
+                                 unsigned int mm_flags, unsigned long vm_flags,
+-- 
+2.39.2
+
diff --git a/queue-5.10/asoc-dt-bindings-adjust-sound-dai-cells-on-ti-s-sing.patch b/queue-5.10/asoc-dt-bindings-adjust-sound-dai-cells-on-ti-s-sing.patch
new file mode 100644 (file)
index 0000000..a6bc6b8
--- /dev/null
@@ -0,0 +1,101 @@
+From 0d89f4f7d60c6cdbaff2e4ed121cb043f0024c64 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 9 May 2023 17:34:12 +0200
+Subject: ASoC: dt-bindings: Adjust #sound-dai-cells on TI's single-DAI codecs
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Martin Povišer <povik+lin@cutebit.org>
+
+[ Upstream commit efb2bfd7b3d210c479b9361c176d7426e5eb8663 ]
+
+A bunch of TI's codecs have binding schemas which force #sound-dai-cells
+to one despite those codecs only having a single DAI. Allow for bindings
+with zero DAI cells and deprecate the former non-zero value.
+
+Signed-off-by: Martin Povišer <povik+lin@cutebit.org
+Link: https://lore.kernel.org/r/20230509153412.62847-1-povik+lin@cutebit.org
+Signed-off-by: Mark Brown <broonie@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/devicetree/bindings/sound/tas2562.yaml | 6 ++++--
+ Documentation/devicetree/bindings/sound/tas2764.yaml | 6 ++++--
+ Documentation/devicetree/bindings/sound/tas2770.yaml | 6 ++++--
+ 3 files changed, 12 insertions(+), 6 deletions(-)
+
+diff --git a/Documentation/devicetree/bindings/sound/tas2562.yaml b/Documentation/devicetree/bindings/sound/tas2562.yaml
+index 27f7132ba2ef0..6ccb346d4a4d5 100644
+--- a/Documentation/devicetree/bindings/sound/tas2562.yaml
++++ b/Documentation/devicetree/bindings/sound/tas2562.yaml
+@@ -50,7 +50,9 @@ properties:
+     description: TDM TX current sense time slot.
+   '#sound-dai-cells':
+-    const: 1
++    # The codec has a single DAI, the #sound-dai-cells=<1>; case is left in for backward
++    # compatibility but is deprecated.
++    enum: [0, 1]
+ required:
+   - compatible
+@@ -67,7 +69,7 @@ examples:
+      codec: codec@4c {
+        compatible = "ti,tas2562";
+        reg = <0x4c>;
+-       #sound-dai-cells = <1>;
++       #sound-dai-cells = <0>;
+        interrupt-parent = <&gpio1>;
+        interrupts = <14>;
+        shutdown-gpios = <&gpio1 15 0>;
+diff --git a/Documentation/devicetree/bindings/sound/tas2764.yaml b/Documentation/devicetree/bindings/sound/tas2764.yaml
+index 5bf8c76ecda11..1ffe1a01668fe 100644
+--- a/Documentation/devicetree/bindings/sound/tas2764.yaml
++++ b/Documentation/devicetree/bindings/sound/tas2764.yaml
+@@ -46,7 +46,9 @@ properties:
+     description: TDM TX voltage sense time slot.
+   '#sound-dai-cells':
+-    const: 1
++    # The codec has a single DAI, the #sound-dai-cells=<1>; case is left in for backward
++    # compatibility but is deprecated.
++    enum: [0, 1]
+ required:
+   - compatible
+@@ -63,7 +65,7 @@ examples:
+      codec: codec@38 {
+        compatible = "ti,tas2764";
+        reg = <0x38>;
+-       #sound-dai-cells = <1>;
++       #sound-dai-cells = <0>;
+        interrupt-parent = <&gpio1>;
+        interrupts = <14>;
+        reset-gpios = <&gpio1 15 0>;
+diff --git a/Documentation/devicetree/bindings/sound/tas2770.yaml b/Documentation/devicetree/bindings/sound/tas2770.yaml
+index 07e7f9951d2ed..f3d0ca067bea4 100644
+--- a/Documentation/devicetree/bindings/sound/tas2770.yaml
++++ b/Documentation/devicetree/bindings/sound/tas2770.yaml
+@@ -52,7 +52,9 @@ properties:
+       - 1 # Falling edge
+   '#sound-dai-cells':
+-    const: 1
++    # The codec has a single DAI, the #sound-dai-cells=<1>; case is left in for backward
++    # compatibility but is deprecated.
++    enum: [0, 1]
+ required:
+   - compatible
+@@ -69,7 +71,7 @@ examples:
+      codec: codec@41 {
+        compatible = "ti,tas2770";
+        reg = <0x41>;
+-       #sound-dai-cells = <1>;
++       #sound-dai-cells = <0>;
+        interrupt-parent = <&gpio1>;
+        interrupts = <14>;
+        reset-gpio = <&gpio1 15 0>;
+-- 
+2.39.2
+
diff --git a/queue-5.10/asoc-dwc-limit-the-number-of-overrun-messages.patch b/queue-5.10/asoc-dwc-limit-the-number-of-overrun-messages.patch
new file mode 100644 (file)
index 0000000..a88b8aa
--- /dev/null
@@ -0,0 +1,44 @@
+From 3f9143c5a2bb06e40f0f5f31eef3b0ab26d1763a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 5 May 2023 09:28:20 +0300
+Subject: ASoC: dwc: limit the number of overrun messages
+
+From: Maxim Kochetkov <fido_max@inbox.ru>
+
+[ Upstream commit ab6ecfbf40fccf74b6ec2ba7ed6dd2fc024c3af2 ]
+
+On slow CPU (FPGA/QEMU emulated) printing overrun messages from
+interrupt handler to uart console may leads to more overrun errors.
+So use dev_err_ratelimited to limit the number of error messages.
+
+Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru
+Link: https://lore.kernel.org/r/20230505062820.21840-1-fido_max@inbox.ru
+Signed-off-by: Mark Brown <broonie@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/dwc/dwc-i2s.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c
+index 36da0f01571a1..5469399abcb44 100644
+--- a/sound/soc/dwc/dwc-i2s.c
++++ b/sound/soc/dwc/dwc-i2s.c
+@@ -132,13 +132,13 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id)
+               /* Error Handling: TX */
+               if (isr[i] & ISR_TXFO) {
+-                      dev_err(dev->dev, "TX overrun (ch_id=%d)\n", i);
++                      dev_err_ratelimited(dev->dev, "TX overrun (ch_id=%d)\n", i);
+                       irq_valid = true;
+               }
+               /* Error Handling: TX */
+               if (isr[i] & ISR_RXFO) {
+-                      dev_err(dev->dev, "RX overrun (ch_id=%d)\n", i);
++                      dev_err_ratelimited(dev->dev, "RX overrun (ch_id=%d)\n", i);
+                       irq_valid = true;
+               }
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.10/asoc-ssm2602-add-workaround-for-playback-distortions.patch b/queue-5.10/asoc-ssm2602-add-workaround-for-playback-distortions.patch
new file mode 100644 (file)
index 0000000..5ec6a9f
--- /dev/null
@@ -0,0 +1,140 @@
+From 7629744d5e01de70883be7baa3ba16d51ca324fd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 8 May 2023 13:30:37 +0200
+Subject: ASoC: ssm2602: Add workaround for playback distortions
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Paweł Anikiel <pan@semihalf.com>
+
+[ Upstream commit f63550e2b165208a2f382afcaf5551df9569e1d4 ]
+
+Apply a workaround for what appears to be a hardware quirk.
+
+The problem seems to happen when enabling "whole chip power" (bit D7
+register R6) for the very first time after the chip receives power. If
+either "output" (D4) or "DAC" (D3) aren't powered on at that time,
+playback becomes very distorted later on.
+
+This happens on the Google Chameleon v3, as well as on a ZYBO Z7-10:
+https://ez.analog.com/audio/f/q-a/543726/solved-ssm2603-right-output-offset-issue/480229
+I suspect this happens only when using an external MCLK signal (which
+is the case for both of these boards).
+
+Here are some experiments run on a Google Chameleon v3. These were run
+in userspace using a wrapper around the i2cset utility:
+ssmset() {
+        i2cset -y 0 0x1a $(($1*2)) $2
+}
+
+For each of the following sequences, we apply power to the ssm2603
+chip, set the configuration registers R0-R5 and R7-R8, run the selected
+sequence, and check for distortions on playback.
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x07 # chip, out, dac
+  OK
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x87 # out, dac
+  ssmset 0x06 0x07 # chip
+  OK
+
+  (disable MCLK)
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x1f # chip
+  ssmset 0x06 0x07 # out, dac
+  (enable MCLK)
+  OK
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x1f # chip
+  ssmset 0x06 0x07 # out, dac
+  NOT OK
+
+  ssmset 0x06 0x1f # chip
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x07 # out, dac
+  NOT OK
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x0f # chip, out
+  ssmset 0x06 0x07 # dac
+  NOT OK
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x17 # chip, dac
+  ssmset 0x06 0x07 # out
+  NOT OK
+
+For each of the following sequences, we apply power to the ssm2603
+chip, run the selected sequence, issue a reset with R15, configure
+R0-R5 and R7-R8, run one of the NOT OK sequences from above, and check
+for distortions.
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x07 # chip, out, dac
+  OK
+
+  (disable MCLK)
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x07 # chip, out, dac
+  (enable MCLK after reset)
+  NOT OK
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x17 # chip, dac
+  NOT OK
+
+  ssmset 0x09 0x01 # core
+  ssmset 0x06 0x0f # chip, out
+  NOT OK
+
+  ssmset 0x06 0x07 # chip, out, dac
+  NOT OK
+
+Signed-off-by: Paweł Anikiel <pan@semihalf.com
+Link: https://lore.kernel.org/r/20230508113037.137627-8-pan@semihalf.com
+Signed-off-by: Mark Brown <broonie@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/codecs/ssm2602.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
+index 9051602466146..c7a90c34d8f08 100644
+--- a/sound/soc/codecs/ssm2602.c
++++ b/sound/soc/codecs/ssm2602.c
+@@ -53,6 +53,18 @@ static const struct reg_default ssm2602_reg[SSM2602_CACHEREGNUM] = {
+       { .reg = 0x09, .def = 0x0000 }
+ };
++/*
++ * ssm2602 register patch
++ * Workaround for playback distortions after power up: activates digital
++ * core, and then powers on output, DAC, and whole chip at the same time
++ */
++
++static const struct reg_sequence ssm2602_patch[] = {
++      { SSM2602_ACTIVE, 0x01 },
++      { SSM2602_PWR,    0x07 },
++      { SSM2602_RESET,  0x00 },
++};
++
+ /*Appending several "None"s just for OSS mixer use*/
+ static const char *ssm2602_input_select[] = {
+@@ -589,6 +601,9 @@ static int ssm260x_component_probe(struct snd_soc_component *component)
+               return ret;
+       }
++      regmap_register_patch(ssm2602->regmap, ssm2602_patch,
++                            ARRAY_SIZE(ssm2602_patch));
++
+       /* set the update bits */
+       regmap_update_bits(ssm2602->regmap, SSM2602_LINVOL,
+                           LINVOL_LRIN_BOTH, LINVOL_LRIN_BOTH);
+-- 
+2.39.2
+
diff --git a/queue-5.10/atm-hide-unused-procfs-functions.patch b/queue-5.10/atm-hide-unused-procfs-functions.patch
new file mode 100644 (file)
index 0000000..5acab5f
--- /dev/null
@@ -0,0 +1,47 @@
+From 9f64aaf7389bea21d8604ca942b231715160c1c4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 May 2023 21:45:34 +0200
+Subject: atm: hide unused procfs functions
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit fb1b7be9b16c1f4626969ba4e95a97da2a452b41 ]
+
+When CONFIG_PROC_FS is disabled, the function declarations for some
+procfs functions are hidden, but the definitions are still build,
+as shown by this compiler warning:
+
+net/atm/resources.c:403:7: error: no previous prototype for 'atm_dev_seq_start' [-Werror=missing-prototypes]
+net/atm/resources.c:409:6: error: no previous prototype for 'atm_dev_seq_stop' [-Werror=missing-prototypes]
+net/atm/resources.c:414:7: error: no previous prototype for 'atm_dev_seq_next' [-Werror=missing-prototypes]
+
+Add another #ifdef to leave these out of the build.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Link: https://lore.kernel.org/r/20230516194625.549249-2-arnd@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/atm/resources.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/net/atm/resources.c b/net/atm/resources.c
+index 53236986dfe09..3ad39ae971323 100644
+--- a/net/atm/resources.c
++++ b/net/atm/resources.c
+@@ -403,6 +403,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
+       return error;
+ }
++#ifdef CONFIG_PROC_FS
+ void *atm_dev_seq_start(struct seq_file *seq, loff_t *pos)
+ {
+       mutex_lock(&atm_dev_mutex);
+@@ -418,3 +419,4 @@ void *atm_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+ {
+       return seq_list_next(v, &atm_devs, pos);
+ }
++#endif
+-- 
+2.39.2
+
diff --git a/queue-5.10/block-rnbd-replace-req_op_flush-with-req_op_write.patch b/queue-5.10/block-rnbd-replace-req_op_flush-with-req_op_write.patch
new file mode 100644 (file)
index 0000000..a0c15fc
--- /dev/null
@@ -0,0 +1,72 @@
+From 9d82eacee2358bf5a224d4161afbce2ab684f26c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 May 2023 11:46:31 +0800
+Subject: block/rnbd: replace REQ_OP_FLUSH with REQ_OP_WRITE
+
+From: Guoqing Jiang <guoqing.jiang@linux.dev>
+
+[ Upstream commit 5e6e08087a4acb4ee3574cea32dbff0f63c7f608 ]
+
+Since flush bios are implemented as writes with no data and
+the preflush flag per Christoph's comment [1].
+
+And we need to change it in rnbd accordingly. Otherwise, I
+got splatting when create fs from rnbd client.
+
+[  464.028545] ------------[ cut here ]------------
+[  464.028553] WARNING: CPU: 0 PID: 65 at block/blk-core.c:751 submit_bio_noacct+0x32c/0x5d0
+[ ... ]
+[  464.028668] CPU: 0 PID: 65 Comm: kworker/0:1H Tainted: G           OE      6.4.0-rc1 #9
+[  464.028671] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014
+[  464.028673] Workqueue: ib-comp-wq ib_cq_poll_work [ib_core]
+[  464.028717] RIP: 0010:submit_bio_noacct+0x32c/0x5d0
+[  464.028720] Code: 03 0f 85 51 fe ff ff 48 8b 43 18 8b 88 04 03 00 00 85 c9 0f 85 3f fe ff ff e9 be fd ff ff 0f b6 d0 3c 0d 74 26 83 fa 01 74 21 <0f> 0b b8 0a 00 00 00 e9 56 fd ff ff 4c 89 e7 e8 70 a1 03 00 84 c0
+[  464.028722] RSP: 0018:ffffaf3680b57c68 EFLAGS: 00010202
+[  464.028724] RAX: 0000000000060802 RBX: ffffa09dcc18bf00 RCX: 0000000000000000
+[  464.028726] RDX: 0000000000000002 RSI: 0000000000000000 RDI: ffffa09dde081d00
+[  464.028727] RBP: ffffaf3680b57c98 R08: ffffa09dde081d00 R09: ffffa09e38327200
+[  464.028729] R10: 0000000000000000 R11: 0000000000000000 R12: ffffa09dde081d00
+[  464.028730] R13: ffffa09dcb06e1e8 R14: 0000000000000000 R15: 0000000000200000
+[  464.028733] FS:  0000000000000000(0000) GS:ffffa09e3bc00000(0000) knlGS:0000000000000000
+[  464.028735] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[  464.028736] CR2: 000055a4e8206c40 CR3: 0000000119f06000 CR4: 00000000003506f0
+[  464.028738] Call Trace:
+[  464.028740]  <TASK>
+[  464.028746]  submit_bio+0x1b/0x80
+[  464.028748]  rnbd_srv_rdma_ev+0x50d/0x10c0 [rnbd_server]
+[  464.028754]  ? percpu_ref_get_many.constprop.0+0x55/0x140 [rtrs_server]
+[  464.028760]  ? __this_cpu_preempt_check+0x13/0x20
+[  464.028769]  process_io_req+0x1dc/0x450 [rtrs_server]
+[  464.028775]  rtrs_srv_inv_rkey_done+0x67/0xb0 [rtrs_server]
+[  464.028780]  __ib_process_cq+0xbc/0x1f0 [ib_core]
+[  464.028793]  ib_cq_poll_work+0x2b/0xa0 [ib_core]
+[  464.028804]  process_one_work+0x2a9/0x580
+
+[1]. https://lore.kernel.org/all/ZFHgefWofVt24tRl@infradead.org/
+
+Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
+Link: https://lore.kernel.org/r/20230512034631.28686-1-guoqing.jiang@linux.dev
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/block/rnbd/rnbd-proto.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/block/rnbd/rnbd-proto.h b/drivers/block/rnbd/rnbd-proto.h
+index ca166241452c2..cb11855455dde 100644
+--- a/drivers/block/rnbd/rnbd-proto.h
++++ b/drivers/block/rnbd/rnbd-proto.h
+@@ -234,7 +234,7 @@ static inline u32 rnbd_to_bio_flags(u32 rnbd_opf)
+               bio_opf = REQ_OP_WRITE;
+               break;
+       case RNBD_OP_FLUSH:
+-              bio_opf = REQ_OP_FLUSH | REQ_PREFLUSH;
++              bio_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+               break;
+       case RNBD_OP_DISCARD:
+               bio_opf = REQ_OP_DISCARD;
+-- 
+2.39.2
+
diff --git a/queue-5.10/btrfs-abort-transaction-when-sibling-keys-check-fail.patch b/queue-5.10/btrfs-abort-transaction-when-sibling-keys-check-fail.patch
new file mode 100644 (file)
index 0000000..08501b0
--- /dev/null
@@ -0,0 +1,56 @@
+From abcd2ba212c0fa1c54f0accef58ef29ace3b3d4a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 26 Apr 2023 11:51:35 +0100
+Subject: btrfs: abort transaction when sibling keys check fails for leaves
+
+From: Filipe Manana <fdmanana@suse.com>
+
+[ Upstream commit 9ae5afd02a03d4e22a17a9609b19400b77c36273 ]
+
+If the sibling keys check fails before we move keys from one sibling
+leaf to another, we are not aborting the transaction - we leave that to
+some higher level caller of btrfs_search_slot() (or anything else that
+uses it to insert items into a b+tree).
+
+This means that the transaction abort will provide a stack trace that
+omits the b+tree modification call chain. So change this to immediately
+abort the transaction and therefore get a more useful stack trace that
+shows us the call chain in the bt+tree modification code.
+
+It's also important to immediately abort the transaction just in case
+some higher level caller is not doing it, as this indicates a very
+serious corruption and we should stop the possibility of doing further
+damage.
+
+Reviewed-by: Qu Wenruo <wqu@suse.com>
+Signed-off-by: Filipe Manana <fdmanana@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/ctree.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
+index 3e55245e54e7c..41a7ace9998e4 100644
+--- a/fs/btrfs/ctree.c
++++ b/fs/btrfs/ctree.c
+@@ -3872,6 +3872,7 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
+       if (check_sibling_keys(left, right)) {
+               ret = -EUCLEAN;
++              btrfs_abort_transaction(trans, ret);
+               btrfs_tree_unlock(right);
+               free_extent_buffer(right);
+               return ret;
+@@ -4116,6 +4117,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
+       if (check_sibling_keys(left, right)) {
+               ret = -EUCLEAN;
++              btrfs_abort_transaction(trans, ret);
+               goto out;
+       }
+       return __push_leaf_left(path, min_data_size,
+-- 
+2.39.2
+
diff --git a/queue-5.10/dmaengine-at_xdmac-fix-concurrency-over-chan-s-compl.patch b/queue-5.10/dmaengine-at_xdmac-fix-concurrency-over-chan-s-compl.patch
new file mode 100644 (file)
index 0000000..094ec00
--- /dev/null
@@ -0,0 +1,43 @@
+From eec9c8e70e776ae22270541a870f27d0a84fbab5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Dec 2021 13:01:07 +0200
+Subject: dmaengine: at_xdmac: Fix concurrency over chan's completed_cookie
+
+From: Tudor Ambarus <tudor.ambarus@microchip.com>
+
+[ Upstream commit 506875c30fc5bf92246060bc3b4c38799646266b ]
+
+Caller of dma_cookie_complete is expected to hold a lock to prevent
+concurrency over the channel's completed cookie marker. Call
+dma_cookie_complete() with the lock held.
+
+Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
+Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
+Link: https://lore.kernel.org/r/20211215110115.191749-5-tudor.ambarus@microchip.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Stable-dep-of: 4d43acb145c3 ("dmaengine: at_xdmac: fix potential Oops in at_xdmac_prep_interleaved()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/at_xdmac.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
+index 1fe006cc643e7..501196d8c4881 100644
+--- a/drivers/dma/at_xdmac.c
++++ b/drivers/dma/at_xdmac.c
+@@ -1651,11 +1651,10 @@ static void at_xdmac_tasklet(struct tasklet_struct *t)
+               }
+               txd = &desc->tx_dma_desc;
+-
++              dma_cookie_complete(txd);
+               at_xdmac_remove_xfer(atchan, desc);
+               spin_unlock_irq(&atchan->lock);
+-              dma_cookie_complete(txd);
+               if (txd->flags & DMA_PREP_INTERRUPT)
+                       dmaengine_desc_get_callback_invoke(txd, NULL);
+-- 
+2.39.2
+
diff --git a/queue-5.10/dmaengine-at_xdmac-fix-potential-oops-in-at_xdmac_pr.patch b/queue-5.10/dmaengine-at_xdmac-fix-potential-oops-in-at_xdmac_pr.patch
new file mode 100644 (file)
index 0000000..d490726
--- /dev/null
@@ -0,0 +1,56 @@
+From 6dc1c670421c4cb4dbfb7923ef4131d45ab41d4b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 15 May 2023 13:32:10 +0300
+Subject: dmaengine: at_xdmac: fix potential Oops in
+ at_xdmac_prep_interleaved()
+
+From: Dan Carpenter <dan.carpenter@linaro.org>
+
+[ Upstream commit 4d43acb145c363626d76f49febb4240c488cd1cf ]
+
+There are two place if the at_xdmac_interleaved_queue_desc() fails which
+could lead to a NULL dereference where "first" is NULL and we call
+list_add_tail(&first->desc_node, ...).  In the first caller, the return
+is not checked so add a check for that.  In the next caller, the return
+is checked but if it fails on the first iteration through the loop then
+it will lead to a NULL pointer dereference.
+
+Fixes: 4e5385784e69 ("dmaengine: at_xdmac: handle numf > 1")
+Fixes: 62b5cb757f1d ("dmaengine: at_xdmac: fix memory leak in interleaved mode")
+Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
+Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
+Link: https://lore.kernel.org/r/21282b66-9860-410a-83df-39c17fcf2f1b@kili.mountain
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/at_xdmac.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
+index 96559c5df944d..861be862a775a 100644
+--- a/drivers/dma/at_xdmac.c
++++ b/drivers/dma/at_xdmac.c
+@@ -970,6 +970,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
+                                                       NULL,
+                                                       src_addr, dst_addr,
+                                                       xt, xt->sgl);
++              if (!first)
++                      return NULL;
+               /* Length of the block is (BLEN+1) microblocks. */
+               for (i = 0; i < xt->numf - 1; i++)
+@@ -1000,8 +1002,9 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
+                                                              src_addr, dst_addr,
+                                                              xt, chunk);
+                       if (!desc) {
+-                              list_splice_tail_init(&first->descs_list,
+-                                                    &atchan->free_descs_list);
++                              if (first)
++                                      list_splice_tail_init(&first->descs_list,
++                                                            &atchan->free_descs_list);
+                               return NULL;
+                       }
+-- 
+2.39.2
+
diff --git a/queue-5.10/dmaengine-at_xdmac-fix-race-for-the-tx-desc-callback.patch b/queue-5.10/dmaengine-at_xdmac-fix-race-for-the-tx-desc-callback.patch
new file mode 100644 (file)
index 0000000..2080db7
--- /dev/null
@@ -0,0 +1,86 @@
+From ebe464366a3298f16f16ddd26bc69901b927c750 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Dec 2021 13:01:08 +0200
+Subject: dmaengine: at_xdmac: Fix race for the tx desc callback
+
+From: Tudor Ambarus <tudor.ambarus@microchip.com>
+
+[ Upstream commit b63e5cb94ad6947ab5fe38b5a9417dcfd0bc6122 ]
+
+The transfer descriptors were wrongly moved to the free descriptors list
+before calling the tx desc callback. As the DMA engine drivers drop any
+locks before calling the callback function, txd could be taken again,
+resulting in its callback called prematurely. Fix the race for the tx desc
+callback by moving the xfer desc into the free desc list after the
+callback is invoked.
+
+Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
+Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
+Link: https://lore.kernel.org/r/20211215110115.191749-6-tudor.ambarus@microchip.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Stable-dep-of: 4d43acb145c3 ("dmaengine: at_xdmac: fix potential Oops in at_xdmac_prep_interleaved()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/at_xdmac.c | 25 ++++++++-----------------
+ 1 file changed, 8 insertions(+), 17 deletions(-)
+
+diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
+index 501196d8c4881..8af1c0fd3a736 100644
+--- a/drivers/dma/at_xdmac.c
++++ b/drivers/dma/at_xdmac.c
+@@ -1527,20 +1527,6 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
+       return ret;
+ }
+-/* Call must be protected by lock. */
+-static void at_xdmac_remove_xfer(struct at_xdmac_chan *atchan,
+-                                  struct at_xdmac_desc *desc)
+-{
+-      dev_dbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
+-
+-      /*
+-       * Remove the transfer from the transfer list then move the transfer
+-       * descriptors into the free descriptors list.
+-       */
+-      list_del(&desc->xfer_node);
+-      list_splice_init(&desc->descs_list, &atchan->free_descs_list);
+-}
+-
+ static void at_xdmac_advance_work(struct at_xdmac_chan *atchan)
+ {
+       struct at_xdmac_desc    *desc;
+@@ -1652,7 +1638,8 @@ static void at_xdmac_tasklet(struct tasklet_struct *t)
+               txd = &desc->tx_dma_desc;
+               dma_cookie_complete(txd);
+-              at_xdmac_remove_xfer(atchan, desc);
++              /* Remove the transfer from the transfer list. */
++              list_del(&desc->xfer_node);
+               spin_unlock_irq(&atchan->lock);
+               if (txd->flags & DMA_PREP_INTERRUPT)
+@@ -1661,6 +1648,8 @@ static void at_xdmac_tasklet(struct tasklet_struct *t)
+               dma_run_dependencies(txd);
+               spin_lock_irq(&atchan->lock);
++              /* Move the xfer descriptors into the free descriptors list. */
++              list_splice_init(&desc->descs_list, &atchan->free_descs_list);
+               at_xdmac_advance_work(atchan);
+               spin_unlock_irq(&atchan->lock);
+       }
+@@ -1807,8 +1796,10 @@ static int at_xdmac_device_terminate_all(struct dma_chan *chan)
+               cpu_relax();
+       /* Cancel all pending transfers. */
+-      list_for_each_entry_safe(desc, _desc, &atchan->xfers_list, xfer_node)
+-              at_xdmac_remove_xfer(atchan, desc);
++      list_for_each_entry_safe(desc, _desc, &atchan->xfers_list, xfer_node) {
++              list_del(&desc->xfer_node);
++              list_splice_init(&desc->descs_list, &atchan->free_descs_list);
++      }
+       clear_bit(AT_XDMAC_CHAN_IS_PAUSED, &atchan->status);
+       clear_bit(AT_XDMAC_CHAN_IS_CYCLIC, &atchan->status);
+-- 
+2.39.2
+
diff --git a/queue-5.10/dmaengine-at_xdmac-move-the-free-desc-to-the-tail-of.patch b/queue-5.10/dmaengine-at_xdmac-move-the-free-desc-to-the-tail-of.patch
new file mode 100644 (file)
index 0000000..5f81abb
--- /dev/null
@@ -0,0 +1,103 @@
+From b04411f9723988db12d8480c40bc02b2afff0106 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Dec 2021 13:01:09 +0200
+Subject: dmaengine: at_xdmac: Move the free desc to the tail of the desc list
+
+From: Tudor Ambarus <tudor.ambarus@microchip.com>
+
+[ Upstream commit 801db90bf294f647b967e8d99b9ae121bea63d0d ]
+
+Move the free desc to the tail of the list, so that the sequence of
+descriptors is more track-able in case of debug. One would know which
+descriptor should come next and could easier catch concurrency over
+descriptors for example. virt-dma uses list_splice_tail_init() as well,
+follow the core driver.
+
+Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
+Link: https://lore.kernel.org/r/20211215110115.191749-7-tudor.ambarus@microchip.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Stable-dep-of: 4d43acb145c3 ("dmaengine: at_xdmac: fix potential Oops in at_xdmac_prep_interleaved()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/at_xdmac.c | 23 ++++++++++++++---------
+ 1 file changed, 14 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
+index 8af1c0fd3a736..96559c5df944d 100644
+--- a/drivers/dma/at_xdmac.c
++++ b/drivers/dma/at_xdmac.c
+@@ -678,7 +678,8 @@ at_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
+               if (!desc) {
+                       dev_err(chan2dev(chan), "can't get descriptor\n");
+                       if (first)
+-                              list_splice_init(&first->descs_list, &atchan->free_descs_list);
++                              list_splice_tail_init(&first->descs_list,
++                                                    &atchan->free_descs_list);
+                       goto spin_unlock;
+               }
+@@ -766,7 +767,8 @@ at_xdmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
+               if (!desc) {
+                       dev_err(chan2dev(chan), "can't get descriptor\n");
+                       if (first)
+-                              list_splice_init(&first->descs_list, &atchan->free_descs_list);
++                              list_splice_tail_init(&first->descs_list,
++                                                    &atchan->free_descs_list);
+                       spin_unlock_irqrestore(&atchan->lock, irqflags);
+                       return NULL;
+               }
+@@ -998,8 +1000,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
+                                                              src_addr, dst_addr,
+                                                              xt, chunk);
+                       if (!desc) {
+-                              list_splice_init(&first->descs_list,
+-                                               &atchan->free_descs_list);
++                              list_splice_tail_init(&first->descs_list,
++                                                    &atchan->free_descs_list);
+                               return NULL;
+                       }
+@@ -1077,7 +1079,8 @@ at_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
+               if (!desc) {
+                       dev_err(chan2dev(chan), "can't get descriptor\n");
+                       if (first)
+-                              list_splice_init(&first->descs_list, &atchan->free_descs_list);
++                              list_splice_tail_init(&first->descs_list,
++                                                    &atchan->free_descs_list);
+                       return NULL;
+               }
+@@ -1251,8 +1254,8 @@ at_xdmac_prep_dma_memset_sg(struct dma_chan *chan, struct scatterlist *sgl,
+                                                  sg_dma_len(sg),
+                                                  value);
+               if (!desc && first)
+-                      list_splice_init(&first->descs_list,
+-                                       &atchan->free_descs_list);
++                      list_splice_tail_init(&first->descs_list,
++                                            &atchan->free_descs_list);
+               if (!first)
+                       first = desc;
+@@ -1649,7 +1652,8 @@ static void at_xdmac_tasklet(struct tasklet_struct *t)
+               spin_lock_irq(&atchan->lock);
+               /* Move the xfer descriptors into the free descriptors list. */
+-              list_splice_init(&desc->descs_list, &atchan->free_descs_list);
++              list_splice_tail_init(&desc->descs_list,
++                                    &atchan->free_descs_list);
+               at_xdmac_advance_work(atchan);
+               spin_unlock_irq(&atchan->lock);
+       }
+@@ -1798,7 +1802,8 @@ static int at_xdmac_device_terminate_all(struct dma_chan *chan)
+       /* Cancel all pending transfers. */
+       list_for_each_entry_safe(desc, _desc, &atchan->xfers_list, xfer_node) {
+               list_del(&desc->xfer_node);
+-              list_splice_init(&desc->descs_list, &atchan->free_descs_list);
++              list_splice_tail_init(&desc->descs_list,
++                                    &atchan->free_descs_list);
+       }
+       clear_bit(AT_XDMAC_CHAN_IS_PAUSED, &atchan->status);
+-- 
+2.39.2
+
diff --git a/queue-5.10/dmaengine-pl330-rename-_start-to-prevent-build-error.patch b/queue-5.10/dmaengine-pl330-rename-_start-to-prevent-build-error.patch
new file mode 100644 (file)
index 0000000..ad0b151
--- /dev/null
@@ -0,0 +1,85 @@
+From b7d1656a16b9e9f919e73e0ad9bd133993c198dd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 23 May 2023 21:53:10 -0700
+Subject: dmaengine: pl330: rename _start to prevent build error
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+[ Upstream commit a1a5f2c887252dec161c1e12e04303ca9ba56fa9 ]
+
+"_start" is used in several arches and proably should be reserved
+for ARCH usage. Using it in a driver for a private symbol can cause
+a build error when it conflicts with ARCH usage of the same symbol.
+
+Therefore rename pl330's "_start" to "pl330_start_thread" so that there
+is no conflict and no build error.
+
+drivers/dma/pl330.c:1053:13: error: '_start' redeclared as different kind of symbol
+ 1053 | static bool _start(struct pl330_thread *thrd)
+      |             ^~~~~~
+In file included from ../include/linux/interrupt.h:21,
+                 from ../drivers/dma/pl330.c:18:
+arch/riscv/include/asm/sections.h:11:13: note: previous declaration of '_start' with type 'char[]'
+   11 | extern char _start[];
+      |             ^~~~~~
+
+Fixes: b7d861d93945 ("DMA: PL330: Merge PL330 driver into drivers/dma/")
+Fixes: ae43b3289186 ("ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12")
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Cc: Jaswinder Singh <jassisinghbrar@gmail.com>
+Cc: Boojin Kim <boojin.kim@samsung.com>
+Cc: Krzysztof Kozlowski <krzk@kernel.org>
+Cc: Russell King <rmk+kernel@arm.linux.org.uk>
+Cc: Vinod Koul <vkoul@kernel.org>
+Cc: dmaengine@vger.kernel.org
+Cc: linux-riscv@lists.infradead.org
+Link: https://lore.kernel.org/r/20230524045310.27923-1-rdunlap@infradead.org
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/dma/pl330.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
+index 5bbae99f2d34e..6f697b3f2c184 100644
+--- a/drivers/dma/pl330.c
++++ b/drivers/dma/pl330.c
+@@ -1050,7 +1050,7 @@ static bool _trigger(struct pl330_thread *thrd)
+       return true;
+ }
+-static bool _start(struct pl330_thread *thrd)
++static bool pl330_start_thread(struct pl330_thread *thrd)
+ {
+       switch (_state(thrd)) {
+       case PL330_STATE_FAULT_COMPLETING:
+@@ -1704,7 +1704,7 @@ static int pl330_update(struct pl330_dmac *pl330)
+                       thrd->req_running = -1;
+                       /* Get going again ASAP */
+-                      _start(thrd);
++                      pl330_start_thread(thrd);
+                       /* For now, just make a list of callbacks to be done */
+                       list_add_tail(&descdone->rqd, &pl330->req_done);
+@@ -2091,7 +2091,7 @@ static void pl330_tasklet(struct tasklet_struct *t)
+       } else {
+               /* Make sure the PL330 Channel thread is active */
+               spin_lock(&pch->thread->dmac->lock);
+-              _start(pch->thread);
++              pl330_start_thread(pch->thread);
+               spin_unlock(&pch->thread->dmac->lock);
+       }
+@@ -2109,7 +2109,7 @@ static void pl330_tasklet(struct tasklet_struct *t)
+                       if (power_down) {
+                               pch->active = true;
+                               spin_lock(&pch->thread->dmac->lock);
+-                              _start(pch->thread);
++                              pl330_start_thread(pch->thread);
+                               spin_unlock(&pch->thread->dmac->lock);
+                               power_down = false;
+                       }
+-- 
+2.39.2
+
diff --git a/queue-5.10/drm-msm-be-more-shouty-if-per-process-pgtables-aren-.patch b/queue-5.10/drm-msm-be-more-shouty-if-per-process-pgtables-aren-.patch
new file mode 100644 (file)
index 0000000..8c9e54b
--- /dev/null
@@ -0,0 +1,42 @@
+From 1f42b83667c9d7930d2fc3cafbca7261c9d3a25f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 May 2023 15:20:37 -0700
+Subject: drm/msm: Be more shouty if per-process pgtables aren't working
+
+From: Rob Clark <robdclark@chromium.org>
+
+[ Upstream commit 5c054db54c43a5fcb5cc81012361f5e3fac37637 ]
+
+Otherwise it is not always obvious if a dt or iommu change is causing us
+to fall back to global pgtable.
+
+Signed-off-by: Rob Clark <robdclark@chromium.org>
+Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
+Patchwork: https://patchwork.freedesktop.org/patch/537359/
+Link: https://lore.kernel.org/r/20230516222039.907690-2-robdclark@gmail.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/msm/msm_iommu.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
+index ecab6287c1c39..b81390d6ebd38 100644
+--- a/drivers/gpu/drm/msm/msm_iommu.c
++++ b/drivers/gpu/drm/msm/msm_iommu.c
+@@ -155,7 +155,12 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)
+       /* Get the pagetable configuration from the domain */
+       if (adreno_smmu->cookie)
+               ttbr1_cfg = adreno_smmu->get_ttbr1_cfg(adreno_smmu->cookie);
+-      if (!ttbr1_cfg)
++
++      /*
++       * If you hit this WARN_ONCE() you are probably missing an entry in
++       * qcom_smmu_impl_of_match[] in arm-smmu-qcom.c
++       */
++      if (WARN_ONCE(!ttbr1_cfg, "No per-process page tables"))
+               return ERR_PTR(-ENODEV);
+       pagetable = kzalloc(sizeof(*pagetable), GFP_KERNEL);
+-- 
+2.39.2
+
diff --git a/queue-5.10/fbdev-modedb-add-1920x1080-at-60-hz-video-mode.patch b/queue-5.10/fbdev-modedb-add-1920x1080-at-60-hz-video-mode.patch
new file mode 100644 (file)
index 0000000..7be92f2
--- /dev/null
@@ -0,0 +1,36 @@
+From 4d8bd11c5123bfe2533d2ca9e139e62598756e8a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 22 Apr 2023 23:24:26 +0200
+Subject: fbdev: modedb: Add 1920x1080 at 60 Hz video mode
+
+From: Helge Deller <deller@gmx.de>
+
+[ Upstream commit c8902258b2b8ecaa1b8d88c312853c5b14c2553d ]
+
+Add typical resolution for Full-HD monitors.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/video/fbdev/core/modedb.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c
+index 6473e0dfe1464..e78ec7f728463 100644
+--- a/drivers/video/fbdev/core/modedb.c
++++ b/drivers/video/fbdev/core/modedb.c
+@@ -257,6 +257,11 @@ static const struct fb_videomode modedb[] = {
+       { NULL, 72, 480, 300, 33386, 40, 24, 11, 19, 80, 3, 0,
+               FB_VMODE_DOUBLE },
++      /* 1920x1080 @ 60 Hz, 67.3 kHz hsync */
++      { NULL, 60, 1920, 1080, 6734, 148, 88, 36, 4, 44, 5, 0,
++              FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
++              FB_VMODE_NONINTERLACED },
++
+       /* 1920x1200 @ 60 Hz, 74.5 Khz hsync */
+       { NULL, 60, 1920, 1200, 5177, 128, 336, 1, 38, 208, 3,
+               FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+-- 
+2.39.2
+
diff --git a/queue-5.10/fbdev-stifb-fix-info-entry-in-sti_struct-on-error-pa.patch b/queue-5.10/fbdev-stifb-fix-info-entry-in-sti_struct-on-error-pa.patch
new file mode 100644 (file)
index 0000000..8853680
--- /dev/null
@@ -0,0 +1,32 @@
+From 408e0f25b9dd74ece3d9c50dfd733d8adfcd7bae Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 May 2023 11:50:33 +0200
+Subject: fbdev: stifb: Fix info entry in sti_struct on error path
+
+From: Helge Deller <deller@gmx.de>
+
+[ Upstream commit 0bdf1ad8d10bd4e50a8b1a2c53d15984165f7fea ]
+
+Minor fix to reset the info field to NULL in case of error.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/video/fbdev/stifb.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c
+index ef8a4c5fc6875..63f51783352dc 100644
+--- a/drivers/video/fbdev/stifb.c
++++ b/drivers/video/fbdev/stifb.c
+@@ -1413,6 +1413,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
+       iounmap(info->screen_base);
+ out_err0:
+       kfree(fb);
++      sti->info = NULL;
+       return -ENXIO;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.10/gfs2-don-t-deref-jdesc-in-evict.patch b/queue-5.10/gfs2-don-t-deref-jdesc-in-evict.patch
new file mode 100644 (file)
index 0000000..fbb367f
--- /dev/null
@@ -0,0 +1,66 @@
+From e650dff56ee7cd14f588150741bf30f0a8780b4e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 28 Apr 2023 12:07:46 -0400
+Subject: gfs2: Don't deref jdesc in evict
+
+From: Bob Peterson <rpeterso@redhat.com>
+
+[ Upstream commit 504a10d9e46bc37b23d0a1ae2f28973c8516e636 ]
+
+On corrupt gfs2 file systems the evict code can try to reference the
+journal descriptor structure, jdesc, after it has been freed and set to
+NULL. The sequence of events is:
+
+init_journal()
+...
+fail_jindex:
+   gfs2_jindex_free(sdp); <------frees journals, sets jdesc = NULL
+      if (gfs2_holder_initialized(&ji_gh))
+         gfs2_glock_dq_uninit(&ji_gh);
+fail:
+   iput(sdp->sd_jindex); <--references jdesc in evict_linked_inode
+      evict()
+         gfs2_evict_inode()
+            evict_linked_inode()
+               ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
+<------references the now freed/zeroed sd_jdesc pointer.
+
+The call to gfs2_trans_begin is done because the truncate_inode_pages
+call can cause gfs2 events that require a transaction, such as removing
+journaled data (jdata) blocks from the journal.
+
+This patch fixes the problem by adding a check for sdp->sd_jdesc to
+function gfs2_evict_inode. In theory, this should only happen to corrupt
+gfs2 file systems, when gfs2 detects the problem, reports it, then tries
+to evict all the system inodes it has read in up to that point.
+
+Reported-by: Yang Lan <lanyang0908@gmail.com>
+Signed-off-by: Bob Peterson <rpeterso@redhat.com>
+Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/gfs2/super.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
+index 5cb7e771b57ab..e01b6a2d12d30 100644
+--- a/fs/gfs2/super.c
++++ b/fs/gfs2/super.c
+@@ -1416,6 +1416,14 @@ static void gfs2_evict_inode(struct inode *inode)
+       if (inode->i_nlink || sb_rdonly(sb))
+               goto out;
++      /*
++       * In case of an incomplete mount, gfs2_evict_inode() may be called for
++       * system files without having an active journal to write to.  In that
++       * case, skip the filesystem evict.
++       */
++      if (!sdp->sd_jdesc)
++              goto out;
++
+       gfs2_holder_mark_uninitialized(&gh);
+       ret = evict_should_delete(inode, &gh);
+       if (ret == SHOULD_DEFER_EVICTION)
+-- 
+2.39.2
+
diff --git a/queue-5.10/iommu-amd-don-t-block-updates-to-gatag-if-guest-mode.patch b/queue-5.10/iommu-amd-don-t-block-updates-to-gatag-if-guest-mode.patch
new file mode 100644 (file)
index 0000000..1229758
--- /dev/null
@@ -0,0 +1,76 @@
+From 6117c4168f05c4765e7a0c89e4d7586d360de5f3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 19 Apr 2023 21:11:53 +0100
+Subject: iommu/amd: Don't block updates to GATag if guest mode is on
+
+From: Joao Martins <joao.m.martins@oracle.com>
+
+[ Upstream commit ed8a2f4ddef2eaaf864ab1efbbca9788187036ab ]
+
+On KVM GSI routing table updates, specially those where they have vIOMMUs
+with interrupt remapping enabled (to boot >255vcpus setups without relying
+on KVM_FEATURE_MSI_EXT_DEST_ID), a VMM may update the backing VF MSIs
+with a new VCPU affinity.
+
+On AMD with AVIC enabled, the new vcpu affinity info is updated via:
+       avic_pi_update_irte()
+               irq_set_vcpu_affinity()
+                       amd_ir_set_vcpu_affinity()
+                               amd_iommu_{de}activate_guest_mode()
+
+Where the IRTE[GATag] is updated with the new vcpu affinity. The GATag
+contains VM ID and VCPU ID, and is used by IOMMU hardware to signal KVM
+(via GALog) when interrupt cannot be delivered due to vCPU is in
+blocking state.
+
+The issue is that amd_iommu_activate_guest_mode() will essentially
+only change IRTE fields on transitions from non-guest-mode to guest-mode
+and otherwise returns *with no changes to IRTE* on already configured
+guest-mode interrupts. To the guest this means that the VF interrupts
+remain affined to the first vCPU they were first configured, and guest
+will be unable to issue VF interrupts and receive messages like this
+from spurious interrupts (e.g. from waking the wrong vCPU in GALog):
+
+[  167.759472] __common_interrupt: 3.34 No irq handler for vector
+[  230.680927] mlx5_core 0000:00:02.0: mlx5_cmd_eq_recover:247:(pid
+3122): Recovered 1 EQEs on cmd_eq
+[  230.681799] mlx5_core 0000:00:02.0:
+wait_func_handle_exec_timeout:1113:(pid 3122): cmd[0]: CREATE_CQ(0x400)
+recovered after timeout
+[  230.683266] __common_interrupt: 3.34 No irq handler for vector
+
+Given the fact that amd_ir_set_vcpu_affinity() uses
+amd_iommu_activate_guest_mode() underneath it essentially means that VCPU
+affinity changes of IRTEs are nops. Fix it by dropping the check for
+guest-mode at amd_iommu_activate_guest_mode(). Same thing is applicable to
+amd_iommu_deactivate_guest_mode() although, even if the IRTE doesn't change
+underlying DestID on the host, the VFIO IRQ handler will still be able to
+poke at the right guest-vCPU.
+
+Fixes: b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activation code")
+Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
+Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
+Link: https://lore.kernel.org/r/20230419201154.83880-2-joao.m.martins@oracle.com
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iommu/amd/iommu.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
+index f216a86d9c817..0a061a196b531 100644
+--- a/drivers/iommu/amd/iommu.c
++++ b/drivers/iommu/amd/iommu.c
+@@ -3914,8 +3914,7 @@ int amd_iommu_activate_guest_mode(void *data)
+       struct irte_ga *entry = (struct irte_ga *) ir_data->entry;
+       u64 valid;
+-      if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) ||
+-          !entry || entry->lo.fields_vapic.guest_mode)
++      if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) || !entry)
+               return 0;
+       valid = entry->lo.fields_vapic.valid;
+-- 
+2.39.2
+
diff --git a/queue-5.10/iommu-rockchip-fix-unwind-goto-issue.patch b/queue-5.10/iommu-rockchip-fix-unwind-goto-issue.patch
new file mode 100644 (file)
index 0000000..1b6036d
--- /dev/null
@@ -0,0 +1,65 @@
+From 754e2828553684c4f49fe012dff4845c3977478e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 Apr 2023 03:04:21 +0000
+Subject: iommu/rockchip: Fix unwind goto issue
+
+From: Chao Wang <D202280639@hust.edu.cn>
+
+[ Upstream commit ec014683c564fb74fc68e8f5e84691d3b3839d24 ]
+
+Smatch complains that
+drivers/iommu/rockchip-iommu.c:1306 rk_iommu_probe() warn: missing unwind goto?
+
+The rk_iommu_probe function, after obtaining the irq value through
+platform_get_irq, directly returns an error if the returned value
+is negative, without releasing any resources.
+
+Fix this by adding a new error handling label "err_pm_disable" and
+use a goto statement to redirect to the error handling process. In
+order to preserve the original semantics, set err to the value of irq.
+
+Fixes: 1aa55ca9b14a ("iommu/rockchip: Move irq request past pm_runtime_enable")
+Signed-off-by: Chao Wang <D202280639@hust.edu.cn>
+Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
+Reviewed-by: Heiko Stuebner <heiko@sntech.de>
+Link: https://lore.kernel.org/r/20230417030421.2777-1-D202280639@hust.edu.cn
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iommu/rockchip-iommu.c | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
+index e5d86b7177dec..12551dc117148 100644
+--- a/drivers/iommu/rockchip-iommu.c
++++ b/drivers/iommu/rockchip-iommu.c
+@@ -1218,18 +1218,20 @@ static int rk_iommu_probe(struct platform_device *pdev)
+       for (i = 0; i < iommu->num_irq; i++) {
+               int irq = platform_get_irq(pdev, i);
+-              if (irq < 0)
+-                      return irq;
++              if (irq < 0) {
++                      err = irq;
++                      goto err_pm_disable;
++              }
+               err = devm_request_irq(iommu->dev, irq, rk_iommu_irq,
+                                      IRQF_SHARED, dev_name(dev), iommu);
+-              if (err) {
+-                      pm_runtime_disable(dev);
+-                      goto err_remove_sysfs;
+-              }
++              if (err)
++                      goto err_pm_disable;
+       }
+       return 0;
++err_pm_disable:
++      pm_runtime_disable(dev);
+ err_remove_sysfs:
+       iommu_device_sysfs_remove(&iommu->iommu);
+ err_put_group:
+-- 
+2.39.2
+
diff --git a/queue-5.10/mailbox-mailbox-test-fix-a-locking-issue-in-mbox_tes.patch b/queue-5.10/mailbox-mailbox-test-fix-a-locking-issue-in-mbox_tes.patch
new file mode 100644 (file)
index 0000000..e450a06
--- /dev/null
@@ -0,0 +1,56 @@
+From ba50977c0afb1b4231eb1f88f320a4e8af6348be Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 5 May 2023 12:22:09 +0300
+Subject: mailbox: mailbox-test: fix a locking issue in
+ mbox_test_message_write()
+
+From: Dan Carpenter <dan.carpenter@linaro.org>
+
+[ Upstream commit 8fe72b76db79d694858e872370df49676bc3be8c ]
+
+There was a bug where this code forgot to unlock the tdev->mutex if the
+kzalloc() failed.  Fix this issue, by moving the allocation outside the
+lock.
+
+Fixes: 2d1e952a2b8e ("mailbox: mailbox-test: Fix potential double-free in mbox_test_message_write()")
+Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
+Reviewed-by: Lee Jones <lee@kernel.org>
+Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mailbox/mailbox-test.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
+index 6dd5b9614452b..abcee58e851c2 100644
+--- a/drivers/mailbox/mailbox-test.c
++++ b/drivers/mailbox/mailbox-test.c
+@@ -97,6 +97,7 @@ static ssize_t mbox_test_message_write(struct file *filp,
+                                      size_t count, loff_t *ppos)
+ {
+       struct mbox_test_device *tdev = filp->private_data;
++      char *message;
+       void *data;
+       int ret;
+@@ -112,12 +113,13 @@ static ssize_t mbox_test_message_write(struct file *filp,
+               return -EINVAL;
+       }
+-      mutex_lock(&tdev->mutex);
+-
+-      tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
+-      if (!tdev->message)
++      message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
++      if (!message)
+               return -ENOMEM;
++      mutex_lock(&tdev->mutex);
++
++      tdev->message = message;
+       ret = copy_from_user(tdev->message, userbuf, count);
+       if (ret) {
+               ret = -EFAULT;
+-- 
+2.39.2
+
diff --git a/queue-5.10/mailbox-mailbox-test-fix-potential-double-free-in-mb.patch b/queue-5.10/mailbox-mailbox-test-fix-potential-double-free-in-mb.patch
new file mode 100644 (file)
index 0000000..91a0a3b
--- /dev/null
@@ -0,0 +1,136 @@
+From 60fffc33146e751f2e491c5625f1422a793c57b7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 20 Apr 2023 08:27:18 +0100
+Subject: mailbox: mailbox-test: Fix potential double-free in
+ mbox_test_message_write()
+
+From: Lee Jones <lee@kernel.org>
+
+[ Upstream commit 2d1e952a2b8e5e92d8d55ac88a7cf7ca5ea591ad ]
+
+If a user can make copy_from_user() fail, there is a potential for
+UAF/DF due to a lack of locking around the allocation, use and freeing
+of the data buffers.
+
+This issue is not theoretical.  I managed to author a POC for it:
+
+    BUG: KASAN: double-free in kfree+0x5c/0xac
+    Free of addr ffff29280be5de00 by task poc/356
+    CPU: 1 PID: 356 Comm: poc Not tainted 6.1.0-00001-g961aa6552c04-dirty #20
+    Hardware name: linux,dummy-virt (DT)
+    Call trace:
+     dump_backtrace.part.0+0xe0/0xf0
+     show_stack+0x18/0x40
+     dump_stack_lvl+0x64/0x80
+     print_report+0x188/0x48c
+     kasan_report_invalid_free+0xa0/0xc0
+     ____kasan_slab_free+0x174/0x1b0
+     __kasan_slab_free+0x18/0x24
+     __kmem_cache_free+0x130/0x2e0
+     kfree+0x5c/0xac
+     mbox_test_message_write+0x208/0x29c
+     full_proxy_write+0x90/0xf0
+     vfs_write+0x154/0x440
+     ksys_write+0xcc/0x180
+     __arm64_sys_write+0x44/0x60
+     invoke_syscall+0x60/0x190
+     el0_svc_common.constprop.0+0x7c/0x160
+     do_el0_svc+0x40/0xf0
+     el0_svc+0x2c/0x6c
+     el0t_64_sync_handler+0xf4/0x120
+     el0t_64_sync+0x18c/0x190
+
+    Allocated by task 356:
+     kasan_save_stack+0x3c/0x70
+     kasan_set_track+0x2c/0x40
+     kasan_save_alloc_info+0x24/0x34
+     __kasan_kmalloc+0xb8/0xc0
+     kmalloc_trace+0x58/0x70
+     mbox_test_message_write+0x6c/0x29c
+     full_proxy_write+0x90/0xf0
+     vfs_write+0x154/0x440
+     ksys_write+0xcc/0x180
+     __arm64_sys_write+0x44/0x60
+     invoke_syscall+0x60/0x190
+     el0_svc_common.constprop.0+0x7c/0x160
+     do_el0_svc+0x40/0xf0
+     el0_svc+0x2c/0x6c
+     el0t_64_sync_handler+0xf4/0x120
+     el0t_64_sync+0x18c/0x190
+
+    Freed by task 357:
+     kasan_save_stack+0x3c/0x70
+     kasan_set_track+0x2c/0x40
+     kasan_save_free_info+0x38/0x5c
+     ____kasan_slab_free+0x13c/0x1b0
+     __kasan_slab_free+0x18/0x24
+     __kmem_cache_free+0x130/0x2e0
+     kfree+0x5c/0xac
+     mbox_test_message_write+0x208/0x29c
+     full_proxy_write+0x90/0xf0
+     vfs_write+0x154/0x440
+     ksys_write+0xcc/0x180
+     __arm64_sys_write+0x44/0x60
+     invoke_syscall+0x60/0x190
+     el0_svc_common.constprop.0+0x7c/0x160
+     do_el0_svc+0x40/0xf0
+     el0_svc+0x2c/0x6c
+     el0t_64_sync_handler+0xf4/0x120
+     el0t_64_sync+0x18c/0x190
+
+Signed-off-by: Lee Jones <lee@kernel.org>
+Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mailbox/mailbox-test.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
+index 4555d678fadda..6dd5b9614452b 100644
+--- a/drivers/mailbox/mailbox-test.c
++++ b/drivers/mailbox/mailbox-test.c
+@@ -12,6 +12,7 @@
+ #include <linux/kernel.h>
+ #include <linux/mailbox_client.h>
+ #include <linux/module.h>
++#include <linux/mutex.h>
+ #include <linux/of.h>
+ #include <linux/platform_device.h>
+ #include <linux/poll.h>
+@@ -38,6 +39,7 @@ struct mbox_test_device {
+       char                    *signal;
+       char                    *message;
+       spinlock_t              lock;
++      struct mutex            mutex;
+       wait_queue_head_t       waitq;
+       struct fasync_struct    *async_queue;
+       struct dentry           *root_debugfs_dir;
+@@ -110,6 +112,8 @@ static ssize_t mbox_test_message_write(struct file *filp,
+               return -EINVAL;
+       }
++      mutex_lock(&tdev->mutex);
++
+       tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
+       if (!tdev->message)
+               return -ENOMEM;
+@@ -144,6 +148,8 @@ static ssize_t mbox_test_message_write(struct file *filp,
+       kfree(tdev->message);
+       tdev->signal = NULL;
++      mutex_unlock(&tdev->mutex);
++
+       return ret < 0 ? ret : count;
+ }
+@@ -392,6 +398,7 @@ static int mbox_test_probe(struct platform_device *pdev)
+       platform_set_drvdata(pdev, tdev);
+       spin_lock_init(&tdev->lock);
++      mutex_init(&tdev->mutex);
+       if (tdev->rx_channel) {
+               tdev->rx_buffer = devm_kzalloc(&pdev->dev,
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-core-fix-kernel-warning-for-blocking-opera.patch b/queue-5.10/media-dvb-core-fix-kernel-warning-for-blocking-opera.patch
new file mode 100644 (file)
index 0000000..15c5cbe
--- /dev/null
@@ -0,0 +1,67 @@
+From 765f7a2568cf9a558e2f02ed1bc894a56a66794c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 May 2023 16:18:00 +0100
+Subject: media: dvb-core: Fix kernel WARNING for blocking operation in
+ wait_event*()
+
+From: Takashi Iwai <tiwai@suse.de>
+
+[ Upstream commit b8c75e4a1b325ea0a9433fa8834be97b5836b946 ]
+
+Using a semaphore in the wait_event*() condition is no good idea.
+It hits a kernel WARN_ON() at prepare_to_wait_event() like:
+  do not call blocking ops when !TASK_RUNNING; state=1 set at
+  prepare_to_wait_event+0x6d/0x690
+
+For avoiding the potential deadlock, rewrite to an open-coded loop
+instead.  Unlike the loop in wait_event*(), this uses wait_woken()
+after the condition check, hence the task state stays consistent.
+
+CVE-2023-31084 was assigned to this bug.
+
+Link: https://lore.kernel.org/r/CA+UBctCu7fXn4q41O_3=id1+OdyQ85tZY1x+TkT-6OVBL6KAUw@mail.gmail.com/
+
+Link: https://lore.kernel.org/linux-media/20230512151800.1874-1-tiwai@suse.de
+Reported-by: Yu Hao <yhao016@ucr.edu>
+Closes: https://nvd.nist.gov/vuln/detail/CVE-2023-31084
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/dvb-core/dvb_frontend.c | 16 ++++++++++++----
+ 1 file changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
+index b04638321b75b..ad3e42a4eaf73 100644
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -292,14 +292,22 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe,
+       }
+       if (events->eventw == events->eventr) {
+-              int ret;
++              struct wait_queue_entry wait;
++              int ret = 0;
+               if (flags & O_NONBLOCK)
+                       return -EWOULDBLOCK;
+-              ret = wait_event_interruptible(events->wait_queue,
+-                                             dvb_frontend_test_event(fepriv, events));
+-
++              init_waitqueue_entry(&wait, current);
++              add_wait_queue(&events->wait_queue, &wait);
++              while (!dvb_frontend_test_event(fepriv, events)) {
++                      wait_woken(&wait, TASK_INTERRUPTIBLE, 0);
++                      if (signal_pending(current)) {
++                              ret = -ERESTARTSYS;
++                              break;
++                      }
++              }
++              remove_wait_queue(&events->wait_queue, &wait);
+               if (ret < 0)
+                       return ret;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-core-fix-use-after-free-due-on-race-condit.patch b/queue-5.10/media-dvb-core-fix-use-after-free-due-on-race-condit.patch
new file mode 100644 (file)
index 0000000..f65a4d4
--- /dev/null
@@ -0,0 +1,138 @@
+From eb8211c8d4f0a1b94c0b190584c4387348d0fb60 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 17 Nov 2022 04:59:23 +0000
+Subject: media: dvb-core: Fix use-after-free due on race condition at dvb_net
+
+From: Hyunwoo Kim <imv4bel@gmail.com>
+
+[ Upstream commit 4172385b0c9ac366dcab78eda48c26814b87ed1a ]
+
+A race condition may occur between the .disconnect function, which
+is called when the device is disconnected, and the dvb_device_open()
+function, which is called when the device node is open()ed.
+This results in several types of UAFs.
+
+The root cause of this is that you use the dvb_device_open() function,
+which does not implement a conditional statement
+that checks 'dvbnet->exit'.
+
+So, add 'remove_mutex` to protect 'dvbnet->exit' and use
+locked_dvb_net_open() function to check 'dvbnet->exit'.
+
+[mchehab: fix a checkpatch warning]
+
+Link: https://lore.kernel.org/linux-media/20221117045925.14297-3-imv4bel@gmail.com
+Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/dvb-core/dvb_net.c | 38 +++++++++++++++++++++++++++++---
+ include/media/dvb_net.h          |  4 ++++
+ 2 files changed, 39 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
+index dddebea644bb8..c594b1bdfcaa5 100644
+--- a/drivers/media/dvb-core/dvb_net.c
++++ b/drivers/media/dvb-core/dvb_net.c
+@@ -1564,15 +1564,43 @@ static long dvb_net_ioctl(struct file *file,
+       return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
+ }
++static int locked_dvb_net_open(struct inode *inode, struct file *file)
++{
++      struct dvb_device *dvbdev = file->private_data;
++      struct dvb_net *dvbnet = dvbdev->priv;
++      int ret;
++
++      if (mutex_lock_interruptible(&dvbnet->remove_mutex))
++              return -ERESTARTSYS;
++
++      if (dvbnet->exit) {
++              mutex_unlock(&dvbnet->remove_mutex);
++              return -ENODEV;
++      }
++
++      ret = dvb_generic_open(inode, file);
++
++      mutex_unlock(&dvbnet->remove_mutex);
++
++      return ret;
++}
++
+ static int dvb_net_close(struct inode *inode, struct file *file)
+ {
+       struct dvb_device *dvbdev = file->private_data;
+       struct dvb_net *dvbnet = dvbdev->priv;
++      mutex_lock(&dvbnet->remove_mutex);
++
+       dvb_generic_release(inode, file);
+-      if(dvbdev->users == 1 && dvbnet->exit == 1)
++      if (dvbdev->users == 1 && dvbnet->exit == 1) {
++              mutex_unlock(&dvbnet->remove_mutex);
+               wake_up(&dvbdev->wait_queue);
++      } else {
++              mutex_unlock(&dvbnet->remove_mutex);
++      }
++
+       return 0;
+ }
+@@ -1580,7 +1608,7 @@ static int dvb_net_close(struct inode *inode, struct file *file)
+ static const struct file_operations dvb_net_fops = {
+       .owner = THIS_MODULE,
+       .unlocked_ioctl = dvb_net_ioctl,
+-      .open = dvb_generic_open,
++      .open = locked_dvb_net_open,
+       .release = dvb_net_close,
+       .llseek = noop_llseek,
+ };
+@@ -1599,10 +1627,13 @@ void dvb_net_release (struct dvb_net *dvbnet)
+ {
+       int i;
++      mutex_lock(&dvbnet->remove_mutex);
+       dvbnet->exit = 1;
++      mutex_unlock(&dvbnet->remove_mutex);
++
+       if (dvbnet->dvbdev->users < 1)
+               wait_event(dvbnet->dvbdev->wait_queue,
+-                              dvbnet->dvbdev->users==1);
++                              dvbnet->dvbdev->users == 1);
+       dvb_unregister_device(dvbnet->dvbdev);
+@@ -1621,6 +1652,7 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
+       int i;
+       mutex_init(&dvbnet->ioctl_mutex);
++      mutex_init(&dvbnet->remove_mutex);
+       dvbnet->demux = dmx;
+       for (i=0; i<DVB_NET_DEVICES_MAX; i++)
+diff --git a/include/media/dvb_net.h b/include/media/dvb_net.h
+index 5e31d37f25fac..cc01dffcc9f35 100644
+--- a/include/media/dvb_net.h
++++ b/include/media/dvb_net.h
+@@ -41,6 +41,9 @@
+  * @exit:             flag to indicate when the device is being removed.
+  * @demux:            pointer to &struct dmx_demux.
+  * @ioctl_mutex:      protect access to this struct.
++ * @remove_mutex:     mutex that avoids a race condition between a callback
++ *                    called when the hardware is disconnected and the
++ *                    file_operations of dvb_net.
+  *
+  * Currently, the core supports up to %DVB_NET_DEVICES_MAX (10) network
+  * devices.
+@@ -53,6 +56,7 @@ struct dvb_net {
+       unsigned int exit:1;
+       struct dmx_demux *demux;
+       struct mutex ioctl_mutex;
++      struct mutex remove_mutex;
+ };
+ /**
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-core-fix-use-after-free-due-to-race-condit.patch b/queue-5.10/media-dvb-core-fix-use-after-free-due-to-race-condit.patch
new file mode 100644 (file)
index 0000000..5895142
--- /dev/null
@@ -0,0 +1,129 @@
+From 43b1a9a032c8628a2a28a1f25d4581f752a1a01d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 21 Nov 2022 06:33:08 +0000
+Subject: media: dvb-core: Fix use-after-free due to race condition at
+ dvb_ca_en50221
+
+From: Hyunwoo Kim <v4bel@theori.io>
+
+[ Upstream commit 280a8ab81733da8bc442253c700a52c4c0886ffd ]
+
+If the device node of dvb_ca_en50221 is open() and the
+device is disconnected, a UAF may occur when calling
+close() on the device node.
+
+The root cause is that wake_up() and wait_event() for
+dvbdev->wait_queue are not implemented.
+
+So implement wait_event() function in dvb_ca_en50221_release()
+and add 'remove_mutex' which prevents race condition
+for 'ca->exit'.
+
+[mchehab: fix a checkpatch warning]
+
+Link: https://lore.kernel.org/linux-media/20221121063308.GA33821@ubuntu
+Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/dvb-core/dvb_ca_en50221.c | 37 ++++++++++++++++++++++++-
+ 1 file changed, 36 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
+index b1a7b5f8b9aa4..dec036e0336cb 100644
+--- a/drivers/media/dvb-core/dvb_ca_en50221.c
++++ b/drivers/media/dvb-core/dvb_ca_en50221.c
+@@ -151,6 +151,12 @@ struct dvb_ca_private {
+       /* mutex serializing ioctls */
+       struct mutex ioctl_mutex;
++
++      /* A mutex used when a device is disconnected */
++      struct mutex remove_mutex;
++
++      /* Whether the device is disconnected */
++      int exit;
+ };
+ static void dvb_ca_private_free(struct dvb_ca_private *ca)
+@@ -1708,12 +1714,22 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
+       dprintk("%s\n", __func__);
+-      if (!try_module_get(ca->pub->owner))
++      mutex_lock(&ca->remove_mutex);
++
++      if (ca->exit) {
++              mutex_unlock(&ca->remove_mutex);
++              return -ENODEV;
++      }
++
++      if (!try_module_get(ca->pub->owner)) {
++              mutex_unlock(&ca->remove_mutex);
+               return -EIO;
++      }
+       err = dvb_generic_open(inode, file);
+       if (err < 0) {
+               module_put(ca->pub->owner);
++              mutex_unlock(&ca->remove_mutex);
+               return err;
+       }
+@@ -1738,6 +1754,7 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
+       dvb_ca_private_get(ca);
++      mutex_unlock(&ca->remove_mutex);
+       return 0;
+ }
+@@ -1757,6 +1774,8 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
+       dprintk("%s\n", __func__);
++      mutex_lock(&ca->remove_mutex);
++
+       /* mark the CA device as closed */
+       ca->open = 0;
+       dvb_ca_en50221_thread_update_delay(ca);
+@@ -1767,6 +1786,13 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
+       dvb_ca_private_put(ca);
++      if (dvbdev->users == 1 && ca->exit == 1) {
++              mutex_unlock(&ca->remove_mutex);
++              wake_up(&dvbdev->wait_queue);
++      } else {
++              mutex_unlock(&ca->remove_mutex);
++      }
++
+       return err;
+ }
+@@ -1890,6 +1916,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
+       }
+       mutex_init(&ca->ioctl_mutex);
++      mutex_init(&ca->remove_mutex);
+       if (signal_pending(current)) {
+               ret = -EINTR;
+@@ -1932,6 +1959,14 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
+       dprintk("%s\n", __func__);
++      mutex_lock(&ca->remove_mutex);
++      ca->exit = 1;
++      mutex_unlock(&ca->remove_mutex);
++
++      if (ca->dvbdev->users < 1)
++              wait_event(ca->dvbdev->wait_queue,
++                              ca->dvbdev->users == 1);
++
+       /* shutdown the thread if there was one */
+       kthread_stop(ca->thread);
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-usb-az6027-fix-three-null-ptr-deref-in-az6.patch b/queue-5.10/media-dvb-usb-az6027-fix-three-null-ptr-deref-in-az6.patch
new file mode 100644 (file)
index 0000000..21e7b1f
--- /dev/null
@@ -0,0 +1,63 @@
+From 127f0d3888209f1547bfe7c5bceee4aadaf03d20 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Mar 2023 16:56:04 +0000
+Subject: media: dvb-usb: az6027: fix three null-ptr-deref in az6027_i2c_xfer()
+
+From: Wei Chen <harperchen1110@gmail.com>
+
+[ Upstream commit 858e97d7956d17a2cb56a9413468704a4d5abfe1 ]
+
+In az6027_i2c_xfer, msg is controlled by user. When msg[i].buf is null,
+commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in
+az6027_i2c_xfer()") fix the null-ptr-deref bug when msg[i].addr is 0x99.
+However, null-ptr-deref also happens when msg[i].addr is 0xd0 and 0xc0.
+We add check on msg[i].len to prevent null-ptr-deref.
+
+Link: https://lore.kernel.org/linux-media/20230310165604.3093483-1-harperchen1110@gmail.com
+Signed-off-by: Wei Chen <harperchen1110@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb/az6027.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
+index 32b4ee65c2802..991f4510aaebb 100644
+--- a/drivers/media/usb/dvb-usb/az6027.c
++++ b/drivers/media/usb/dvb-usb/az6027.c
+@@ -988,6 +988,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
+                       /* write/read request */
+                       if (i + 1 < num && (msg[i + 1].flags & I2C_M_RD)) {
+                               req = 0xB9;
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff));
+                               value = msg[i].addr + (msg[i].len << 8);
+                               length = msg[i + 1].len + 6;
+@@ -1001,6 +1005,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
+                               /* demod 16bit addr */
+                               req = 0xBD;
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               index = (((msg[i].buf[0] << 8) & 0xff00) | (msg[i].buf[1] & 0x00ff));
+                               value = msg[i].addr + (2 << 8);
+                               length = msg[i].len - 2;
+@@ -1026,6 +1034,10 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n
+                       } else {
+                               req = 0xBD;
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               index = msg[i].buf[0] & 0x00FF;
+                               value = msg[i].addr + (1 << 8);
+                               length = msg[i].len - 1;
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-usb-digitv-fix-null-ptr-deref-in-digitv_i2.patch b/queue-5.10/media-dvb-usb-digitv-fix-null-ptr-deref-in-digitv_i2.patch
new file mode 100644 (file)
index 0000000..cf41008
--- /dev/null
@@ -0,0 +1,44 @@
+From b416401a806928764b08e0532a8bb5c12f46b4bc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Mar 2023 09:50:08 +0000
+Subject: media: dvb-usb: digitv: fix null-ptr-deref in digitv_i2c_xfer()
+
+From: Wei Chen <harperchen1110@gmail.com>
+
+[ Upstream commit 9ded5bd2a49ce3015b7c936743eec0a0e6e11f0c ]
+
+In digitv_i2c_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach digitv_i2c_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen. We add
+check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Link: https://lore.kernel.org/linux-media/20230313095008.1039689-1-harperchen1110@gmail.com
+Signed-off-by: Wei Chen <harperchen1110@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb/digitv.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c
+index 4e3b3c064bcfb..e56efebd4f0a1 100644
+--- a/drivers/media/usb/dvb-usb/digitv.c
++++ b/drivers/media/usb/dvb-usb/digitv.c
+@@ -63,6 +63,10 @@ static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
+               warn("more than 2 i2c messages at a time is not handled yet. TODO.");
+       for (i = 0; i < num; i++) {
++              if (msg[i].len < 1) {
++                      i = -EOPNOTSUPP;
++                      break;
++              }
+               /* write/read request */
+               if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
+                       if (digitv_ctrl_msg(d, USB_READ_COFDM, msg[i].buf[0], NULL, 0,
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-usb-dw2102-fix-uninit-value-in-su3000_read.patch b/queue-5.10/media-dvb-usb-dw2102-fix-uninit-value-in-su3000_read.patch
new file mode 100644 (file)
index 0000000..f36851d
--- /dev/null
@@ -0,0 +1,40 @@
+From 90414eb7c1ffa3da1d77b70474c47ead34c4ea4e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 28 Mar 2023 13:44:16 +0100
+Subject: media: dvb-usb: dw2102: fix uninit-value in su3000_read_mac_address
+
+From: Wei Chen <harperchen1110@gmail.com>
+
+[ Upstream commit a3fd1ef27aa686d871cefe207bd6168c4b0cd29e ]
+
+In su3000_read_mac_address, if i2c_transfer fails to execute two
+messages, array mac address will not be initialized. Without handling
+such error, later in function dvb_usb_adapter_dvb_init, proposed_mac
+is accessed before initialization.
+
+Fix this error by returning a negative value if message execution fails.
+
+Link: https://lore.kernel.org/linux-media/20230328124416.560889-1-harperchen1110@gmail.com
+Signed-off-by: Wei Chen <harperchen1110@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb/dw2102.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
+index aa929db56db1f..3c4ac998d040f 100644
+--- a/drivers/media/usb/dvb-usb/dw2102.c
++++ b/drivers/media/usb/dvb-usb/dw2102.c
+@@ -946,7 +946,7 @@ static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
+       for (i = 0; i < 6; i++) {
+               obuf[1] = 0xf0 + i;
+               if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
+-                      break;
++                      return -1;
+               else
+                       mac[i] = ibuf[0];
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-usb-v2-ce6230-fix-null-ptr-deref-in-ce6230.patch b/queue-5.10/media-dvb-usb-v2-ce6230-fix-null-ptr-deref-in-ce6230.patch
new file mode 100644 (file)
index 0000000..3dec023
--- /dev/null
@@ -0,0 +1,56 @@
+From 8fe5fb511a5bd1f6d5c13d3a55e608beb685b0f0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Mar 2023 09:27:51 +0000
+Subject: media: dvb-usb-v2: ce6230: fix null-ptr-deref in
+ ce6230_i2c_master_xfer()
+
+From: Wei Chen <harperchen1110@gmail.com>
+
+[ Upstream commit dff919090155fb22679869e8469168f270dcd97f ]
+
+In ce6230_i2c_master_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach ce6230_i2c_master_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen. We add
+check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Link: https://lore.kernel.org/linux-media/20230313092751.209496-1-harperchen1110@gmail.com
+Signed-off-by: Wei Chen <harperchen1110@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb-v2/ce6230.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb-v2/ce6230.c b/drivers/media/usb/dvb-usb-v2/ce6230.c
+index 44540de1a2066..d3b5cb4a24daf 100644
+--- a/drivers/media/usb/dvb-usb-v2/ce6230.c
++++ b/drivers/media/usb/dvb-usb-v2/ce6230.c
+@@ -101,6 +101,10 @@ static int ce6230_i2c_master_xfer(struct i2c_adapter *adap,
+               if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
+                       if (msg[i].addr ==
+                               ce6230_zl10353_config.demod_address) {
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               req.cmd = DEMOD_READ;
+                               req.value = msg[i].addr >> 1;
+                               req.index = msg[i].buf[0];
+@@ -117,6 +121,10 @@ static int ce6230_i2c_master_xfer(struct i2c_adapter *adap,
+               } else {
+                       if (msg[i].addr ==
+                               ce6230_zl10353_config.demod_address) {
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               req.cmd = DEMOD_WRITE;
+                               req.value = msg[i].addr >> 1;
+                               req.index = msg[i].buf[0];
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-usb-v2-ec168-fix-null-ptr-deref-in-ec168_i.patch b/queue-5.10/media-dvb-usb-v2-ec168-fix-null-ptr-deref-in-ec168_i.patch
new file mode 100644 (file)
index 0000000..c2d86e3
--- /dev/null
@@ -0,0 +1,65 @@
+From 3572e849e33b95364f340eb86c29e0666ad57393 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Mar 2023 08:58:53 +0000
+Subject: media: dvb-usb-v2: ec168: fix null-ptr-deref in ec168_i2c_xfer()
+
+From: Wei Chen <harperchen1110@gmail.com>
+
+[ Upstream commit a6dcefcc08eca1bf4e3d213c97c3cfb75f377935 ]
+
+In ec168_i2c_xfer, msg is controlled by user. When msg[i].buf is null
+and msg[i].len is zero, former checks on msg[i].buf would be passed.
+If accessing msg[i].buf[0] without sanity check, null pointer deref
+would happen. We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Link: https://lore.kernel.org/linux-media/20230313085853.3252349-1-harperchen1110@gmail.com
+Signed-off-by: Wei Chen <harperchen1110@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb-v2/ec168.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb-v2/ec168.c b/drivers/media/usb/dvb-usb-v2/ec168.c
+index 7ed0ab9e429b1..0e4773fc025c9 100644
+--- a/drivers/media/usb/dvb-usb-v2/ec168.c
++++ b/drivers/media/usb/dvb-usb-v2/ec168.c
+@@ -115,6 +115,10 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+       while (i < num) {
+               if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
+                       if (msg[i].addr == ec168_ec100_config.demod_address) {
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               req.cmd = READ_DEMOD;
+                               req.value = 0;
+                               req.index = 0xff00 + msg[i].buf[0]; /* reg */
+@@ -131,6 +135,10 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                       }
+               } else {
+                       if (msg[i].addr == ec168_ec100_config.demod_address) {
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               req.cmd = WRITE_DEMOD;
+                               req.value = msg[i].buf[1]; /* val */
+                               req.index = 0xff00 + msg[i].buf[0]; /* reg */
+@@ -139,6 +147,10 @@ static int ec168_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                               ret = ec168_ctrl_msg(d, &req);
+                               i += 1;
+                       } else {
++                              if (msg[i].len < 1) {
++                                      i = -EOPNOTSUPP;
++                                      break;
++                              }
+                               req.cmd = WRITE_I2C;
+                               req.value = msg[i].buf[0]; /* val */
+                               req.index = 0x0100 + msg[i].addr; /* I2C addr */
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb-usb-v2-rtl28xxu-fix-null-ptr-deref-in-rtl2.patch b/queue-5.10/media-dvb-usb-v2-rtl28xxu-fix-null-ptr-deref-in-rtl2.patch
new file mode 100644 (file)
index 0000000..4c779ff
--- /dev/null
@@ -0,0 +1,84 @@
+From 7b02069f7320910d68f9dfbbdc7868df0cd0bab8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 7 May 2023 15:52:47 +0100
+Subject: media: dvb-usb-v2: rtl28xxu: fix null-ptr-deref in rtl28xxu_i2c_xfer
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit aa4a447b81b84f69c1a89ad899df157f386d7636 ]
+
+In rtl28xxu_i2c_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach rtl28xxu_i2c_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen.
+We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a
+("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Link: https://lore.kernel.org/linux-media/tencent_3623572106754AC2F266B316798B0F6CCA05@qq.com
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+index c278b9b0f1024..70a2f04942164 100644
+--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
++++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+@@ -176,6 +176,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                       ret = -EOPNOTSUPP;
+                       goto err_mutex_unlock;
+               } else if (msg[0].addr == 0x10) {
++                      if (msg[0].len < 1 || msg[1].len < 1) {
++                              ret = -EOPNOTSUPP;
++                              goto err_mutex_unlock;
++                      }
+                       /* method 1 - integrated demod */
+                       if (msg[0].buf[0] == 0x00) {
+                               /* return demod page from driver cache */
+@@ -189,6 +193,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                               ret = rtl28xxu_ctrl_msg(d, &req);
+                       }
+               } else if (msg[0].len < 2) {
++                      if (msg[0].len < 1) {
++                              ret = -EOPNOTSUPP;
++                              goto err_mutex_unlock;
++                      }
+                       /* method 2 - old I2C */
+                       req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
+                       req.index = CMD_I2C_RD;
+@@ -217,8 +225,16 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                       ret = -EOPNOTSUPP;
+                       goto err_mutex_unlock;
+               } else if (msg[0].addr == 0x10) {
++                      if (msg[0].len < 1) {
++                              ret = -EOPNOTSUPP;
++                              goto err_mutex_unlock;
++                      }
+                       /* method 1 - integrated demod */
+                       if (msg[0].buf[0] == 0x00) {
++                              if (msg[0].len < 2) {
++                                      ret = -EOPNOTSUPP;
++                                      goto err_mutex_unlock;
++                              }
+                               /* save demod page for later demod access */
+                               dev->page = msg[0].buf[1];
+                               ret = 0;
+@@ -231,6 +247,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                               ret = rtl28xxu_ctrl_msg(d, &req);
+                       }
+               } else if ((msg[0].len < 23) && (!dev->new_i2c_write)) {
++                      if (msg[0].len < 1) {
++                              ret = -EOPNOTSUPP;
++                              goto err_mutex_unlock;
++                      }
+                       /* method 2 - old I2C */
+                       req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
+                       req.index = CMD_I2C_WR;
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb_ca_en50221-fix-a-size-write-bug.patch b/queue-5.10/media-dvb_ca_en50221-fix-a-size-write-bug.patch
new file mode 100644 (file)
index 0000000..1e08a57
--- /dev/null
@@ -0,0 +1,118 @@
+From 88808573d3c9a67157a47ffb1d254d6dad5a21be Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 Aug 2022 13:50:27 +0100
+Subject: media: dvb_ca_en50221: fix a size write bug
+
+From: YongSu Yoo <yongsuyoo0215@gmail.com>
+
+[ Upstream commit a4315e5be7020aac9b24a8151caf4bb85224cd0e ]
+
+The function of "dvb_ca_en50221_write_data" at source/drivers/media
+/dvb-core/dvb_ca_en50221.c is used for two cases.
+The first case is for writing APDU data in the function of
+"dvb_ca_en50221_io_write" at source/drivers/media/dvb-core/
+dvb_ca_en50221.c.
+The second case is for writing the host link buf size on the
+Command Register in the function of "dvb_ca_en50221_link_init"
+at source/drivers/media/dvb-core/dvb_ca_en50221.c.
+In the second case, there exists a bug like following.
+In the function of the "dvb_ca_en50221_link_init",
+after a TV host calculates the host link buf_size,
+the TV host writes the calculated host link buf_size on the
+Size Register.
+Accroding to the en50221 Spec (the page 60 of
+https://dvb.org/wp-content/uploads/2020/02/En50221.V1.pdf),
+before this writing operation, the "SW(CMDREG_SW)" flag in the
+Command Register should be set. We can see this setting operation
+in the function of the "dvb_ca_en50221_link_init" like below.
+...
+       if ((ret = ca->pub->write_cam_control(ca->pub, slot,
+CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
+               return ret;
+...
+But, after that, the real writing operation is implemented using
+the function of the "dvb_ca_en50221_write_data" in the function of
+"dvb_ca_en50221_link_init", and the "dvb_ca_en50221_write_data"
+includes the function of "ca->pub->write_cam_control",
+and the function of the "ca->pub->write_cam_control" in the
+function of the "dvb_ca_en50221_wrte_data" does not include
+"CMDREG_SW" flag like below.
+...
+       if ((status = ca->pub->write_cam_control(ca->pub, slot,
+CTRLIF_COMMAND, IRQEN | CMDREG_HC)) != 0)
+...
+In the above source code, we can see only the "IRQEN | CMDREG_HC",
+but we cannot see the "CMDREG_SW".
+The "CMDREG_SW" flag which was set in the function of the
+"dvb_ca_en50221_link_init" was rollbacked by the follwoing function
+of the "dvb_ca_en50221_write_data".
+This is a bug. and this bug causes that the calculated host link buf_size
+is not properly written in the CI module.
+Through this patch, we fix this bug.
+
+Link: https://lore.kernel.org/linux-media/20220818125027.1131-1-yongsuyoo0215@gmail.com
+Signed-off-by: YongSu Yoo <yongsuyoo0215@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/dvb-core/dvb_ca_en50221.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
+index fd476536d32ed..b1a7b5f8b9aa4 100644
+--- a/drivers/media/dvb-core/dvb_ca_en50221.c
++++ b/drivers/media/dvb-core/dvb_ca_en50221.c
+@@ -187,7 +187,7 @@ static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca);
+ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
+                                   u8 *ebuf, int ecount);
+ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
+-                                   u8 *ebuf, int ecount);
++                                   u8 *ebuf, int ecount, int size_write_flag);
+ /**
+  * Safely find needle in haystack.
+@@ -370,7 +370,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
+       ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10);
+       if (ret)
+               return ret;
+-      ret = dvb_ca_en50221_write_data(ca, slot, buf, 2);
++      ret = dvb_ca_en50221_write_data(ca, slot, buf, 2, CMDREG_SW);
+       if (ret != 2)
+               return -EIO;
+       ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
+@@ -778,11 +778,13 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
+  * @buf: The data in this buffer is treated as a complete link-level packet to
+  *     be written.
+  * @bytes_write: Size of ebuf.
++ * @size_write_flag: A flag on Command Register which says whether the link size
++ * information will be writen or not.
+  *
+  * return: Number of bytes written, or < 0 on error.
+  */
+ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
+-                                   u8 *buf, int bytes_write)
++                                   u8 *buf, int bytes_write, int size_write_flag)
+ {
+       struct dvb_ca_slot *sl = &ca->slot_info[slot];
+       int status;
+@@ -817,7 +819,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
+       /* OK, set HC bit */
+       status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
+-                                          IRQEN | CMDREG_HC);
++                                          IRQEN | CMDREG_HC | size_write_flag);
+       if (status)
+               goto exit;
+@@ -1505,7 +1507,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
+                       mutex_lock(&sl->slot_lock);
+                       status = dvb_ca_en50221_write_data(ca, slot, fragbuf,
+-                                                         fraglen + 2);
++                                                         fraglen + 2, 0);
+                       mutex_unlock(&sl->slot_lock);
+                       if (status == (fraglen + 2)) {
+                               written = 1;
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-dvb_demux-fix-a-bug-for-the-continuity-counter.patch b/queue-5.10/media-dvb_demux-fix-a-bug-for-the-continuity-counter.patch
new file mode 100644 (file)
index 0000000..680a619
--- /dev/null
@@ -0,0 +1,65 @@
+From c54cf57ebef65cf1e410c34147ec74c036a17052 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 5 Mar 2023 21:25:19 +0000
+Subject: media: dvb_demux: fix a bug for the continuity counter
+
+From: YongSu Yoo <yongsuyoo0215@gmail.com>
+
+[ Upstream commit 7efb10d8dc70ea3000cc70dca53407c52488acd1 ]
+
+In dvb_demux.c, some logics exist which compare the expected
+continuity counter and the real continuity counter. If they
+are not matched each other, both of the expected continuity
+counter and the real continuity counter should be printed.
+But there exists a bug that the expected continuity counter
+is not correctly printed. The expected continuity counter is
+replaced with the real countinuity counter + 1 so that
+the epected continuity counter is not correclty printed.
+This is wrong. This bug is fixed.
+
+Link: https://lore.kernel.org/linux-media/20230305212519.499-1-yongsuyoo0215@gmail.com
+
+Signed-off-by: YongSu Yoo <yongsuyoo0215@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/dvb-core/dvb_demux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
+index 5fde1d38b3e34..80b495982f63c 100644
+--- a/drivers/media/dvb-core/dvb_demux.c
++++ b/drivers/media/dvb-core/dvb_demux.c
+@@ -125,12 +125,12 @@ static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed,
+       cc = buf[3] & 0x0f;
+       ccok = ((feed->cc + 1) & 0x0f) == cc;
+-      feed->cc = cc;
+       if (!ccok) {
+               set_buf_flags(feed, DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED);
+               dprintk_sect_loss("missed packet: %d instead of %d!\n",
+                                 cc, (feed->cc + 1) & 0x0f);
+       }
++      feed->cc = cc;
+       if (buf[1] & 0x40)      // PUSI ?
+               feed->peslen = 0xfffa;
+@@ -310,7 +310,6 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
+       cc = buf[3] & 0x0f;
+       ccok = ((feed->cc + 1) & 0x0f) == cc;
+-      feed->cc = cc;
+       if (buf[3] & 0x20) {
+               /* adaption field present, check for discontinuity_indicator */
+@@ -346,6 +345,7 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
+               feed->pusi_seen = false;
+               dvb_dmx_swfilter_section_new(feed);
+       }
++      feed->cc = cc;
+       if (buf[1] & 0x40) {
+               /* PUSI=1 (is set), section boundary is here */
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-mn88443x-fix-config_of-error-by-drop-of_match_.patch b/queue-5.10/media-mn88443x-fix-config_of-error-by-drop-of_match_.patch
new file mode 100644 (file)
index 0000000..da64520
--- /dev/null
@@ -0,0 +1,44 @@
+From 106c91a50dfea2d968a1ff5118f992807b319bc6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 12 Mar 2023 13:13:18 +0000
+Subject: media: mn88443x: fix !CONFIG_OF error by drop of_match_ptr from ID
+ table
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+[ Upstream commit ae11c0efaec32fb45130ee9886689f467232eebc ]
+
+The driver will match mostly by DT table (even thought there is regular
+ID table) so there is little benefit in of_match_ptr (this also allows
+ACPI matching via PRP0001, even though it might not be relevant here).
+This also fixes !CONFIG_OF error:
+
+  drivers/media/dvb-frontends/mn88443x.c:782:34: error: ‘mn88443x_of_match’ defined but not used [-Werror=unused-const-variable=]
+
+Link: https://lore.kernel.org/linux-media/20230312131318.351173-28-krzysztof.kozlowski@linaro.org
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/dvb-frontends/mn88443x.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/dvb-frontends/mn88443x.c b/drivers/media/dvb-frontends/mn88443x.c
+index fff212c0bf3b5..05894deb8a19a 100644
+--- a/drivers/media/dvb-frontends/mn88443x.c
++++ b/drivers/media/dvb-frontends/mn88443x.c
+@@ -800,7 +800,7 @@ MODULE_DEVICE_TABLE(i2c, mn88443x_i2c_id);
+ static struct i2c_driver mn88443x_driver = {
+       .driver = {
+               .name = "mn88443x",
+-              .of_match_table = of_match_ptr(mn88443x_of_match),
++              .of_match_table = mn88443x_of_match,
+       },
+       .probe    = mn88443x_probe,
+       .remove   = mn88443x_remove,
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-netup_unidvb-fix-irq-init-by-register-it-at-th.patch b/queue-5.10/media-netup_unidvb-fix-irq-init-by-register-it-at-th.patch
new file mode 100644 (file)
index 0000000..d7fd281
--- /dev/null
@@ -0,0 +1,70 @@
+From 0a33a23b6461b2bbe51f67d522576743c6c2fdae Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Mar 2023 13:45:18 +0000
+Subject: media: netup_unidvb: fix irq init by register it at the end of probe
+
+From: Wei Chen <harperchen1110@gmail.com>
+
+[ Upstream commit e6ad6233592593079db5c8fa592c298e51bc1356 ]
+
+IRQ handler netup_spi_interrupt() takes spinlock spi->lock. The lock
+is initialized in netup_spi_init(). However, irq handler is registered
+before initializing the lock.
+
+Spinlock dma->lock and i2c->lock suffer from the same problem.
+
+Fix this by registering the irq at the end of probe.
+
+Link: https://lore.kernel.org/linux-media/20230315134518.1074497-1-harperchen1110@gmail.com
+Signed-off-by: Wei Chen <harperchen1110@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../media/pci/netup_unidvb/netup_unidvb_core.c  | 17 +++++++++--------
+ 1 file changed, 9 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+index a71814e2772d1..7c5061953ee82 100644
+--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
++++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+@@ -887,12 +887,7 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,
+               ndev->lmmio0, (u32)pci_resource_len(pci_dev, 0),
+               ndev->lmmio1, (u32)pci_resource_len(pci_dev, 1),
+               pci_dev->irq);
+-      if (request_irq(pci_dev->irq, netup_unidvb_isr, IRQF_SHARED,
+-                      "netup_unidvb", pci_dev) < 0) {
+-              dev_err(&pci_dev->dev,
+-                      "%s(): can't get IRQ %d\n", __func__, pci_dev->irq);
+-              goto irq_request_err;
+-      }
++
+       ndev->dma_size = 2 * 188 *
+               NETUP_DMA_BLOCKS_COUNT * NETUP_DMA_PACKETS_COUNT;
+       ndev->dma_virt = dma_alloc_coherent(&pci_dev->dev,
+@@ -933,6 +928,14 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,
+               dev_err(&pci_dev->dev, "netup_unidvb: DMA setup failed\n");
+               goto dma_setup_err;
+       }
++
++      if (request_irq(pci_dev->irq, netup_unidvb_isr, IRQF_SHARED,
++                      "netup_unidvb", pci_dev) < 0) {
++              dev_err(&pci_dev->dev,
++                      "%s(): can't get IRQ %d\n", __func__, pci_dev->irq);
++              goto dma_setup_err;
++      }
++
+       dev_info(&pci_dev->dev,
+               "netup_unidvb: device has been initialized\n");
+       return 0;
+@@ -951,8 +954,6 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,
+       dma_free_coherent(&pci_dev->dev, ndev->dma_size,
+                       ndev->dma_virt, ndev->dma_phys);
+ dma_alloc_err:
+-      free_irq(pci_dev->irq, pci_dev);
+-irq_request_err:
+       iounmap(ndev->lmmio1);
+ pci_bar1_error:
+       iounmap(ndev->lmmio0);
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-rcar-vin-select-correct-interrupt-mode-for-v4l.patch b/queue-5.10/media-rcar-vin-select-correct-interrupt-mode-for-v4l.patch
new file mode 100644 (file)
index 0000000..965c6e3
--- /dev/null
@@ -0,0 +1,49 @@
+From 6f53381633d0d8ce03a7ee02601768cc1c7b8091 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 11 Feb 2023 21:55:34 +0100
+Subject: media: rcar-vin: Select correct interrupt mode for
+ V4L2_FIELD_ALTERNATE
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
+
+[ Upstream commit e10707d5865c90d3dfe4ef589ce02ff4287fef85 ]
+
+When adding proper support for V4L2_FIELD_ALTERNATE it was missed that
+this field format should trigger an interrupt for each field, not just
+for the whole frame. Fix this by marking it as progressive in the
+capture setup, which will then select the correct interrupt mode.
+
+Tested on both Gen2 and Gen3 with the result of a doubling of the frame
+rate for V4L2_FIELD_ALTERNATE. From a PAL video source the frame rate is
+now 50, which is expected for alternate field capture.
+
+Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/platform/rcar-vin/rcar-dma.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
+index 692dea300b0de..63c61c704446b 100644
+--- a/drivers/media/platform/rcar-vin/rcar-dma.c
++++ b/drivers/media/platform/rcar-vin/rcar-dma.c
+@@ -645,11 +645,9 @@ static int rvin_setup(struct rvin_dev *vin)
+       case V4L2_FIELD_SEQ_TB:
+       case V4L2_FIELD_SEQ_BT:
+       case V4L2_FIELD_NONE:
+-              vnmc = VNMC_IM_ODD_EVEN;
+-              progressive = true;
+-              break;
+       case V4L2_FIELD_ALTERNATE:
+               vnmc = VNMC_IM_ODD_EVEN;
++              progressive = true;
+               break;
+       default:
+               vnmc = VNMC_IM_ODD;
+-- 
+2.39.2
+
diff --git a/queue-5.10/media-ttusb-dec-fix-memory-leak-in-ttusb_dec_exit_dv.patch b/queue-5.10/media-ttusb-dec-fix-memory-leak-in-ttusb_dec_exit_dv.patch
new file mode 100644 (file)
index 0000000..05c7211
--- /dev/null
@@ -0,0 +1,43 @@
+From e4d455148f6d637616239467ba390c7438ed8e6c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 17 Nov 2022 04:59:25 +0000
+Subject: media: ttusb-dec: fix memory leak in ttusb_dec_exit_dvb()
+
+From: Hyunwoo Kim <imv4bel@gmail.com>
+
+[ Upstream commit 517a281338322ff8293f988771c98aaa7205e457 ]
+
+Since dvb_frontend_detach() is not called in ttusb_dec_exit_dvb(),
+which is called when the device is disconnected, dvb_frontend_free()
+is not finally called.
+
+This causes a memory leak just by repeatedly plugging and
+unplugging the device.
+
+Fix this issue by adding dvb_frontend_detach() to ttusb_dec_exit_dvb().
+
+Link: https://lore.kernel.org/linux-media/20221117045925.14297-5-imv4bel@gmail.com
+Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/ttusb-dec/ttusb_dec.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
+index df6c5e4a0f058..68f88143c8a6e 100644
+--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
++++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
+@@ -1551,8 +1551,7 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)
+       dvb_dmx_release(&dec->demux);
+       if (dec->fe) {
+               dvb_unregister_frontend(dec->fe);
+-              if (dec->fe->ops.release)
+-                      dec->fe->ops.release(dec->fe);
++              dvb_frontend_detach(dec->fe);
+       }
+       dvb_unregister_adapter(&dec->adapter);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.10/mtd-rawnand-ingenic-fix-empty-stub-helper-definition.patch b/queue-5.10/mtd-rawnand-ingenic-fix-empty-stub-helper-definition.patch
new file mode 100644 (file)
index 0000000..2ef0e4f
--- /dev/null
@@ -0,0 +1,67 @@
+From b333366f085fe504ea8bca066a552eff6046cbdc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 May 2023 22:21:24 +0200
+Subject: mtd: rawnand: ingenic: fix empty stub helper definitions
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit 650a8884a364ff2568b51cde9009cfd43cdae6ad ]
+
+A few functions provide an empty interface definition when
+CONFIG_MTD_NAND_INGENIC_ECC is disabled, but they are accidentally
+defined as global functions in the header:
+
+drivers/mtd/nand/raw/ingenic/ingenic_ecc.h:39:5: error: no previous prototype for 'ingenic_ecc_calculate'
+drivers/mtd/nand/raw/ingenic/ingenic_ecc.h:46:5: error: no previous prototype for 'ingenic_ecc_correct'
+drivers/mtd/nand/raw/ingenic/ingenic_ecc.h:53:6: error: no previous prototype for 'ingenic_ecc_release'
+drivers/mtd/nand/raw/ingenic/ingenic_ecc.h:57:21: error: no previous prototype for 'of_ingenic_ecc_get'
+
+Turn them into 'static inline' definitions instead.
+
+Fixes: 15de8c6efd0e ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Paul Cercueil <paul@crapouillou.net>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20230516202133.559488-1-arnd@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/nand/raw/ingenic/ingenic_ecc.h | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_ecc.h b/drivers/mtd/nand/raw/ingenic/ingenic_ecc.h
+index 2cda439b5e11b..017868f59f222 100644
+--- a/drivers/mtd/nand/raw/ingenic/ingenic_ecc.h
++++ b/drivers/mtd/nand/raw/ingenic/ingenic_ecc.h
+@@ -36,25 +36,25 @@ int ingenic_ecc_correct(struct ingenic_ecc *ecc,
+ void ingenic_ecc_release(struct ingenic_ecc *ecc);
+ struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np);
+ #else /* CONFIG_MTD_NAND_INGENIC_ECC */
+-int ingenic_ecc_calculate(struct ingenic_ecc *ecc,
++static inline int ingenic_ecc_calculate(struct ingenic_ecc *ecc,
+                         struct ingenic_ecc_params *params,
+                         const u8 *buf, u8 *ecc_code)
+ {
+       return -ENODEV;
+ }
+-int ingenic_ecc_correct(struct ingenic_ecc *ecc,
++static inline int ingenic_ecc_correct(struct ingenic_ecc *ecc,
+                       struct ingenic_ecc_params *params, u8 *buf,
+                       u8 *ecc_code)
+ {
+       return -ENODEV;
+ }
+-void ingenic_ecc_release(struct ingenic_ecc *ecc)
++static inline void ingenic_ecc_release(struct ingenic_ecc *ecc)
+ {
+ }
+-struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np)
++static inline struct ingenic_ecc *of_ingenic_ecc_get(struct device_node *np)
+ {
+       return ERR_PTR(-ENODEV);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.10/mtd-rawnand-marvell-don-t-set-the-nand-frequency-sel.patch b/queue-5.10/mtd-rawnand-marvell-don-t-set-the-nand-frequency-sel.patch
new file mode 100644 (file)
index 0000000..cb57303
--- /dev/null
@@ -0,0 +1,44 @@
+From 6cca6181b486b331ad42cc41360776daffb795f6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 May 2023 12:31:53 +1200
+Subject: mtd: rawnand: marvell: don't set the NAND frequency select
+
+From: Chris Packham <chris.packham@alliedtelesis.co.nz>
+
+[ Upstream commit c4d28e30a8d0b979e4029465ab8f312ab6ce2644 ]
+
+marvell_nfc_setup_interface() uses the frequency retrieved from the
+clock associated with the nand interface to determine the timings that
+will be used. By changing the NAND frequency select without reflecting
+this in the clock configuration this means that the timings calculated
+don't correctly meet the requirements of the NAND chip. This hasn't been
+an issue up to now because of a different bug that was stopping the
+timings being updated after they were initially set.
+
+Fixes: b25251414f6e ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
+Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20230525003154.2303012-2-chris.packham@alliedtelesis.co.nz
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/nand/raw/marvell_nand.c | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
+index 9d437f1566ed5..2ef1a5adfcfc1 100644
+--- a/drivers/mtd/nand/raw/marvell_nand.c
++++ b/drivers/mtd/nand/raw/marvell_nand.c
+@@ -2891,10 +2891,6 @@ static int marvell_nfc_init(struct marvell_nfc *nfc)
+               regmap_update_bits(sysctrl_base, GENCONF_CLK_GATING_CTRL,
+                                  GENCONF_CLK_GATING_CTRL_ND_GATE,
+                                  GENCONF_CLK_GATING_CTRL_ND_GATE);
+-
+-              regmap_update_bits(sysctrl_base, GENCONF_ND_CLK_CTRL,
+-                                 GENCONF_ND_CLK_CTRL_EN,
+-                                 GENCONF_ND_CLK_CTRL_EN);
+       }
+       /* Configure the DMA if appropriate */
+-- 
+2.39.2
+
diff --git a/queue-5.10/mtd-rawnand-marvell-ensure-timing-values-are-written.patch b/queue-5.10/mtd-rawnand-marvell-ensure-timing-values-are-written.patch
new file mode 100644 (file)
index 0000000..571b6ad
--- /dev/null
@@ -0,0 +1,43 @@
+From 89582e35e71fe530ef4d7e0bd8967afba1b54f71 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 25 May 2023 12:31:52 +1200
+Subject: mtd: rawnand: marvell: ensure timing values are written
+
+From: Chris Packham <chris.packham@alliedtelesis.co.nz>
+
+[ Upstream commit 8a6f4d346f3bad9c68b4a87701eb3f7978542d57 ]
+
+When new timing values are calculated in marvell_nfc_setup_interface()
+ensure that they will be applied in marvell_nfc_select_target() by
+clearing the selected_chip pointer.
+
+Fixes: b25251414f6e ("mtd: rawnand: marvell: Stop implementing ->select_chip()")
+Suggested-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20230525003154.2303012-1-chris.packham@alliedtelesis.co.nz
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/nand/raw/marvell_nand.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
+index dce35f81e0a55..9d437f1566ed5 100644
+--- a/drivers/mtd/nand/raw/marvell_nand.c
++++ b/drivers/mtd/nand/raw/marvell_nand.c
+@@ -2443,6 +2443,12 @@ static int marvell_nfc_setup_interface(struct nand_chip *chip, int chipnr,
+                       NDTR1_WAIT_MODE;
+       }
++      /*
++       * Reset nfc->selected_chip so the next command will cause the timing
++       * registers to be updated in marvell_nfc_select_target().
++       */
++      nfc->selected_chip = NULL;
++
+       return 0;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.10/nbd-fix-debugfs_create_dir-error-checking.patch b/queue-5.10/nbd-fix-debugfs_create_dir-error-checking.patch
new file mode 100644 (file)
index 0000000..2d7086b
--- /dev/null
@@ -0,0 +1,46 @@
+From dad4a77b50daea110a7c85b92ded6bd60c18105c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 May 2023 17:05:32 +0400
+Subject: nbd: Fix debugfs_create_dir error checking
+
+From: Ivan Orlov <ivan.orlov0322@gmail.com>
+
+[ Upstream commit 4913cfcf014c95f0437db2df1734472fd3e15098 ]
+
+The debugfs_create_dir function returns ERR_PTR in case of error, and the
+only correct way to check if an error occurred is 'IS_ERR' inline function.
+This patch will replace the null-comparison with IS_ERR.
+
+Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
+Link: https://lore.kernel.org/r/20230512130533.98709-1-ivan.orlov0322@gmail.com
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/block/nbd.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
+index dbcd903ba128f..b6940f0a9c905 100644
+--- a/drivers/block/nbd.c
++++ b/drivers/block/nbd.c
+@@ -1624,7 +1624,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd)
+               return -EIO;
+       dir = debugfs_create_dir(nbd_name(nbd), nbd_dbg_dir);
+-      if (!dir) {
++      if (IS_ERR(dir)) {
+               dev_err(nbd_to_dev(nbd), "Failed to create debugfs dir for '%s'\n",
+                       nbd_name(nbd));
+               return -EIO;
+@@ -1650,7 +1650,7 @@ static int nbd_dbg_init(void)
+       struct dentry *dbg_dir;
+       dbg_dir = debugfs_create_dir("nbd", NULL);
+-      if (!dbg_dir)
++      if (IS_ERR(dbg_dir))
+               return -EIO;
+       nbd_dbg_dir = dbg_dir;
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-dsa-mv88e6xxx-increase-wait-after-reset-deactiva.patch b/queue-5.10/net-dsa-mv88e6xxx-increase-wait-after-reset-deactiva.patch
new file mode 100644 (file)
index 0000000..0d0ffd8
--- /dev/null
@@ -0,0 +1,45 @@
+From ee0d0301efb04e27a866dfd3475bdb5e7009484a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 30 May 2023 16:52:23 +0200
+Subject: net: dsa: mv88e6xxx: Increase wait after reset deactivation
+
+From: Andreas Svensson <andreas.svensson@axis.com>
+
+[ Upstream commit 3c27f3d53d588618d81d30d6712459a3cc9489b8 ]
+
+A switch held in reset by default needs to wait longer until we can
+reliably detect it.
+
+An issue was observed when testing on the Marvell 88E6393X (Link Street).
+The driver failed to detect the switch on some upstarts. Increasing the
+wait time after reset deactivation solves this issue.
+
+The updated wait time is now also the same as the wait time in the
+mv88e6xxx_hardware_reset function.
+
+Fixes: 7b75e49de424 ("net: dsa: mv88e6xxx: wait after reset deactivation")
+Signed-off-by: Andreas Svensson <andreas.svensson@axis.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Link: https://lore.kernel.org/r/20230530145223.1223993-1-andreas.svensson@axis.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
+index 321c821876f65..8b2c8546f4c99 100644
+--- a/drivers/net/dsa/mv88e6xxx/chip.c
++++ b/drivers/net/dsa/mv88e6xxx/chip.c
+@@ -5547,7 +5547,7 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
+               goto out;
+       }
+       if (chip->reset)
+-              usleep_range(1000, 2000);
++              usleep_range(10000, 20000);
+       err = mv88e6xxx_detect(chip);
+       if (err)
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-mlx5-fw_tracer-fix-event-handling.patch b/queue-5.10/net-mlx5-fw_tracer-fix-event-handling.patch
new file mode 100644 (file)
index 0000000..a6ec643
--- /dev/null
@@ -0,0 +1,40 @@
+From b8e7fde4f09471d19678c7f252ca295474877d09 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 29 Apr 2023 20:41:41 +0300
+Subject: net/mlx5: fw_tracer, Fix event handling
+
+From: Shay Drory <shayd@nvidia.com>
+
+[ Upstream commit 341a80de2468f481b1f771683709b5649cbfe513 ]
+
+mlx5 driver needs to parse traces with event_id inside the range of
+first_string_trace and num_string_trace. However, mlx5 is parsing all
+events with event_id >= first_string_trace.
+
+Fix it by checking for the correct range.
+
+Fixes: c71ad41ccb0c ("net/mlx5: FW tracer, events handling")
+Signed-off-by: Shay Drory <shayd@nvidia.com>
+Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
+Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c b/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
+index 0a011a41c039e..5273644fb2bf9 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
+@@ -483,7 +483,7 @@ static void poll_trace(struct mlx5_fw_tracer *tracer,
+                               (u64)timestamp_low;
+               break;
+       default:
+-              if (tracer_event->event_id >= tracer->str_db.first_string_trace ||
++              if (tracer_event->event_id >= tracer->str_db.first_string_trace &&
+                   tracer_event->event_id <= tracer->str_db.first_string_trace +
+                                             tracer->str_db.num_string_trace) {
+                       tracer_event->type = TRACER_EVENT_TYPE_STRING;
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-mlx5-read-embedded-cpu-after-init-bit-cleared.patch b/queue-5.10/net-mlx5-read-embedded-cpu-after-init-bit-cleared.patch
new file mode 100644 (file)
index 0000000..e731e57
--- /dev/null
@@ -0,0 +1,48 @@
+From c44b818ce43a76f732ecc1f65435a37fb7e83fa4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 28 Apr 2023 13:48:13 +0300
+Subject: net/mlx5: Read embedded cpu after init bit cleared
+
+From: Moshe Shemesh <moshe@nvidia.com>
+
+[ Upstream commit bbfa4b58997e3d38ba629c9f6fc0bd1c163aaf43 ]
+
+During driver load it reads embedded_cpu bit from initialization
+segment, but the initialization segment is readable only after
+initialization bit is cleared.
+
+Move the call to mlx5_read_embedded_cpu() right after initialization bit
+cleared.
+
+Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
+Fixes: 591905ba9679 ("net/mlx5: Introduce Mellanox SmartNIC and modify page management logic")
+Reviewed-by: Shay Drory <shayd@nvidia.com>
+Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
+index da4ca0f67e9ce..22907f6364f54 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
+@@ -783,7 +783,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev,
+       }
+       mlx5_pci_vsc_init(dev);
+-      dev->caps.embedded_cpu = mlx5_read_embedded_cpu(dev);
+       return 0;
+ err_clr_master:
+@@ -978,6 +977,7 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot)
+               goto err_cmd_cleanup;
+       }
++      dev->caps.embedded_cpu = mlx5_read_embedded_cpu(dev);
+       mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_UP);
+       err = mlx5_core_enable_hca(dev, 0);
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-netlink-fix-netlink_list_memberships-length-repo.patch b/queue-5.10/net-netlink-fix-netlink_list_memberships-length-repo.patch
new file mode 100644 (file)
index 0000000..6dfe9d7
--- /dev/null
@@ -0,0 +1,40 @@
+From db8e0e2f40eca8a00eb25356057e92d3f6273864 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 May 2023 12:33:35 -0300
+Subject: net/netlink: fix NETLINK_LIST_MEMBERSHIPS length report
+
+From: Pedro Tammela <pctammela@mojatatu.com>
+
+[ Upstream commit f4e4534850a9d18c250a93f8d7fbb51310828110 ]
+
+The current code for the length calculation wrongly truncates the reported
+length of the groups array, causing an under report of the subscribed
+groups. To fix this, use 'BITS_TO_BYTES()' which rounds up the
+division by 8.
+
+Fixes: b42be38b2778 ("netlink: add API to retrieve all group memberships")
+Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Link: https://lore.kernel.org/r/20230529153335.389815-1-pctammela@mojatatu.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netlink/af_netlink.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
+index 651f8ca912af0..99c869d8d3044 100644
+--- a/net/netlink/af_netlink.c
++++ b/net/netlink/af_netlink.c
+@@ -1781,7 +1781,7 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
+                               break;
+                       }
+               }
+-              if (put_user(ALIGN(nlk->ngroups / 8, sizeof(u32)), optlen))
++              if (put_user(ALIGN(BITS_TO_BYTES(nlk->ngroups), sizeof(u32)), optlen))
+                       err = -EFAULT;
+               netlink_unlock_table();
+               return err;
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-sched-fix-null-pointer-dereference-in-mq_attach.patch b/queue-5.10/net-sched-fix-null-pointer-dereference-in-mq_attach.patch
new file mode 100644 (file)
index 0000000..8b96802
--- /dev/null
@@ -0,0 +1,93 @@
+From 709786c894866d5ec34e23b9386262a6e88806c3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 May 2023 17:37:47 +0800
+Subject: net: sched: fix NULL pointer dereference in mq_attach
+
+From: Zhengchao Shao <shaozhengchao@huawei.com>
+
+[ Upstream commit 36eec020fab668719b541f34d97f44e232ffa165 ]
+
+When use the following command to test:
+1)ip link add bond0 type bond
+2)ip link set bond0 up
+3)tc qdisc add dev bond0 root handle ffff: mq
+4)tc qdisc replace dev bond0 parent ffff:fff1 handle ffff: mq
+
+The kernel reports NULL pointer dereference issue. The stack information
+is as follows:
+Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
+Internal error: Oops: 0000000096000006 [#1] SMP
+Modules linked in:
+pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
+pc : mq_attach+0x44/0xa0
+lr : qdisc_graft+0x20c/0x5cc
+sp : ffff80000e2236a0
+x29: ffff80000e2236a0 x28: ffff0000c0e59d80 x27: ffff0000c0be19c0
+x26: ffff0000cae3e800 x25: 0000000000000010 x24: 00000000fffffff1
+x23: 0000000000000000 x22: ffff0000cae3e800 x21: ffff0000c9df4000
+x20: ffff0000c9df4000 x19: 0000000000000000 x18: ffff80000a934000
+x17: ffff8000f5b56000 x16: ffff80000bb08000 x15: 0000000000000000
+x14: 0000000000000000 x13: 6b6b6b6b6b6b6b6b x12: 6b6b6b6b00000001
+x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000
+x8 : ffff0000c0be0730 x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000008
+x5 : ffff0000cae3e864 x4 : 0000000000000000 x3 : 0000000000000001
+x2 : 0000000000000001 x1 : ffff8000090bc23c x0 : 0000000000000000
+Call trace:
+mq_attach+0x44/0xa0
+qdisc_graft+0x20c/0x5cc
+tc_modify_qdisc+0x1c4/0x664
+rtnetlink_rcv_msg+0x354/0x440
+netlink_rcv_skb+0x64/0x144
+rtnetlink_rcv+0x28/0x34
+netlink_unicast+0x1e8/0x2a4
+netlink_sendmsg+0x308/0x4a0
+sock_sendmsg+0x64/0xac
+____sys_sendmsg+0x29c/0x358
+___sys_sendmsg+0x90/0xd0
+__sys_sendmsg+0x7c/0xd0
+__arm64_sys_sendmsg+0x2c/0x38
+invoke_syscall+0x54/0x114
+el0_svc_common.constprop.1+0x90/0x174
+do_el0_svc+0x3c/0xb0
+el0_svc+0x24/0xec
+el0t_64_sync_handler+0x90/0xb4
+el0t_64_sync+0x174/0x178
+
+This is because when mq is added for the first time, qdiscs in mq is set
+to NULL in mq_attach(). Therefore, when replacing mq after adding mq, we
+need to initialize qdiscs in the mq before continuing to graft. Otherwise,
+it will couse NULL pointer dereference issue in mq_attach(). And the same
+issue will occur in the attach functions of mqprio, taprio and htb.
+ffff:fff1 means that the repalce qdisc is ingress. Ingress does not allow
+any qdisc to be attached. Therefore, ffff:fff1 is incorrectly used, and
+the command should be dropped.
+
+Fixes: 6ec1c69a8f64 ("net_sched: add classful multiqueue dummy scheduler")
+Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
+Tested-by: Peilin Ye <peilin.ye@bytedance.com>
+Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Link: https://lore.kernel.org/r/20230527093747.3583502-1-shaozhengchao@huawei.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_api.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
+index b330f1192cf8d..2084724c36ad3 100644
+--- a/net/sched/sch_api.c
++++ b/net/sched/sch_api.c
+@@ -1599,6 +1599,10 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
+                                       NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected");
+                                       return -ELOOP;
+                               }
++                              if (clid == TC_H_INGRESS) {
++                                      NL_SET_ERR_MSG(extack, "Ingress cannot graft directly");
++                                      return -EINVAL;
++                              }
+                               qdisc_refcount_inc(q);
+                               goto graft;
+                       } else {
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-sched-flower-fix-possible-oob-write-in-fl_set_ge.patch b/queue-5.10/net-sched-flower-fix-possible-oob-write-in-fl_set_ge.patch
new file mode 100644 (file)
index 0000000..038f574
--- /dev/null
@@ -0,0 +1,43 @@
+From a920c5d35a36acaabf19f6d45e80f13c4f1857ef Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 31 May 2023 18:28:04 +0800
+Subject: net/sched: flower: fix possible OOB write in fl_set_geneve_opt()
+
+From: Hangyu Hua <hbh25y@gmail.com>
+
+[ Upstream commit 4d56304e5827c8cc8cc18c75343d283af7c4825c ]
+
+If we send two TCA_FLOWER_KEY_ENC_OPTS_GENEVE packets and their total
+size is 252 bytes(key->enc_opts.len = 252) then
+key->enc_opts.len = opt->length = data_len / 4 = 0 when the third
+TCA_FLOWER_KEY_ENC_OPTS_GENEVE packet enters fl_set_geneve_opt. This
+bypasses the next bounds check and results in an out-of-bounds.
+
+Fixes: 0a6e77784f49 ("net/sched: allow flower to match tunnel options")
+Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
+Link: https://lore.kernel.org/r/20230531102805.27090-1-hbh25y@gmail.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/cls_flower.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
+index 35ee6d8226e61..caf1a05bfbde4 100644
+--- a/net/sched/cls_flower.c
++++ b/net/sched/cls_flower.c
+@@ -1086,6 +1086,9 @@ static int fl_set_geneve_opt(const struct nlattr *nla, struct fl_flow_key *key,
+       if (option_len > sizeof(struct geneve_opt))
+               data_len = option_len - sizeof(struct geneve_opt);
++      if (key->enc_opts.len > FLOW_DIS_TUN_OPTS_MAX - 4)
++              return -ERANGE;
++
+       opt = (struct geneve_opt *)&key->enc_opts.data[key->enc_opts.len];
+       memset(opt, 0xff, option_len);
+       opt->length = data_len / 4;
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-sched-prohibit-regrafting-ingress-or-clsact-qdis.patch b/queue-5.10/net-sched-prohibit-regrafting-ingress-or-clsact-qdis.patch
new file mode 100644 (file)
index 0000000..ff6cb90
--- /dev/null
@@ -0,0 +1,60 @@
+From 960eabc81ccc7abbae19c5c875812c44709bb8ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 May 2023 12:54:26 -0700
+Subject: net/sched: Prohibit regrafting ingress or clsact Qdiscs
+
+From: Peilin Ye <peilin.ye@bytedance.com>
+
+[ Upstream commit 9de95df5d15baa956c2b70b9e794842e790a8a13 ]
+
+Currently, after creating an ingress (or clsact) Qdisc and grafting it
+under TC_H_INGRESS (TC_H_CLSACT), it is possible to graft it again under
+e.g. a TBF Qdisc:
+
+  $ ip link add ifb0 type ifb
+  $ tc qdisc add dev ifb0 handle 1: root tbf rate 20kbit buffer 1600 limit 3000
+  $ tc qdisc add dev ifb0 clsact
+  $ tc qdisc link dev ifb0 handle ffff: parent 1:1
+  $ tc qdisc show dev ifb0
+  qdisc tbf 1: root refcnt 2 rate 20Kbit burst 1600b lat 560.0ms
+  qdisc clsact ffff: parent ffff:fff1 refcnt 2
+                                      ^^^^^^^^
+
+clsact's refcount has increased: it is now grafted under both
+TC_H_CLSACT and 1:1.
+
+ingress and clsact Qdiscs should only be used under TC_H_INGRESS
+(TC_H_CLSACT).  Prohibit regrafting them.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Fixes: 1f211a1b929c ("net, sched: add clsact qdisc")
+Tested-by: Pedro Tammela <pctammela@mojatatu.com>
+Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
+Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_api.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
+index b665f4ff49a60..b330f1192cf8d 100644
+--- a/net/sched/sch_api.c
++++ b/net/sched/sch_api.c
+@@ -1589,6 +1589,11 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
+                                       NL_SET_ERR_MSG(extack, "Invalid qdisc name");
+                                       return -EINVAL;
+                               }
++                              if (q->flags & TCQ_F_INGRESS) {
++                                      NL_SET_ERR_MSG(extack,
++                                                     "Cannot regraft ingress or clsact Qdiscs");
++                                      return -EINVAL;
++                              }
+                               if (q == p ||
+                                   (p && check_loop(q, p, 0))) {
+                                       NL_SET_ERR_MSG(extack, "Qdisc parent/child loop detected");
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-sched-reserve-tc_h_ingress-tc_h_clsact-for-ingre.patch b/queue-5.10/net-sched-reserve-tc_h_ingress-tc_h_clsact-for-ingre.patch
new file mode 100644 (file)
index 0000000..acf4bf9
--- /dev/null
@@ -0,0 +1,87 @@
+From b7754b09822f0cd0d558da98050078b8b56f046a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 May 2023 12:54:03 -0700
+Subject: net/sched: Reserve TC_H_INGRESS (TC_H_CLSACT) for ingress (clsact)
+ Qdiscs
+
+From: Peilin Ye <peilin.ye@bytedance.com>
+
+[ Upstream commit f85fa45d4a9408d98c46c8fa45ba2e3b2f4bf219 ]
+
+Currently it is possible to add e.g. an HTB Qdisc under ffff:fff1
+(TC_H_INGRESS, TC_H_CLSACT):
+
+  $ ip link add name ifb0 type ifb
+  $ tc qdisc add dev ifb0 parent ffff:fff1 htb
+  $ tc qdisc add dev ifb0 clsact
+  Error: Exclusivity flag on, cannot modify.
+  $ drgn
+  ...
+  >>> ifb0 = netdev_get_by_name(prog, "ifb0")
+  >>> qdisc = ifb0.ingress_queue.qdisc_sleeping
+  >>> print(qdisc.ops.id.string_().decode())
+  htb
+  >>> qdisc.flags.value_() # TCQ_F_INGRESS
+  2
+
+Only allow ingress and clsact Qdiscs under ffff:fff1.  Return -EINVAL
+for everything else.  Make TCQ_F_INGRESS a static flag of ingress and
+clsact Qdiscs.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Fixes: 1f211a1b929c ("net, sched: add clsact qdisc")
+Tested-by: Pedro Tammela <pctammela@mojatatu.com>
+Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
+Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_api.c     | 7 ++++++-
+ net/sched/sch_ingress.c | 4 ++--
+ 2 files changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
+index 54e2309315eb5..b665f4ff49a60 100644
+--- a/net/sched/sch_api.c
++++ b/net/sched/sch_api.c
+@@ -1223,7 +1223,12 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
+       sch->parent = parent;
+       if (handle == TC_H_INGRESS) {
+-              sch->flags |= TCQ_F_INGRESS;
++              if (!(sch->flags & TCQ_F_INGRESS)) {
++                      NL_SET_ERR_MSG(extack,
++                                     "Specified parent ID is reserved for ingress and clsact Qdiscs");
++                      err = -EINVAL;
++                      goto err_out3;
++              }
+               handle = TC_H_MAKE(TC_H_INGRESS, 0);
+       } else {
+               if (handle == 0) {
+diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
+index 35963929e1178..e43a454993723 100644
+--- a/net/sched/sch_ingress.c
++++ b/net/sched/sch_ingress.c
+@@ -140,7 +140,7 @@ static struct Qdisc_ops ingress_qdisc_ops __read_mostly = {
+       .cl_ops                 =       &ingress_class_ops,
+       .id                     =       "ingress",
+       .priv_size              =       sizeof(struct ingress_sched_data),
+-      .static_flags           =       TCQ_F_CPUSTATS,
++      .static_flags           =       TCQ_F_INGRESS | TCQ_F_CPUSTATS,
+       .init                   =       ingress_init,
+       .destroy                =       ingress_destroy,
+       .dump                   =       ingress_dump,
+@@ -281,7 +281,7 @@ static struct Qdisc_ops clsact_qdisc_ops __read_mostly = {
+       .cl_ops                 =       &clsact_class_ops,
+       .id                     =       "clsact",
+       .priv_size              =       sizeof(struct clsact_sched_data),
+-      .static_flags           =       TCQ_F_CPUSTATS,
++      .static_flags           =       TCQ_F_INGRESS | TCQ_F_CPUSTATS,
+       .init                   =       clsact_init,
+       .destroy                =       clsact_destroy,
+       .dump                   =       ingress_dump,
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-sched-sch_clsact-only-create-under-tc_h_clsact.patch b/queue-5.10/net-sched-sch_clsact-only-create-under-tc_h_clsact.patch
new file mode 100644 (file)
index 0000000..adf6e14
--- /dev/null
@@ -0,0 +1,52 @@
+From c0e9b23273a3f5aad51c5541f798f7f4c1f7b43a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 May 2023 12:53:21 -0700
+Subject: net/sched: sch_clsact: Only create under TC_H_CLSACT
+
+From: Peilin Ye <peilin.ye@bytedance.com>
+
+[ Upstream commit 5eeebfe6c493192b10d516abfd72742900f2a162 ]
+
+clsact Qdiscs are only supposed to be created under TC_H_CLSACT (which
+equals TC_H_INGRESS).  Return -EOPNOTSUPP if 'parent' is not
+TC_H_CLSACT.
+
+Fixes: 1f211a1b929c ("net, sched: add clsact qdisc")
+Tested-by: Pedro Tammela <pctammela@mojatatu.com>
+Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
+Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_ingress.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
+index f9ef6deb27709..35963929e1178 100644
+--- a/net/sched/sch_ingress.c
++++ b/net/sched/sch_ingress.c
+@@ -225,6 +225,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
+       struct net_device *dev = qdisc_dev(sch);
+       int err;
++      if (sch->parent != TC_H_CLSACT)
++              return -EOPNOTSUPP;
++
+       net_inc_ingress_queue();
+       net_inc_egress_queue();
+@@ -254,6 +257,9 @@ static void clsact_destroy(struct Qdisc *sch)
+ {
+       struct clsact_sched_data *q = qdisc_priv(sch);
++      if (sch->parent != TC_H_CLSACT)
++              return;
++
+       tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info);
+       tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
+-- 
+2.39.2
+
diff --git a/queue-5.10/net-sched-sch_ingress-only-create-under-tc_h_ingress.patch b/queue-5.10/net-sched-sch_ingress-only-create-under-tc_h_ingress.patch
new file mode 100644 (file)
index 0000000..1a3f859
--- /dev/null
@@ -0,0 +1,54 @@
+From a57d971694115397daa34a999e9898cac31e42e3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 29 May 2023 12:52:55 -0700
+Subject: net/sched: sch_ingress: Only create under TC_H_INGRESS
+
+From: Peilin Ye <peilin.ye@bytedance.com>
+
+[ Upstream commit c7cfbd115001f94de9e4053657946a383147e803 ]
+
+ingress Qdiscs are only supposed to be created under TC_H_INGRESS.
+Return -EOPNOTSUPP if 'parent' is not TC_H_INGRESS, similar to
+mq_init().
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Reported-by: syzbot+b53a9c0d1ea4ad62da8b@syzkaller.appspotmail.com
+Closes: https://lore.kernel.org/r/0000000000006cf87705f79acf1a@google.com/
+Tested-by: Pedro Tammela <pctammela@mojatatu.com>
+Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
+Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_ingress.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
+index 84838128b9c5b..f9ef6deb27709 100644
+--- a/net/sched/sch_ingress.c
++++ b/net/sched/sch_ingress.c
+@@ -80,6 +80,9 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,
+       struct net_device *dev = qdisc_dev(sch);
+       int err;
++      if (sch->parent != TC_H_INGRESS)
++              return -EOPNOTSUPP;
++
+       net_inc_ingress_queue();
+       mini_qdisc_pair_init(&q->miniqp, sch, &dev->miniq_ingress);
+@@ -101,6 +104,9 @@ static void ingress_destroy(struct Qdisc *sch)
+ {
+       struct ingress_sched_data *q = qdisc_priv(sch);
++      if (sch->parent != TC_H_INGRESS)
++              return;
++
+       tcf_block_put_ext(q->block, sch, &q->block_info);
+       net_dec_ingress_queue();
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.10/netfilter-conntrack-define-variables-exp_nat_nla_pol.patch b/queue-5.10/netfilter-conntrack-define-variables-exp_nat_nla_pol.patch
new file mode 100644 (file)
index 0000000..8cb44ea
--- /dev/null
@@ -0,0 +1,63 @@
+From c627712eac0abb5ba364174fda0cc004a5cbab3d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 14 May 2023 10:00:10 -0400
+Subject: netfilter: conntrack: define variables exp_nat_nla_policy and
+ any_addr with CONFIG_NF_NAT
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Tom Rix <trix@redhat.com>
+
+[ Upstream commit 224a876e37543eee111bf9b6aa4935080e619335 ]
+
+gcc with W=1 and ! CONFIG_NF_NAT
+net/netfilter/nf_conntrack_netlink.c:3463:32: error:
+  ‘exp_nat_nla_policy’ defined but not used [-Werror=unused-const-variable=]
+ 3463 | static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX+1] = {
+      |                                ^~~~~~~~~~~~~~~~~~
+net/netfilter/nf_conntrack_netlink.c:2979:33: error:
+  ‘any_addr’ defined but not used [-Werror=unused-const-variable=]
+ 2979 | static const union nf_inet_addr any_addr;
+      |                                 ^~~~~~~~
+
+These variables use is controlled by CONFIG_NF_NAT, so should their definitions.
+
+Signed-off-by: Tom Rix <trix@redhat.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_conntrack_netlink.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
+index 6a055a2216831..ceb7c988edefa 100644
+--- a/net/netfilter/nf_conntrack_netlink.c
++++ b/net/netfilter/nf_conntrack_netlink.c
+@@ -2968,7 +2968,9 @@ static int ctnetlink_exp_dump_mask(struct sk_buff *skb,
+       return -1;
+ }
++#if IS_ENABLED(CONFIG_NF_NAT)
+ static const union nf_inet_addr any_addr;
++#endif
+ static __be32 nf_expect_get_id(const struct nf_conntrack_expect *exp)
+ {
+@@ -3458,10 +3460,12 @@ ctnetlink_change_expect(struct nf_conntrack_expect *x,
+       return 0;
+ }
++#if IS_ENABLED(CONFIG_NF_NAT)
+ static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX+1] = {
+       [CTA_EXPECT_NAT_DIR]    = { .type = NLA_U32 },
+       [CTA_EXPECT_NAT_TUPLE]  = { .type = NLA_NESTED },
+ };
++#endif
+ static int
+ ctnetlink_parse_expect_nat(const struct nlattr *attr,
+-- 
+2.39.2
+
diff --git a/queue-5.10/netrom-fix-info-leak-in-nr_write_internal.patch b/queue-5.10/netrom-fix-info-leak-in-nr_write_internal.patch
new file mode 100644 (file)
index 0000000..3ba8d1f
--- /dev/null
@@ -0,0 +1,85 @@
+From c34245646563bbd1cdd6a97ea0bbf1aa3876bc68 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 24 May 2023 14:14:56 +0000
+Subject: netrom: fix info-leak in nr_write_internal()
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 31642e7089df8fd3f54ca7843f7ee2952978cad1 ]
+
+Simon Kapadia reported the following issue:
+
+<quote>
+
+The Online Amateur Radio Community (OARC) has recently been experimenting
+with building a nationwide packet network in the UK.
+As part of our experimentation, we have been testing out packet on 300bps HF,
+and playing with net/rom.  For HF packet at this baud rate you really need
+to make sure that your MTU is relatively low; AX.25 suggests a PACLEN of 60,
+and a net/rom PACLEN of 40 to go with that.
+However the Linux net/rom support didn't work with a low PACLEN;
+the mkiss module would truncate packets if you set the PACLEN below about 200 or so, e.g.:
+
+Apr 19 14:00:51 radio kernel: [12985.747310] mkiss: ax1: truncating oversized transmit packet!
+
+This didn't make any sense to me (if the packets are smaller why would they
+be truncated?) so I started investigating.
+I looked at the packets using ethereal, and found that many were just huge
+compared to what I would expect.
+A simple net/rom connection request packet had the request and then a bunch
+of what appeared to be random data following it:
+
+</quote>
+
+Simon provided a patch that I slightly revised:
+Not only we must not use skb_tailroom(), we also do
+not want to count NR_NETWORK_LEN twice.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Co-Developed-by: Simon Kapadia <szymon@kapadia.pl>
+Signed-off-by: Simon Kapadia <szymon@kapadia.pl>
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Tested-by: Simon Kapadia <szymon@kapadia.pl>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Link: https://lore.kernel.org/r/20230524141456.1045467-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netrom/nr_subr.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c
+index 3f99b432ea707..e2d2af924cff4 100644
+--- a/net/netrom/nr_subr.c
++++ b/net/netrom/nr_subr.c
+@@ -123,7 +123,7 @@ void nr_write_internal(struct sock *sk, int frametype)
+       unsigned char  *dptr;
+       int len, timeout;
+-      len = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
++      len = NR_TRANSPORT_LEN;
+       switch (frametype & 0x0F) {
+       case NR_CONNREQ:
+@@ -141,7 +141,8 @@ void nr_write_internal(struct sock *sk, int frametype)
+               return;
+       }
+-      if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)
++      skb = alloc_skb(NR_NETWORK_LEN + len, GFP_ATOMIC);
++      if (!skb)
+               return;
+       /*
+@@ -149,7 +150,7 @@ void nr_write_internal(struct sock *sk, int frametype)
+        */
+       skb_reserve(skb, NR_NETWORK_LEN);
+-      dptr = skb_put(skb, skb_tailroom(skb));
++      dptr = skb_put(skb, len);
+       switch (frametype & 0x0F) {
+       case NR_CONNREQ:
+-- 
+2.39.2
+
diff --git a/queue-5.10/rdma-bnxt_re-code-refactor-while-populating-user-mrs.patch b/queue-5.10/rdma-bnxt_re-code-refactor-while-populating-user-mrs.patch
new file mode 100644 (file)
index 0000000..e29346a
--- /dev/null
@@ -0,0 +1,213 @@
+From 7fdfe49e4fd3a3288b78190b028afd4440d6f74e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 7 Jan 2021 01:43:27 -0800
+Subject: RDMA/bnxt_re: Code refactor while populating user MRs
+
+From: Selvin Xavier <selvin.xavier@broadcom.com>
+
+[ Upstream commit f6919d56388c95dba2e630670a77c380e4616c50 ]
+
+Refactor code that populates MR page buffer list. Instead of allocating a
+pbl_tbl to hold the buffer list, pass the struct ib_umem directly to
+bnxt_qplib_alloc_init_hwq() as done for other user space memories.  Fix
+the PBL level to handle the above mentioned change.
+
+Also, remove an unwanted flag from the input to bnxt_qplib_reg_mr()
+function.
+
+Link: https://lore.kernel.org/r/1610012608-14528-2-git-send-email-selvin.xavier@broadcom.com
+Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
+Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Stable-dep-of: 08c7f09356e4 ("RDMA/bnxt_re: Fix the page_size used during the MR creation")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/hw/bnxt_re/ib_verbs.c | 41 ++++--------------------
+ drivers/infiniband/hw/bnxt_re/qplib_sp.c | 17 ++++------
+ drivers/infiniband/hw/bnxt_re/qplib_sp.h |  2 +-
+ 3 files changed, 13 insertions(+), 47 deletions(-)
+
+diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+index 10d77f50f818b..85fecb432aa00 100644
+--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
++++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+@@ -469,7 +469,6 @@ static int bnxt_re_create_fence_mr(struct bnxt_re_pd *pd)
+       struct bnxt_re_mr *mr = NULL;
+       dma_addr_t dma_addr = 0;
+       struct ib_mw *mw;
+-      u64 pbl_tbl;
+       int rc;
+       dma_addr = dma_map_single(dev, fence->va, BNXT_RE_FENCE_BYTES,
+@@ -504,9 +503,8 @@ static int bnxt_re_create_fence_mr(struct bnxt_re_pd *pd)
+       mr->ib_mr.lkey = mr->qplib_mr.lkey;
+       mr->qplib_mr.va = (u64)(unsigned long)fence->va;
+       mr->qplib_mr.total_size = BNXT_RE_FENCE_BYTES;
+-      pbl_tbl = dma_addr;
+-      rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mr->qplib_mr, &pbl_tbl,
+-                             BNXT_RE_FENCE_PBL_SIZE, false, PAGE_SIZE);
++      rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mr->qplib_mr, NULL,
++                             BNXT_RE_FENCE_PBL_SIZE, PAGE_SIZE);
+       if (rc) {
+               ibdev_err(&rdev->ibdev, "Failed to register fence-MR\n");
+               goto fail;
+@@ -3588,7 +3586,6 @@ struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *ib_pd, int mr_access_flags)
+       struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
+       struct bnxt_re_dev *rdev = pd->rdev;
+       struct bnxt_re_mr *mr;
+-      u64 pbl = 0;
+       int rc;
+       mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+@@ -3607,7 +3604,7 @@ struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *ib_pd, int mr_access_flags)
+       mr->qplib_mr.hwq.level = PBL_LVL_MAX;
+       mr->qplib_mr.total_size = -1; /* Infinte length */
+-      rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mr->qplib_mr, &pbl, 0, false,
++      rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mr->qplib_mr, NULL, 0,
+                              PAGE_SIZE);
+       if (rc)
+               goto fail_mr;
+@@ -3778,19 +3775,6 @@ int bnxt_re_dealloc_mw(struct ib_mw *ib_mw)
+       return rc;
+ }
+-static int fill_umem_pbl_tbl(struct ib_umem *umem, u64 *pbl_tbl_orig,
+-                           int page_shift)
+-{
+-      u64 *pbl_tbl = pbl_tbl_orig;
+-      u64 page_size =  BIT_ULL(page_shift);
+-      struct ib_block_iter biter;
+-
+-      rdma_umem_for_each_dma_block(umem, &biter, page_size)
+-              *pbl_tbl++ = rdma_block_iter_dma_address(&biter);
+-
+-      return pbl_tbl - pbl_tbl_orig;
+-}
+-
+ /* uverbs */
+ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
+                                 u64 virt_addr, int mr_access_flags,
+@@ -3800,7 +3784,6 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
+       struct bnxt_re_dev *rdev = pd->rdev;
+       struct bnxt_re_mr *mr;
+       struct ib_umem *umem;
+-      u64 *pbl_tbl = NULL;
+       unsigned long page_size;
+       int umem_pgs, rc;
+@@ -3854,30 +3837,18 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length,
+       }
+       umem_pgs = ib_umem_num_dma_blocks(umem, page_size);
+-      pbl_tbl = kcalloc(umem_pgs, sizeof(*pbl_tbl), GFP_KERNEL);
+-      if (!pbl_tbl) {
+-              rc = -ENOMEM;
+-              goto free_umem;
+-      }
+-
+-      /* Map umem buf ptrs to the PBL */
+-      umem_pgs = fill_umem_pbl_tbl(umem, pbl_tbl, order_base_2(page_size));
+-      rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mr->qplib_mr, pbl_tbl,
+-                             umem_pgs, false, page_size);
++      rc = bnxt_qplib_reg_mr(&rdev->qplib_res, &mr->qplib_mr, umem,
++                             umem_pgs, page_size);
+       if (rc) {
+               ibdev_err(&rdev->ibdev, "Failed to register user MR");
+-              goto fail;
++              goto free_umem;
+       }
+-      kfree(pbl_tbl);
+-
+       mr->ib_mr.lkey = mr->qplib_mr.lkey;
+       mr->ib_mr.rkey = mr->qplib_mr.lkey;
+       atomic_inc(&rdev->mr_count);
+       return &mr->ib_mr;
+-fail:
+-      kfree(pbl_tbl);
+ free_umem:
+       ib_umem_release(umem);
+ free_mrw:
+diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+index 64d44f51db4b6..4afa33f58b105 100644
+--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c
++++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+@@ -650,16 +650,15 @@ int bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
+ }
+ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+-                    u64 *pbl_tbl, int num_pbls, bool block, u32 buf_pg_size)
++                    struct ib_umem *umem, int num_pbls, u32 buf_pg_size)
+ {
+       struct bnxt_qplib_rcfw *rcfw = res->rcfw;
+       struct bnxt_qplib_hwq_attr hwq_attr = {};
+       struct bnxt_qplib_sg_info sginfo = {};
+       struct creq_register_mr_resp resp;
+       struct cmdq_register_mr req;
+-      int pg_ptrs, pages, i, rc;
+       u16 cmd_flags = 0, level;
+-      dma_addr_t **pbl_ptr;
++      int pages, rc, pg_ptrs;
+       u32 pg_size;
+       if (num_pbls) {
+@@ -683,9 +682,10 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+               /* Use system PAGE_SIZE */
+               hwq_attr.res = res;
+               hwq_attr.depth = pages;
+-              hwq_attr.stride = PAGE_SIZE;
++              hwq_attr.stride = buf_pg_size;
+               hwq_attr.type = HWQ_TYPE_MR;
+               hwq_attr.sginfo = &sginfo;
++              hwq_attr.sginfo->umem = umem;
+               hwq_attr.sginfo->npages = pages;
+               hwq_attr.sginfo->pgsize = PAGE_SIZE;
+               hwq_attr.sginfo->pgshft = PAGE_SHIFT;
+@@ -695,11 +695,6 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+                               "SP: Reg MR memory allocation failed\n");
+                       return -ENOMEM;
+               }
+-              /* Write to the hwq */
+-              pbl_ptr = (dma_addr_t **)mr->hwq.pbl_ptr;
+-              for (i = 0; i < num_pbls; i++)
+-                      pbl_ptr[PTR_PG(i)][PTR_IDX(i)] =
+-                              (pbl_tbl[i] & PAGE_MASK) | PTU_PTE_VALID;
+       }
+       RCFW_CMD_PREP(req, REGISTER_MR, cmd_flags);
+@@ -711,7 +706,7 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+               req.pbl = 0;
+               pg_size = PAGE_SIZE;
+       } else {
+-              level = mr->hwq.level + 1;
++              level = mr->hwq.level;
+               req.pbl = cpu_to_le64(mr->hwq.pbl[PBL_LVL_0].pg_map_arr[0]);
+       }
+       pg_size = buf_pg_size ? buf_pg_size : PAGE_SIZE;
+@@ -728,7 +723,7 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+       req.mr_size = cpu_to_le64(mr->total_size);
+       rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req,
+-                                        (void *)&resp, NULL, block);
++                                        (void *)&resp, NULL, false);
+       if (rc)
+               goto fail;
+diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.h b/drivers/infiniband/hw/bnxt_re/qplib_sp.h
+index 967890cd81f27..bc228340684f4 100644
+--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.h
++++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.h
+@@ -254,7 +254,7 @@ int bnxt_qplib_alloc_mrw(struct bnxt_qplib_res *res,
+ int bnxt_qplib_dereg_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mrw,
+                        bool block);
+ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+-                    u64 *pbl_tbl, int num_pbls, bool block, u32 buf_pg_size);
++                    struct ib_umem *umem, int num_pbls, u32 buf_pg_size);
+ int bnxt_qplib_free_mrw(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr);
+ int bnxt_qplib_alloc_fast_reg_mr(struct bnxt_qplib_res *res,
+                                struct bnxt_qplib_mrw *mr, int max);
+-- 
+2.39.2
+
diff --git a/queue-5.10/rdma-bnxt_re-fix-a-possible-memory-leak.patch b/queue-5.10/rdma-bnxt_re-fix-a-possible-memory-leak.patch
new file mode 100644 (file)
index 0000000..402eaf0
--- /dev/null
@@ -0,0 +1,59 @@
+From a4f54be28b0facb4e0d16fea3c1a02ebf025cf1e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 May 2023 01:10:59 -0700
+Subject: RDMA/bnxt_re: Fix a possible memory leak
+
+From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
+
+[ Upstream commit 349e3c0cf239cc01d58a1e6c749e171de014cd6a ]
+
+Inside bnxt_qplib_create_cq(), when the check for NULL DPI fails, driver
+returns directly without freeing the memory allocated inside
+bnxt_qplib_alloc_init_hwq() routine.
+
+Fixed this by moving the check for NULL DPI before invoking
+bnxt_qplib_alloc_init_hwq().
+
+Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
+Link: https://lore.kernel.org/r/1684397461-23082-2-git-send-email-selvin.xavier@broadcom.com
+Reviewed-by: Kashyap Desai <kashyap.desai@broadcom.com>
+Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
+Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/hw/bnxt_re/qplib_fp.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+index bd153aa7e9ab3..b26a89187a192 100644
+--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
++++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+@@ -2041,6 +2041,12 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
+       u32 pg_sz_lvl;
+       int rc;
++      if (!cq->dpi) {
++              dev_err(&rcfw->pdev->dev,
++                      "FP: CREATE_CQ failed due to NULL DPI\n");
++              return -EINVAL;
++      }
++
+       hwq_attr.res = res;
+       hwq_attr.depth = cq->max_wqe;
+       hwq_attr.stride = sizeof(struct cq_base);
+@@ -2052,11 +2058,6 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
+       RCFW_CMD_PREP(req, CREATE_CQ, cmd_flags);
+-      if (!cq->dpi) {
+-              dev_err(&rcfw->pdev->dev,
+-                      "FP: CREATE_CQ failed due to NULL DPI\n");
+-              return -EINVAL;
+-      }
+       req.dpi = cpu_to_le32(cq->dpi->dpi);
+       req.cq_handle = cpu_to_le64(cq->cq_handle);
+       req.cq_size = cpu_to_le32(cq->hwq.max_elements);
+-- 
+2.39.2
+
diff --git a/queue-5.10/rdma-bnxt_re-fix-return-value-of-bnxt_re_process_raw.patch b/queue-5.10/rdma-bnxt_re-fix-return-value-of-bnxt_re_process_raw.patch
new file mode 100644 (file)
index 0000000..e945970
--- /dev/null
@@ -0,0 +1,42 @@
+From 31361710f5b36161443d5d1c68ca3a74c54efbeb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 18 May 2023 01:11:00 -0700
+Subject: RDMA/bnxt_re: Fix return value of bnxt_re_process_raw_qp_pkt_rx
+
+From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
+
+[ Upstream commit 0fa0d520e2a878cb4c94c4dc84395905d3f14f54 ]
+
+bnxt_re_process_raw_qp_pkt_rx() always return 0 and ignores the return
+value of bnxt_re_post_send_shadow_qp().
+
+Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
+Link: https://lore.kernel.org/r/1684397461-23082-3-git-send-email-selvin.xavier@broadcom.com
+Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
+Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
+Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
+Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+index 85fecb432aa00..2a973a1390a4a 100644
+--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
++++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+@@ -3247,9 +3247,7 @@ static int bnxt_re_process_raw_qp_pkt_rx(struct bnxt_re_qp *gsi_qp,
+       udwr.remote_qkey = gsi_sqp->qplib_qp.qkey;
+       /* post data received  in the send queue */
+-      rc = bnxt_re_post_send_shadow_qp(rdev, gsi_sqp, swr);
+-
+-      return 0;
++      return bnxt_re_post_send_shadow_qp(rdev, gsi_sqp, swr);
+ }
+ static void bnxt_re_process_res_rawqp1_wc(struct ib_wc *wc,
+-- 
+2.39.2
+
diff --git a/queue-5.10/rdma-bnxt_re-fix-the-page_size-used-during-the-mr-cr.patch b/queue-5.10/rdma-bnxt_re-fix-the-page_size-used-during-the-mr-cr.patch
new file mode 100644 (file)
index 0000000..d90c7f2
--- /dev/null
@@ -0,0 +1,83 @@
+From c048c18a41563e9442b410395503d26272cb510f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 7 May 2023 11:29:29 -0700
+Subject: RDMA/bnxt_re: Fix the page_size used during the MR creation
+
+From: Selvin Xavier <selvin.xavier@broadcom.com>
+
+[ Upstream commit 08c7f09356e45d093d1867c7a3c6ac6526e2f98b ]
+
+Driver populates the list of pages used for Memory region wrongly when
+page size is more than system page size. This is causing a failure when
+some of the applications that creates MR with page size as 2M.  Since HW
+can support multiple page sizes, pass the correct page size while creating
+the MR.
+
+Also, driver need not adjust the number of pages when HW Queues are
+created with user memory. It should work with the number of dma blocks
+returned by ib_umem_num_dma_blocks. Fix this calculation also.
+
+Fixes: 0c4dcd602817 ("RDMA/bnxt_re: Refactor hardware queue memory allocation")
+Fixes: f6919d56388c ("RDMA/bnxt_re: Code refactor while populating user MRs")
+Link: https://lore.kernel.org/r/1683484169-9539-1-git-send-email-selvin.xavier@broadcom.com
+Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
+Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
+Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/hw/bnxt_re/qplib_res.c | 12 ++----------
+ drivers/infiniband/hw/bnxt_re/qplib_sp.c  |  7 +++----
+ 2 files changed, 5 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c
+index 754dcebeb4ca1..123ea759f2826 100644
+--- a/drivers/infiniband/hw/bnxt_re/qplib_res.c
++++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c
+@@ -215,17 +215,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
+                       return -EINVAL;
+               hwq_attr->sginfo->npages = npages;
+       } else {
+-              unsigned long sginfo_num_pages = ib_umem_num_dma_blocks(
+-                      hwq_attr->sginfo->umem, hwq_attr->sginfo->pgsize);
+-
++              npages = ib_umem_num_dma_blocks(hwq_attr->sginfo->umem,
++                                              hwq_attr->sginfo->pgsize);
+               hwq->is_user = true;
+-              npages = sginfo_num_pages;
+-              npages = (npages * PAGE_SIZE) /
+-                        BIT_ULL(hwq_attr->sginfo->pgshft);
+-              if ((sginfo_num_pages * PAGE_SIZE) %
+-                   BIT_ULL(hwq_attr->sginfo->pgshft))
+-                      if (!npages)
+-                              npages++;
+       }
+       if (npages == MAX_PBL_LVL_0_PGS) {
+diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+index 4afa33f58b105..f53d94c812ec8 100644
+--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c
++++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+@@ -679,16 +679,15 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
+               /* Free the hwq if it already exist, must be a rereg */
+               if (mr->hwq.max_elements)
+                       bnxt_qplib_free_hwq(res, &mr->hwq);
+-              /* Use system PAGE_SIZE */
+               hwq_attr.res = res;
+               hwq_attr.depth = pages;
+-              hwq_attr.stride = buf_pg_size;
++              hwq_attr.stride = sizeof(dma_addr_t);
+               hwq_attr.type = HWQ_TYPE_MR;
+               hwq_attr.sginfo = &sginfo;
+               hwq_attr.sginfo->umem = umem;
+               hwq_attr.sginfo->npages = pages;
+-              hwq_attr.sginfo->pgsize = PAGE_SIZE;
+-              hwq_attr.sginfo->pgshft = PAGE_SHIFT;
++              hwq_attr.sginfo->pgsize = buf_pg_size;
++              hwq_attr.sginfo->pgshft = ilog2(buf_pg_size);
+               rc = bnxt_qplib_alloc_init_hwq(&mr->hwq, &hwq_attr);
+               if (rc) {
+                       dev_err(&res->pdev->dev,
+-- 
+2.39.2
+
diff --git a/queue-5.10/rdma-efa-fix-unsupported-page-sizes-in-device.patch b/queue-5.10/rdma-efa-fix-unsupported-page-sizes-in-device.patch
new file mode 100644 (file)
index 0000000..4e06716
--- /dev/null
@@ -0,0 +1,42 @@
+From 83716974e2c8c62d25ba01bbe0edf001ebdface6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 11 May 2023 11:51:03 +0000
+Subject: RDMA/efa: Fix unsupported page sizes in device
+
+From: Yonatan Nachum <ynachum@amazon.com>
+
+[ Upstream commit 866422cdddcdf59d8c68e9472d49ba1be29b5fcf ]
+
+Device uses 4KB size blocks for user pages indirect list while the
+driver creates those blocks with the size of PAGE_SIZE of the kernel. On
+kernels with PAGE_SIZE different than 4KB (ARM RHEL), this leads to a
+failure on register MR with indirect list because of the miss
+communication between driver and device.
+
+Fixes: 40909f664d27 ("RDMA/efa: Add EFA verbs implementation")
+Link: https://lore.kernel.org/r/20230511115103.13876-1-ynachum@amazon.com
+Reviewed-by: Firas Jahjah <firasj@amazon.com>
+Reviewed-by: Michael Margolin <mrgolin@amazon.com>
+Signed-off-by: Yonatan Nachum <ynachum@amazon.com>
+Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/hw/efa/efa_verbs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
+index 2ece682c7835b..9cf051818725c 100644
+--- a/drivers/infiniband/hw/efa/efa_verbs.c
++++ b/drivers/infiniband/hw/efa/efa_verbs.c
+@@ -1328,7 +1328,7 @@ static int pbl_continuous_initialize(struct efa_dev *dev,
+  */
+ static int pbl_indirect_initialize(struct efa_dev *dev, struct pbl_context *pbl)
+ {
+-      u32 size_in_pages = DIV_ROUND_UP(pbl->pbl_buf_size_in_bytes, PAGE_SIZE);
++      u32 size_in_pages = DIV_ROUND_UP(pbl->pbl_buf_size_in_bytes, EFA_CHUNK_PAYLOAD_SIZE);
+       struct scatterlist *sgl;
+       int sg_dma_cnt, err;
+-- 
+2.39.2
+
diff --git a/queue-5.10/s390-pkey-zeroize-key-blobs.patch b/queue-5.10/s390-pkey-zeroize-key-blobs.patch
new file mode 100644 (file)
index 0000000..36c909d
--- /dev/null
@@ -0,0 +1,52 @@
+From c142d752e4e073497909138231127edf4b019972 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 20 Apr 2023 14:34:10 +0200
+Subject: s390/pkey: zeroize key blobs
+
+From: Holger Dengler <dengler@linux.ibm.com>
+
+[ Upstream commit 844cf829e5f33e00b279230470c8c93b58b8c16f ]
+
+Key blobs for the IOCTLs PKEY_KBLOB2PROTK[23] may contain clear key
+material. Zeroize the copies of these keys in kernel memory after
+creating the protected key.
+
+Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
+Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
+Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/s390/crypto/pkey_api.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c
+index dd84995049b91..870e00effe439 100644
+--- a/drivers/s390/crypto/pkey_api.c
++++ b/drivers/s390/crypto/pkey_api.c
+@@ -1271,6 +1271,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
+                       return PTR_ERR(kkey);
+               rc = pkey_keyblob2pkey(kkey, ktp.keylen, &ktp.protkey);
+               DEBUG_DBG("%s pkey_keyblob2pkey()=%d\n", __func__, rc);
++              memzero_explicit(kkey, ktp.keylen);
+               kfree(kkey);
+               if (rc)
+                       break;
+@@ -1404,6 +1405,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
+                                       kkey, ktp.keylen, &ktp.protkey);
+               DEBUG_DBG("%s pkey_keyblob2pkey2()=%d\n", __func__, rc);
+               kfree(apqns);
++              memzero_explicit(kkey, ktp.keylen);
+               kfree(kkey);
+               if (rc)
+                       break;
+@@ -1530,6 +1532,7 @@ static long pkey_unlocked_ioctl(struct file *filp, unsigned int cmd,
+                                       protkey, &protkeylen);
+               DEBUG_DBG("%s pkey_keyblob2pkey3()=%d\n", __func__, rc);
+               kfree(apqns);
++              memzero_explicit(kkey, ktp.keylen);
+               kfree(kkey);
+               if (rc) {
+                       kfree(protkey);
+-- 
+2.39.2
+
diff --git a/queue-5.10/scsi-core-decrease-scsi_device-s-iorequest_cnt-if-di.patch b/queue-5.10/scsi-core-decrease-scsi_device-s-iorequest_cnt-if-di.patch
new file mode 100644 (file)
index 0000000..fd30184
--- /dev/null
@@ -0,0 +1,51 @@
+From 995271b815f81e26de52f0201ac2e7be3ff7c361 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 15 May 2023 15:01:56 +0800
+Subject: scsi: core: Decrease scsi_device's iorequest_cnt if dispatch failed
+
+From: Wenchao Hao <haowenchao2@huawei.com>
+
+[ Upstream commit 09e797c8641f6ad435c33ae24c223351197ea29a ]
+
+If scsi_dispatch_cmd() failed, the SCSI command was not sent to the target,
+scsi_queue_rq() would return BLK_STS_RESOURCE and the related request would
+be requeued. The timeout of this request would not fire, no one would
+increase iodone_cnt.
+
+The above flow would result the iodone_cnt smaller than iorequest_cnt.  So
+decrease the iorequest_cnt if dispatch failed to workaround the issue.
+
+Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
+Reported-by: Ming Lei <ming.lei@redhat.com>
+Closes: https://lore.kernel.org/r/ZF+zB+bB7iqe0wGd@ovpn-8-17.pek2.redhat.com
+Link: https://lore.kernel.org/r/20230515070156.1790181-3-haowenchao2@huawei.com
+Reviewed-by: Ming Lei <ming.lei@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/scsi/scsi_lib.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
+index 6f3d29d16d1f4..99b90031500b2 100644
+--- a/drivers/scsi/scsi_lib.c
++++ b/drivers/scsi/scsi_lib.c
+@@ -1490,6 +1490,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
+                */
+               SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd,
+                       "queuecommand : device blocked\n"));
++              atomic_dec(&cmd->device->iorequest_cnt);
+               return SCSI_MLQUEUE_DEVICE_BUSY;
+       }
+@@ -1522,6 +1523,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
+       trace_scsi_dispatch_cmd_start(cmd);
+       rtn = host->hostt->queuecommand(host, cmd);
+       if (rtn) {
++              atomic_dec(&cmd->device->iorequest_cnt);
+               trace_scsi_dispatch_cmd_error(cmd, rtn);
+               if (rtn != SCSI_MLQUEUE_DEVICE_BUSY &&
+                   rtn != SCSI_MLQUEUE_TARGET_BUSY)
+-- 
+2.39.2
+
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bcdc9ddcb400fa0dc86b8b7cfc553871ee3e610a 100644 (file)
@@ -0,0 +1,75 @@
+rdma-bnxt_re-code-refactor-while-populating-user-mrs.patch
+rdma-bnxt_re-fix-the-page_size-used-during-the-mr-cr.patch
+rdma-efa-fix-unsupported-page-sizes-in-device.patch
+dmaengine-at_xdmac-fix-concurrency-over-chan-s-compl.patch
+dmaengine-at_xdmac-fix-race-for-the-tx-desc-callback.patch
+dmaengine-at_xdmac-move-the-free-desc-to-the-tail-of.patch
+dmaengine-at_xdmac-fix-potential-oops-in-at_xdmac_pr.patch
+rdma-bnxt_re-fix-a-possible-memory-leak.patch
+rdma-bnxt_re-fix-return-value-of-bnxt_re_process_raw.patch
+iommu-rockchip-fix-unwind-goto-issue.patch
+iommu-amd-don-t-block-updates-to-gatag-if-guest-mode.patch
+dmaengine-pl330-rename-_start-to-prevent-build-error.patch
+net-mlx5-fw_tracer-fix-event-handling.patch
+netrom-fix-info-leak-in-nr_write_internal.patch
+af_packet-fix-data-races-of-pkt_sk-sk-num.patch
+amd-xgbe-fix-the-false-linkup-in-xgbe_phy_status.patch
+mtd-rawnand-ingenic-fix-empty-stub-helper-definition.patch
+af_packet-do-not-use-read_once-in-packet_bind.patch
+tcp-deny-tcp_disconnect-when-threads-are-waiting.patch
+tcp-return-user_mss-for-tcp_maxseg-in-close-listen-s.patch
+net-sched-sch_ingress-only-create-under-tc_h_ingress.patch
+net-sched-sch_clsact-only-create-under-tc_h_clsact.patch
+net-sched-reserve-tc_h_ingress-tc_h_clsact-for-ingre.patch
+net-sched-prohibit-regrafting-ingress-or-clsact-qdis.patch
+net-sched-fix-null-pointer-dereference-in-mq_attach.patch
+net-netlink-fix-netlink_list_memberships-length-repo.patch
+sock-expose-so_timestamp-options-for-mptcp.patch
+sock-expose-so_timestamping-options-for-mptcp.patch
+tcp-remove-sk_-tr-x_skb_cache.patch
+udp6-fix-race-condition-in-udp6_sendmsg-connect.patch
+net-mlx5-read-embedded-cpu-after-init-bit-cleared.patch
+net-sched-flower-fix-possible-oob-write-in-fl_set_ge.patch
+net-dsa-mv88e6xxx-increase-wait-after-reset-deactiva.patch
+mtd-rawnand-marvell-ensure-timing-values-are-written.patch
+mtd-rawnand-marvell-don-t-set-the-nand-frequency-sel.patch
+watchdog-menz069_wdt-fix-watchdog-initialisation.patch
+alsa-hda-glenfly-add-hd-audio-pci-ids-and-hdmi-codec.patch
+mailbox-mailbox-test-fix-potential-double-free-in-mb.patch
+btrfs-abort-transaction-when-sibling-keys-check-fail.patch
+arm-9295-1-unwind-fix-unwind-abort-for-uleb128-case.patch
+media-rcar-vin-select-correct-interrupt-mode-for-v4l.patch
+gfs2-don-t-deref-jdesc-in-evict.patch
+fbdev-modedb-add-1920x1080-at-60-hz-video-mode.patch
+fbdev-stifb-fix-info-entry-in-sti_struct-on-error-pa.patch
+nbd-fix-debugfs_create_dir-error-checking.patch
+block-rnbd-replace-req_op_flush-with-req_op_write.patch
+asoc-dwc-limit-the-number-of-overrun-messages.patch
+xfrm-check-if_id-in-inbound-policy-secpath-match.patch
+asoc-dt-bindings-adjust-sound-dai-cells-on-ti-s-sing.patch
+asoc-ssm2602-add-workaround-for-playback-distortions.patch
+media-dvb_demux-fix-a-bug-for-the-continuity-counter.patch
+media-dvb-usb-az6027-fix-three-null-ptr-deref-in-az6.patch
+media-dvb-usb-v2-ec168-fix-null-ptr-deref-in-ec168_i.patch
+media-dvb-usb-v2-ce6230-fix-null-ptr-deref-in-ce6230.patch
+media-dvb-usb-v2-rtl28xxu-fix-null-ptr-deref-in-rtl2.patch
+media-dvb-usb-digitv-fix-null-ptr-deref-in-digitv_i2.patch
+media-dvb-usb-dw2102-fix-uninit-value-in-su3000_read.patch
+media-netup_unidvb-fix-irq-init-by-register-it-at-th.patch
+media-dvb_ca_en50221-fix-a-size-write-bug.patch
+media-ttusb-dec-fix-memory-leak-in-ttusb_dec_exit_dv.patch
+media-mn88443x-fix-config_of-error-by-drop-of_match_.patch
+media-dvb-core-fix-use-after-free-due-on-race-condit.patch
+media-dvb-core-fix-kernel-warning-for-blocking-opera.patch
+media-dvb-core-fix-use-after-free-due-to-race-condit.patch
+s390-pkey-zeroize-key-blobs.patch
+wifi-rtl8xxxu-fix-authentication-timeout-due-to-inco.patch
+arm-dts-stm32-add-pin-map-for-can-controller-on-stm3.patch
+arm64-mm-mark-private-vm_fault_x-defines-as-vm_fault.patch
+scsi-core-decrease-scsi_device-s-iorequest_cnt-if-di.patch
+wifi-b43-fix-incorrect-__packed-annotation.patch
+netfilter-conntrack-define-variables-exp_nat_nla_pol.patch
+alsa-oss-avoid-missing-prototype-warnings.patch
+drm-msm-be-more-shouty-if-per-process-pgtables-aren-.patch
+atm-hide-unused-procfs-functions.patch
+mailbox-mailbox-test-fix-a-locking-issue-in-mbox_tes.patch
diff --git a/queue-5.10/sock-expose-so_timestamp-options-for-mptcp.patch b/queue-5.10/sock-expose-so_timestamp-options-for-mptcp.patch
new file mode 100644 (file)
index 0000000..8387c2f
--- /dev/null
@@ -0,0 +1,87 @@
+From 96be4aecebc993609750ce66ca31fc6396932e5d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 3 Jun 2021 16:24:27 -0700
+Subject: sock: expose so_timestamp options for mptcp
+
+From: Florian Westphal <fw@strlen.de>
+
+[ Upstream commit 371087aa476ab0ac0072303ac94a3bba2d7b0a1d ]
+
+This exports SO_TIMESTAMP_* function for re-use by MPTCP.
+
+Without this there is too much copy & paste needed to support
+this from mptcp setsockopt path.
+
+Acked-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 448a5ce1120c ("udp6: Fix race condition in udp6_sendmsg & connect")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/sock.h |  1 +
+ net/core/sock.c    | 26 +++++++++++++++++++-------
+ 2 files changed, 20 insertions(+), 7 deletions(-)
+
+diff --git a/include/net/sock.h b/include/net/sock.h
+index 3da0601b573ed..09cd879d0dda1 100644
+--- a/include/net/sock.h
++++ b/include/net/sock.h
+@@ -2775,6 +2775,7 @@ static inline bool sk_dev_equal_l3scope(struct sock *sk, int dif)
+ void sock_def_readable(struct sock *sk);
+ int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk);
++void sock_set_timestamp(struct sock *sk, int optname, bool valbool);
+ void sock_enable_timestamps(struct sock *sk);
+ void sock_no_linger(struct sock *sk);
+ void sock_set_keepalive(struct sock *sk);
+diff --git a/net/core/sock.c b/net/core/sock.c
+index c5ae520d4a69c..7d421b0f863f9 100644
+--- a/net/core/sock.c
++++ b/net/core/sock.c
+@@ -768,6 +768,24 @@ void sock_enable_timestamps(struct sock *sk)
+ }
+ EXPORT_SYMBOL(sock_enable_timestamps);
++void sock_set_timestamp(struct sock *sk, int optname, bool valbool)
++{
++      switch (optname) {
++      case SO_TIMESTAMP_OLD:
++              __sock_set_timestamps(sk, valbool, false, false);
++              break;
++      case SO_TIMESTAMP_NEW:
++              __sock_set_timestamps(sk, valbool, true, false);
++              break;
++      case SO_TIMESTAMPNS_OLD:
++              __sock_set_timestamps(sk, valbool, false, true);
++              break;
++      case SO_TIMESTAMPNS_NEW:
++              __sock_set_timestamps(sk, valbool, true, true);
++              break;
++      }
++}
++
+ void sock_set_keepalive(struct sock *sk)
+ {
+       lock_sock(sk);
+@@ -989,16 +1007,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
+               break;
+       case SO_TIMESTAMP_OLD:
+-              __sock_set_timestamps(sk, valbool, false, false);
+-              break;
+       case SO_TIMESTAMP_NEW:
+-              __sock_set_timestamps(sk, valbool, true, false);
+-              break;
+       case SO_TIMESTAMPNS_OLD:
+-              __sock_set_timestamps(sk, valbool, false, true);
+-              break;
+       case SO_TIMESTAMPNS_NEW:
+-              __sock_set_timestamps(sk, valbool, true, true);
++              sock_set_timestamp(sk, valbool, optname);
+               break;
+       case SO_TIMESTAMPING_NEW:
+       case SO_TIMESTAMPING_OLD:
+-- 
+2.39.2
+
diff --git a/queue-5.10/sock-expose-so_timestamping-options-for-mptcp.patch b/queue-5.10/sock-expose-so_timestamping-options-for-mptcp.patch
new file mode 100644 (file)
index 0000000..0f246c5
--- /dev/null
@@ -0,0 +1,130 @@
+From 1022e0aacca2382b0b688397a993c595fa9a3a71 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 3 Jun 2021 16:24:28 -0700
+Subject: sock: expose so_timestamping options for mptcp
+
+From: Florian Westphal <fw@strlen.de>
+
+[ Upstream commit ced122d90f52eb6ff37272e32941845d46ac64c6 ]
+
+Similar to previous patch: expose SO_TIMESTAMPING helper so we do not
+have to copy & paste this into the mptcp core.
+
+Acked-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 448a5ce1120c ("udp6: Fix race condition in udp6_sendmsg & connect")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/sock.h |  2 ++
+ net/core/sock.c    | 71 +++++++++++++++++++++++-----------------------
+ 2 files changed, 38 insertions(+), 35 deletions(-)
+
+diff --git a/include/net/sock.h b/include/net/sock.h
+index 09cd879d0dda1..71bd4f6741f1e 100644
+--- a/include/net/sock.h
++++ b/include/net/sock.h
+@@ -2776,6 +2776,8 @@ void sock_def_readable(struct sock *sk);
+ int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk);
+ void sock_set_timestamp(struct sock *sk, int optname, bool valbool);
++int sock_set_timestamping(struct sock *sk, int optname, int val);
++
+ void sock_enable_timestamps(struct sock *sk);
+ void sock_no_linger(struct sock *sk);
+ void sock_set_keepalive(struct sock *sk);
+diff --git a/net/core/sock.c b/net/core/sock.c
+index 7d421b0f863f9..b8f8252d36819 100644
+--- a/net/core/sock.c
++++ b/net/core/sock.c
+@@ -786,6 +786,40 @@ void sock_set_timestamp(struct sock *sk, int optname, bool valbool)
+       }
+ }
++int sock_set_timestamping(struct sock *sk, int optname, int val)
++{
++      if (val & ~SOF_TIMESTAMPING_MASK)
++              return -EINVAL;
++
++      if (val & SOF_TIMESTAMPING_OPT_ID &&
++          !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
++              if (sk->sk_protocol == IPPROTO_TCP &&
++                  sk->sk_type == SOCK_STREAM) {
++                      if ((1 << sk->sk_state) &
++                          (TCPF_CLOSE | TCPF_LISTEN))
++                              return -EINVAL;
++                      sk->sk_tskey = tcp_sk(sk)->snd_una;
++              } else {
++                      sk->sk_tskey = 0;
++              }
++      }
++
++      if (val & SOF_TIMESTAMPING_OPT_STATS &&
++          !(val & SOF_TIMESTAMPING_OPT_TSONLY))
++              return -EINVAL;
++
++      sk->sk_tsflags = val;
++      sock_valbool_flag(sk, SOCK_TSTAMP_NEW, optname == SO_TIMESTAMPING_NEW);
++
++      if (val & SOF_TIMESTAMPING_RX_SOFTWARE)
++              sock_enable_timestamp(sk,
++                                    SOCK_TIMESTAMPING_RX_SOFTWARE);
++      else
++              sock_disable_timestamp(sk,
++                                     (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));
++      return 0;
++}
++
+ void sock_set_keepalive(struct sock *sk)
+ {
+       lock_sock(sk);
+@@ -1012,43 +1046,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
+       case SO_TIMESTAMPNS_NEW:
+               sock_set_timestamp(sk, valbool, optname);
+               break;
++
+       case SO_TIMESTAMPING_NEW:
+       case SO_TIMESTAMPING_OLD:
+-              if (val & ~SOF_TIMESTAMPING_MASK) {
+-                      ret = -EINVAL;
+-                      break;
+-              }
+-
+-              if (val & SOF_TIMESTAMPING_OPT_ID &&
+-                  !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
+-                      if (sk->sk_protocol == IPPROTO_TCP &&
+-                          sk->sk_type == SOCK_STREAM) {
+-                              if ((1 << sk->sk_state) &
+-                                  (TCPF_CLOSE | TCPF_LISTEN)) {
+-                                      ret = -EINVAL;
+-                                      break;
+-                              }
+-                              sk->sk_tskey = tcp_sk(sk)->snd_una;
+-                      } else {
+-                              sk->sk_tskey = 0;
+-                      }
+-              }
+-
+-              if (val & SOF_TIMESTAMPING_OPT_STATS &&
+-                  !(val & SOF_TIMESTAMPING_OPT_TSONLY)) {
+-                      ret = -EINVAL;
+-                      break;
+-              }
+-
+-              sk->sk_tsflags = val;
+-              sock_valbool_flag(sk, SOCK_TSTAMP_NEW, optname == SO_TIMESTAMPING_NEW);
+-
+-              if (val & SOF_TIMESTAMPING_RX_SOFTWARE)
+-                      sock_enable_timestamp(sk,
+-                                            SOCK_TIMESTAMPING_RX_SOFTWARE);
+-              else
+-                      sock_disable_timestamp(sk,
+-                                             (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));
++              ret = sock_set_timestamping(sk, optname, val);
+               break;
+       case SO_RCVLOWAT:
+-- 
+2.39.2
+
diff --git a/queue-5.10/tcp-deny-tcp_disconnect-when-threads-are-waiting.patch b/queue-5.10/tcp-deny-tcp_disconnect-when-threads-are-waiting.patch
new file mode 100644 (file)
index 0000000..b2807a6
--- /dev/null
@@ -0,0 +1,186 @@
+From b7c845405cc240796804203b5fe9ca9f2f1a41ee Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 26 May 2023 16:34:58 +0000
+Subject: tcp: deny tcp_disconnect() when threads are waiting
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 4faeee0cf8a5d88d63cdbc3bab124fb0e6aed08c ]
+
+Historically connect(AF_UNSPEC) has been abused by syzkaller
+and other fuzzers to trigger various bugs.
+
+A recent one triggers a divide-by-zero [1], and Paolo Abeni
+was able to diagnose the issue.
+
+tcp_recvmsg_locked() has tests about sk_state being not TCP_LISTEN
+and TCP REPAIR mode being not used.
+
+Then later if socket lock is released in sk_wait_data(),
+another thread can call connect(AF_UNSPEC), then make this
+socket a TCP listener.
+
+When recvmsg() is resumed, it can eventually call tcp_cleanup_rbuf()
+and attempt a divide by 0 in tcp_rcv_space_adjust() [1]
+
+This patch adds a new socket field, counting number of threads
+blocked in sk_wait_event() and inet_wait_for_connect().
+
+If this counter is not zero, tcp_disconnect() returns an error.
+
+This patch adds code in blocking socket system calls, thus should
+not hurt performance of non blocking ones.
+
+Note that we probably could revert commit 499350a5a6e7 ("tcp:
+initialize rcv_mss to TCP_MIN_MSS instead of 0") to restore
+original tcpi_rcv_mss meaning (was 0 if no payload was ever
+received on a socket)
+
+[1]
+divide error: 0000 [#1] PREEMPT SMP KASAN
+CPU: 0 PID: 13832 Comm: syz-executor.5 Not tainted 6.3.0-rc4-syzkaller-00224-g00c7b5f4ddc5 #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
+RIP: 0010:tcp_rcv_space_adjust+0x36e/0x9d0 net/ipv4/tcp_input.c:740
+Code: 00 00 00 00 fc ff df 4c 89 64 24 48 8b 44 24 04 44 89 f9 41 81 c7 80 03 00 00 c1 e1 04 44 29 f0 48 63 c9 48 01 e9 48 0f af c1 <49> f7 f6 48 8d 04 41 48 89 44 24 40 48 8b 44 24 30 48 c1 e8 03 48
+RSP: 0018:ffffc900033af660 EFLAGS: 00010206
+RAX: 4a66b76cbade2c48 RBX: ffff888076640cc0 RCX: 00000000c334e4ac
+RDX: 0000000000000000 RSI: dffffc0000000000 RDI: 0000000000000001
+RBP: 00000000c324e86c R08: 0000000000000001 R09: 0000000000000000
+R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880766417f8
+R13: ffff888028fbb980 R14: 0000000000000000 R15: 0000000000010344
+FS: 00007f5bffbfe700(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
+CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+CR2: 0000001b32f25000 CR3: 000000007ced0000 CR4: 00000000003506f0
+DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+Call Trace:
+<TASK>
+tcp_recvmsg_locked+0x100e/0x22e0 net/ipv4/tcp.c:2616
+tcp_recvmsg+0x117/0x620 net/ipv4/tcp.c:2681
+inet6_recvmsg+0x114/0x640 net/ipv6/af_inet6.c:670
+sock_recvmsg_nosec net/socket.c:1017 [inline]
+sock_recvmsg+0xe2/0x160 net/socket.c:1038
+____sys_recvmsg+0x210/0x5a0 net/socket.c:2720
+___sys_recvmsg+0xf2/0x180 net/socket.c:2762
+do_recvmmsg+0x25e/0x6e0 net/socket.c:2856
+__sys_recvmmsg net/socket.c:2935 [inline]
+__do_sys_recvmmsg net/socket.c:2958 [inline]
+__se_sys_recvmmsg net/socket.c:2951 [inline]
+__x64_sys_recvmmsg+0x20f/0x260 net/socket.c:2951
+do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
+entry_SYSCALL_64_after_hwframe+0x63/0xcd
+RIP: 0033:0x7f5c0108c0f9
+Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
+RSP: 002b:00007f5bffbfe168 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
+RAX: ffffffffffffffda RBX: 00007f5c011ac050 RCX: 00007f5c0108c0f9
+RDX: 0000000000000001 RSI: 0000000020000bc0 RDI: 0000000000000003
+RBP: 00007f5c010e7b39 R08: 0000000000000000 R09: 0000000000000000
+R10: 0000000000000122 R11: 0000000000000246 R12: 0000000000000000
+R13: 00007f5c012cfb1f R14: 00007f5bffbfe300 R15: 0000000000022000
+</TASK>
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Reported-by: Paolo Abeni <pabeni@redhat.com>
+Diagnosed-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Tested-by: Paolo Abeni <pabeni@redhat.com>
+Link: https://lore.kernel.org/r/20230526163458.2880232-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/sock.h              | 4 ++++
+ net/ipv4/af_inet.c              | 2 ++
+ net/ipv4/inet_connection_sock.c | 1 +
+ net/ipv4/tcp.c                  | 6 ++++++
+ 4 files changed, 13 insertions(+)
+
+diff --git a/include/net/sock.h b/include/net/sock.h
+index 651dc0a7bbd58..3da0601b573ed 100644
+--- a/include/net/sock.h
++++ b/include/net/sock.h
+@@ -326,6 +326,7 @@ struct bpf_local_storage;
+   *   @sk_cgrp_data: cgroup data for this cgroup
+   *   @sk_memcg: this socket's memory cgroup association
+   *   @sk_write_pending: a write to stream socket waits to start
++  *   @sk_wait_pending: number of threads blocked on this socket
+   *   @sk_state_change: callback to indicate change in the state of the sock
+   *   @sk_data_ready: callback to indicate there is data to be processed
+   *   @sk_write_space: callback to indicate there is bf sending space available
+@@ -410,6 +411,7 @@ struct sock {
+       unsigned int            sk_napi_id;
+ #endif
+       int                     sk_rcvbuf;
++      int                     sk_wait_pending;
+       struct sk_filter __rcu  *sk_filter;
+       union {
+@@ -1095,6 +1097,7 @@ static inline void sock_rps_reset_rxhash(struct sock *sk)
+ #define sk_wait_event(__sk, __timeo, __condition, __wait)             \
+       ({      int __rc;                                               \
++              __sk->sk_wait_pending++;                                \
+               release_sock(__sk);                                     \
+               __rc = __condition;                                     \
+               if (!__rc) {                                            \
+@@ -1104,6 +1107,7 @@ static inline void sock_rps_reset_rxhash(struct sock *sk)
+               }                                                       \
+               sched_annotate_sleep();                                 \
+               lock_sock(__sk);                                        \
++              __sk->sk_wait_pending--;                                \
+               __rc = __condition;                                     \
+               __rc;                                                   \
+       })
+diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
+index 800c2c7607e1a..acb4887351daf 100644
+--- a/net/ipv4/af_inet.c
++++ b/net/ipv4/af_inet.c
+@@ -584,6 +584,7 @@ static long inet_wait_for_connect(struct sock *sk, long timeo, int writebias)
+       add_wait_queue(sk_sleep(sk), &wait);
+       sk->sk_write_pending += writebias;
++      sk->sk_wait_pending++;
+       /* Basic assumption: if someone sets sk->sk_err, he _must_
+        * change state of the socket from TCP_SYN_*.
+@@ -599,6 +600,7 @@ static long inet_wait_for_connect(struct sock *sk, long timeo, int writebias)
+       }
+       remove_wait_queue(sk_sleep(sk), &wait);
+       sk->sk_write_pending -= writebias;
++      sk->sk_wait_pending--;
+       return timeo;
+ }
+diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
+index e05dd87848f78..406305aaec904 100644
+--- a/net/ipv4/inet_connection_sock.c
++++ b/net/ipv4/inet_connection_sock.c
+@@ -839,6 +839,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
+       if (newsk) {
+               struct inet_connection_sock *newicsk = inet_csk(newsk);
++              newsk->sk_wait_pending = 0;
+               inet_sk_set_state(newsk, TCP_SYN_RECV);
+               newicsk->icsk_bind_hash = NULL;
+diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
+index eecce63ba25e3..edb743bcbc391 100644
+--- a/net/ipv4/tcp.c
++++ b/net/ipv4/tcp.c
+@@ -2748,6 +2748,12 @@ int tcp_disconnect(struct sock *sk, int flags)
+       int old_state = sk->sk_state;
+       u32 seq;
++      /* Deny disconnect if other threads are blocked in sk_wait_event()
++       * or inet_wait_for_connect().
++       */
++      if (sk->sk_wait_pending)
++              return -EBUSY;
++
+       if (old_state != TCP_CLOSE)
+               tcp_set_state(sk, TCP_CLOSE);
+-- 
+2.39.2
+
diff --git a/queue-5.10/tcp-remove-sk_-tr-x_skb_cache.patch b/queue-5.10/tcp-remove-sk_-tr-x_skb_cache.patch
new file mode 100644 (file)
index 0000000..e4f6555
--- /dev/null
@@ -0,0 +1,294 @@
+From 9057e4395d8c2432bef26bad16c64a0a376298b9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Sep 2021 19:26:43 +0200
+Subject: tcp: remove sk_{tr}x_skb_cache
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit d8b81175e412c7abebdb5b37d8a84d5fd19b1aad ]
+
+This reverts the following patches :
+
+- commit 2e05fcae83c4 ("tcp: fix compile error if !CONFIG_SYSCTL")
+- commit 4f661542a402 ("tcp: fix zerocopy and notsent_lowat issues")
+- commit 472c2e07eef0 ("tcp: add one skb cache for tx")
+- commit 8b27dae5a2e8 ("tcp: add one skb cache for rx")
+
+Having a cache of one skb (in each direction) per TCP socket is fragile,
+since it can cause a significant increase of memory needs,
+and not good enough for high speed flows anyway where more than one skb
+is needed.
+
+We want instead to add a generic infrastructure, with more flexible
+per-cpu caches, for alien NUMA nodes.
+
+Acked-by: Paolo Abeni <pabeni@redhat.com>
+Acked-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 448a5ce1120c ("udp6: Fix race condition in udp6_sendmsg & connect")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/networking/ip-sysctl.rst |  8 --------
+ include/net/sock.h                     | 19 -------------------
+ net/ipv4/af_inet.c                     |  4 ----
+ net/ipv4/sysctl_net_ipv4.c             | 12 ------------
+ net/ipv4/tcp.c                         | 26 --------------------------
+ net/ipv4/tcp_ipv4.c                    |  6 ------
+ net/ipv6/tcp_ipv6.c                    |  6 ------
+ 7 files changed, 81 deletions(-)
+
+diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
+index df26cf4110ef5..7a58e8c8edb24 100644
+--- a/Documentation/networking/ip-sysctl.rst
++++ b/Documentation/networking/ip-sysctl.rst
+@@ -916,14 +916,6 @@ tcp_challenge_ack_limit - INTEGER
+       in RFC 5961 (Improving TCP's Robustness to Blind In-Window Attacks)
+       Default: 1000
+-tcp_rx_skb_cache - BOOLEAN
+-      Controls a per TCP socket cache of one skb, that might help
+-      performance of some workloads. This might be dangerous
+-      on systems with a lot of TCP sockets, since it increases
+-      memory usage.
+-
+-      Default: 0 (disabled)
+-
+ UDP variables
+ =============
+diff --git a/include/net/sock.h b/include/net/sock.h
+index 71bd4f6741f1e..eb96f39a19f35 100644
+--- a/include/net/sock.h
++++ b/include/net/sock.h
+@@ -258,7 +258,6 @@ struct bpf_local_storage;
+   *   @sk_dst_cache: destination cache
+   *   @sk_dst_pending_confirm: need to confirm neighbour
+   *   @sk_policy: flow policy
+-  *   @sk_rx_skb_cache: cache copy of recently accessed RX skb
+   *   @sk_receive_queue: incoming packets
+   *   @sk_wmem_alloc: transmit queue bytes committed
+   *   @sk_tsq_flags: TCP Small Queues flags
+@@ -320,7 +319,6 @@ struct bpf_local_storage;
+   *   @sk_peek_off: current peek_offset value
+   *   @sk_send_head: front of stuff to transmit
+   *   @tcp_rtx_queue: TCP re-transmit queue [union with @sk_send_head]
+-  *   @sk_tx_skb_cache: cache copy of recently accessed TX skb
+   *   @sk_security: used by security modules
+   *   @sk_mark: generic packet mark
+   *   @sk_cgrp_data: cgroup data for this cgroup
+@@ -386,7 +384,6 @@ struct sock {
+       atomic_t                sk_drops;
+       int                     sk_rcvlowat;
+       struct sk_buff_head     sk_error_queue;
+-      struct sk_buff          *sk_rx_skb_cache;
+       struct sk_buff_head     sk_receive_queue;
+       /*
+        * The backlog queue is special, it is always used with
+@@ -436,7 +433,6 @@ struct sock {
+               struct sk_buff  *sk_send_head;
+               struct rb_root  tcp_rtx_queue;
+       };
+-      struct sk_buff          *sk_tx_skb_cache;
+       struct sk_buff_head     sk_write_queue;
+       __s32                   sk_peek_off;
+       int                     sk_write_pending;
+@@ -1557,18 +1553,10 @@ static inline void sk_mem_uncharge(struct sock *sk, int size)
+               __sk_mem_reclaim(sk, 1 << 20);
+ }
+-DECLARE_STATIC_KEY_FALSE(tcp_tx_skb_cache_key);
+ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
+ {
+       sk_wmem_queued_add(sk, -skb->truesize);
+       sk_mem_uncharge(sk, skb->truesize);
+-      if (static_branch_unlikely(&tcp_tx_skb_cache_key) &&
+-          !sk->sk_tx_skb_cache && !skb_cloned(skb)) {
+-              skb_ext_reset(skb);
+-              skb_zcopy_clear(skb, true);
+-              sk->sk_tx_skb_cache = skb;
+-              return;
+-      }
+       __kfree_skb(skb);
+ }
+@@ -2579,7 +2567,6 @@ static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags)
+                          &skb_shinfo(skb)->tskey);
+ }
+-DECLARE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key);
+ /**
+  * sk_eat_skb - Release a skb if it is no longer needed
+  * @sk: socket to eat this skb from
+@@ -2591,12 +2578,6 @@ DECLARE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key);
+ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)
+ {
+       __skb_unlink(skb, &sk->sk_receive_queue);
+-      if (static_branch_unlikely(&tcp_rx_skb_cache_key) &&
+-          !sk->sk_rx_skb_cache) {
+-              sk->sk_rx_skb_cache = skb;
+-              skb_orphan(skb);
+-              return;
+-      }
+       __kfree_skb(skb);
+ }
+diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
+index acb4887351daf..6a8d17c891e5e 100644
+--- a/net/ipv4/af_inet.c
++++ b/net/ipv4/af_inet.c
+@@ -133,10 +133,6 @@ void inet_sock_destruct(struct sock *sk)
+       struct inet_sock *inet = inet_sk(sk);
+       __skb_queue_purge(&sk->sk_receive_queue);
+-      if (sk->sk_rx_skb_cache) {
+-              __kfree_skb(sk->sk_rx_skb_cache);
+-              sk->sk_rx_skb_cache = NULL;
+-      }
+       __skb_queue_purge(&sk->sk_error_queue);
+       sk_mem_reclaim(sk);
+diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
+index 3a34e9768bff0..f9bdba88269aa 100644
+--- a/net/ipv4/sysctl_net_ipv4.c
++++ b/net/ipv4/sysctl_net_ipv4.c
+@@ -522,18 +522,6 @@ static struct ctl_table ipv4_table[] = {
+               .extra1         = &sysctl_fib_sync_mem_min,
+               .extra2         = &sysctl_fib_sync_mem_max,
+       },
+-      {
+-              .procname       = "tcp_rx_skb_cache",
+-              .data           = &tcp_rx_skb_cache_key.key,
+-              .mode           = 0644,
+-              .proc_handler   = proc_do_static_key,
+-      },
+-      {
+-              .procname       = "tcp_tx_skb_cache",
+-              .data           = &tcp_tx_skb_cache_key.key,
+-              .mode           = 0644,
+-              .proc_handler   = proc_do_static_key,
+-      },
+       { }
+ };
+diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
+index 82abbf1929851..2eb044c55855f 100644
+--- a/net/ipv4/tcp.c
++++ b/net/ipv4/tcp.c
+@@ -318,11 +318,6 @@ struct tcp_splice_state {
+ unsigned long tcp_memory_pressure __read_mostly;
+ EXPORT_SYMBOL_GPL(tcp_memory_pressure);
+-DEFINE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key);
+-EXPORT_SYMBOL(tcp_rx_skb_cache_key);
+-
+-DEFINE_STATIC_KEY_FALSE(tcp_tx_skb_cache_key);
+-
+ void tcp_enter_memory_pressure(struct sock *sk)
+ {
+       unsigned long val;
+@@ -870,18 +865,6 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
+ {
+       struct sk_buff *skb;
+-      if (likely(!size)) {
+-              skb = sk->sk_tx_skb_cache;
+-              if (skb) {
+-                      skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
+-                      sk->sk_tx_skb_cache = NULL;
+-                      pskb_trim(skb, 0);
+-                      INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
+-                      skb_shinfo(skb)->tx_flags = 0;
+-                      memset(TCP_SKB_CB(skb), 0, sizeof(struct tcp_skb_cb));
+-                      return skb;
+-              }
+-      }
+       /* The TCP header must be at least 32-bit aligned.  */
+       size = ALIGN(size, 4);
+@@ -2728,11 +2711,6 @@ void tcp_write_queue_purge(struct sock *sk)
+               sk_wmem_free_skb(sk, skb);
+       }
+       tcp_rtx_queue_purge(sk);
+-      skb = sk->sk_tx_skb_cache;
+-      if (skb) {
+-              __kfree_skb(skb);
+-              sk->sk_tx_skb_cache = NULL;
+-      }
+       INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue);
+       sk_mem_reclaim(sk);
+       tcp_clear_all_retrans_hints(tcp_sk(sk));
+@@ -2775,10 +2753,6 @@ int tcp_disconnect(struct sock *sk, int flags)
+       tcp_clear_xmit_timers(sk);
+       __skb_queue_purge(&sk->sk_receive_queue);
+-      if (sk->sk_rx_skb_cache) {
+-              __kfree_skb(sk->sk_rx_skb_cache);
+-              sk->sk_rx_skb_cache = NULL;
+-      }
+       WRITE_ONCE(tp->copied_seq, tp->rcv_nxt);
+       tp->urg_data = 0;
+       tcp_write_queue_purge(sk);
+diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
+index 270b20e0907c2..2a0878179b5ec 100644
+--- a/net/ipv4/tcp_ipv4.c
++++ b/net/ipv4/tcp_ipv4.c
+@@ -1944,7 +1944,6 @@ static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph,
+ int tcp_v4_rcv(struct sk_buff *skb)
+ {
+       struct net *net = dev_net(skb->dev);
+-      struct sk_buff *skb_to_free;
+       int sdif = inet_sdif(skb);
+       int dif = inet_iif(skb);
+       const struct iphdr *iph;
+@@ -2079,17 +2078,12 @@ int tcp_v4_rcv(struct sk_buff *skb)
+       tcp_segs_in(tcp_sk(sk), skb);
+       ret = 0;
+       if (!sock_owned_by_user(sk)) {
+-              skb_to_free = sk->sk_rx_skb_cache;
+-              sk->sk_rx_skb_cache = NULL;
+               ret = tcp_v4_do_rcv(sk, skb);
+       } else {
+               if (tcp_add_backlog(sk, skb))
+                       goto discard_and_relse;
+-              skb_to_free = NULL;
+       }
+       bh_unlock_sock(sk);
+-      if (skb_to_free)
+-              __kfree_skb(skb_to_free);
+ put_and_return:
+       if (refcounted)
+diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
+index fe29bc66aeac7..1d118a953abe6 100644
+--- a/net/ipv6/tcp_ipv6.c
++++ b/net/ipv6/tcp_ipv6.c
+@@ -1602,7 +1602,6 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
+ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
+ {
+-      struct sk_buff *skb_to_free;
+       int sdif = inet6_sdif(skb);
+       int dif = inet6_iif(skb);
+       const struct tcphdr *th;
+@@ -1730,17 +1729,12 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
+       tcp_segs_in(tcp_sk(sk), skb);
+       ret = 0;
+       if (!sock_owned_by_user(sk)) {
+-              skb_to_free = sk->sk_rx_skb_cache;
+-              sk->sk_rx_skb_cache = NULL;
+               ret = tcp_v6_do_rcv(sk, skb);
+       } else {
+               if (tcp_add_backlog(sk, skb))
+                       goto discard_and_relse;
+-              skb_to_free = NULL;
+       }
+       bh_unlock_sock(sk);
+-      if (skb_to_free)
+-              __kfree_skb(skb_to_free);
+ put_and_return:
+       if (refcounted)
+               sock_put(sk);
+-- 
+2.39.2
+
diff --git a/queue-5.10/tcp-return-user_mss-for-tcp_maxseg-in-close-listen-s.patch b/queue-5.10/tcp-return-user_mss-for-tcp_maxseg-in-close-listen-s.patch
new file mode 100644 (file)
index 0000000..2d6afd0
--- /dev/null
@@ -0,0 +1,50 @@
+From 2be598d03640815834a242b16ffdefb856f15c54 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 27 May 2023 12:03:17 +0800
+Subject: tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss
+ set
+
+From: Cambda Zhu <cambda@linux.alibaba.com>
+
+[ Upstream commit 34dfde4ad87b84d21278a7e19d92b5b2c68e6c4d ]
+
+This patch replaces the tp->mss_cache check in getting TCP_MAXSEG
+with tp->rx_opt.user_mss check for CLOSE/LISTEN sock. Since
+tp->mss_cache is initialized with TCP_MSS_DEFAULT, checking if
+it's zero is probably a bug.
+
+With this change, getting TCP_MAXSEG before connecting will return
+default MSS normally, and return user_mss if user_mss is set.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Reported-by: Jack Yang <mingliang@linux.alibaba.com>
+Suggested-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/netdev/CANn89i+3kL9pYtkxkwxwNMzvC_w3LNUum_2=3u+UyLBmGmifHA@mail.gmail.com/#t
+Signed-off-by: Cambda Zhu <cambda@linux.alibaba.com>
+Link: https://lore.kernel.org/netdev/14D45862-36EA-4076-974C-EA67513C92F6@linux.alibaba.com/
+Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
+Reviewed-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/r/20230527040317.68247-1-cambda@linux.alibaba.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/tcp.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
+index edb743bcbc391..82abbf1929851 100644
+--- a/net/ipv4/tcp.c
++++ b/net/ipv4/tcp.c
+@@ -3719,7 +3719,8 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
+       switch (optname) {
+       case TCP_MAXSEG:
+               val = tp->mss_cache;
+-              if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
++              if (tp->rx_opt.user_mss &&
++                  ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
+                       val = tp->rx_opt.user_mss;
+               if (tp->repair)
+                       val = tp->rx_opt.mss_clamp;
+-- 
+2.39.2
+
diff --git a/queue-5.10/udp6-fix-race-condition-in-udp6_sendmsg-connect.patch b/queue-5.10/udp6-fix-race-condition-in-udp6_sendmsg-connect.patch
new file mode 100644 (file)
index 0000000..1040330
--- /dev/null
@@ -0,0 +1,63 @@
+From bb7fa174539bff4a50e35c694272454ae3a02fd6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 30 May 2023 14:39:41 +0300
+Subject: udp6: Fix race condition in udp6_sendmsg & connect
+
+From: Vladislav Efanov <VEfanov@ispras.ru>
+
+[ Upstream commit 448a5ce1120c5bdbce1f1ccdabcd31c7d029f328 ]
+
+Syzkaller got the following report:
+BUG: KASAN: use-after-free in sk_setup_caps+0x621/0x690 net/core/sock.c:2018
+Read of size 8 at addr ffff888027f82780 by task syz-executor276/3255
+
+The function sk_setup_caps (called by ip6_sk_dst_store_flow->
+ip6_dst_store) referenced already freed memory as this memory was
+freed by parallel task in udpv6_sendmsg->ip6_sk_dst_lookup_flow->
+sk_dst_check.
+
+          task1 (connect)              task2 (udp6_sendmsg)
+        sk_setup_caps->sk_dst_set |
+                                  |  sk_dst_check->
+                                  |      sk_dst_set
+                                  |      dst_release
+        sk_setup_caps references  |
+        to already freed dst_entry|
+
+The reason for this race condition is: sk_setup_caps() keeps using
+the dst after transferring the ownership to the dst cache.
+
+Found by Linux Verification Center (linuxtesting.org) with syzkaller.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru>
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/sock.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/core/sock.c b/net/core/sock.c
+index b8f8252d36819..2fba329e8c7a5 100644
+--- a/net/core/sock.c
++++ b/net/core/sock.c
+@@ -2029,7 +2029,6 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
+ {
+       u32 max_segs = 1;
+-      sk_dst_set(sk, dst);
+       sk->sk_route_caps = dst->dev->features | sk->sk_route_forced_caps;
+       if (sk->sk_route_caps & NETIF_F_GSO)
+               sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
+@@ -2044,6 +2043,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
+               }
+       }
+       sk->sk_gso_max_segs = max_segs;
++      sk_dst_set(sk, dst);
+ }
+ EXPORT_SYMBOL_GPL(sk_setup_caps);
+-- 
+2.39.2
+
diff --git a/queue-5.10/watchdog-menz069_wdt-fix-watchdog-initialisation.patch b/queue-5.10/watchdog-menz069_wdt-fix-watchdog-initialisation.patch
new file mode 100644 (file)
index 0000000..365de59
--- /dev/null
@@ -0,0 +1,71 @@
+From b8a2a9aeef0d662375be0dcbb12a7401d737b774 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 18 Apr 2023 19:25:30 +0200
+Subject: watchdog: menz069_wdt: fix watchdog initialisation
+
+From: Johannes Thumshirn <jth@kernel.org>
+
+[ Upstream commit 87b22656ca6a896d0378e9e60ffccb0c82f48b08 ]
+
+Doing a 'cat /dev/watchdog0' with menz069_wdt as watchdog0 will result in
+a NULL pointer dereference.
+
+This happens because we're passing the wrong pointer to
+watchdog_register_device(). Fix this by getting rid of the static
+watchdog_device structure and use the one embedded into the driver's
+per-instance private data.
+
+Signed-off-by: Johannes Thumshirn <jth@kernel.org>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Link: https://lore.kernel.org/r/20230418172531.177349-2-jth@kernel.org
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/watchdog/menz69_wdt.c | 16 ++++++----------
+ 1 file changed, 6 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/watchdog/menz69_wdt.c b/drivers/watchdog/menz69_wdt.c
+index 8973f98bc6a56..bca0938f3429f 100644
+--- a/drivers/watchdog/menz69_wdt.c
++++ b/drivers/watchdog/menz69_wdt.c
+@@ -98,14 +98,6 @@ static const struct watchdog_ops men_z069_ops = {
+       .set_timeout = men_z069_wdt_set_timeout,
+ };
+-static struct watchdog_device men_z069_wdt = {
+-      .info = &men_z069_info,
+-      .ops = &men_z069_ops,
+-      .timeout = MEN_Z069_DEFAULT_TIMEOUT,
+-      .min_timeout = 1,
+-      .max_timeout = MEN_Z069_WDT_COUNTER_MAX / MEN_Z069_TIMER_FREQ,
+-};
+-
+ static int men_z069_probe(struct mcb_device *dev,
+                         const struct mcb_device_id *id)
+ {
+@@ -125,15 +117,19 @@ static int men_z069_probe(struct mcb_device *dev,
+               goto release_mem;
+       drv->mem = mem;
++      drv->wdt.info = &men_z069_info;
++      drv->wdt.ops = &men_z069_ops;
++      drv->wdt.timeout = MEN_Z069_DEFAULT_TIMEOUT;
++      drv->wdt.min_timeout = 1;
++      drv->wdt.max_timeout = MEN_Z069_WDT_COUNTER_MAX / MEN_Z069_TIMER_FREQ;
+-      drv->wdt = men_z069_wdt;
+       watchdog_init_timeout(&drv->wdt, 0, &dev->dev);
+       watchdog_set_nowayout(&drv->wdt, nowayout);
+       watchdog_set_drvdata(&drv->wdt, drv);
+       drv->wdt.parent = &dev->dev;
+       mcb_set_drvdata(dev, drv);
+-      return watchdog_register_device(&men_z069_wdt);
++      return watchdog_register_device(&drv->wdt);
+ release_mem:
+       mcb_release_mem(mem);
+-- 
+2.39.2
+
diff --git a/queue-5.10/wifi-b43-fix-incorrect-__packed-annotation.patch b/queue-5.10/wifi-b43-fix-incorrect-__packed-annotation.patch
new file mode 100644 (file)
index 0000000..6a3f28e
--- /dev/null
@@ -0,0 +1,69 @@
+From 8f2a37d7a276aeb622e69fe1cd3ff177189e78b6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 May 2023 20:34:22 +0200
+Subject: wifi: b43: fix incorrect __packed annotation
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit 212457ccbd60dba34f965e4ffbe62f0e4f970538 ]
+
+clang warns about an unpacked structure inside of a packed one:
+
+drivers/net/wireless/broadcom/b43/b43.h:654:4: error: field data within 'struct b43_iv' is less aligned than 'union (unnamed union at /home/arnd/arm-soc/drivers/net/wireless/broadcom/b43/b43.h:651:2)' and is usually due to 'struct b43_iv' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
+
+The problem here is that the anonymous union has the default alignment
+from its members, apparently because the original author mixed up the
+placement of the __packed attribute by placing it next to the struct
+member rather than the union definition. As the struct itself is
+also marked as __packed, there is no need to mark its members, so just
+move the annotation to the inner type instead.
+
+As Michael noted, the same problem is present in b43legacy, so
+change both at the same time.
+
+Acked-by: Michael Büsch <m@bues.ch>
+Reported-by: kernel test robot <lkp@intel.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
+Link: https://lore.kernel.org/oe-kbuild-all/202305160749.ay1HAoyP-lkp@intel.com/
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://lore.kernel.org/r/20230516183442.536589-1-arnd@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/broadcom/b43/b43.h             | 2 +-
+ drivers/net/wireless/broadcom/b43legacy/b43legacy.h | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/broadcom/b43/b43.h b/drivers/net/wireless/broadcom/b43/b43.h
+index 9fc7c088a539e..67b4bac048e58 100644
+--- a/drivers/net/wireless/broadcom/b43/b43.h
++++ b/drivers/net/wireless/broadcom/b43/b43.h
+@@ -651,7 +651,7 @@ struct b43_iv {
+       union {
+               __be16 d16;
+               __be32 d32;
+-      } data __packed;
++      } __packed data;
+ } __packed;
+diff --git a/drivers/net/wireless/broadcom/b43legacy/b43legacy.h b/drivers/net/wireless/broadcom/b43legacy/b43legacy.h
+index 6b0cec467938f..f49365d14619f 100644
+--- a/drivers/net/wireless/broadcom/b43legacy/b43legacy.h
++++ b/drivers/net/wireless/broadcom/b43legacy/b43legacy.h
+@@ -379,7 +379,7 @@ struct b43legacy_iv {
+       union {
+               __be16 d16;
+               __be32 d32;
+-      } data __packed;
++      } __packed data;
+ } __packed;
+ #define B43legacy_PHYMODE(phytype)    (1 << (phytype))
+-- 
+2.39.2
+
diff --git a/queue-5.10/wifi-rtl8xxxu-fix-authentication-timeout-due-to-inco.patch b/queue-5.10/wifi-rtl8xxxu-fix-authentication-timeout-due-to-inco.patch
new file mode 100644 (file)
index 0000000..988abf3
--- /dev/null
@@ -0,0 +1,73 @@
+From 9c00c8c7fa33a7b77ee3d520ca7ae520b8fb05c7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 12 May 2023 09:20:55 +0800
+Subject: wifi: rtl8xxxu: fix authentication timeout due to incorrect RCR value
+
+From: Yun Lu <luyun@kylinos.cn>
+
+[ Upstream commit 20429444e653ee8242dfbf815c0c37866beb371b ]
+
+When using rtl8192cu with rtl8xxxu driver to connect wifi, there is a
+probability of failure, which shows "authentication with ... timed out".
+Through debugging, it was found that the RCR register has been inexplicably
+modified to an incorrect value, resulting in the nic not being able to
+receive authenticated frames.
+
+To fix this problem, add regrcr in rtl8xxxu_priv struct, and store
+the RCR value every time the register is written, and use it the next
+time the register need to be modified.
+
+Signed-off-by: Yun Lu <luyun@kylinos.cn>
+Link: https://lore.kernel.org/all/20230427020512.1221062-1-luyun_611@163.com
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://lore.kernel.org/r/20230512012055.2990472-1-luyun_611@163.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h      | 1 +
+ drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 +++-
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+index 0ed4d67308d78..fe1e4c4c17c42 100644
+--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+@@ -1346,6 +1346,7 @@ struct rtl8xxxu_priv {
+       u32 rege9c;
+       u32 regeb4;
+       u32 regebc;
++      u32 regrcr;
+       int next_mbox;
+       int nr_out_eps;
+diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+index deef1c09de319..004778faf3d07 100644
+--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+@@ -4045,6 +4045,7 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
+               RCR_ACCEPT_MGMT_FRAME | RCR_HTC_LOC_CTRL |
+               RCR_APPEND_PHYSTAT | RCR_APPEND_ICV | RCR_APPEND_MIC;
+       rtl8xxxu_write32(priv, REG_RCR, val32);
++      priv->regrcr = val32;
+       /*
+        * Accept all multicast
+@@ -5999,7 +6000,7 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw,
+                                     unsigned int *total_flags, u64 multicast)
+ {
+       struct rtl8xxxu_priv *priv = hw->priv;
+-      u32 rcr = rtl8xxxu_read32(priv, REG_RCR);
++      u32 rcr = priv->regrcr;
+       dev_dbg(&priv->udev->dev, "%s: changed_flags %08x, total_flags %08x\n",
+               __func__, changed_flags, *total_flags);
+@@ -6045,6 +6046,7 @@ static void rtl8xxxu_configure_filter(struct ieee80211_hw *hw,
+        */
+       rtl8xxxu_write32(priv, REG_RCR, rcr);
++      priv->regrcr = rcr;
+       *total_flags &= (FIF_ALLMULTI | FIF_FCSFAIL | FIF_BCN_PRBRESP_PROMISC |
+                        FIF_CONTROL | FIF_OTHER_BSS | FIF_PSPOLL |
+-- 
+2.39.2
+
diff --git a/queue-5.10/xfrm-check-if_id-in-inbound-policy-secpath-match.patch b/queue-5.10/xfrm-check-if_id-in-inbound-policy-secpath-match.patch
new file mode 100644 (file)
index 0000000..88eb369
--- /dev/null
@@ -0,0 +1,79 @@
+From 3f72519e3bde4c30ca2385fd16e100092cbea5b3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 10 May 2023 01:14:14 +0000
+Subject: xfrm: Check if_id in inbound policy/secpath match
+
+From: Benedict Wong <benedictwong@google.com>
+
+[ Upstream commit 8680407b6f8f5fba59e8f1d63c869abc280f04df ]
+
+This change ensures that if configured in the policy, the if_id set in
+the policy and secpath states match during the inbound policy check.
+Without this, there is potential for ambiguity where entries in the
+secpath differing by only the if_id could be mismatched.
+
+Notably, this is checked in the outbound direction when resolving
+templates to SAs, but not on the inbound path when matching SAs and
+policies.
+
+Test: Tested against Android kernel unit tests & CTS
+Signed-off-by: Benedict Wong <benedictwong@google.com>
+Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/xfrm/xfrm_policy.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
+index 2956854928537..d3b128b74a382 100644
+--- a/net/xfrm/xfrm_policy.c
++++ b/net/xfrm/xfrm_policy.c
+@@ -3240,7 +3240,7 @@ xfrm_secpath_reject(int idx, struct sk_buff *skb, const struct flowi *fl)
+ static inline int
+ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x,
+-            unsigned short family)
++            unsigned short family, u32 if_id)
+ {
+       if (xfrm_state_kern(x))
+               return tmpl->optional && !xfrm_state_addr_cmp(tmpl, x, tmpl->encap_family);
+@@ -3251,7 +3251,8 @@ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x,
+               (tmpl->allalgs || (tmpl->aalgos & (1<<x->props.aalgo)) ||
+                !(xfrm_id_proto_match(tmpl->id.proto, IPSEC_PROTO_ANY))) &&
+               !(x->props.mode != XFRM_MODE_TRANSPORT &&
+-                xfrm_state_addr_cmp(tmpl, x, family));
++                xfrm_state_addr_cmp(tmpl, x, family)) &&
++              (if_id == 0 || if_id == x->if_id);
+ }
+ /*
+@@ -3263,7 +3264,7 @@ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x,
+  */
+ static inline int
+ xfrm_policy_ok(const struct xfrm_tmpl *tmpl, const struct sec_path *sp, int start,
+-             unsigned short family)
++             unsigned short family, u32 if_id)
+ {
+       int idx = start;
+@@ -3273,7 +3274,7 @@ xfrm_policy_ok(const struct xfrm_tmpl *tmpl, const struct sec_path *sp, int star
+       } else
+               start = -1;
+       for (; idx < sp->len; idx++) {
+-              if (xfrm_state_ok(tmpl, sp->xvec[idx], family))
++              if (xfrm_state_ok(tmpl, sp->xvec[idx], family, if_id))
+                       return ++idx;
+               if (sp->xvec[idx]->props.mode != XFRM_MODE_TRANSPORT) {
+                       if (start == -1)
+@@ -3689,7 +3690,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
+                * are implied between each two transformations.
+                */
+               for (i = xfrm_nr-1, k = 0; i >= 0; i--) {
+-                      k = xfrm_policy_ok(tpp[i], sp, k, family);
++                      k = xfrm_policy_ok(tpp[i], sp, k, family, if_id);
+                       if (k < 0) {
+                               if (k < -1)
+                                       /* "-2 - errored_index" returned */
+-- 
+2.39.2
+