]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.15
authorSasha Levin <sashal@kernel.org>
Fri, 10 Mar 2023 10:31:50 +0000 (05:31 -0500)
committerSasha Levin <sashal@kernel.org>
Fri, 10 Mar 2023 10:31:50 +0000 (05:31 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
124 files changed:
queue-5.15/9p-rdma-unmap-receive-dma-buffer-in-rdma_request-pos.patch [new file with mode: 0644]
queue-5.15/9p-xen-fix-connection-sequence.patch [new file with mode: 0644]
queue-5.15/9p-xen-fix-version-parsing.patch [new file with mode: 0644]
queue-5.15/arm-dts-spear320-hmi-correct-stmpe-gpio-compatible.patch [new file with mode: 0644]
queue-5.15/asoc-adau7118-don-t-disable-regulators-on-device-unb.patch [new file with mode: 0644]
queue-5.15/asoc-mediatek-mt8195-add-missing-initialization.patch [new file with mode: 0644]
queue-5.15/asoc-zl38060-add-gpiolib-dependency.patch [new file with mode: 0644]
queue-5.15/asoc-zl38060-remove-spurious-gpiolib-select.patch [new file with mode: 0644]
queue-5.15/auxdisplay-hd44780-fix-potential-memory-leak-in-hd44.patch [new file with mode: 0644]
queue-5.15/bootconfig-increase-max-nodes-of-bootconfig-from-102.patch [new file with mode: 0644]
queue-5.15/drivers-base-component-fix-memory-leak-with-using-de.patch [new file with mode: 0644]
queue-5.15/drivers-base-dd-fix-memory-leak-with-using-debugfs_l.patch [new file with mode: 0644]
queue-5.15/ext4-use-ext4_fc_tl_mem-in-fast-commit-replay-path.patch [new file with mode: 0644]
queue-5.15/f2fs-allow-set-compression-option-of-files-without-b.patch [new file with mode: 0644]
queue-5.15/f2fs-fix-to-avoid-potential-memory-corruption-in-__u.patch [new file with mode: 0644]
queue-5.15/f2fs-use-memcpy_-to-from-_page-where-possible.patch [new file with mode: 0644]
queue-5.15/firmware-efi-sysfb_efi-add-quirk-for-lenovo-ideapad-.patch [new file with mode: 0644]
queue-5.15/fs-f2fs-initialize-fsdata-in-pagecache_write.patch [new file with mode: 0644]
queue-5.15/fs-jfs-fix-shift-exponent-db_agl2size-negative.patch [new file with mode: 0644]
queue-5.15/genirq-add-and-use-an-irq_data_update_affinity-helpe.patch [new file with mode: 0644]
queue-5.15/genirq-refactor-accessors-to-use-irq_data_get_affini.patch [new file with mode: 0644]
queue-5.15/ib-hfi1-update-rmt-size-calculation.patch [new file with mode: 0644]
queue-5.15/iio-accel-mma9551_core-prevent-uninitialized-variabl.patch [new file with mode: 0644]
queue-5.15/iio-accel-mma9551_core-prevent-uninitialized-variabl.patch-31264 [new file with mode: 0644]
queue-5.15/iommu-amd-fix-error-handling-for-pdev_pri_ats_enable.patch [new file with mode: 0644]
queue-5.15/ipv6-add-lwtunnel-encap-size-of-all-siblings-in-next.patch [new file with mode: 0644]
queue-5.15/kernel-fail_function-fix-memory-leak-with-using-debu.patch [new file with mode: 0644]
queue-5.15/kernel-printk-index.c-fix-memory-leak-with-using-deb.patch [new file with mode: 0644]
queue-5.15/loop-loop_set_status_from_info-check-before-assignme.patch [new file with mode: 0644]
queue-5.15/media-uvcvideo-handle-cameras-with-invalid-descripto.patch [new file with mode: 0644]
queue-5.15/media-uvcvideo-handle-errors-from-calls-to-usb_strin.patch [new file with mode: 0644]
queue-5.15/media-uvcvideo-quirk-for-autosuspend-in-logitech-b91.patch [new file with mode: 0644]
queue-5.15/media-uvcvideo-remove-format-descriptions.patch [new file with mode: 0644]
queue-5.15/media-uvcvideo-silence-memcpy-run-time-false-positiv.patch [new file with mode: 0644]
queue-5.15/mei-bus-fixup-upon-error-print-return-values-of-send.patch [new file with mode: 0644]
queue-5.15/mfd-arizona-use-pm_runtime_resume_and_get-to-prevent.patch [new file with mode: 0644]
queue-5.15/misc-vmw_balloon-fix-memory-leak-with-using-debugfs_.patch [new file with mode: 0644]
queue-5.15/net-fix-__dev_kfree_skb_any-vs-drop-monitor.patch [new file with mode: 0644]
queue-5.15/net-mlx5-geneve-fix-handling-of-geneve-object-id-as-.patch [new file with mode: 0644]
queue-5.15/net-mlx5e-verify-flow_source-cap-before-using-it.patch [new file with mode: 0644]
queue-5.15/net-sched-act_mpls-fix-action-bind-logic.patch [new file with mode: 0644]
queue-5.15/net-sched-act_pedit-fix-action-bind-logic.patch [new file with mode: 0644]
queue-5.15/net-sched-act_sample-fix-action-bind-logic.patch [new file with mode: 0644]
queue-5.15/net-sched-transition-act_pedit-to-rcu-and-percpu-sta.patch [new file with mode: 0644]
queue-5.15/netfilter-ctnetlink-fix-possible-refcount-leak-in-ct.patch [new file with mode: 0644]
queue-5.15/netfilter-ebtables-fix-table-blob-use-after-free.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-allow-to-fetch-set-elements-when.patch [new file with mode: 0644]
queue-5.15/netfilter-x_tables-fix-percpu-counter-block-leak-on-.patch [new file with mode: 0644]
queue-5.15/nfc-fix-memory-leak-of-se_io-context-in-nfc_genl_se_.patch [new file with mode: 0644]
queue-5.15/objtool-fix-memory-leak-in-create_static_call_sectio.patch [new file with mode: 0644]
queue-5.15/octeontx2-pf-use-correct-struct-reference-in-test-co.patch [new file with mode: 0644]
queue-5.15/parport_pc-set-up-mode-and-ecr-masks-for-oxford-semi.patch [new file with mode: 0644]
queue-5.15/pci-add-acs-quirk-for-wangxun-nics.patch [new file with mode: 0644]
queue-5.15/pci-align-extra-resources-for-hotplug-bridges-proper.patch [new file with mode: 0644]
queue-5.15/pci-loongson-add-more-devices-that-need-mrrs-quirk.patch [new file with mode: 0644]
queue-5.15/pci-loongson-prevent-ls7a-mrrs-increases.patch [new file with mode: 0644]
queue-5.15/pci-take-other-bus-devices-into-account-when-distrib.patch [new file with mode: 0644]
queue-5.15/phy-rockchip-typec-fix-unsigned-comparison-with-less.patch [new file with mode: 0644]
queue-5.15/pwm-sifive-always-let-the-first-pwm_apply_state-succ.patch [new file with mode: 0644]
queue-5.15/pwm-sifive-reduce-time-the-controller-lock-is-held.patch [new file with mode: 0644]
queue-5.15/pwm-stm32-lp-fix-the-check-on-arr-and-cmp-registers-.patch [new file with mode: 0644]
queue-5.15/rtc-allow-rtc_read_alarm-without-read_alarm-callback.patch [new file with mode: 0644]
queue-5.15/rtc-sun6i-always-export-the-internal-oscillator.patch [new file with mode: 0644]
queue-5.15/scsi-ipr-work-around-fortify-string-warning.patch [new file with mode: 0644]
queue-5.15/sctp-add-a-refcnt-in-sctp_stream_priorities-to-avoid.patch [new file with mode: 0644]
queue-5.15/serial-sc16is7xx-setup-gpio-controller-later-in-prob.patch [new file with mode: 0644]
queue-5.15/series
queue-5.15/soundwire-bus_type-avoid-lockdep-assert-in-sdw_drv_p.patch [new file with mode: 0644]
queue-5.15/soundwire-cadence-drain-the-rx-fifo-after-an-io-time.patch [new file with mode: 0644]
queue-5.15/soundwire-cadence-remove-wasted-space-in-response_bu.patch [new file with mode: 0644]
queue-5.15/staging-emxx_udc-add-checks-for-dma_alloc_coherent.patch [new file with mode: 0644]
queue-5.15/tcp-tcp_check_req-can-be-called-from-process-context.patch [new file with mode: 0644]
queue-5.15/thermal-intel-bxt_pmic-select-regmap-instead-of-depe.patch [new file with mode: 0644]
queue-5.15/thermal-intel-quark_dts-fix-error-pointer-dereferenc.patch [new file with mode: 0644]
queue-5.15/tools-iio-iio_utils-fix-memory-leak.patch [new file with mode: 0644]
queue-5.15/tracing-add-null-checks-for-buffer-in-ring_buffer_fr.patch [new file with mode: 0644]
queue-5.15/tty-fix-out-of-bounds-access-in-tty_driver_lookup_tt.patch [new file with mode: 0644]
queue-5.15/tty-pcn_uart-fix-memory-leak-with-using-debugfs_look.patch [new file with mode: 0644]
queue-5.15/tty-serial-fsl_lpuart-disable-the-cts-when-send-brea.patch [new file with mode: 0644]
queue-5.15/ubi-ensure-that-vid-header-offset-vid-header-size-al.patch [new file with mode: 0644]
queue-5.15/ubi-fastmap-fix-missed-fm_anchor-peb-in-wear-levelin.patch [new file with mode: 0644]
queue-5.15/ubi-fix-possible-null-ptr-deref-in-ubi_free_volume.patch [new file with mode: 0644]
queue-5.15/ubi-fix-uaf-wear-leveling-entry-in-eraseblk_count_se.patch [new file with mode: 0644]
queue-5.15/ubi-fix-unreferenced-object-reported-by-kmemleak-in-.patch [new file with mode: 0644]
queue-5.15/ubi-fix-use-after-free-when-volume-resizing-failed.patch [new file with mode: 0644]
queue-5.15/ubi-ubi_wl_put_peb-fix-infinite-loop-when-wear-level.patch [new file with mode: 0644]
queue-5.15/ubifs-dirty_cow_znode-fix-memleak-in-error-handling-.patch [new file with mode: 0644]
queue-5.15/ubifs-do_rename-fix-wrong-space-budget-when-target-i.patch [new file with mode: 0644]
queue-5.15/ubifs-fix-build-errors-as-symbol-undefined.patch [new file with mode: 0644]
queue-5.15/ubifs-fix-memory-leak-in-alloc_wbufs.patch [new file with mode: 0644]
queue-5.15/ubifs-fix-wrong-dirty-space-budget-for-dirty-inode.patch [new file with mode: 0644]
queue-5.15/ubifs-re-statistic-cleaned-znode-count-if-commit-fai.patch [new file with mode: 0644]
queue-5.15/ubifs-rectify-space-budget-for-ubifs_symlink-if-syml.patch [new file with mode: 0644]
queue-5.15/ubifs-rectify-space-budget-for-ubifs_xrename.patch [new file with mode: 0644]
queue-5.15/ubifs-reserve-one-leb-for-each-journal-head-while-do.patch [new file with mode: 0644]
queue-5.15/ubifs-ubifs_writepage-mark-page-dirty-after-writing-.patch [new file with mode: 0644]
queue-5.15/um-vector-fix-memory-leak-in-vector_config.patch [new file with mode: 0644]
queue-5.15/um-virt-pci-properly-remove-pci-device-from-bus.patch [new file with mode: 0644]
queue-5.15/um-virtio_uml-free-command-if-adding-to-virtqueue-fa.patch [new file with mode: 0644]
queue-5.15/um-virtio_uml-mark-device-as-unregistered-when-break.patch [new file with mode: 0644]
queue-5.15/um-virtio_uml-move-device-breaking-into-workqueue.patch [new file with mode: 0644]
queue-5.15/usb-chipidea-fix-memory-leak-with-using-debugfs_look.patch [new file with mode: 0644]
queue-5.15/usb-dwc3-fix-memory-leak-with-using-debugfs_lookup.patch [new file with mode: 0644]
queue-5.15/usb-ene_usb6250-allocate-enough-memory-for-full-obje.patch [new file with mode: 0644]
queue-5.15/usb-fix-memory-leak-with-using-debugfs_lookup.patch [new file with mode: 0644]
queue-5.15/usb-fotg210-fix-memory-leak-with-using-debugfs_looku.patch [new file with mode: 0644]
queue-5.15/usb-gadget-bcm63xx_udc-fix-memory-leak-with-using-de.patch [new file with mode: 0644]
queue-5.15/usb-gadget-gr_udc-fix-memory-leak-with-using-debugfs.patch [new file with mode: 0644]
queue-5.15/usb-gadget-lpc32xx_udc-fix-memory-leak-with-using-de.patch [new file with mode: 0644]
queue-5.15/usb-gadget-pxa25x_udc-fix-memory-leak-with-using-deb.patch [new file with mode: 0644]
queue-5.15/usb-gadget-pxa27x_udc-fix-memory-leak-with-using-deb.patch [new file with mode: 0644]
queue-5.15/usb-gadget-uvc-make-bsourceid-read-write.patch [new file with mode: 0644]
queue-5.15/usb-host-xhci-mvebu-iterate-over-array-indexes-inste.patch [new file with mode: 0644]
queue-5.15/usb-isp116x-fix-memory-leak-with-using-debugfs_looku.patch [new file with mode: 0644]
queue-5.15/usb-isp1362-fix-memory-leak-with-using-debugfs_looku.patch [new file with mode: 0644]
queue-5.15/usb-sl811-fix-memory-leak-with-using-debugfs_lookup.patch [new file with mode: 0644]
queue-5.15/usb-uhci-fix-memory-leak-with-using-debugfs_lookup.patch [new file with mode: 0644]
queue-5.15/usb-uvc-enumerate-valid-values-for-color-matching.patch [new file with mode: 0644]
queue-5.15/vc_screen-modify-vcs_size-handling-in-vcs_read.patch [new file with mode: 0644]
queue-5.15/watchdog-at91sam9_wdt-use-devm_request_irq-to-avoid-.patch [new file with mode: 0644]
queue-5.15/watchdog-fix-kmemleak-in-watchdog_cdev_register.patch [new file with mode: 0644]
queue-5.15/watchdog-pcwd_usb-fix-attempting-to-access-uninitial.patch [new file with mode: 0644]
queue-5.15/watchdog-sbsa_wdog-make-sure-the-timeout-programming.patch [new file with mode: 0644]
queue-5.15/x86-um-vdso-add-rcx-and-r11-to-the-syscall-clobber-l.patch [new file with mode: 0644]

diff --git a/queue-5.15/9p-rdma-unmap-receive-dma-buffer-in-rdma_request-pos.patch b/queue-5.15/9p-rdma-unmap-receive-dma-buffer-in-rdma_request-pos.patch
new file mode 100644 (file)
index 0000000..2cb62b9
--- /dev/null
@@ -0,0 +1,79 @@
+From 9f7152dc4743fa3c6264ea178e041951ff74a136 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 4 Jan 2023 10:04:24 +0800
+Subject: 9p/rdma: unmap receive dma buffer in rdma_request()/post_recv()
+
+From: Zhengchao Shao <shaozhengchao@huawei.com>
+
+[ Upstream commit 74a25e6e916cb57dab4267a96fbe8864ed21abdb ]
+
+When down_interruptible() or ib_post_send() failed in rdma_request(),
+receive dma buffer is not unmapped. Add unmap action to error path.
+Also if ib_post_recv() failed in post_recv(), dma buffer is not unmapped.
+Add unmap action to error path.
+
+Link: https://lkml.kernel.org/r/20230104020424.611926-1-shaozhengchao@huawei.com
+Fixes: fc79d4b104f0 ("9p: rdma: RDMA Transport Support for 9P")
+Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
+Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
+Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
+Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/9p/trans_rdma.c | 15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
+index f6d145873b497..e5bfe8d7ef449 100644
+--- a/net/9p/trans_rdma.c
++++ b/net/9p/trans_rdma.c
+@@ -388,6 +388,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
+       struct p9_trans_rdma *rdma = client->trans;
+       struct ib_recv_wr wr;
+       struct ib_sge sge;
++      int ret;
+       c->busa = ib_dma_map_single(rdma->cm_id->device,
+                                   c->rc.sdata, client->msize,
+@@ -405,7 +406,12 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
+       wr.wr_cqe = &c->cqe;
+       wr.sg_list = &sge;
+       wr.num_sge = 1;
+-      return ib_post_recv(rdma->qp, &wr, NULL);
++
++      ret = ib_post_recv(rdma->qp, &wr, NULL);
++      if (ret)
++              ib_dma_unmap_single(rdma->cm_id->device, c->busa,
++                                  client->msize, DMA_FROM_DEVICE);
++      return ret;
+  error:
+       p9_debug(P9_DEBUG_ERROR, "EIO\n");
+@@ -502,7 +508,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
+       if (down_interruptible(&rdma->sq_sem)) {
+               err = -EINTR;
+-              goto send_error;
++              goto dma_unmap;
+       }
+       /* Mark request as `sent' *before* we actually send it,
+@@ -512,11 +518,14 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
+       req->status = REQ_STATUS_SENT;
+       err = ib_post_send(rdma->qp, &wr, NULL);
+       if (err)
+-              goto send_error;
++              goto dma_unmap;
+       /* Success */
+       return 0;
++dma_unmap:
++      ib_dma_unmap_single(rdma->cm_id->device, c->busa,
++                          c->req->tc.size, DMA_TO_DEVICE);
+  /* Handle errors that happened during or while preparing the send: */
+  send_error:
+       req->status = REQ_STATUS_ERROR;
+-- 
+2.39.2
+
diff --git a/queue-5.15/9p-xen-fix-connection-sequence.patch b/queue-5.15/9p-xen-fix-connection-sequence.patch
new file mode 100644 (file)
index 0000000..ae18216
--- /dev/null
@@ -0,0 +1,117 @@
+From cd3161ad7e70a37622c77a96a4e946b218b342e4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Jan 2023 12:30:36 +0100
+Subject: 9p/xen: fix connection sequence
+
+From: Juergen Gross <jgross@suse.com>
+
+[ Upstream commit c15fe55d14b3b4ded5af2a3260877460a6ffb8ad ]
+
+Today the connection sequence of the Xen 9pfs frontend doesn't match
+the documented sequence. It can work reliably only for a PV 9pfs device
+having been added at boot time already, as the frontend is not waiting
+for the backend to have set its state to "XenbusStateInitWait" before
+reading the backend properties from Xenstore.
+
+Fix that by following the documented sequence [1] (the documentation
+has a bug, so the reference is for the patch fixing that).
+
+[1]: https://lore.kernel.org/xen-devel/20230130090937.31623-1-jgross@suse.com/T/#u
+
+Link: https://lkml.kernel.org/r/20230130113036.7087-3-jgross@suse.com
+Fixes: 868eb122739a ("xen/9pfs: introduce Xen 9pfs transport driver")
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
+Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/9p/trans_xen.c | 38 +++++++++++++++++++++++---------------
+ 1 file changed, 23 insertions(+), 15 deletions(-)
+
+diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
+index afa29f2a16050..9e4da8c1b907e 100644
+--- a/net/9p/trans_xen.c
++++ b/net/9p/trans_xen.c
+@@ -393,12 +393,11 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
+       return ret;
+ }
+-static int xen_9pfs_front_probe(struct xenbus_device *dev,
+-                              const struct xenbus_device_id *id)
++static int xen_9pfs_front_init(struct xenbus_device *dev)
+ {
+       int ret, i;
+       struct xenbus_transaction xbt;
+-      struct xen_9pfs_front_priv *priv = NULL;
++      struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev);
+       char *versions, *v;
+       unsigned int max_rings, max_ring_order, len = 0;
+@@ -426,11 +425,6 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
+       if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order))
+               p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2;
+-      priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+-      if (!priv)
+-              return -ENOMEM;
+-
+-      priv->dev = dev;
+       priv->num_rings = XEN_9PFS_NUM_RINGS;
+       priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings),
+                             GFP_KERNEL);
+@@ -489,23 +483,35 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
+               goto error;
+       }
+-      write_lock(&xen_9pfs_lock);
+-      list_add_tail(&priv->list, &xen_9pfs_devs);
+-      write_unlock(&xen_9pfs_lock);
+-      dev_set_drvdata(&dev->dev, priv);
+-      xenbus_switch_state(dev, XenbusStateInitialised);
+-
+       return 0;
+  error_xenbus:
+       xenbus_transaction_end(xbt, 1);
+       xenbus_dev_fatal(dev, ret, "writing xenstore");
+  error:
+-      dev_set_drvdata(&dev->dev, NULL);
+       xen_9pfs_front_free(priv);
+       return ret;
+ }
++static int xen_9pfs_front_probe(struct xenbus_device *dev,
++                              const struct xenbus_device_id *id)
++{
++      struct xen_9pfs_front_priv *priv = NULL;
++
++      priv = kzalloc(sizeof(*priv), GFP_KERNEL);
++      if (!priv)
++              return -ENOMEM;
++
++      priv->dev = dev;
++      dev_set_drvdata(&dev->dev, priv);
++
++      write_lock(&xen_9pfs_lock);
++      list_add_tail(&priv->list, &xen_9pfs_devs);
++      write_unlock(&xen_9pfs_lock);
++
++      return 0;
++}
++
+ static int xen_9pfs_front_resume(struct xenbus_device *dev)
+ {
+       dev_warn(&dev->dev, "suspend/resume unsupported\n");
+@@ -524,6 +530,8 @@ static void xen_9pfs_front_changed(struct xenbus_device *dev,
+               break;
+       case XenbusStateInitWait:
++              if (!xen_9pfs_front_init(dev))
++                      xenbus_switch_state(dev, XenbusStateInitialised);
+               break;
+       case XenbusStateConnected:
+-- 
+2.39.2
+
diff --git a/queue-5.15/9p-xen-fix-version-parsing.patch b/queue-5.15/9p-xen-fix-version-parsing.patch
new file mode 100644 (file)
index 0000000..1f2bba6
--- /dev/null
@@ -0,0 +1,63 @@
+From ec0e4280b6487b98be969b3219afedb53acaac4c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Jan 2023 12:30:35 +0100
+Subject: 9p/xen: fix version parsing
+
+From: Juergen Gross <jgross@suse.com>
+
+[ Upstream commit f1956f4ec15195ec60976d9b5625326285ab102e ]
+
+When connecting the Xen 9pfs frontend to the backend, the "versions"
+Xenstore entry written by the backend is parsed in a wrong way.
+
+The "versions" entry is defined to contain the versions supported by
+the backend separated by commas (e.g. "1,2"). Today only version "1"
+is defined. Unfortunately the frontend doesn't look for "1" being
+listed in the entry, but it is expecting the entry to have the value
+"1".
+
+This will result in failure as soon as the backend will support e.g.
+versions "1" and "2".
+
+Fix that by scanning the entry correctly.
+
+Link: https://lkml.kernel.org/r/20230130113036.7087-2-jgross@suse.com
+Fixes: 71ebd71921e4 ("xen/9pfs: connect to the backend")
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
+Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/9p/trans_xen.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
+index 4255f2a3bea48..afa29f2a16050 100644
+--- a/net/9p/trans_xen.c
++++ b/net/9p/trans_xen.c
+@@ -399,13 +399,19 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
+       int ret, i;
+       struct xenbus_transaction xbt;
+       struct xen_9pfs_front_priv *priv = NULL;
+-      char *versions;
++      char *versions, *v;
+       unsigned int max_rings, max_ring_order, len = 0;
+       versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
+       if (IS_ERR(versions))
+               return PTR_ERR(versions);
+-      if (strcmp(versions, "1")) {
++      for (v = versions; *v; v++) {
++              if (simple_strtoul(v, &v, 10) == 1) {
++                      v = NULL;
++                      break;
++              }
++      }
++      if (v) {
+               kfree(versions);
+               return -EINVAL;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/arm-dts-spear320-hmi-correct-stmpe-gpio-compatible.patch b/queue-5.15/arm-dts-spear320-hmi-correct-stmpe-gpio-compatible.patch
new file mode 100644 (file)
index 0000000..730185c
--- /dev/null
@@ -0,0 +1,37 @@
+From c289c90a769d8a28711d9714dc8864ad64ad2d5b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 25 Feb 2023 17:22:37 +0100
+Subject: ARM: dts: spear320-hmi: correct STMPE GPIO compatible
+
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+
+[ Upstream commit 33a0c1b850c8c85f400531dab3a0b022cdb164b1 ]
+
+The compatible is st,stmpe-gpio.
+
+Fixes: e2eb69183ec4 ("ARM: SPEAr320: DT: Add SPEAr 320 HMI board support")
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
+Link: https://lore.kernel.org/r/20230225162237.40242-1-krzysztof.kozlowski@linaro.org
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/boot/dts/spear320-hmi.dts | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm/boot/dts/spear320-hmi.dts b/arch/arm/boot/dts/spear320-hmi.dts
+index 367ba48aac3e5..5c562fb4886f4 100644
+--- a/arch/arm/boot/dts/spear320-hmi.dts
++++ b/arch/arm/boot/dts/spear320-hmi.dts
+@@ -242,7 +242,7 @@
+                                       irq-trigger = <0x1>;
+                                       stmpegpio: stmpe-gpio {
+-                                              compatible = "stmpe,gpio";
++                                              compatible = "st,stmpe-gpio";
+                                               reg = <0>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+-- 
+2.39.2
+
diff --git a/queue-5.15/asoc-adau7118-don-t-disable-regulators-on-device-unb.patch b/queue-5.15/asoc-adau7118-don-t-disable-regulators-on-device-unb.patch
new file mode 100644 (file)
index 0000000..dec60f1
--- /dev/null
@@ -0,0 +1,66 @@
+From 06c6fd0c2b46590b15be687b331d91f7056fa425 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Feb 2023 11:45:51 +0100
+Subject: ASoC: adau7118: don't disable regulators on device unbind
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Nuno Sá <nuno.sa@analog.com>
+
+[ Upstream commit b5bfa7277ee7d944421e0ef193586c6e34d7492c ]
+
+The regulators are supposed to be controlled through the
+set_bias_level() component callback. Moreover, the regulators are not
+enabled during probe and so, this would lead to a regulator unbalanced
+use count.
+
+Fixes: ca514c0f12b02 ("ASOC: Add ADAU7118 8 Channel PDM-to-I2S/TDM Converter driver")
+Signed-off-by: Nuno Sá <nuno.sa@analog.com>
+Link: https://lore.kernel.org/r/20230224104551.1139981-1-nuno.sa@analog.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/codecs/adau7118.c | 19 +------------------
+ 1 file changed, 1 insertion(+), 18 deletions(-)
+
+diff --git a/sound/soc/codecs/adau7118.c b/sound/soc/codecs/adau7118.c
+index 841229dcbca10..305f294b7710e 100644
+--- a/sound/soc/codecs/adau7118.c
++++ b/sound/soc/codecs/adau7118.c
+@@ -445,22 +445,6 @@ static const struct snd_soc_component_driver adau7118_component_driver = {
+       .non_legacy_dai_naming  = 1,
+ };
+-static void adau7118_regulator_disable(void *data)
+-{
+-      struct adau7118_data *st = data;
+-      int ret;
+-      /*
+-       * If we fail to disable DVDD, don't bother in trying IOVDD. We
+-       * actually don't want to be left in the situation where DVDD
+-       * is enabled and IOVDD is disabled.
+-       */
+-      ret = regulator_disable(st->dvdd);
+-      if (ret)
+-              return;
+-
+-      regulator_disable(st->iovdd);
+-}
+-
+ static int adau7118_regulator_setup(struct adau7118_data *st)
+ {
+       st->iovdd = devm_regulator_get(st->dev, "iovdd");
+@@ -482,8 +466,7 @@ static int adau7118_regulator_setup(struct adau7118_data *st)
+               regcache_cache_only(st->map, true);
+       }
+-      return devm_add_action_or_reset(st->dev, adau7118_regulator_disable,
+-                                      st);
++      return 0;
+ }
+ static int adau7118_parset_dt(const struct adau7118_data *st)
+-- 
+2.39.2
+
diff --git a/queue-5.15/asoc-mediatek-mt8195-add-missing-initialization.patch b/queue-5.15/asoc-mediatek-mt8195-add-missing-initialization.patch
new file mode 100644 (file)
index 0000000..531f2df
--- /dev/null
@@ -0,0 +1,45 @@
+From 502ed284547ca251985b4e347f3f47673a73aba4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Mar 2023 19:02:00 +0800
+Subject: ASoC: mediatek: mt8195: add missing initialization
+
+From: Trevor Wu <trevor.wu@mediatek.com>
+
+[ Upstream commit b56ec2992a2e43bc3e60d6db86849d31640e791f ]
+
+In etdm dai driver, dai_etdm_parse_of() function is used to parse dts
+properties to get parameters. There are two for-loops which are
+sepearately for all etdm and etdm input only cases. In etdm in only
+loop, dai_id is not initialized, so it keeps the value intiliazed in
+another loop.
+
+In the patch, add the missing initialization to fix the unexpected
+parsing problem.
+
+Fixes: 1de9a54acafb ("ASoC: mediatek: mt8195: support etdm in platform driver")
+Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
+Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Link: https://lore.kernel.org/r/20230301110200.26177-3-trevor.wu@mediatek.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/mediatek/mt8195/mt8195-dai-etdm.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c b/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
+index 7378e42f27669..9031d410bbd0a 100644
+--- a/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
++++ b/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
+@@ -2567,6 +2567,9 @@ static void mt8195_dai_etdm_parse_of(struct mtk_base_afe *afe)
+       /* etdm in only */
+       for (i = 0; i < 2; i++) {
++              dai_id = ETDM_TO_DAI_ID(i);
++              etdm_data = afe_priv->dai_priv[dai_id];
++
+               ret = snprintf(prop, sizeof(prop),
+                              "mediatek,%s-chn-disabled",
+                              of_afe_etdms[i].name);
+-- 
+2.39.2
+
diff --git a/queue-5.15/asoc-zl38060-add-gpiolib-dependency.patch b/queue-5.15/asoc-zl38060-add-gpiolib-dependency.patch
new file mode 100644 (file)
index 0000000..06964ac
--- /dev/null
@@ -0,0 +1,44 @@
+From f8e1adb988d86c4732e4600ae821fb1988dc923e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 27 Feb 2023 09:58:26 +0100
+Subject: ASoC: zl38060 add gpiolib dependency
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit 0de2cc3707b6b6e2ad40bd24ce09a5c1f65d01e1 ]
+
+Without gpiolib, this driver fails to link:
+
+arm-linux-gnueabi-ld: sound/soc/codecs/zl38060.o: in function `chip_gpio_get':
+zl38060.c:(.text+0x30): undefined reference to `gpiochip_get_data'
+arm-linux-gnueabi-ld: sound/soc/codecs/zl38060.o: in function `zl38_spi_probe':
+zl38060.c:(.text+0xa18): undefined reference to `devm_gpiochip_add_data_with_key'
+
+This appears to have been in the driver since the start, but is hard to
+hit in randconfig testing since gpiolib is almost always selected by something
+else.
+
+Fixes: 52e8a94baf90 ("ASoC: Add initial ZL38060 driver")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Link: https://lore.kernel.org/r/20230227085850.2503725-1-arnd@kernel.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/codecs/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
+index e9d2408f8480c..c3deb82c5da3a 100644
+--- a/sound/soc/codecs/Kconfig
++++ b/sound/soc/codecs/Kconfig
+@@ -1830,6 +1830,7 @@ config SND_SOC_WSA881X
+ config SND_SOC_ZL38060
+       tristate "Microsemi ZL38060 Connected Home Audio Processor"
+       depends on SPI_MASTER
++      depends on GPIOLIB
+       select REGMAP
+       help
+         Support for ZL38060 Connected Home Audio Processor from Microsemi,
+-- 
+2.39.2
+
diff --git a/queue-5.15/asoc-zl38060-remove-spurious-gpiolib-select.patch b/queue-5.15/asoc-zl38060-remove-spurious-gpiolib-select.patch
new file mode 100644 (file)
index 0000000..d73d0af
--- /dev/null
@@ -0,0 +1,36 @@
+From 965cafbe5a83c0771dd849a7f0be2e2f12d12cf3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 2 Feb 2022 19:23:32 +0000
+Subject: ASoC: zl38060: Remove spurious gpiolib select
+
+From: Mark Brown <broonie@kernel.org>
+
+[ Upstream commit 8e70aaae32b72d3088d18a3447b67112b3f5979a ]
+
+The usage of GPIOs is optional in the code so don't force on gpiolib when
+building it, avoiding warnings in randconfigs.
+
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/r/20220202192333.3655269-6-broonie@kernel.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Stable-dep-of: 0de2cc3707b6 ("ASoC: zl38060 add gpiolib dependency")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/codecs/Kconfig | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
+index d59a7e99ce42a..e9d2408f8480c 100644
+--- a/sound/soc/codecs/Kconfig
++++ b/sound/soc/codecs/Kconfig
+@@ -1830,7 +1830,6 @@ config SND_SOC_WSA881X
+ config SND_SOC_ZL38060
+       tristate "Microsemi ZL38060 Connected Home Audio Processor"
+       depends on SPI_MASTER
+-      select GPIOLIB
+       select REGMAP
+       help
+         Support for ZL38060 Connected Home Audio Processor from Microsemi,
+-- 
+2.39.2
+
diff --git a/queue-5.15/auxdisplay-hd44780-fix-potential-memory-leak-in-hd44.patch b/queue-5.15/auxdisplay-hd44780-fix-potential-memory-leak-in-hd44.patch
new file mode 100644 (file)
index 0000000..d1b36a8
--- /dev/null
@@ -0,0 +1,45 @@
+From c06ad3e881b90c1dd31beeea9f2494f0e5e08cab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 29 Nov 2022 16:15:42 +0800
+Subject: auxdisplay: hd44780: Fix potential memory leak in hd44780_remove()
+
+From: Jianglei Nie <niejianglei2021@163.com>
+
+[ Upstream commit ddf75a86aba2cfb7ec4497e8692b60c8c8fe0ee7 ]
+
+hd44780_probe() allocates a memory chunk for hd with kzalloc() and
+makes "lcd->drvdata->hd44780" point to it. When we call hd44780_remove(),
+we should release all relevant memory and resource. But "lcd->drvdata
+->hd44780" is not released, which will lead to a memory leak.
+
+We should release the "lcd->drvdata->hd44780" in hd44780_remove() to fix
+the memory leak bug.
+
+Fixes: 718e05ed92ec ("auxdisplay: Introduce hd44780_common.[ch]")
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Reported-by: kernel test robot <lkp@intel.com>
+Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
+Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/auxdisplay/hd44780.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c
+index 8b2a0eb3f32a4..d56a5d508ccd7 100644
+--- a/drivers/auxdisplay/hd44780.c
++++ b/drivers/auxdisplay/hd44780.c
+@@ -322,8 +322,10 @@ static int hd44780_probe(struct platform_device *pdev)
+ static int hd44780_remove(struct platform_device *pdev)
+ {
+       struct charlcd *lcd = platform_get_drvdata(pdev);
++      struct hd44780_common *hdc = lcd->drvdata;
+       charlcd_unregister(lcd);
++      kfree(hdc->hd44780);
+       kfree(lcd->drvdata);
+       kfree(lcd);
+-- 
+2.39.2
+
diff --git a/queue-5.15/bootconfig-increase-max-nodes-of-bootconfig-from-102.patch b/queue-5.15/bootconfig-increase-max-nodes-of-bootconfig-from-102.patch
new file mode 100644 (file)
index 0000000..d61d3aa
--- /dev/null
@@ -0,0 +1,41 @@
+From a1226666029819497d4853144bbd67acaac626b8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Feb 2023 08:27:49 +0900
+Subject: bootconfig: Increase max nodes of bootconfig from 1024 to 8192 for
+ DCC support
+
+From: Souradeep Chowdhury <quic_schowdhu@quicinc.com>
+
+[ Upstream commit 6c40624930c58529185a257380442547580ed837 ]
+
+The Data Capture and Compare(DCC) is a debugging tool that uses the bootconfig
+for configuring the register values during boot-time. Increase the max nodes
+supported by bootconfig to cater to the requirements of the Data Capture and
+Compare Driver.
+
+Link: https://lore.kernel.org/all/1674536682-18404-1-git-send-email-quic_schowdhu@quicinc.com/
+
+Signed-off-by: Souradeep Chowdhury <quic_schowdhu@quicinc.com>
+Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
+Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/bootconfig.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h
+index 537e1b991f115..5296fbb8408ca 100644
+--- a/include/linux/bootconfig.h
++++ b/include/linux/bootconfig.h
+@@ -49,7 +49,7 @@ struct xbc_node {
+ /* Maximum size of boot config is 32KB - 1 */
+ #define XBC_DATA_MAX  (XBC_VALUE - 1)
+-#define XBC_NODE_MAX  1024
++#define XBC_NODE_MAX  8192
+ #define XBC_KEYLEN_MAX        256
+ #define XBC_DEPTH_MAX 16
+-- 
+2.39.2
+
diff --git a/queue-5.15/drivers-base-component-fix-memory-leak-with-using-de.patch b/queue-5.15/drivers-base-component-fix-memory-leak-with-using-de.patch
new file mode 100644 (file)
index 0000000..97cb777
--- /dev/null
@@ -0,0 +1,38 @@
+From 1d52f0f8f1f21281400235ffdcab076f6aa28ff1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 15:16:20 +0100
+Subject: drivers: base: component: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 8deb87b1e810dd558371e88ffd44339fbef27870 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: "Rafael J. Wysocki" <rafael@kernel.org>
+Link: https://lore.kernel.org/r/20230202141621.2296458-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/component.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/base/component.c b/drivers/base/component.c
+index 870485cbbb87c..058f1a2cb2a9a 100644
+--- a/drivers/base/component.c
++++ b/drivers/base/component.c
+@@ -130,7 +130,7 @@ static void component_master_debugfs_add(struct master *m)
+ static void component_master_debugfs_del(struct master *m)
+ {
+-      debugfs_remove(debugfs_lookup(dev_name(m->parent), component_debugfs_dir));
++      debugfs_lookup_and_remove(dev_name(m->parent), component_debugfs_dir);
+ }
+ #else
+-- 
+2.39.2
+
diff --git a/queue-5.15/drivers-base-dd-fix-memory-leak-with-using-debugfs_l.patch b/queue-5.15/drivers-base-dd-fix-memory-leak-with-using-debugfs_l.patch
new file mode 100644 (file)
index 0000000..1b79ee8
--- /dev/null
@@ -0,0 +1,38 @@
+From 0a87b3bf96d811e93088c69737368bf1ce90d767 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 15:16:21 +0100
+Subject: drivers: base: dd: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 36c893d3a759ae7c91ee7d4871ebfc7504f08c40 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: "Rafael J. Wysocki" <rafael@kernel.org>
+Link: https://lore.kernel.org/r/20230202141621.2296458-2-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/dd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/base/dd.c b/drivers/base/dd.c
+index 060348125635b..9cbf086fe5524 100644
+--- a/drivers/base/dd.c
++++ b/drivers/base/dd.c
+@@ -352,7 +352,7 @@ late_initcall(deferred_probe_initcall);
+ static void __exit deferred_probe_exit(void)
+ {
+-      debugfs_remove_recursive(debugfs_lookup("devices_deferred", NULL));
++      debugfs_lookup_and_remove("devices_deferred", NULL);
+ }
+ __exitcall(deferred_probe_exit);
+-- 
+2.39.2
+
diff --git a/queue-5.15/ext4-use-ext4_fc_tl_mem-in-fast-commit-replay-path.patch b/queue-5.15/ext4-use-ext4_fc_tl_mem-in-fast-commit-replay-path.patch
new file mode 100644 (file)
index 0000000..0105426
--- /dev/null
@@ -0,0 +1,143 @@
+From 656ce8cf73610291a3f7027f4b1a9e207cb0b636 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 16 Dec 2022 21:02:12 -0800
+Subject: ext4: use ext4_fc_tl_mem in fast-commit replay path
+
+From: Eric Biggers <ebiggers@google.com>
+
+[ Upstream commit 11768cfd98136dd8399480c60b7a5d3d3c7b109b ]
+
+To avoid 'sparse' warnings about missing endianness conversions, don't
+store native endianness values into struct ext4_fc_tl.  Instead, use a
+separate struct type, ext4_fc_tl_mem.
+
+Fixes: dcc5827484d6 ("ext4: factor out ext4_fc_get_tl()")
+Cc: Ye Bin <yebin10@huawei.com>
+Signed-off-by: Eric Biggers <ebiggers@google.com>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/20221217050212.150665-1-ebiggers@kernel.org
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ext4/fast_commit.c | 44 +++++++++++++++++++++++++------------------
+ 1 file changed, 26 insertions(+), 18 deletions(-)
+
+diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
+index a8d0a8081a1da..2660c34c770e3 100644
+--- a/fs/ext4/fast_commit.c
++++ b/fs/ext4/fast_commit.c
+@@ -1282,8 +1282,14 @@ struct dentry_info_args {
+       char *dname;
+ };
++/* Same as struct ext4_fc_tl, but uses native endianness fields */
++struct ext4_fc_tl_mem {
++      u16 fc_tag;
++      u16 fc_len;
++};
++
+ static inline void tl_to_darg(struct dentry_info_args *darg,
+-                            struct ext4_fc_tl *tl, u8 *val)
++                            struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       struct ext4_fc_dentry_info fcd;
+@@ -1295,16 +1301,18 @@ static inline void tl_to_darg(struct dentry_info_args *darg,
+       darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info);
+ }
+-static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val)
++static inline void ext4_fc_get_tl(struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+-      memcpy(tl, val, EXT4_FC_TAG_BASE_LEN);
+-      tl->fc_len = le16_to_cpu(tl->fc_len);
+-      tl->fc_tag = le16_to_cpu(tl->fc_tag);
++      struct ext4_fc_tl tl_disk;
++
++      memcpy(&tl_disk, val, EXT4_FC_TAG_BASE_LEN);
++      tl->fc_len = le16_to_cpu(tl_disk.fc_len);
++      tl->fc_tag = le16_to_cpu(tl_disk.fc_tag);
+ }
+ /* Unlink replay function */
+-static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl,
+-                               u8 *val)
++static int ext4_fc_replay_unlink(struct super_block *sb,
++                               struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       struct inode *inode, *old_parent;
+       struct qstr entry;
+@@ -1401,8 +1409,8 @@ static int ext4_fc_replay_link_internal(struct super_block *sb,
+ }
+ /* Link replay function */
+-static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl,
+-                             u8 *val)
++static int ext4_fc_replay_link(struct super_block *sb,
++                             struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       struct inode *inode;
+       struct dentry_info_args darg;
+@@ -1456,8 +1464,8 @@ static int ext4_fc_record_modified_inode(struct super_block *sb, int ino)
+ /*
+  * Inode replay function
+  */
+-static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
+-                              u8 *val)
++static int ext4_fc_replay_inode(struct super_block *sb,
++                              struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       struct ext4_fc_inode fc_inode;
+       struct ext4_inode *raw_inode;
+@@ -1557,8 +1565,8 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
+  * inode for which we are trying to create a dentry here, should already have
+  * been replayed before we start here.
+  */
+-static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl,
+-                               u8 *val)
++static int ext4_fc_replay_create(struct super_block *sb,
++                               struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       int ret = 0;
+       struct inode *inode = NULL;
+@@ -1657,7 +1665,7 @@ int ext4_fc_record_regions(struct super_block *sb, int ino,
+ /* Replay add range tag */
+ static int ext4_fc_replay_add_range(struct super_block *sb,
+-                                  struct ext4_fc_tl *tl, u8 *val)
++                                  struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       struct ext4_fc_add_range fc_add_ex;
+       struct ext4_extent newex, *ex;
+@@ -1778,8 +1786,8 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
+ /* Replay DEL_RANGE tag */
+ static int
+-ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl,
+-                       u8 *val)
++ext4_fc_replay_del_range(struct super_block *sb,
++                       struct ext4_fc_tl_mem *tl, u8 *val)
+ {
+       struct inode *inode;
+       struct ext4_fc_del_range lrange;
+@@ -1972,7 +1980,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
+       struct ext4_fc_replay_state *state;
+       int ret = JBD2_FC_REPLAY_CONTINUE;
+       struct ext4_fc_add_range ext;
+-      struct ext4_fc_tl tl;
++      struct ext4_fc_tl_mem tl;
+       struct ext4_fc_tail tail;
+       __u8 *start, *end, *cur, *val;
+       struct ext4_fc_head head;
+@@ -2091,7 +2099,7 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
+ {
+       struct super_block *sb = journal->j_private;
+       struct ext4_sb_info *sbi = EXT4_SB(sb);
+-      struct ext4_fc_tl tl;
++      struct ext4_fc_tl_mem tl;
+       __u8 *start, *end, *cur, *val;
+       int ret = JBD2_FC_REPLAY_CONTINUE;
+       struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state;
+-- 
+2.39.2
+
diff --git a/queue-5.15/f2fs-allow-set-compression-option-of-files-without-b.patch b/queue-5.15/f2fs-allow-set-compression-option-of-files-without-b.patch
new file mode 100644 (file)
index 0000000..e8df603
--- /dev/null
@@ -0,0 +1,37 @@
+From fb26c66737df4f9dc6a689fb8deafbb1fedb0ed4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 Jan 2023 17:46:01 +0800
+Subject: f2fs: allow set compression option of files without blocks
+
+From: Yangtao Li <frank.li@vivo.com>
+
+[ Upstream commit e6261beb0c629403dc58997294dd521bd23664af ]
+
+Files created by truncate have a size but no blocks, so
+they can be allowed to set compression option.
+
+Fixes: e1e8debec656 ("f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl")
+Signed-off-by: Yangtao Li <frank.li@vivo.com>
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/file.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
+index 758048a885d24..326c1a4c2a6ac 100644
+--- a/fs/f2fs/file.c
++++ b/fs/f2fs/file.c
+@@ -3928,7 +3928,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
+               goto out;
+       }
+-      if (inode->i_size != 0) {
++      if (F2FS_HAS_BLOCKS(inode)) {
+               ret = -EFBIG;
+               goto out;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/f2fs-fix-to-avoid-potential-memory-corruption-in-__u.patch b/queue-5.15/f2fs-fix-to-avoid-potential-memory-corruption-in-__u.patch
new file mode 100644 (file)
index 0000000..c37db9c
--- /dev/null
@@ -0,0 +1,76 @@
+From ebb7fcaa71c86830f0ee4a58e729e2c865efa20b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 21 Jan 2023 00:16:55 +0800
+Subject: f2fs: fix to avoid potential memory corruption in
+ __update_iostat_latency()
+
+From: Yangtao Li <frank.li@vivo.com>
+
+[ Upstream commit 0dbbf0fb38d5ec5d4138d1aeaeb43d9217b9a592 ]
+
+Add iotype sanity check to avoid potential memory corruption.
+This is to fix the compile error below:
+
+fs/f2fs/iostat.c:231 __update_iostat_latency() error: buffer overflow
+'io_lat->peak_lat[type]' 3 <= 3
+
+vim +228 fs/f2fs/iostat.c
+
+  211  static inline void __update_iostat_latency(struct bio_iostat_ctx
+       *iostat_ctx,
+  212                                  enum iostat_lat_type type)
+  213  {
+  214          unsigned long ts_diff;
+  215          unsigned int page_type = iostat_ctx->type;
+  216          struct f2fs_sb_info *sbi = iostat_ctx->sbi;
+  217          struct iostat_lat_info *io_lat = sbi->iostat_io_lat;
+  218          unsigned long flags;
+  219
+  220          if (!sbi->iostat_enable)
+  221                  return;
+  222
+  223          ts_diff = jiffies - iostat_ctx->submit_ts;
+  224          if (page_type >= META_FLUSH)
+                                 ^^^^^^^^^^
+
+  225                  page_type = META;
+  226
+  227          spin_lock_irqsave(&sbi->iostat_lat_lock, flags);
+ @228          io_lat->sum_lat[type][page_type] += ts_diff;
+                                      ^^^^^^^^^
+Mixup between META_FLUSH and NR_PAGE_TYPE leads to memory corruption.
+
+Fixes: a4b6817625e7 ("f2fs: introduce periodic iostat io latency traces")
+Reported-by: kernel test robot <lkp@intel.com>
+Reported-by: Dan Carpenter <error27@gmail.com>
+Suggested-by: Chao Yu <chao@kernel.org>
+Suggested-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Yangtao Li <frank.li@vivo.com>
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/iostat.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
+index cdcf54ae0db8f..9e0160a02bf4a 100644
+--- a/fs/f2fs/iostat.c
++++ b/fs/f2fs/iostat.c
+@@ -194,8 +194,12 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx,
+               return;
+       ts_diff = jiffies - iostat_ctx->submit_ts;
+-      if (iotype >= META_FLUSH)
++      if (iotype == META_FLUSH) {
+               iotype = META;
++      } else if (iotype >= NR_PAGE_TYPE) {
++              f2fs_warn(sbi, "%s: %d over NR_PAGE_TYPE", __func__, iotype);
++              return;
++      }
+       if (rw == 0) {
+               idx = READ_IO;
+-- 
+2.39.2
+
diff --git a/queue-5.15/f2fs-use-memcpy_-to-from-_page-where-possible.patch b/queue-5.15/f2fs-use-memcpy_-to-from-_page-where-possible.patch
new file mode 100644 (file)
index 0000000..83b63fd
--- /dev/null
@@ -0,0 +1,158 @@
+From fdf44df1f07d1af3195a9d79d134bd2c1e057048 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 19 Aug 2022 15:33:00 -0700
+Subject: f2fs: use memcpy_{to,from}_page() where possible
+
+From: Eric Biggers <ebiggers@google.com>
+
+[ Upstream commit b87846bd61c7c09560617da416208a5454530d57 ]
+
+This is simpler, and as a side effect it replaces several uses of
+kmap_atomic() with its recommended replacement kmap_local_page().
+
+Signed-off-by: Eric Biggers <ebiggers@google.com>
+Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
+Reviewed-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Stable-dep-of: b1b9896718bc ("fs: f2fs: initialize fsdata in pagecache_write()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/inline.c | 15 ++++-----------
+ fs/f2fs/super.c  | 11 ++---------
+ fs/f2fs/verity.c | 10 ++--------
+ 3 files changed, 8 insertions(+), 28 deletions(-)
+
+diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
+index 480d5f76491db..bce1c2ae6d153 100644
+--- a/fs/f2fs/inline.c
++++ b/fs/f2fs/inline.c
+@@ -64,7 +64,6 @@ bool f2fs_may_inline_dentry(struct inode *inode)
+ void f2fs_do_read_inline_data(struct page *page, struct page *ipage)
+ {
+       struct inode *inode = page->mapping->host;
+-      void *src_addr, *dst_addr;
+       if (PageUptodate(page))
+               return;
+@@ -74,11 +73,8 @@ void f2fs_do_read_inline_data(struct page *page, struct page *ipage)
+       zero_user_segment(page, MAX_INLINE_DATA(inode), PAGE_SIZE);
+       /* Copy the whole inline data block */
+-      src_addr = inline_data_addr(inode, ipage);
+-      dst_addr = kmap_atomic(page);
+-      memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
+-      flush_dcache_page(page);
+-      kunmap_atomic(dst_addr);
++      memcpy_to_page(page, 0, inline_data_addr(inode, ipage),
++                     MAX_INLINE_DATA(inode));
+       if (!PageUptodate(page))
+               SetPageUptodate(page);
+ }
+@@ -246,7 +242,6 @@ int f2fs_convert_inline_inode(struct inode *inode)
+ int f2fs_write_inline_data(struct inode *inode, struct page *page)
+ {
+-      void *src_addr, *dst_addr;
+       struct dnode_of_data dn;
+       int err;
+@@ -263,10 +258,8 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
+       f2fs_bug_on(F2FS_I_SB(inode), page->index);
+       f2fs_wait_on_page_writeback(dn.inode_page, NODE, true, true);
+-      src_addr = kmap_atomic(page);
+-      dst_addr = inline_data_addr(inode, dn.inode_page);
+-      memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
+-      kunmap_atomic(src_addr);
++      memcpy_from_page(inline_data_addr(inode, dn.inode_page),
++                       page, 0, MAX_INLINE_DATA(inode));
+       set_page_dirty(dn.inode_page);
+       f2fs_clear_page_cache_dirty_tag(page);
+diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
+index f4e8de1f47899..ae72211e422e7 100644
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -2442,7 +2442,6 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
+       size_t toread;
+       loff_t i_size = i_size_read(inode);
+       struct page *page;
+-      char *kaddr;
+       if (off > i_size)
+               return 0;
+@@ -2476,9 +2475,7 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
+                       return -EIO;
+               }
+-              kaddr = kmap_atomic(page);
+-              memcpy(data, kaddr + offset, tocopy);
+-              kunmap_atomic(kaddr);
++              memcpy_from_page(data, page, offset, tocopy);
+               f2fs_put_page(page, 1);
+               offset = 0;
+@@ -2500,7 +2497,6 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
+       size_t towrite = len;
+       struct page *page;
+       void *fsdata = NULL;
+-      char *kaddr;
+       int err = 0;
+       int tocopy;
+@@ -2520,10 +2516,7 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type,
+                       break;
+               }
+-              kaddr = kmap_atomic(page);
+-              memcpy(kaddr + offset, data, tocopy);
+-              kunmap_atomic(kaddr);
+-              flush_dcache_page(page);
++              memcpy_to_page(page, offset, data, tocopy);
+               a_ops->write_end(NULL, mapping, off, tocopy, tocopy,
+                                               page, fsdata);
+diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
+index a28968bb56e62..26e7154168291 100644
+--- a/fs/f2fs/verity.c
++++ b/fs/f2fs/verity.c
+@@ -47,16 +47,13 @@ static int pagecache_read(struct inode *inode, void *buf, size_t count,
+               size_t n = min_t(size_t, count,
+                                PAGE_SIZE - offset_in_page(pos));
+               struct page *page;
+-              void *addr;
+               page = read_mapping_page(inode->i_mapping, pos >> PAGE_SHIFT,
+                                        NULL);
+               if (IS_ERR(page))
+                       return PTR_ERR(page);
+-              addr = kmap_atomic(page);
+-              memcpy(buf, addr + offset_in_page(pos), n);
+-              kunmap_atomic(addr);
++              memcpy_from_page(buf, page, offset_in_page(pos), n);
+               put_page(page);
+@@ -82,7 +79,6 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
+                                PAGE_SIZE - offset_in_page(pos));
+               struct page *page;
+               void *fsdata;
+-              void *addr;
+               int res;
+               res = pagecache_write_begin(NULL, inode->i_mapping, pos, n, 0,
+@@ -90,9 +86,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
+               if (res)
+                       return res;
+-              addr = kmap_atomic(page);
+-              memcpy(addr + offset_in_page(pos), buf, n);
+-              kunmap_atomic(addr);
++              memcpy_to_page(page, offset_in_page(pos), buf, n);
+               res = pagecache_write_end(NULL, inode->i_mapping, pos, n, n,
+                                         page, fsdata);
+-- 
+2.39.2
+
diff --git a/queue-5.15/firmware-efi-sysfb_efi-add-quirk-for-lenovo-ideapad-.patch b/queue-5.15/firmware-efi-sysfb_efi-add-quirk-for-lenovo-ideapad-.patch
new file mode 100644 (file)
index 0000000..945d39e
--- /dev/null
@@ -0,0 +1,43 @@
+From 570ddffcb36445065570e8ee1f70ad2d4fb8fbaa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Feb 2023 11:50:45 +0000
+Subject: firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 3
+
+From: Darrell Kavanagh <darrell.kavanagh@gmail.com>
+
+[ Upstream commit e1d447157f232c650e6f32c9fb89ff3d0207c69a ]
+
+Another Lenovo convertable which reports a landscape resolution of
+1920x1200 with a pitch of (1920 * 4) bytes, while the actual framebuffer
+has a resolution of 1200x1920 with a pitch of (1200 * 4) bytes.
+
+Signed-off-by: Darrell Kavanagh <darrell.kavanagh@gmail.com>
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/firmware/efi/sysfb_efi.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
+index 4c7c9dd7733f9..6aa2bb5bbd5e4 100644
+--- a/drivers/firmware/efi/sysfb_efi.c
++++ b/drivers/firmware/efi/sysfb_efi.c
+@@ -266,6 +266,14 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
+                                       "Lenovo ideapad D330-10IGM"),
+               },
+       },
++      {
++              /* Lenovo IdeaPad Duet 3 10IGL5 with 1200x1920 portrait screen */
++              .matches = {
++                      DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++                      DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
++                                      "IdeaPad Duet 3 10IGL5"),
++              },
++      },
+       {},
+ };
+-- 
+2.39.2
+
diff --git a/queue-5.15/fs-f2fs-initialize-fsdata-in-pagecache_write.patch b/queue-5.15/fs-f2fs-initialize-fsdata-in-pagecache_write.patch
new file mode 100644 (file)
index 0000000..0cb74f3
--- /dev/null
@@ -0,0 +1,40 @@
+From a77437210e447857d1a9ef30be09f0cdd13de6be Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 21 Nov 2022 12:21:32 +0100
+Subject: fs: f2fs: initialize fsdata in pagecache_write()
+
+From: Alexander Potapenko <glider@google.com>
+
+[ Upstream commit b1b9896718bc1a212dc288ad66a5fa2fef11353d ]
+
+When aops->write_begin() does not initialize fsdata, KMSAN may report
+an error passing the latter to aops->write_end().
+
+Fix this by unconditionally initializing fsdata.
+
+Suggested-by: Eric Biggers <ebiggers@kernel.org>
+Fixes: 95ae251fe828 ("f2fs: add fs-verity support")
+Signed-off-by: Alexander Potapenko <glider@google.com>
+Reviewed-by: Eric Biggers <ebiggers@google.com>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/verity.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
+index 26e7154168291..d5a50e73ec32b 100644
+--- a/fs/f2fs/verity.c
++++ b/fs/f2fs/verity.c
+@@ -78,7 +78,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count,
+               size_t n = min_t(size_t, count,
+                                PAGE_SIZE - offset_in_page(pos));
+               struct page *page;
+-              void *fsdata;
++              void *fsdata = NULL;
+               int res;
+               res = pagecache_write_begin(NULL, inode->i_mapping, pos, n, 0,
+-- 
+2.39.2
+
diff --git a/queue-5.15/fs-jfs-fix-shift-exponent-db_agl2size-negative.patch b/queue-5.15/fs-jfs-fix-shift-exponent-db_agl2size-negative.patch
new file mode 100644 (file)
index 0000000..24ce5da
--- /dev/null
@@ -0,0 +1,41 @@
+From b49161cdad9c074ef596249cac49ead72989b234 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 3 Nov 2022 11:01:59 +0800
+Subject: fs/jfs: fix shift exponent db_agl2size negative
+
+From: Liu Shixin via Jfs-discussion <jfs-discussion@lists.sourceforge.net>
+
+[ Upstream commit fad376fce0af58deebc5075b8539dc05bf639af3 ]
+
+As a shift exponent, db_agl2size can not be less than 0. Add the missing
+check to fix the shift-out-of-bounds bug reported by syzkaller:
+
+ UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:2227:15
+ shift exponent -744642816 is negative
+
+Reported-by: syzbot+0be96567042453c0c820@syzkaller.appspotmail.com
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Liu Shixin <liushixin2@huawei.com>
+Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/jfs/jfs_dmap.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
+index f401bc05d5ff6..0034b0f397153 100644
+--- a/fs/jfs/jfs_dmap.c
++++ b/fs/jfs/jfs_dmap.c
+@@ -193,7 +193,8 @@ int dbMount(struct inode *ipbmap)
+       bmp->db_agwidth = le32_to_cpu(dbmp_le->dn_agwidth);
+       bmp->db_agstart = le32_to_cpu(dbmp_le->dn_agstart);
+       bmp->db_agl2size = le32_to_cpu(dbmp_le->dn_agl2size);
+-      if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG) {
++      if (bmp->db_agl2size > L2MAXL2SIZE - L2MAXAG ||
++          bmp->db_agl2size < 0) {
+               err = -EINVAL;
+               goto err_release_metapage;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/genirq-add-and-use-an-irq_data_update_affinity-helpe.patch b/queue-5.15/genirq-add-and-use-an-irq_data_update_affinity-helpe.patch
new file mode 100644 (file)
index 0000000..e6d191f
--- /dev/null
@@ -0,0 +1,195 @@
+From 5bdaee55f2236d4de2954a7d0f6e5b18c8524fd1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 1 Jul 2022 15:00:54 -0500
+Subject: genirq: Add and use an irq_data_update_affinity helper
+
+From: Samuel Holland <samuel@sholland.org>
+
+[ Upstream commit 073352e951f60946452da358d64841066c3142ff ]
+
+Some architectures and irqchip drivers modify the cpumask returned by
+irq_data_get_affinity_mask, usually by copying in to it. This is
+problematic for uniprocessor configurations, where the affinity mask
+should be constant, as it is known at compile time.
+
+Add and use a setter for the affinity mask, following the pattern of
+irq_data_update_effective_affinity. This allows the getter function to
+return a const cpumask pointer.
+
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> # Xen bits
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Link: https://lore.kernel.org/r/20220701200056.46555-7-samuel@sholland.org
+Stable-dep-of: feabecaff590 ("genirq/ipi: Fix NULL pointer deref in irq_data_get_affinity_mask()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/alpha/kernel/irq.c          | 2 +-
+ arch/ia64/kernel/iosapic.c       | 2 +-
+ arch/ia64/kernel/irq.c           | 4 ++--
+ arch/ia64/kernel/msi_ia64.c      | 4 ++--
+ arch/parisc/kernel/irq.c         | 2 +-
+ drivers/irqchip/irq-bcm6345-l1.c | 4 ++--
+ drivers/parisc/iosapic.c         | 2 +-
+ drivers/sh/intc/chip.c           | 2 +-
+ drivers/xen/events/events_base.c | 7 ++++---
+ include/linux/irq.h              | 6 ++++++
+ 10 files changed, 21 insertions(+), 14 deletions(-)
+
+diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
+index f6d2946edbd24..15f2effd6baf8 100644
+--- a/arch/alpha/kernel/irq.c
++++ b/arch/alpha/kernel/irq.c
+@@ -60,7 +60,7 @@ int irq_select_affinity(unsigned int irq)
+               cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
+       last_cpu = cpu;
+-      cpumask_copy(irq_data_get_affinity_mask(data), cpumask_of(cpu));
++      irq_data_update_affinity(data, cpumask_of(cpu));
+       chip->irq_set_affinity(data, cpumask_of(cpu), false);
+       return 0;
+ }
+diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
+index 35adcf89035ad..99300850abc19 100644
+--- a/arch/ia64/kernel/iosapic.c
++++ b/arch/ia64/kernel/iosapic.c
+@@ -834,7 +834,7 @@ iosapic_unregister_intr (unsigned int gsi)
+       if (iosapic_intr_info[irq].count == 0) {
+ #ifdef CONFIG_SMP
+               /* Clear affinity */
+-              cpumask_setall(irq_get_affinity_mask(irq));
++              irq_data_update_affinity(irq_get_irq_data(irq), cpu_all_mask);
+ #endif
+               /* Clear the interrupt information */
+               iosapic_intr_info[irq].dest = 0;
+diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
+index ecef17c7c35b1..275b9ea58c643 100644
+--- a/arch/ia64/kernel/irq.c
++++ b/arch/ia64/kernel/irq.c
+@@ -57,8 +57,8 @@ static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 };
+ void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
+ {
+       if (irq < NR_IRQS) {
+-              cpumask_copy(irq_get_affinity_mask(irq),
+-                           cpumask_of(cpu_logical_id(hwid)));
++              irq_data_update_affinity(irq_get_irq_data(irq),
++                                       cpumask_of(cpu_logical_id(hwid)));
+               irq_redir[irq] = (char) (redir & 0xff);
+       }
+ }
+diff --git a/arch/ia64/kernel/msi_ia64.c b/arch/ia64/kernel/msi_ia64.c
+index df5c28f252e3d..025e5133c860c 100644
+--- a/arch/ia64/kernel/msi_ia64.c
++++ b/arch/ia64/kernel/msi_ia64.c
+@@ -37,7 +37,7 @@ static int ia64_set_msi_irq_affinity(struct irq_data *idata,
+       msg.data = data;
+       pci_write_msi_msg(irq, &msg);
+-      cpumask_copy(irq_data_get_affinity_mask(idata), cpumask_of(cpu));
++      irq_data_update_affinity(idata, cpumask_of(cpu));
+       return 0;
+ }
+@@ -132,7 +132,7 @@ static int dmar_msi_set_affinity(struct irq_data *data,
+       msg.address_lo |= MSI_ADDR_DEST_ID_CPU(cpu_physical_id(cpu));
+       dmar_msi_write(irq, &msg);
+-      cpumask_copy(irq_data_get_affinity_mask(data), mask);
++      irq_data_update_affinity(data, mask);
+       return 0;
+ }
+diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c
+index 0d46b19dc4d3d..e6cc38ef69458 100644
+--- a/arch/parisc/kernel/irq.c
++++ b/arch/parisc/kernel/irq.c
+@@ -333,7 +333,7 @@ unsigned long txn_affinity_addr(unsigned int irq, int cpu)
+ {
+ #ifdef CONFIG_SMP
+       struct irq_data *d = irq_get_irq_data(irq);
+-      cpumask_copy(irq_data_get_affinity_mask(d), cpumask_of(cpu));
++      irq_data_update_affinity(d, cpumask_of(cpu));
+ #endif
+       return per_cpu(cpu_data, cpu).txn_addr;
+diff --git a/drivers/irqchip/irq-bcm6345-l1.c b/drivers/irqchip/irq-bcm6345-l1.c
+index 1bd0621c4ce2a..ebc3a253f735d 100644
+--- a/drivers/irqchip/irq-bcm6345-l1.c
++++ b/drivers/irqchip/irq-bcm6345-l1.c
+@@ -220,11 +220,11 @@ static int bcm6345_l1_set_affinity(struct irq_data *d,
+               enabled = intc->cpus[old_cpu]->enable_cache[word] & mask;
+               if (enabled)
+                       __bcm6345_l1_mask(d);
+-              cpumask_copy(irq_data_get_affinity_mask(d), dest);
++              irq_data_update_affinity(d, dest);
+               if (enabled)
+                       __bcm6345_l1_unmask(d);
+       } else {
+-              cpumask_copy(irq_data_get_affinity_mask(d), dest);
++              irq_data_update_affinity(d, dest);
+       }
+       raw_spin_unlock_irqrestore(&intc->lock, flags);
+diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
+index fd99735dca3e6..93ea922618c3d 100644
+--- a/drivers/parisc/iosapic.c
++++ b/drivers/parisc/iosapic.c
+@@ -677,7 +677,7 @@ static int iosapic_set_affinity_irq(struct irq_data *d,
+       if (dest_cpu < 0)
+               return -1;
+-      cpumask_copy(irq_data_get_affinity_mask(d), cpumask_of(dest_cpu));
++      irq_data_update_affinity(d, cpumask_of(dest_cpu));
+       vi->txn_addr = txn_affinity_addr(d->irq, dest_cpu);
+       spin_lock_irqsave(&iosapic_lock, flags);
+diff --git a/drivers/sh/intc/chip.c b/drivers/sh/intc/chip.c
+index 358df75101860..828d81e02b37a 100644
+--- a/drivers/sh/intc/chip.c
++++ b/drivers/sh/intc/chip.c
+@@ -72,7 +72,7 @@ static int intc_set_affinity(struct irq_data *data,
+       if (!cpumask_intersects(cpumask, cpu_online_mask))
+               return -1;
+-      cpumask_copy(irq_data_get_affinity_mask(data), cpumask);
++      irq_data_update_affinity(data, cpumask);
+       return IRQ_SET_MASK_OK_NOCOPY;
+ }
+diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
+index 46d9295d9a6e4..5e8321f43cbdd 100644
+--- a/drivers/xen/events/events_base.c
++++ b/drivers/xen/events/events_base.c
+@@ -528,9 +528,10 @@ static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu,
+       BUG_ON(irq == -1);
+       if (IS_ENABLED(CONFIG_SMP) && force_affinity) {
+-              cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(cpu));
+-              cpumask_copy(irq_get_effective_affinity_mask(irq),
+-                           cpumask_of(cpu));
++              struct irq_data *data = irq_get_irq_data(irq);
++
++              irq_data_update_affinity(data, cpumask_of(cpu));
++              irq_data_update_effective_affinity(data, cpumask_of(cpu));
+       }
+       xen_evtchn_port_bind_to_cpu(evtchn, cpu, info->cpu);
+diff --git a/include/linux/irq.h b/include/linux/irq.h
+index 5f8f0f24a2801..f9e6449fbbbae 100644
+--- a/include/linux/irq.h
++++ b/include/linux/irq.h
+@@ -880,6 +880,12 @@ static inline struct cpumask *irq_data_get_affinity_mask(struct irq_data *d)
+       return d->common->affinity;
+ }
++static inline void irq_data_update_affinity(struct irq_data *d,
++                                          const struct cpumask *m)
++{
++      cpumask_copy(d->common->affinity, m);
++}
++
+ static inline struct cpumask *irq_get_affinity_mask(int irq)
+ {
+       struct irq_data *d = irq_get_irq_data(irq);
+-- 
+2.39.2
+
diff --git a/queue-5.15/genirq-refactor-accessors-to-use-irq_data_get_affini.patch b/queue-5.15/genirq-refactor-accessors-to-use-irq_data_get_affini.patch
new file mode 100644 (file)
index 0000000..12ed73c
--- /dev/null
@@ -0,0 +1,61 @@
+From 0d789d22b8b79f36daf15bdb6faf01bcc1566b8c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 1 Jul 2022 15:00:53 -0500
+Subject: genirq: Refactor accessors to use irq_data_get_affinity_mask
+
+From: Samuel Holland <samuel@sholland.org>
+
+[ Upstream commit 961343d7822624d0e329ab4167c7e1d02bb53112 ]
+
+A couple of functions directly reference the affinity mask. Route them
+through irq_data_get_affinity_mask so they will pick up any refactoring
+done there.
+
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+Signed-off-by: Marc Zyngier <maz@kernel.org>
+Link: https://lore.kernel.org/r/20220701200056.46555-6-samuel@sholland.org
+Stable-dep-of: feabecaff590 ("genirq/ipi: Fix NULL pointer deref in irq_data_get_affinity_mask()")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/irq.h | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/include/linux/irq.h b/include/linux/irq.h
+index c8293c817646c..5f8f0f24a2801 100644
+--- a/include/linux/irq.h
++++ b/include/linux/irq.h
+@@ -875,16 +875,16 @@ static inline int irq_data_get_node(struct irq_data *d)
+       return irq_common_data_get_node(d->common);
+ }
+-static inline struct cpumask *irq_get_affinity_mask(int irq)
++static inline struct cpumask *irq_data_get_affinity_mask(struct irq_data *d)
+ {
+-      struct irq_data *d = irq_get_irq_data(irq);
+-
+-      return d ? d->common->affinity : NULL;
++      return d->common->affinity;
+ }
+-static inline struct cpumask *irq_data_get_affinity_mask(struct irq_data *d)
++static inline struct cpumask *irq_get_affinity_mask(int irq)
+ {
+-      return d->common->affinity;
++      struct irq_data *d = irq_get_irq_data(irq);
++
++      return d ? irq_data_get_affinity_mask(d) : NULL;
+ }
+ #ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK
+@@ -906,7 +906,7 @@ static inline void irq_data_update_effective_affinity(struct irq_data *d,
+ static inline
+ struct cpumask *irq_data_get_effective_affinity_mask(struct irq_data *d)
+ {
+-      return d->common->affinity;
++      return irq_data_get_affinity_mask(d);
+ }
+ #endif
+-- 
+2.39.2
+
diff --git a/queue-5.15/ib-hfi1-update-rmt-size-calculation.patch b/queue-5.15/ib-hfi1-update-rmt-size-calculation.patch
new file mode 100644 (file)
index 0000000..0f9dfa7
--- /dev/null
@@ -0,0 +1,136 @@
+From b27eed9c6db1d8ce22db31894189f8a9de692b5d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 9 Jan 2023 14:04:29 -0500
+Subject: IB/hfi1: Update RMT size calculation
+
+From: Dean Luick <dean.luick@cornelisnetworks.com>
+
+[ Upstream commit 892ede5a77f337831609fb9c248ac60948061894 ]
+
+Fix possible RMT overflow:  Use the correct netdev size.
+Don't allow adjusted user contexts to go negative.
+
+Fix QOS calculation: Send kernel context count as an argument since
+dd->n_krcv_queues is not yet set up in earliest call.  Do not include
+the control context in the QOS calculation.  Use the same sized
+variable to find the max of krcvq[] entries.
+
+Update the RMT count explanation to make more sense.
+
+Signed-off-by: Dean Luick <dean.luick@cornelisnetworks.com>
+Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
+Link: https://lore.kernel.org/r/167329106946.1472990.18385495251650939054.stgit@awfm-02.cornelisnetworks.com
+Signed-off-by: Leon Romanovsky <leon@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/hw/hfi1/chip.c | 59 +++++++++++++++++--------------
+ 1 file changed, 32 insertions(+), 27 deletions(-)
+
+diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
+index b0d587254fe66..689921dc3d4a8 100644
+--- a/drivers/infiniband/hw/hfi1/chip.c
++++ b/drivers/infiniband/hw/hfi1/chip.c
+@@ -1055,7 +1055,7 @@ static void read_link_down_reason(struct hfi1_devdata *dd, u8 *ldr);
+ static void handle_temp_err(struct hfi1_devdata *dd);
+ static void dc_shutdown(struct hfi1_devdata *dd);
+ static void dc_start(struct hfi1_devdata *dd);
+-static int qos_rmt_entries(struct hfi1_devdata *dd, unsigned int *mp,
++static int qos_rmt_entries(unsigned int n_krcv_queues, unsigned int *mp,
+                          unsigned int *np);
+ static void clear_full_mgmt_pkey(struct hfi1_pportdata *ppd);
+ static int wait_link_transfer_active(struct hfi1_devdata *dd, int wait_ms);
+@@ -13361,7 +13361,6 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
+       int ret;
+       unsigned ngroups;
+       int rmt_count;
+-      int user_rmt_reduced;
+       u32 n_usr_ctxts;
+       u32 send_contexts = chip_send_contexts(dd);
+       u32 rcv_contexts = chip_rcv_contexts(dd);
+@@ -13420,28 +13419,34 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
+                                        (num_kernel_contexts + n_usr_ctxts),
+                                        &node_affinity.real_cpu_mask);
+       /*
+-       * The RMT entries are currently allocated as shown below:
+-       * 1. QOS (0 to 128 entries);
+-       * 2. FECN (num_kernel_context - 1 + num_user_contexts +
+-       *    num_netdev_contexts);
+-       * 3. netdev (num_netdev_contexts).
+-       * It should be noted that FECN oversubscribe num_netdev_contexts
+-       * entries of RMT because both netdev and PSM could allocate any receive
+-       * context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
+-       * and PSM FECN must reserve an RMT entry for each possible PSM receive
+-       * context.
++       * RMT entries are allocated as follows:
++       * 1. QOS (0 to 128 entries)
++       * 2. FECN (num_kernel_context - 1 [a] + num_user_contexts +
++       *          num_netdev_contexts [b])
++       * 3. netdev (NUM_NETDEV_MAP_ENTRIES)
++       *
++       * Notes:
++       * [a] Kernel contexts (except control) are included in FECN if kernel
++       *     TID_RDMA is active.
++       * [b] Netdev and user contexts are randomly allocated from the same
++       *     context pool, so FECN must cover all contexts in the pool.
+        */
+-      rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_netdev_contexts * 2);
+-      if (HFI1_CAP_IS_KSET(TID_RDMA))
+-              rmt_count += num_kernel_contexts - 1;
+-      if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
+-              user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
+-              dd_dev_err(dd,
+-                         "RMT size is reducing the number of user receive contexts from %u to %d\n",
+-                         n_usr_ctxts,
+-                         user_rmt_reduced);
+-              /* recalculate */
+-              n_usr_ctxts = user_rmt_reduced;
++      rmt_count = qos_rmt_entries(num_kernel_contexts - 1, NULL, NULL)
++                  + (HFI1_CAP_IS_KSET(TID_RDMA) ? num_kernel_contexts - 1
++                                                : 0)
++                  + n_usr_ctxts
++                  + num_netdev_contexts
++                  + NUM_NETDEV_MAP_ENTRIES;
++      if (rmt_count > NUM_MAP_ENTRIES) {
++              int over = rmt_count - NUM_MAP_ENTRIES;
++              /* try to squish user contexts, minimum of 1 */
++              if (over >= n_usr_ctxts) {
++                      dd_dev_err(dd, "RMT overflow: reduce the requested number of contexts\n");
++                      return -EINVAL;
++              }
++              dd_dev_err(dd, "RMT overflow: reducing # user contexts from %u to %u\n",
++                         n_usr_ctxts, n_usr_ctxts - over);
++              n_usr_ctxts -= over;
+       }
+       /* the first N are kernel contexts, the rest are user/netdev contexts */
+@@ -14298,15 +14303,15 @@ static void clear_rsm_rule(struct hfi1_devdata *dd, u8 rule_index)
+ }
+ /* return the number of RSM map table entries that will be used for QOS */
+-static int qos_rmt_entries(struct hfi1_devdata *dd, unsigned int *mp,
++static int qos_rmt_entries(unsigned int n_krcv_queues, unsigned int *mp,
+                          unsigned int *np)
+ {
+       int i;
+       unsigned int m, n;
+-      u8 max_by_vl = 0;
++      uint max_by_vl = 0;
+       /* is QOS active at all? */
+-      if (dd->n_krcv_queues <= MIN_KERNEL_KCTXTS ||
++      if (n_krcv_queues < MIN_KERNEL_KCTXTS ||
+           num_vls == 1 ||
+           krcvqsset <= 1)
+               goto no_qos;
+@@ -14364,7 +14369,7 @@ static void init_qos(struct hfi1_devdata *dd, struct rsm_map_table *rmt)
+       if (!rmt)
+               goto bail;
+-      rmt_entries = qos_rmt_entries(dd, &m, &n);
++      rmt_entries = qos_rmt_entries(dd->n_krcv_queues - 1, &m, &n);
+       if (rmt_entries == 0)
+               goto bail;
+       qpns_per_vl = 1 << m;
+-- 
+2.39.2
+
diff --git a/queue-5.15/iio-accel-mma9551_core-prevent-uninitialized-variabl.patch b/queue-5.15/iio-accel-mma9551_core-prevent-uninitialized-variabl.patch
new file mode 100644 (file)
index 0000000..11a8f91
--- /dev/null
@@ -0,0 +1,48 @@
+From 8386559f1ba08eb32d4ca30149d2430fe8f762c9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jan 2023 07:21:46 -0800
+Subject: iio: accel: mma9551_core: Prevent uninitialized variable in
+ mma9551_read_status_word()
+
+From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
+
+[ Upstream commit e56d2c34ce9dc122b1a618172ec0e05e50adb9e9 ]
+
+Smatch Warns: drivers/iio/accel/mma9551_core.c:357
+       mma9551_read_status_word() error: uninitialized symbol 'v'.
+
+When (offset >= 1 << 12) is true mma9551_transfer() will return -EINVAL
+without 'v' being initialized, so check for the error and return.
+
+Note: Not a bug as such because the caller checks return value and
+doesn't not use this parameter in the problem case.
+
+Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
+Link: https://lore.kernel.org/r/20230126152147.3585874-1-harshit.m.mogalapalli@oracle.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/accel/mma9551_core.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c
+index fbf2e2c45678b..413610a749c24 100644
+--- a/drivers/iio/accel/mma9551_core.c
++++ b/drivers/iio/accel/mma9551_core.c
+@@ -354,9 +354,12 @@ int mma9551_read_status_word(struct i2c_client *client, u8 app_id,
+       ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_STATUS,
+                              reg, NULL, 0, (u8 *)&v, 2);
++      if (ret < 0)
++              return ret;
++
+       *val = be16_to_cpu(v);
+-      return ret;
++      return 0;
+ }
+ EXPORT_SYMBOL(mma9551_read_status_word);
+-- 
+2.39.2
+
diff --git a/queue-5.15/iio-accel-mma9551_core-prevent-uninitialized-variabl.patch-31264 b/queue-5.15/iio-accel-mma9551_core-prevent-uninitialized-variabl.patch-31264
new file mode 100644 (file)
index 0000000..f64b928
--- /dev/null
@@ -0,0 +1,49 @@
+From 8d3a440e7a4a397115afd3f68ab0f3a25fc4c431 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 26 Jan 2023 07:36:09 -0800
+Subject: iio: accel: mma9551_core: Prevent uninitialized variable in
+ mma9551_read_config_word()
+
+From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
+
+[ Upstream commit 64a68158738ec8f520347144352f7a09bdb9e169 ]
+
+Smatch Warns:
+drivers/iio/accel/mma9551_core.c:299
+       mma9551_read_config_word() error: uninitialized symbol 'v'.
+
+When (offset >= 1 << 12) is true mma9551_transfer() will return -EINVAL
+without 'v' being initialized, so check for the error and return.
+
+Note: No actual bug as caller checks the return value and does not
+use the parameter in the problem case.
+
+Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
+Link: https://lore.kernel.org/r/20230126153610.3586243-1-harshit.m.mogalapalli@oracle.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iio/accel/mma9551_core.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c
+index 413610a749c24..9023c07bb57b4 100644
+--- a/drivers/iio/accel/mma9551_core.c
++++ b/drivers/iio/accel/mma9551_core.c
+@@ -296,9 +296,12 @@ int mma9551_read_config_word(struct i2c_client *client, u8 app_id,
+       ret = mma9551_transfer(client, app_id, MMA9551_CMD_READ_CONFIG,
+                              reg, NULL, 0, (u8 *)&v, 2);
++      if (ret < 0)
++              return ret;
++
+       *val = be16_to_cpu(v);
+-      return ret;
++      return 0;
+ }
+ EXPORT_SYMBOL(mma9551_read_config_word);
+-- 
+2.39.2
+
diff --git a/queue-5.15/iommu-amd-fix-error-handling-for-pdev_pri_ats_enable.patch b/queue-5.15/iommu-amd-fix-error-handling-for-pdev_pri_ats_enable.patch
new file mode 100644 (file)
index 0000000..c903953
--- /dev/null
@@ -0,0 +1,66 @@
+From a9dfcd1d6b73df80769c6e41a5d04443c38dbcb4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 11 Jan 2023 12:15:03 +0000
+Subject: iommu/amd: Fix error handling for pdev_pri_ats_enable()
+
+From: Vasant Hegde <vasant.hegde@amd.com>
+
+[ Upstream commit 080920e52148b4fbbf9360d5345fdcd7846e4841 ]
+
+Current code throws kernel warning if it fails to enable pasid/pri [1].
+Do not call pci_disable_[pasid/pri] if pci_enable_[pasid/pri] failed.
+
+[1] https://lore.kernel.org/linux-iommu/15d0f9ff-2a56-b3e9-5b45-e6b23300ae3b@leemhuis.info/
+
+Reported-by: Matt Fagnani <matt.fagnani@bell.net>
+Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
+Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
+Link: https://lore.kernel.org/r/20230111121503.5931-1-vasant.hegde@amd.com
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iommu/amd/iommu.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
+index 7154fb551ddc9..5ceaaabb4f9da 100644
+--- a/drivers/iommu/amd/iommu.c
++++ b/drivers/iommu/amd/iommu.c
+@@ -1586,27 +1586,29 @@ static int pdev_iommuv2_enable(struct pci_dev *pdev)
+       /* Only allow access to user-accessible pages */
+       ret = pci_enable_pasid(pdev, 0);
+       if (ret)
+-              goto out_err;
++              return ret;
+       /* First reset the PRI state of the device */
+       ret = pci_reset_pri(pdev);
+       if (ret)
+-              goto out_err;
++              goto out_err_pasid;
+       /* Enable PRI */
+       /* FIXME: Hardcode number of outstanding requests for now */
+       ret = pci_enable_pri(pdev, 32);
+       if (ret)
+-              goto out_err;
++              goto out_err_pasid;
+       ret = pci_enable_ats(pdev, PAGE_SHIFT);
+       if (ret)
+-              goto out_err;
++              goto out_err_pri;
+       return 0;
+-out_err:
++out_err_pri:
+       pci_disable_pri(pdev);
++
++out_err_pasid:
+       pci_disable_pasid(pdev);
+       return ret;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ipv6-add-lwtunnel-encap-size-of-all-siblings-in-next.patch b/queue-5.15/ipv6-add-lwtunnel-encap-size-of-all-siblings-in-next.patch
new file mode 100644 (file)
index 0000000..9c2ed32
--- /dev/null
@@ -0,0 +1,96 @@
+From 438b6f3ae23cd6098dc264393800fdd6e7637fc2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Feb 2023 16:36:28 +0800
+Subject: ipv6: Add lwtunnel encap size of all siblings in nexthop calculation
+
+From: Lu Wei <luwei32@huawei.com>
+
+[ Upstream commit 4cc59f386991ec9374cb4bc83dbe1c0b5a95033f ]
+
+In function rt6_nlmsg_size(), the length of nexthop is calculated
+by multipling the nexthop length of fib6_info and the number of
+siblings. However if the fib6_info has no lwtunnel but the siblings
+have lwtunnels, the nexthop length is less than it should be, and
+it will trigger a warning in inet6_rt_notify() as follows:
+
+WARNING: CPU: 0 PID: 6082 at net/ipv6/route.c:6180 inet6_rt_notify+0x120/0x130
+......
+Call Trace:
+ <TASK>
+ fib6_add_rt2node+0x685/0xa30
+ fib6_add+0x96/0x1b0
+ ip6_route_add+0x50/0xd0
+ inet6_rtm_newroute+0x97/0xa0
+ rtnetlink_rcv_msg+0x156/0x3d0
+ netlink_rcv_skb+0x5a/0x110
+ netlink_unicast+0x246/0x350
+ netlink_sendmsg+0x250/0x4c0
+ sock_sendmsg+0x66/0x70
+ ___sys_sendmsg+0x7c/0xd0
+ __sys_sendmsg+0x5d/0xb0
+ do_syscall_64+0x3f/0x90
+ entry_SYSCALL_64_after_hwframe+0x72/0xdc
+
+This bug can be reproduced by script:
+
+ip -6 addr add 2002::2/64 dev ens2
+ip -6 route add 100::/64 via 2002::1 dev ens2 metric 100
+
+for i in 10 20 30 40 50 60 70;
+do
+       ip link add link ens2 name ipv_$i type ipvlan
+       ip -6 addr add 2002::$i/64 dev ipv_$i
+       ifconfig ipv_$i up
+done
+
+for i in 10 20 30 40 50 60;
+do
+       ip -6 route append 100::/64 encap ip6 dst 2002::$i via 2002::1
+dev ipv_$i metric 100
+done
+
+ip -6 route append 100::/64 via 2002::1 dev ipv_70 metric 100
+
+This patch fixes it by adding nexthop_len of every siblings using
+rt6_nh_nlmsg_size().
+
+Fixes: beb1afac518d ("net: ipv6: Add support to dump multipath routes via RTA_MULTIPATH attribute")
+Signed-off-by: Lu Wei <luwei32@huawei.com>
+Reviewed-by: David Ahern <dsahern@kernel.org>
+Link: https://lore.kernel.org/r/20230222083629.335683-2-luwei32@huawei.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv6/route.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/net/ipv6/route.c b/net/ipv6/route.c
+index 0655fd8c67e93..7b26882b9e70e 100644
+--- a/net/ipv6/route.c
++++ b/net/ipv6/route.c
+@@ -5555,16 +5555,17 @@ static size_t rt6_nlmsg_size(struct fib6_info *f6i)
+               nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_nlmsg_size,
+                                        &nexthop_len);
+       } else {
++              struct fib6_info *sibling, *next_sibling;
+               struct fib6_nh *nh = f6i->fib6_nh;
+               nexthop_len = 0;
+               if (f6i->fib6_nsiblings) {
+-                      nexthop_len = nla_total_size(0)  /* RTA_MULTIPATH */
+-                                  + NLA_ALIGN(sizeof(struct rtnexthop))
+-                                  + nla_total_size(16) /* RTA_GATEWAY */
+-                                  + lwtunnel_get_encap_size(nh->fib_nh_lws);
++                      rt6_nh_nlmsg_size(nh, &nexthop_len);
+-                      nexthop_len *= f6i->fib6_nsiblings;
++                      list_for_each_entry_safe(sibling, next_sibling,
++                                               &f6i->fib6_siblings, fib6_siblings) {
++                              rt6_nh_nlmsg_size(sibling->fib6_nh, &nexthop_len);
++                      }
+               }
+               nexthop_len += lwtunnel_get_encap_size(nh->fib_nh_lws);
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/kernel-fail_function-fix-memory-leak-with-using-debu.patch b/queue-5.15/kernel-fail_function-fix-memory-leak-with-using-debu.patch
new file mode 100644 (file)
index 0000000..ca2921c
--- /dev/null
@@ -0,0 +1,42 @@
+From 067e4cc0eb33f52398adca4bd70465df46d57aef Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:16:33 +0100
+Subject: kernel/fail_function: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 2bb3669f576559db273efe49e0e69f82450efbca ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
+Link: https://lore.kernel.org/r/20230202151633.2310897-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/fail_function.c | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/kernel/fail_function.c b/kernel/fail_function.c
+index 60dc825ecc2b3..d81ec84765811 100644
+--- a/kernel/fail_function.c
++++ b/kernel/fail_function.c
+@@ -163,10 +163,7 @@ static void fei_debugfs_add_attr(struct fei_attr *attr)
+ static void fei_debugfs_remove_attr(struct fei_attr *attr)
+ {
+-      struct dentry *dir;
+-
+-      dir = debugfs_lookup(attr->kp.symbol_name, fei_debugfs_dir);
+-      debugfs_remove_recursive(dir);
++      debugfs_lookup_and_remove(attr->kp.symbol_name, fei_debugfs_dir);
+ }
+ static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)
+-- 
+2.39.2
+
diff --git a/queue-5.15/kernel-printk-index.c-fix-memory-leak-with-using-deb.patch b/queue-5.15/kernel-printk-index.c-fix-memory-leak-with-using-deb.patch
new file mode 100644 (file)
index 0000000..c3d2789
--- /dev/null
@@ -0,0 +1,47 @@
+From c6b8b1ce8171ffe3a5ef8eb85fc09a565520dff9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:14:11 +0100
+Subject: kernel/printk/index.c: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 55bf243c514553e907efcf2bda92ba090eca8c64 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Chris Down <chris@chrisdown.name>
+Cc: Petr Mladek <pmladek@suse.com>
+Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
+Cc: Steven Rostedt <rostedt@goodmis.org>
+Cc: John Ogness <john.ogness@linutronix.de>
+Cc: linux-kernel@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
+Reviewed-by: John Ogness <john.ogness@linutronix.de>
+Reviewed-by: Petr Mladek <pmladek@suse.com>
+Signed-off-by: Petr Mladek <pmladek@suse.com>
+Link: https://lore.kernel.org/r/20230202151411.2308576-1-gregkh@linuxfoundation.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/printk/index.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/printk/index.c b/kernel/printk/index.c
+index d3709408debe9..d23b8f8a51db5 100644
+--- a/kernel/printk/index.c
++++ b/kernel/printk/index.c
+@@ -146,7 +146,7 @@ static void pi_create_file(struct module *mod)
+ #ifdef CONFIG_MODULES
+ static void pi_remove_file(struct module *mod)
+ {
+-      debugfs_remove(debugfs_lookup(pi_get_module_name(mod), dfs_index));
++      debugfs_lookup_and_remove(pi_get_module_name(mod), dfs_index);
+ }
+ static int pi_module_notify(struct notifier_block *nb, unsigned long op,
+-- 
+2.39.2
+
diff --git a/queue-5.15/loop-loop_set_status_from_info-check-before-assignme.patch b/queue-5.15/loop-loop_set_status_from_info-check-before-assignme.patch
new file mode 100644 (file)
index 0000000..b0f087d
--- /dev/null
@@ -0,0 +1,59 @@
+From ae8f0e0e5ec6983e634a8af4a64c0f62a0c162c0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 21 Feb 2023 17:50:27 +0800
+Subject: loop: loop_set_status_from_info() check before assignment
+
+From: Zhong Jinghua <zhongjinghua@huawei.com>
+
+[ Upstream commit 9f6ad5d533d1c71e51bdd06a5712c4fbc8768dfa ]
+
+In loop_set_status_from_info(), lo->lo_offset and lo->lo_sizelimit should
+be checked before reassignment, because if an overflow error occurs, the
+original correct value will be changed to the wrong value, and it will not
+be changed back.
+
+More, the original patch did not solve the problem, the value was set and
+ioctl returned an error, but the subsequent io used the value in the loop
+driver, which still caused an alarm:
+
+loop_handle_cmd
+ do_req_filebacked
+  loff_t pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset;
+  lo_rw_aio
+   cmd->iocb.ki_pos = pos
+
+Fixes: c490a0b5a4f3 ("loop: Check for overflow while configuring loop")
+Signed-off-by: Zhong Jinghua <zhongjinghua@huawei.com>
+Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
+Link: https://lore.kernel.org/r/20230221095027.3656193-1-zhongjinghua@huaweicloud.com
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/block/loop.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/block/loop.c b/drivers/block/loop.c
+index 68a0c0fe64dd8..58a38e61de535 100644
+--- a/drivers/block/loop.c
++++ b/drivers/block/loop.c
+@@ -1152,13 +1152,13 @@ loop_set_status_from_info(struct loop_device *lo,
+       if (err)
+               return err;
++      /* Avoid assigning overflow values */
++      if (info->lo_offset > LLONG_MAX || info->lo_sizelimit > LLONG_MAX)
++              return -EOVERFLOW;
++
+       lo->lo_offset = info->lo_offset;
+       lo->lo_sizelimit = info->lo_sizelimit;
+-      /* loff_t vars have been assigned __u64 */
+-      if (lo->lo_offset < 0 || lo->lo_sizelimit < 0)
+-              return -EOVERFLOW;
+-
+       memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE);
+       memcpy(lo->lo_crypt_name, info->lo_crypt_name, LO_NAME_SIZE);
+       lo->lo_file_name[LO_NAME_SIZE-1] = 0;
+-- 
+2.39.2
+
diff --git a/queue-5.15/media-uvcvideo-handle-cameras-with-invalid-descripto.patch b/queue-5.15/media-uvcvideo-handle-cameras-with-invalid-descripto.patch
new file mode 100644 (file)
index 0000000..db46b54
--- /dev/null
@@ -0,0 +1,36 @@
+From fc434941acb061aafd53e6179d550938a07e71c4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 20 Sep 2022 16:04:55 +0200
+Subject: media: uvcvideo: Handle cameras with invalid descriptors
+
+From: Ricardo Ribalda <ribalda@chromium.org>
+
+[ Upstream commit 41ddb251c68ac75c101d3a50a68c4629c9055e4c ]
+
+If the source entity does not contain any pads, do not create a link.
+
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/uvc/uvc_entity.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c
+index 7c4d2f93d3513..cc68dd24eb42d 100644
+--- a/drivers/media/usb/uvc/uvc_entity.c
++++ b/drivers/media/usb/uvc/uvc_entity.c
+@@ -37,7 +37,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain,
+                       continue;
+               remote = uvc_entity_by_id(chain->dev, entity->baSourceID[i]);
+-              if (remote == NULL)
++              if (remote == NULL || remote->num_pads == 0)
+                       return -EINVAL;
+               source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING)
+-- 
+2.39.2
+
diff --git a/queue-5.15/media-uvcvideo-handle-errors-from-calls-to-usb_strin.patch b/queue-5.15/media-uvcvideo-handle-errors-from-calls-to-usb_strin.patch
new file mode 100644 (file)
index 0000000..d76dcec
--- /dev/null
@@ -0,0 +1,138 @@
+From b708c348b422e9c8c5960933e3d3b3e9730cc494 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 25 Oct 2022 16:41:01 +0200
+Subject: media: uvcvideo: Handle errors from calls to usb_string
+
+From: Guenter Roeck <linux@roeck-us.net>
+
+[ Upstream commit 4867bb590ae445bcfaa711a86b603c97e94574b3 ]
+
+On a Webcam from Quanta, we see the following error.
+
+usb 3-5: New USB device found, idVendor=0408, idProduct=30d2, bcdDevice= 0.03
+usb 3-5: New USB device strings: Mfr=3, Product=1, SerialNumber=2
+usb 3-5: Product: USB2.0 HD UVC WebCam
+usb 3-5: Manufacturer: Quanta
+usb 3-5: SerialNumber: 0x0001
+...
+uvcvideo: Found UVC 1.10 device USB2.0 HD UVC WebCam (0408:30d2)
+uvcvideo: Failed to initialize entity for entity 5
+uvcvideo: Failed to register entities (-22).
+
+The Webcam reports an entity of type UVC_VC_EXTENSION_UNIT. It reports a
+string index of '7' associated with that entity. The attempt to read that
+string from the camera fails with error -32 (-EPIPE). usb_string() returns
+that error, but it is ignored. As result, the entity name is empty. This
+later causes v4l2_device_register_subdev() to return -EINVAL, and no
+entities are registered as result.
+
+While this appears to be a firmware problem with the camera, the kernel
+should still handle the situation gracefully. To do that, check the return
+value from usb_string(). If it reports an error, assign the entity's
+default name.
+
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/uvc/uvc_driver.c | 48 ++++++++++++------------------
+ 1 file changed, 19 insertions(+), 29 deletions(-)
+
+diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
+index 57935eb079312..16e84c7c8456c 100644
+--- a/drivers/media/usb/uvc/uvc_driver.c
++++ b/drivers/media/usb/uvc/uvc_driver.c
+@@ -1131,10 +1131,8 @@ static int uvc_parse_vendor_control(struct uvc_device *dev,
+                                              + n;
+               memcpy(unit->extension.bmControls, &buffer[23+p], 2*n);
+-              if (buffer[24+p+2*n] != 0)
+-                      usb_string(udev, buffer[24+p+2*n], unit->name,
+-                                 sizeof(unit->name));
+-              else
++              if (buffer[24+p+2*n] == 0 ||
++                  usb_string(udev, buffer[24+p+2*n], unit->name, sizeof(unit->name)) < 0)
+                       sprintf(unit->name, "Extension %u", buffer[3]);
+               list_add_tail(&unit->list, &dev->entities);
+@@ -1258,15 +1256,15 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
+                       memcpy(term->media.bmTransportModes, &buffer[10+n], p);
+               }
+-              if (buffer[7] != 0)
+-                      usb_string(udev, buffer[7], term->name,
+-                                 sizeof(term->name));
+-              else if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
+-                      sprintf(term->name, "Camera %u", buffer[3]);
+-              else if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
+-                      sprintf(term->name, "Media %u", buffer[3]);
+-              else
+-                      sprintf(term->name, "Input %u", buffer[3]);
++              if (buffer[7] == 0 ||
++                  usb_string(udev, buffer[7], term->name, sizeof(term->name)) < 0) {
++                      if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
++                              sprintf(term->name, "Camera %u", buffer[3]);
++                      if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
++                              sprintf(term->name, "Media %u", buffer[3]);
++                      else
++                              sprintf(term->name, "Input %u", buffer[3]);
++              }
+               list_add_tail(&term->list, &dev->entities);
+               break;
+@@ -1298,10 +1296,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
+               memcpy(term->baSourceID, &buffer[7], 1);
+-              if (buffer[8] != 0)
+-                      usb_string(udev, buffer[8], term->name,
+-                                 sizeof(term->name));
+-              else
++              if (buffer[8] == 0 ||
++                  usb_string(udev, buffer[8], term->name, sizeof(term->name)) < 0)
+                       sprintf(term->name, "Output %u", buffer[3]);
+               list_add_tail(&term->list, &dev->entities);
+@@ -1323,10 +1319,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
+               memcpy(unit->baSourceID, &buffer[5], p);
+-              if (buffer[5+p] != 0)
+-                      usb_string(udev, buffer[5+p], unit->name,
+-                                 sizeof(unit->name));
+-              else
++              if (buffer[5+p] == 0 ||
++                  usb_string(udev, buffer[5+p], unit->name, sizeof(unit->name)) < 0)
+                       sprintf(unit->name, "Selector %u", buffer[3]);
+               list_add_tail(&unit->list, &dev->entities);
+@@ -1356,10 +1350,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
+               if (dev->uvc_version >= 0x0110)
+                       unit->processing.bmVideoStandards = buffer[9+n];
+-              if (buffer[8+n] != 0)
+-                      usb_string(udev, buffer[8+n], unit->name,
+-                                 sizeof(unit->name));
+-              else
++              if (buffer[8+n] == 0 ||
++                  usb_string(udev, buffer[8+n], unit->name, sizeof(unit->name)) < 0)
+                       sprintf(unit->name, "Processing %u", buffer[3]);
+               list_add_tail(&unit->list, &dev->entities);
+@@ -1387,10 +1379,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
+               unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
+               memcpy(unit->extension.bmControls, &buffer[23+p], n);
+-              if (buffer[23+p+n] != 0)
+-                      usb_string(udev, buffer[23+p+n], unit->name,
+-                                 sizeof(unit->name));
+-              else
++              if (buffer[23+p+n] == 0 ||
++                  usb_string(udev, buffer[23+p+n], unit->name, sizeof(unit->name)) < 0)
+                       sprintf(unit->name, "Extension %u", buffer[3]);
+               list_add_tail(&unit->list, &dev->entities);
+-- 
+2.39.2
+
diff --git a/queue-5.15/media-uvcvideo-quirk-for-autosuspend-in-logitech-b91.patch b/queue-5.15/media-uvcvideo-quirk-for-autosuspend-in-logitech-b91.patch
new file mode 100644 (file)
index 0000000..1a30531
--- /dev/null
@@ -0,0 +1,138 @@
+From 1d3daca7aeb53944db29a5c33a10495e500d4af2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 4 Jan 2023 11:45:23 +0100
+Subject: media: uvcvideo: Quirk for autosuspend in Logitech B910 and C910
+
+From: Ricardo Ribalda <ribalda@chromium.org>
+
+[ Upstream commit 136effa754b57632f99574fc4a3433e0cfc031d9 ]
+
+Logitech B910 and C910 firmware are unable to recover from a USB
+autosuspend. When it resumes, the device is in a state where it only
+produces invalid frames. Eg:
+
+$ echo 0xFFFF > /sys/module/uvcvideo/parameters/trace # enable verbose log
+$ yavta -c1 -n1 --file='frame#.jpg' --format MJPEG --size=1920x1080 /dev/video1
+[350438.435219] uvcvideo: uvc_v4l2_open
+[350438.529794] uvcvideo: Resuming interface 2
+[350438.529801] uvcvideo: Resuming interface 3
+[350438.529991] uvcvideo: Trying format 0x47504a4d (MJPG): 1920x1080.
+[350438.529996] uvcvideo: Using default frame interval 33333.3 us (30.0 fps).
+[350438.551496] uvcvideo: uvc_v4l2_mmap
+[350438.555890] uvcvideo: Device requested 3060 B/frame bandwidth.
+[350438.555896] uvcvideo: Selecting alternate setting 11 (3060 B/frame bandwidth).
+[350438.556362] uvcvideo: Allocated 5 URB buffers of 32x3060 bytes each.
+[350439.316468] uvcvideo: Marking buffer as bad (error bit set).
+[350439.316475] uvcvideo: Frame complete (EOF found).
+[350439.316477] uvcvideo: EOF in empty payload.
+[350439.316484] uvcvideo: frame 1 stats: 149/261/417 packets, 1/149/417 pts (early initial), 416/417 scr, last pts/stc/sof 2976325734/2978107243/249
+[350439.384510] uvcvideo: Marking buffer as bad (error bit set).
+[350439.384516] uvcvideo: Frame complete (EOF found).
+[350439.384518] uvcvideo: EOF in empty payload.
+[350439.384525] uvcvideo: frame 2 stats: 265/379/533 packets, 1/265/533 pts (early initial), 532/533 scr, last pts/stc/sof 2979524454/2981305193/316
+[350439.448472] uvcvideo: Marking buffer as bad (error bit set).
+[350439.448478] uvcvideo: Frame complete (EOF found).
+[350439.448480] uvcvideo: EOF in empty payload.
+[350439.448487] uvcvideo: frame 3 stats: 265/377/533 packets, 1/265/533 pts (early initial), 532/533 scr, last pts/stc/sof 2982723174/2984503144/382
+...(loop)...
+
+The devices can leave this invalid state if the alternate setting of
+the streaming interface is toggled.
+
+This patch adds a quirk for this device so it can be autosuspended
+properly.
+
+lsusb -v:
+Bus 001 Device 049: ID 046d:0821 Logitech, Inc. HD Webcam C910
+Device Descriptor:
+  bLength                18
+  bDescriptorType         1
+  bcdUSB               2.00
+  bDeviceClass          239 Miscellaneous Device
+  bDeviceSubClass         2
+  bDeviceProtocol         1 Interface Association
+  bMaxPacketSize0        64
+  idVendor           0x046d Logitech, Inc.
+  idProduct          0x0821 HD Webcam C910
+  bcdDevice            0.10
+  iManufacturer           0
+  iProduct                0
+  iSerial                 1 390022B0
+  bNumConfigurations      1
+
+Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/uvc/uvc_driver.c | 18 ++++++++++++++++++
+ drivers/media/usb/uvc/uvc_video.c  | 11 +++++++++++
+ drivers/media/usb/uvc/uvcvideo.h   |  1 +
+ 3 files changed, 30 insertions(+)
+
+diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
+index 16e84c7c8456c..2e7df1de0af9a 100644
+--- a/drivers/media/usb/uvc/uvc_driver.c
++++ b/drivers/media/usb/uvc/uvc_driver.c
+@@ -2684,6 +2684,24 @@ static const struct usb_device_id uvc_ids[] = {
+         .bInterfaceSubClass   = 1,
+         .bInterfaceProtocol   = 0,
+         .driver_info          = (kernel_ulong_t)&uvc_quirk_probe_minmax },
++      /* Logitech, Webcam C910 */
++      { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
++                              | USB_DEVICE_ID_MATCH_INT_INFO,
++        .idVendor             = 0x046d,
++        .idProduct            = 0x0821,
++        .bInterfaceClass      = USB_CLASS_VIDEO,
++        .bInterfaceSubClass   = 1,
++        .bInterfaceProtocol   = 0,
++        .driver_info          = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)},
++      /* Logitech, Webcam B910 */
++      { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
++                              | USB_DEVICE_ID_MATCH_INT_INFO,
++        .idVendor             = 0x046d,
++        .idProduct            = 0x0823,
++        .bInterfaceClass      = USB_CLASS_VIDEO,
++        .bInterfaceSubClass   = 1,
++        .bInterfaceProtocol   = 0,
++        .driver_info          = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)},
+       /* Logitech Quickcam Fusion */
+       { .match_flags          = USB_DEVICE_ID_MATCH_DEVICE
+                               | USB_DEVICE_ID_MATCH_INT_INFO,
+diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
+index 1b4cc934109e8..af2c6cb9fa3c4 100644
+--- a/drivers/media/usb/uvc/uvc_video.c
++++ b/drivers/media/usb/uvc/uvc_video.c
+@@ -1951,6 +1951,17 @@ static int uvc_video_start_transfer(struct uvc_streaming *stream,
+                       "Selecting alternate setting %u (%u B/frame bandwidth)\n",
+                       altsetting, best_psize);
++              /*
++               * Some devices, namely the Logitech C910 and B910, are unable
++               * to recover from a USB autosuspend, unless the alternate
++               * setting of the streaming interface is toggled.
++               */
++              if (stream->dev->quirks & UVC_QUIRK_WAKE_AUTOSUSPEND) {
++                      usb_set_interface(stream->dev->udev, intfnum,
++                                        altsetting);
++                      usb_set_interface(stream->dev->udev, intfnum, 0);
++              }
++
+               ret = usb_set_interface(stream->dev->udev, intfnum, altsetting);
+               if (ret < 0)
+                       return ret;
+diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
+index 9051006709fd5..bb3f62358dfeb 100644
+--- a/drivers/media/usb/uvc/uvcvideo.h
++++ b/drivers/media/usb/uvc/uvcvideo.h
+@@ -209,6 +209,7 @@
+ #define UVC_QUIRK_RESTORE_CTRLS_ON_INIT       0x00000400
+ #define UVC_QUIRK_FORCE_Y8            0x00000800
+ #define UVC_QUIRK_FORCE_BPP           0x00001000
++#define UVC_QUIRK_WAKE_AUTOSUSPEND    0x00002000
+ /* Format flags */
+ #define UVC_FMT_FLAG_COMPRESSED               0x00000001
+-- 
+2.39.2
+
diff --git a/queue-5.15/media-uvcvideo-remove-format-descriptions.patch b/queue-5.15/media-uvcvideo-remove-format-descriptions.patch
new file mode 100644 (file)
index 0000000..0a69569
--- /dev/null
@@ -0,0 +1,136 @@
+From 9b3d4e11f1c11ea9f1066e342e55410a88da48c6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Nov 2016 18:44:29 +0200
+Subject: media: uvcvideo: Remove format descriptions
+
+From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+
+[ Upstream commit 50459f103edfe47c9a599d766a850ef6014936c5 ]
+
+The V4L2 core overwrites format descriptions in v4l_fill_fmtdesc(),
+there's no need to manually set the descriptions in the driver. This
+prepares for removal of the format descriptions from the uvc_fmts table.
+
+Unlike V4L2, UVC makes a distinction between the SD-DV, SDL-DV and HD-DV
+formats. It also indicates whether the DV format uses 50Hz or 60Hz. This
+information is parsed by the driver to construct a format name string
+that is printed in a debug message, but serves no other purpose as V4L2
+has a single V4L2_PIX_FMT_DV pixel format that covers all those cases.
+
+As the information is available in the UVC descriptors, and thus
+accessible to users with lsusb if they really care, don't log it in a
+debug message and drop the format name string to simplify the code.
+
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
+Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/uvc/uvc_driver.c | 24 ++----------------------
+ drivers/media/usb/uvc/uvc_v4l2.c   |  2 --
+ drivers/media/usb/uvc/uvcvideo.h   |  2 --
+ 3 files changed, 2 insertions(+), 26 deletions(-)
+
+diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
+index ceae2eabc0a1c..57935eb079312 100644
+--- a/drivers/media/usb/uvc/uvc_driver.c
++++ b/drivers/media/usb/uvc/uvc_driver.c
+@@ -531,14 +531,10 @@ static int uvc_parse_format(struct uvc_device *dev,
+               fmtdesc = uvc_format_by_guid(&buffer[5]);
+               if (fmtdesc != NULL) {
+-                      strscpy(format->name, fmtdesc->name,
+-                              sizeof(format->name));
+                       format->fcc = fmtdesc->fcc;
+               } else {
+                       dev_info(&streaming->intf->dev,
+                                "Unknown video format %pUl\n", &buffer[5]);
+-                      snprintf(format->name, sizeof(format->name), "%pUl\n",
+-                              &buffer[5]);
+                       format->fcc = 0;
+               }
+@@ -549,8 +545,6 @@ static int uvc_parse_format(struct uvc_device *dev,
+                */
+               if (dev->quirks & UVC_QUIRK_FORCE_Y8) {
+                       if (format->fcc == V4L2_PIX_FMT_YUYV) {
+-                              strscpy(format->name, "Greyscale 8-bit (Y8  )",
+-                                      sizeof(format->name));
+                               format->fcc = V4L2_PIX_FMT_GREY;
+                               format->bpp = 8;
+                               width_multiplier = 2;
+@@ -591,7 +585,6 @@ static int uvc_parse_format(struct uvc_device *dev,
+                       return -EINVAL;
+               }
+-              strscpy(format->name, "MJPEG", sizeof(format->name));
+               format->fcc = V4L2_PIX_FMT_MJPEG;
+               format->flags = UVC_FMT_FLAG_COMPRESSED;
+               format->bpp = 0;
+@@ -607,17 +600,7 @@ static int uvc_parse_format(struct uvc_device *dev,
+                       return -EINVAL;
+               }
+-              switch (buffer[8] & 0x7f) {
+-              case 0:
+-                      strscpy(format->name, "SD-DV", sizeof(format->name));
+-                      break;
+-              case 1:
+-                      strscpy(format->name, "SDL-DV", sizeof(format->name));
+-                      break;
+-              case 2:
+-                      strscpy(format->name, "HD-DV", sizeof(format->name));
+-                      break;
+-              default:
++              if ((buffer[8] & 0x7f) > 2) {
+                       uvc_dbg(dev, DESCR,
+                               "device %d videostreaming interface %d: unknown DV format %u\n",
+                               dev->udev->devnum,
+@@ -625,9 +608,6 @@ static int uvc_parse_format(struct uvc_device *dev,
+                       return -EINVAL;
+               }
+-              strlcat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz",
+-                      sizeof(format->name));
+-
+               format->fcc = V4L2_PIX_FMT_DV;
+               format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM;
+               format->bpp = 0;
+@@ -654,7 +634,7 @@ static int uvc_parse_format(struct uvc_device *dev,
+               return -EINVAL;
+       }
+-      uvc_dbg(dev, DESCR, "Found format %s\n", format->name);
++      uvc_dbg(dev, DESCR, "Found format %p4cc", &format->fcc);
+       buflen -= buffer[0];
+       buffer += buffer[0];
+diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
+index 023412b2a9b93..ab535e5501583 100644
+--- a/drivers/media/usb/uvc/uvc_v4l2.c
++++ b/drivers/media/usb/uvc/uvc_v4l2.c
+@@ -657,8 +657,6 @@ static int uvc_ioctl_enum_fmt(struct uvc_streaming *stream,
+       fmt->flags = 0;
+       if (format->flags & UVC_FMT_FLAG_COMPRESSED)
+               fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
+-      strscpy(fmt->description, format->name, sizeof(fmt->description));
+-      fmt->description[sizeof(fmt->description) - 1] = 0;
+       fmt->pixelformat = format->fcc;
+       return 0;
+ }
+diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
+index d7c4f6f5fca92..9051006709fd5 100644
+--- a/drivers/media/usb/uvc/uvcvideo.h
++++ b/drivers/media/usb/uvc/uvcvideo.h
+@@ -405,8 +405,6 @@ struct uvc_format {
+       u32 fcc;
+       u32 flags;
+-      char name[32];
+-
+       unsigned int nframes;
+       struct uvc_frame *frame;
+ };
+-- 
+2.39.2
+
diff --git a/queue-5.15/media-uvcvideo-silence-memcpy-run-time-false-positiv.patch b/queue-5.15/media-uvcvideo-silence-memcpy-run-time-false-positiv.patch
new file mode 100644 (file)
index 0000000..6ee0f72
--- /dev/null
@@ -0,0 +1,60 @@
+From 7ef1d1d7ef2e8b0da972a4fa57d916aef5e7c6ef Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 5 Jan 2023 22:17:04 -0800
+Subject: media: uvcvideo: Silence memcpy() run-time false positive warnings
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit b839212988575c701aab4d3d9ca15e44c87e383c ]
+
+The memcpy() in uvc_video_decode_meta() intentionally copies across the
+length and flags members and into the trailing buf flexible array.
+Split the copy so that the compiler can better reason about (the lack
+of) buffer overflows here. Avoid the run-time false positive warning:
+
+  memcpy: detected field-spanning write (size 12) of single field "&meta->length" at drivers/media/usb/uvc/uvc_video.c:1355 (size 1)
+
+Additionally fix a typo in the documentation for struct uvc_meta_buf.
+
+Reported-by: ionut_n2001@yahoo.com
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216810
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/uvc/uvc_video.c | 4 +++-
+ include/uapi/linux/uvcvideo.h     | 2 +-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
+index af2c6cb9fa3c4..f477cfbbb905a 100644
+--- a/drivers/media/usb/uvc/uvc_video.c
++++ b/drivers/media/usb/uvc/uvc_video.c
+@@ -1334,7 +1334,9 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,
+       if (has_scr)
+               memcpy(stream->clock.last_scr, scr, 6);
+-      memcpy(&meta->length, mem, length);
++      meta->length = mem[0];
++      meta->flags  = mem[1];
++      memcpy(meta->buf, &mem[2], length - 2);
+       meta_buf->bytesused += length + sizeof(meta->ns) + sizeof(meta->sof);
+       uvc_dbg(stream->dev, FRAME,
+diff --git a/include/uapi/linux/uvcvideo.h b/include/uapi/linux/uvcvideo.h
+index 8288137387c0d..a9d0a64007ba5 100644
+--- a/include/uapi/linux/uvcvideo.h
++++ b/include/uapi/linux/uvcvideo.h
+@@ -86,7 +86,7 @@ struct uvc_xu_control_query {
+  * struct. The first two fields are added by the driver, they can be used for
+  * clock synchronisation. The rest is an exact copy of a UVC payload header.
+  * Only complete objects with complete buffers are included. Therefore it's
+- * always sizeof(meta->ts) + sizeof(meta->sof) + meta->length bytes large.
++ * always sizeof(meta->ns) + sizeof(meta->sof) + meta->length bytes large.
+  */
+ struct uvc_meta_buf {
+       __u64 ns;
+-- 
+2.39.2
+
diff --git a/queue-5.15/mei-bus-fixup-upon-error-print-return-values-of-send.patch b/queue-5.15/mei-bus-fixup-upon-error-print-return-values-of-send.patch
new file mode 100644 (file)
index 0000000..fa2c79e
--- /dev/null
@@ -0,0 +1,64 @@
+From c20c065b3bb735ae34941b6c3d5fae58c508e0ea Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 12 Dec 2022 23:49:33 +0200
+Subject: mei: bus-fixup:upon error print return values of send and receive
+
+From: Alexander Usyskin <alexander.usyskin@intel.com>
+
+[ Upstream commit 4b8659e2c258e4fdac9ccdf06cc20c0677894ef9 ]
+
+For easier debugging, upon error, print also return values
+from __mei_cl_recv() and __mei_cl_send() functions.
+
+Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
+Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
+Link: https://lore.kernel.org/r/20221212214933.275434-1-tomas.winkler@intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/misc/mei/bus-fixup.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
+index 67844089db216..9d082287dbe02 100644
+--- a/drivers/misc/mei/bus-fixup.c
++++ b/drivers/misc/mei/bus-fixup.c
+@@ -175,7 +175,7 @@ static int mei_fwver(struct mei_cl_device *cldev)
+       ret = __mei_cl_send(cldev->cl, (u8 *)&req, sizeof(req), 0,
+                           MEI_CL_IO_TX_BLOCKING);
+       if (ret < 0) {
+-              dev_err(&cldev->dev, "Could not send ReqFWVersion cmd\n");
++              dev_err(&cldev->dev, "Could not send ReqFWVersion cmd ret = %d\n", ret);
+               return ret;
+       }
+@@ -187,7 +187,7 @@ static int mei_fwver(struct mei_cl_device *cldev)
+                * Should be at least one version block,
+                * error out if nothing found
+                */
+-              dev_err(&cldev->dev, "Could not read FW version\n");
++              dev_err(&cldev->dev, "Could not read FW version ret = %d\n", bytes_recv);
+               return -EIO;
+       }
+@@ -337,7 +337,7 @@ static int mei_nfc_if_version(struct mei_cl *cl,
+       ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(cmd), 0,
+                           MEI_CL_IO_TX_BLOCKING);
+       if (ret < 0) {
+-              dev_err(bus->dev, "Could not send IF version cmd\n");
++              dev_err(bus->dev, "Could not send IF version cmd ret = %d\n", ret);
+               return ret;
+       }
+@@ -352,7 +352,7 @@ static int mei_nfc_if_version(struct mei_cl *cl,
+       bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length, &vtag,
+                                  0, 0);
+       if (bytes_recv < 0 || (size_t)bytes_recv < if_version_length) {
+-              dev_err(bus->dev, "Could not read IF version\n");
++              dev_err(bus->dev, "Could not read IF version ret = %d\n", bytes_recv);
+               ret = -EIO;
+               goto err;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/mfd-arizona-use-pm_runtime_resume_and_get-to-prevent.patch b/queue-5.15/mfd-arizona-use-pm_runtime_resume_and_get-to-prevent.patch
new file mode 100644 (file)
index 0000000..d8c6978
--- /dev/null
@@ -0,0 +1,38 @@
+From f7f89e7c79361a1572cfca7f6e519f6527e0345b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 5 Jan 2023 14:10:55 +0800
+Subject: mfd: arizona: Use pm_runtime_resume_and_get() to prevent refcnt leak
+
+From: Liang He <windhl@126.com>
+
+[ Upstream commit 4414a7ab80cebf715045e3c4d465feefbad21139 ]
+
+In arizona_clk32k_enable(), we should use pm_runtime_resume_and_get()
+as pm_runtime_get_sync() will increase the refcnt even when it
+returns an error.
+
+Signed-off-by: Liang He <windhl@126.com>
+Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
+Signed-off-by: Lee Jones <lee@kernel.org>
+Link: https://lore.kernel.org/r/20230105061055.1509261-1-windhl@126.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mfd/arizona-core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
+index 9323b1e3a69ef..5c8317bd4d98b 100644
+--- a/drivers/mfd/arizona-core.c
++++ b/drivers/mfd/arizona-core.c
+@@ -45,7 +45,7 @@ int arizona_clk32k_enable(struct arizona *arizona)
+       if (arizona->clk32k_ref == 1) {
+               switch (arizona->pdata.clk32k_src) {
+               case ARIZONA_32KZ_MCLK1:
+-                      ret = pm_runtime_get_sync(arizona->dev);
++                      ret = pm_runtime_resume_and_get(arizona->dev);
+                       if (ret != 0)
+                               goto err_ref;
+                       ret = clk_prepare_enable(arizona->mclk[ARIZONA_MCLK1]);
+-- 
+2.39.2
+
diff --git a/queue-5.15/misc-vmw_balloon-fix-memory-leak-with-using-debugfs_.patch b/queue-5.15/misc-vmw_balloon-fix-memory-leak-with-using-debugfs_.patch
new file mode 100644 (file)
index 0000000..6273e47
--- /dev/null
@@ -0,0 +1,40 @@
+From f1066397ab90c5030288c422fe9712b59e34583c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 15:11:00 +0100
+Subject: misc: vmw_balloon: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 209cdbd07cfaa4b7385bad4eeb47e5ec1887d33d ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic at
+once.
+
+Cc: Nadav Amit <namit@vmware.com>
+Cc: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Link: https://lore.kernel.org/r/20230202141100.2291188-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/misc/vmw_balloon.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
+index f1d8ba6d48574..dab8ad9fed6b3 100644
+--- a/drivers/misc/vmw_balloon.c
++++ b/drivers/misc/vmw_balloon.c
+@@ -1711,7 +1711,7 @@ static void __init vmballoon_debugfs_init(struct vmballoon *b)
+ static void __exit vmballoon_debugfs_exit(struct vmballoon *b)
+ {
+       static_key_disable(&balloon_stat_enabled.key);
+-      debugfs_remove(debugfs_lookup("vmmemctl", NULL));
++      debugfs_lookup_and_remove("vmmemctl", NULL);
+       kfree(b->stats);
+       b->stats = NULL;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-fix-__dev_kfree_skb_any-vs-drop-monitor.patch b/queue-5.15/net-fix-__dev_kfree_skb_any-vs-drop-monitor.patch
new file mode 100644 (file)
index 0000000..aeaae78
--- /dev/null
@@ -0,0 +1,49 @@
+From f886de885144460c8cc655286a8ac924d117b1d1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 23 Feb 2023 08:38:45 +0000
+Subject: net: fix __dev_kfree_skb_any() vs drop monitor
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit ac3ad19584b26fae9ac86e4faebe790becc74491 ]
+
+dev_kfree_skb() is aliased to consume_skb().
+
+When a driver is dropping a packet by calling dev_kfree_skb_any()
+we should propagate the drop reason instead of pretending
+the packet was consumed.
+
+Note: Now we have enum skb_drop_reason we could remove
+enum skb_free_reason (for linux-6.4)
+
+v2: added an unlikely(), suggested by Yunsheng Lin.
+
+Fixes: e6247027e517 ("net: introduce dev_consume_skb_any()")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Cc: Yunsheng Lin <linyunsheng@huawei.com>
+Reviewed-by: Yunsheng Lin <linyunsheng@huawei.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/dev.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/net/core/dev.c b/net/core/dev.c
+index 24a80e960d2d9..7fc8ae7f3cd5b 100644
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -3113,8 +3113,10 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
+ {
+       if (in_hardirq() || irqs_disabled())
+               __dev_kfree_skb_irq(skb, reason);
++      else if (unlikely(reason == SKB_REASON_DROPPED))
++              kfree_skb(skb);
+       else
+-              dev_kfree_skb(skb);
++              consume_skb(skb);
+ }
+ EXPORT_SYMBOL(__dev_kfree_skb_any);
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-mlx5-geneve-fix-handling-of-geneve-object-id-as-.patch b/queue-5.15/net-mlx5-geneve-fix-handling-of-geneve-object-id-as-.patch
new file mode 100644 (file)
index 0000000..d2adcbb
--- /dev/null
@@ -0,0 +1,41 @@
+From d6252d52cd600c0634d15a24b842572174f573a4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Feb 2023 17:44:06 +0200
+Subject: net/mlx5: Geneve, Fix handling of Geneve object id as error code
+
+From: Maor Dickman <maord@nvidia.com>
+
+[ Upstream commit d28a06d7dbedc598a06bd1e53a28125f87ca5d0c ]
+
+On success, mlx5_geneve_tlv_option_create returns non negative
+Geneve object id. In case the object id is positive value the
+caller functions will handle it as an error (non zero) and
+will fail to offload the Geneve rule.
+
+Fix this by changing caller function ,mlx5_geneve_tlv_option_add,
+to return 0 in case valid non negative object id was provided.
+
+Fixes: 0ccc171ea6a2 ("net/mlx5: Geneve, Manage Geneve TLV options")
+Signed-off-by: Maor Dickman <maord@nvidia.com>
+Reviewed-by: Raed Salem <raeds@nvidia.com>
+Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/mellanox/mlx5/core/lib/geneve.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/geneve.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/geneve.c
+index 23361a9ae4fa0..6dc83e871cd76 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/geneve.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/geneve.c
+@@ -105,6 +105,7 @@ int mlx5_geneve_tlv_option_add(struct mlx5_geneve *geneve, struct geneve_opt *op
+               geneve->opt_type = opt->type;
+               geneve->obj_id = res;
+               geneve->refcount++;
++              res = 0;
+       }
+ unlock:
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-mlx5e-verify-flow_source-cap-before-using-it.patch b/queue-5.15/net-mlx5e-verify-flow_source-cap-before-using-it.patch
new file mode 100644 (file)
index 0000000..2db93dd
--- /dev/null
@@ -0,0 +1,38 @@
+From 0ff341e5a8ad5a26d8744e7534debd256d766f46 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Jan 2023 12:04:30 +0200
+Subject: net/mlx5e: Verify flow_source cap before using it
+
+From: Roi Dayan <roid@nvidia.com>
+
+[ Upstream commit 1bf8b0dae8dde6f02520a5ea34fdaa3b39342e69 ]
+
+When adding send to vport rule verify flow_source matching is
+supported by checking the flow_source cap.
+
+Fixes: d04442540372 ("net/mlx5: E-Switch, set flow source for send to uplink rule")
+Signed-off-by: Roi Dayan <roid@nvidia.com>
+Reviewed-by: Maor Dickman <maord@nvidia.com>
+Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+index 3194cdcd2f630..002567792e91e 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+@@ -962,7 +962,8 @@ mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *on_esw,
+       dest.vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID;
+       flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
+-      if (rep->vport == MLX5_VPORT_UPLINK)
++      if (MLX5_CAP_ESW_FLOWTABLE(on_esw->dev, flow_source) &&
++          rep->vport == MLX5_VPORT_UPLINK)
+               spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_LOCAL_VPORT;
+       flow_rule = mlx5_add_flow_rules(on_esw->fdb_table.offloads.slow_fdb,
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-sched-act_mpls-fix-action-bind-logic.patch b/queue-5.15/net-sched-act_mpls-fix-action-bind-logic.patch
new file mode 100644 (file)
index 0000000..45b4bd4
--- /dev/null
@@ -0,0 +1,203 @@
+From 6da185e5e830c5051214312cbaf889c12a6dbf79 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Feb 2023 12:00:57 -0300
+Subject: net/sched: act_mpls: fix action bind logic
+
+From: Pedro Tammela <pctammela@mojatatu.com>
+
+[ Upstream commit e88d78a773cb5242e933930c8855bf4b2e8c2397 ]
+
+The TC architecture allows filters and actions to be created independently.
+In filters the user can reference action objects using:
+tc action add action mpls ... index 1
+tc filter add ... action mpls index 1
+
+In the current code for act_mpls this is broken as it checks netlink
+attributes for create/update before actually checking if we are binding to an
+existing action.
+
+tdc results:
+1..53
+ok 1 a933 - Add MPLS dec_ttl action with pipe opcode
+ok 2 08d1 - Add mpls dec_ttl action with pass opcode
+ok 3 d786 - Add mpls dec_ttl action with drop opcode
+ok 4 f334 - Add mpls dec_ttl action with reclassify opcode
+ok 5 29bd - Add mpls dec_ttl action with continue opcode
+ok 6 48df - Add mpls dec_ttl action with jump opcode
+ok 7 62eb - Add mpls dec_ttl action with trap opcode
+ok 8 09d2 - Add mpls dec_ttl action with opcode and cookie
+ok 9 c170 - Add mpls dec_ttl action with opcode and cookie of max length
+ok 10 9118 - Add mpls dec_ttl action with invalid opcode
+ok 11 6ce1 - Add mpls dec_ttl action with label (invalid)
+ok 12 352f - Add mpls dec_ttl action with tc (invalid)
+ok 13 fa1c - Add mpls dec_ttl action with ttl (invalid)
+ok 14 6b79 - Add mpls dec_ttl action with bos (invalid)
+ok 15 d4c4 - Add mpls pop action with ip proto
+ok 16 91fb - Add mpls pop action with ip proto and cookie
+ok 17 92fe - Add mpls pop action with mpls proto
+ok 18 7e23 - Add mpls pop action with no protocol (invalid)
+ok 19 6182 - Add mpls pop action with label (invalid)
+ok 20 6475 - Add mpls pop action with tc (invalid)
+ok 21 067b - Add mpls pop action with ttl (invalid)
+ok 22 7316 - Add mpls pop action with bos (invalid)
+ok 23 38cc - Add mpls push action with label
+ok 24 c281 - Add mpls push action with mpls_mc protocol
+ok 25 5db4 - Add mpls push action with label, tc and ttl
+ok 26 7c34 - Add mpls push action with label, tc ttl and cookie of max length
+ok 27 16eb - Add mpls push action with label and bos
+ok 28 d69d - Add mpls push action with no label (invalid)
+ok 29 e8e4 - Add mpls push action with ipv4 protocol (invalid)
+ok 30 ecd0 - Add mpls push action with out of range label (invalid)
+ok 31 d303 - Add mpls push action with out of range tc (invalid)
+ok 32 fd6e - Add mpls push action with ttl of 0 (invalid)
+ok 33 19e9 - Add mpls mod action with mpls label
+ok 34 1fde - Add mpls mod action with max mpls label
+ok 35 0c50 - Add mpls mod action with mpls label exceeding max (invalid)
+ok 36 10b6 - Add mpls mod action with mpls label of MPLS_LABEL_IMPLNULL (invalid)
+ok 37 57c9 - Add mpls mod action with mpls min tc
+ok 38 6872 - Add mpls mod action with mpls max tc
+ok 39 a70a - Add mpls mod action with mpls tc exceeding max (invalid)
+ok 40 6ed5 - Add mpls mod action with mpls ttl
+ok 41 77c1 - Add mpls mod action with mpls ttl and cookie
+ok 42 b80f - Add mpls mod action with mpls max ttl
+ok 43 8864 - Add mpls mod action with mpls min ttl
+ok 44 6c06 - Add mpls mod action with mpls ttl of 0 (invalid)
+ok 45 b5d8 - Add mpls mod action with mpls ttl exceeding max (invalid)
+ok 46 451f - Add mpls mod action with mpls max bos
+ok 47 a1ed - Add mpls mod action with mpls min bos
+ok 48 3dcf - Add mpls mod action with mpls bos exceeding max (invalid)
+ok 49 db7c - Add mpls mod action with protocol (invalid)
+ok 50 b070 - Replace existing mpls push action with new ID
+ok 51 95a9 - Replace existing mpls push action with new label, tc, ttl and cookie
+ok 52 6cce - Delete mpls pop action
+ok 53 d138 - Flush mpls actions
+
+Fixes: 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/act_mpls.c | 66 +++++++++++++++++++++++++-------------------
+ 1 file changed, 37 insertions(+), 29 deletions(-)
+
+diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
+index 980ad795727e9..d010c5b8e83b1 100644
+--- a/net/sched/act_mpls.c
++++ b/net/sched/act_mpls.c
+@@ -189,40 +189,67 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
+       parm = nla_data(tb[TCA_MPLS_PARMS]);
+       index = parm->index;
++      err = tcf_idr_check_alloc(tn, &index, a, bind);
++      if (err < 0)
++              return err;
++      exists = err;
++      if (exists && bind)
++              return 0;
++
++      if (!exists) {
++              ret = tcf_idr_create(tn, index, est, a, &act_mpls_ops, bind,
++                                   true, flags);
++              if (ret) {
++                      tcf_idr_cleanup(tn, index);
++                      return ret;
++              }
++
++              ret = ACT_P_CREATED;
++      } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
++              tcf_idr_release(*a, bind);
++              return -EEXIST;
++      }
++
+       /* Verify parameters against action type. */
+       switch (parm->m_action) {
+       case TCA_MPLS_ACT_POP:
+               if (!tb[TCA_MPLS_PROTO]) {
+                       NL_SET_ERR_MSG_MOD(extack, "Protocol must be set for MPLS pop");
+-                      return -EINVAL;
++                      err = -EINVAL;
++                      goto release_idr;
+               }
+               if (!eth_proto_is_802_3(nla_get_be16(tb[TCA_MPLS_PROTO]))) {
+                       NL_SET_ERR_MSG_MOD(extack, "Invalid protocol type for MPLS pop");
+-                      return -EINVAL;
++                      err = -EINVAL;
++                      goto release_idr;
+               }
+               if (tb[TCA_MPLS_LABEL] || tb[TCA_MPLS_TTL] || tb[TCA_MPLS_TC] ||
+                   tb[TCA_MPLS_BOS]) {
+                       NL_SET_ERR_MSG_MOD(extack, "Label, TTL, TC or BOS cannot be used with MPLS pop");
+-                      return -EINVAL;
++                      err = -EINVAL;
++                      goto release_idr;
+               }
+               break;
+       case TCA_MPLS_ACT_DEC_TTL:
+               if (tb[TCA_MPLS_PROTO] || tb[TCA_MPLS_LABEL] ||
+                   tb[TCA_MPLS_TTL] || tb[TCA_MPLS_TC] || tb[TCA_MPLS_BOS]) {
+                       NL_SET_ERR_MSG_MOD(extack, "Label, TTL, TC, BOS or protocol cannot be used with MPLS dec_ttl");
+-                      return -EINVAL;
++                      err = -EINVAL;
++                      goto release_idr;
+               }
+               break;
+       case TCA_MPLS_ACT_PUSH:
+       case TCA_MPLS_ACT_MAC_PUSH:
+               if (!tb[TCA_MPLS_LABEL]) {
+                       NL_SET_ERR_MSG_MOD(extack, "Label is required for MPLS push");
+-                      return -EINVAL;
++                      err = -EINVAL;
++                      goto release_idr;
+               }
+               if (tb[TCA_MPLS_PROTO] &&
+                   !eth_p_mpls(nla_get_be16(tb[TCA_MPLS_PROTO]))) {
+                       NL_SET_ERR_MSG_MOD(extack, "Protocol must be an MPLS type for MPLS push");
+-                      return -EPROTONOSUPPORT;
++                      err = -EPROTONOSUPPORT;
++                      goto release_idr;
+               }
+               /* Push needs a TTL - if not specified, set a default value. */
+               if (!tb[TCA_MPLS_TTL]) {
+@@ -237,33 +264,14 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
+       case TCA_MPLS_ACT_MODIFY:
+               if (tb[TCA_MPLS_PROTO]) {
+                       NL_SET_ERR_MSG_MOD(extack, "Protocol cannot be used with MPLS modify");
+-                      return -EINVAL;
++                      err = -EINVAL;
++                      goto release_idr;
+               }
+               break;
+       default:
+               NL_SET_ERR_MSG_MOD(extack, "Unknown MPLS action");
+-              return -EINVAL;
+-      }
+-
+-      err = tcf_idr_check_alloc(tn, &index, a, bind);
+-      if (err < 0)
+-              return err;
+-      exists = err;
+-      if (exists && bind)
+-              return 0;
+-
+-      if (!exists) {
+-              ret = tcf_idr_create(tn, index, est, a,
+-                                   &act_mpls_ops, bind, true, flags);
+-              if (ret) {
+-                      tcf_idr_cleanup(tn, index);
+-                      return ret;
+-              }
+-
+-              ret = ACT_P_CREATED;
+-      } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
+-              tcf_idr_release(*a, bind);
+-              return -EEXIST;
++              err = -EINVAL;
++              goto release_idr;
+       }
+       err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-sched-act_pedit-fix-action-bind-logic.patch b/queue-5.15/net-sched-act_pedit-fix-action-bind-logic.patch
new file mode 100644 (file)
index 0000000..3b1ff7d
--- /dev/null
@@ -0,0 +1,205 @@
+From bc730d1ce2e8a00ce6abb4eb2138a0c299414bc9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Feb 2023 12:00:56 -0300
+Subject: net/sched: act_pedit: fix action bind logic
+
+From: Pedro Tammela <pctammela@mojatatu.com>
+
+[ Upstream commit e9e42292ea76a8358b0c02ffd530d78e133a1b73 ]
+
+The TC architecture allows filters and actions to be created independently.
+In filters the user can reference action objects using:
+tc action add action pedit ... index 1
+tc filter add ... action pedit index 1
+
+In the current code for act_pedit this is broken as it checks netlink
+attributes for create/update before actually checking if we are binding to an
+existing action.
+
+tdc results:
+1..69
+ok 1 319a - Add pedit action that mangles IP TTL
+ok 2 7e67 - Replace pedit action with invalid goto chain
+ok 3 377e - Add pedit action with RAW_OP offset u32
+ok 4 a0ca - Add pedit action with RAW_OP offset u32 (INVALID)
+ok 5 dd8a - Add pedit action with RAW_OP offset u16 u16
+ok 6 53db - Add pedit action with RAW_OP offset u16 (INVALID)
+ok 7 5c7e - Add pedit action with RAW_OP offset u8 add value
+ok 8 2893 - Add pedit action with RAW_OP offset u8 quad
+ok 9 3a07 - Add pedit action with RAW_OP offset u8-u16-u8
+ok 10 ab0f - Add pedit action with RAW_OP offset u16-u8-u8
+ok 11 9d12 - Add pedit action with RAW_OP offset u32 set u16 clear u8 invert
+ok 12 ebfa - Add pedit action with RAW_OP offset overflow u32 (INVALID)
+ok 13 f512 - Add pedit action with RAW_OP offset u16 at offmask shift set
+ok 14 c2cb - Add pedit action with RAW_OP offset u32 retain value
+ok 15 1762 - Add pedit action with RAW_OP offset u8 clear value
+ok 16 bcee - Add pedit action with RAW_OP offset u8 retain value
+ok 17 e89f - Add pedit action with RAW_OP offset u16 retain value
+ok 18 c282 - Add pedit action with RAW_OP offset u32 clear value
+ok 19 c422 - Add pedit action with RAW_OP offset u16 invert value
+ok 20 d3d3 - Add pedit action with RAW_OP offset u32 invert value
+ok 21 57e5 - Add pedit action with RAW_OP offset u8 preserve value
+ok 22 99e0 - Add pedit action with RAW_OP offset u16 preserve value
+ok 23 1892 - Add pedit action with RAW_OP offset u32 preserve value
+ok 24 4b60 - Add pedit action with RAW_OP negative offset u16/u32 set value
+ok 25 a5a7 - Add pedit action with LAYERED_OP eth set src
+ok 26 86d4 - Add pedit action with LAYERED_OP eth set src & dst
+ok 27 f8a9 - Add pedit action with LAYERED_OP eth set dst
+ok 28 c715 - Add pedit action with LAYERED_OP eth set src (INVALID)
+ok 29 8131 - Add pedit action with LAYERED_OP eth set dst (INVALID)
+ok 30 ba22 - Add pedit action with LAYERED_OP eth type set/clear sequence
+ok 31 dec4 - Add pedit action with LAYERED_OP eth set type (INVALID)
+ok 32 ab06 - Add pedit action with LAYERED_OP eth add type
+ok 33 918d - Add pedit action with LAYERED_OP eth invert src
+ok 34 a8d4 - Add pedit action with LAYERED_OP eth invert dst
+ok 35 ee13 - Add pedit action with LAYERED_OP eth invert type
+ok 36 7588 - Add pedit action with LAYERED_OP ip set src
+ok 37 0fa7 - Add pedit action with LAYERED_OP ip set dst
+ok 38 5810 - Add pedit action with LAYERED_OP ip set src & dst
+ok 39 1092 - Add pedit action with LAYERED_OP ip set ihl & dsfield
+ok 40 02d8 - Add pedit action with LAYERED_OP ip set ttl & protocol
+ok 41 3e2d - Add pedit action with LAYERED_OP ip set ttl (INVALID)
+ok 42 31ae - Add pedit action with LAYERED_OP ip ttl clear/set
+ok 43 486f - Add pedit action with LAYERED_OP ip set duplicate fields
+ok 44 e790 - Add pedit action with LAYERED_OP ip set ce, df, mf, firstfrag, nofrag fields
+ok 45 cc8a - Add pedit action with LAYERED_OP ip set tos
+ok 46 7a17 - Add pedit action with LAYERED_OP ip set precedence
+ok 47 c3b6 - Add pedit action with LAYERED_OP ip add tos
+ok 48 43d3 - Add pedit action with LAYERED_OP ip add precedence
+ok 49 438e - Add pedit action with LAYERED_OP ip clear tos
+ok 50 6b1b - Add pedit action with LAYERED_OP ip clear precedence
+ok 51 824a - Add pedit action with LAYERED_OP ip invert tos
+ok 52 106f - Add pedit action with LAYERED_OP ip invert precedence
+ok 53 6829 - Add pedit action with LAYERED_OP beyond ip set dport & sport
+ok 54 afd8 - Add pedit action with LAYERED_OP beyond ip set icmp_type & icmp_code
+ok 55 3143 - Add pedit action with LAYERED_OP beyond ip set dport (INVALID)
+ok 56 815c - Add pedit action with LAYERED_OP ip6 set src
+ok 57 4dae - Add pedit action with LAYERED_OP ip6 set dst
+ok 58 fc1f - Add pedit action with LAYERED_OP ip6 set src & dst
+ok 59 6d34 - Add pedit action with LAYERED_OP ip6 dst retain value (INVALID)
+ok 60 94bb - Add pedit action with LAYERED_OP ip6 traffic_class
+ok 61 6f5e - Add pedit action with LAYERED_OP ip6 flow_lbl
+ok 62 6795 - Add pedit action with LAYERED_OP ip6 set payload_len, nexthdr, hoplimit
+ok 63 1442 - Add pedit action with LAYERED_OP tcp set dport & sport
+ok 64 b7ac - Add pedit action with LAYERED_OP tcp sport set (INVALID)
+ok 65 cfcc - Add pedit action with LAYERED_OP tcp flags set
+ok 66 3bc4 - Add pedit action with LAYERED_OP tcp set dport, sport & flags fields
+ok 67 f1c8 - Add pedit action with LAYERED_OP udp set dport & sport
+ok 68 d784 - Add pedit action with mixed RAW/LAYERED_OP #1
+ok 69 70ca - Add pedit action with mixed RAW/LAYERED_OP #2
+
+Fixes: 71d0ed7079df ("net/act_pedit: Support using offset relative to the conventional network headers")
+Fixes: f67169fef8db ("net/sched: act_pedit: fix WARN() in the traffic path")
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/act_pedit.c | 58 +++++++++++++++++++++++--------------------
+ 1 file changed, 31 insertions(+), 27 deletions(-)
+
+diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
+index bd28bb0804162..051cd20928599 100644
+--- a/net/sched/act_pedit.c
++++ b/net/sched/act_pedit.c
+@@ -181,26 +181,6 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+       }
+       parm = nla_data(pattr);
+-      if (!parm->nkeys) {
+-              NL_SET_ERR_MSG_MOD(extack, "Pedit requires keys to be passed");
+-              return -EINVAL;
+-      }
+-      ksize = parm->nkeys * sizeof(struct tc_pedit_key);
+-      if (nla_len(pattr) < sizeof(*parm) + ksize) {
+-              NL_SET_ERR_MSG_ATTR(extack, pattr, "Length of TCA_PEDIT_PARMS or TCA_PEDIT_PARMS_EX pedit attribute is invalid");
+-              return -EINVAL;
+-      }
+-
+-      nparms = kzalloc(sizeof(*nparms), GFP_KERNEL);
+-      if (!nparms)
+-              return -ENOMEM;
+-
+-      nparms->tcfp_keys_ex =
+-              tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys);
+-      if (IS_ERR(nparms->tcfp_keys_ex)) {
+-              ret = PTR_ERR(nparms->tcfp_keys_ex);
+-              goto out_free;
+-      }
+       index = parm->index;
+       err = tcf_idr_check_alloc(tn, &index, a, bind);
+@@ -209,25 +189,49 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+                                               &act_pedit_ops, bind, flags);
+               if (ret) {
+                       tcf_idr_cleanup(tn, index);
+-                      goto out_free_ex;
++                      return ret;
+               }
+               ret = ACT_P_CREATED;
+       } else if (err > 0) {
+               if (bind)
+-                      goto out_free;
++                      return 0;
+               if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
+                       ret = -EEXIST;
+                       goto out_release;
+               }
+       } else {
+-              ret = err;
+-              goto out_free_ex;
++              return err;
++      }
++
++      if (!parm->nkeys) {
++              NL_SET_ERR_MSG_MOD(extack, "Pedit requires keys to be passed");
++              ret = -EINVAL;
++              goto out_release;
++      }
++      ksize = parm->nkeys * sizeof(struct tc_pedit_key);
++      if (nla_len(pattr) < sizeof(*parm) + ksize) {
++              NL_SET_ERR_MSG_ATTR(extack, pattr, "Length of TCA_PEDIT_PARMS or TCA_PEDIT_PARMS_EX pedit attribute is invalid");
++              ret = -EINVAL;
++              goto out_release;
++      }
++
++      nparms = kzalloc(sizeof(*nparms), GFP_KERNEL);
++      if (!nparms) {
++              ret = -ENOMEM;
++              goto out_release;
++      }
++
++      nparms->tcfp_keys_ex =
++              tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys);
++      if (IS_ERR(nparms->tcfp_keys_ex)) {
++              ret = PTR_ERR(nparms->tcfp_keys_ex);
++              goto out_free;
+       }
+       err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
+       if (err < 0) {
+               ret = err;
+-              goto out_release;
++              goto out_free_ex;
+       }
+       nparms->tcfp_off_max_hint = 0;
+@@ -278,12 +282,12 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+ put_chain:
+       if (goto_ch)
+               tcf_chain_put_by_act(goto_ch);
+-out_release:
+-      tcf_idr_release(*a, bind);
+ out_free_ex:
+       kfree(nparms->tcfp_keys_ex);
+ out_free:
+       kfree(nparms);
++out_release:
++      tcf_idr_release(*a, bind);
+       return ret;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-sched-act_sample-fix-action-bind-logic.patch b/queue-5.15/net-sched-act_sample-fix-action-bind-logic.patch
new file mode 100644 (file)
index 0000000..9668f03
--- /dev/null
@@ -0,0 +1,92 @@
+From 973be3fa555cf67a4d174a3e907a98ffe7587026 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Feb 2023 12:00:58 -0300
+Subject: net/sched: act_sample: fix action bind logic
+
+From: Pedro Tammela <pctammela@mojatatu.com>
+
+[ Upstream commit 4a20056a49a1854966562241922f68197f950539 ]
+
+The TC architecture allows filters and actions to be created independently.
+In filters the user can reference action objects using:
+tc action add action sample ... index 1
+tc filter add ... action pedit index 1
+
+In the current code for act_sample this is broken as it checks netlink
+attributes for create/update before actually checking if we are binding to an
+existing action.
+
+tdc results:
+1..29
+ok 1 9784 - Add valid sample action with mandatory arguments
+ok 2 5c91 - Add valid sample action with mandatory arguments and continue control action
+ok 3 334b - Add valid sample action with mandatory arguments and drop control action
+ok 4 da69 - Add valid sample action with mandatory arguments and reclassify control action
+ok 5 13ce - Add valid sample action with mandatory arguments and pipe control action
+ok 6 1886 - Add valid sample action with mandatory arguments and jump control action
+ok 7 7571 - Add sample action with invalid rate
+ok 8 b6d4 - Add sample action with mandatory arguments and invalid control action
+ok 9 a874 - Add invalid sample action without mandatory arguments
+ok 10 ac01 - Add invalid sample action without mandatory argument rate
+ok 11 4203 - Add invalid sample action without mandatory argument group
+ok 12 14a7 - Add invalid sample action without mandatory argument group
+ok 13 8f2e - Add valid sample action with trunc argument
+ok 14 45f8 - Add sample action with maximum rate argument
+ok 15 ad0c - Add sample action with maximum trunc argument
+ok 16 83a9 - Add sample action with maximum group argument
+ok 17 ed27 - Add sample action with invalid rate argument
+ok 18 2eae - Add sample action with invalid group argument
+ok 19 6ff3 - Add sample action with invalid trunc size
+ok 20 2b2a - Add sample action with invalid index
+ok 21 dee2 - Add sample action with maximum allowed index
+ok 22 560e - Add sample action with cookie
+ok 23 704a - Replace existing sample action with new rate argument
+ok 24 60eb - Replace existing sample action with new group argument
+ok 25 2cce - Replace existing sample action with new trunc argument
+ok 26 59d1 - Replace existing sample action with new control argument
+ok 27 0a6e - Replace sample action with invalid goto chain control
+ok 28 3872 - Delete sample action with valid index
+ok 29 a394 - Delete sample action with invalid index
+
+Fixes: 5c5670fae430 ("net/sched: Introduce sample tc action")
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/act_sample.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c
+index ab4ae24ab886f..ca67d96449176 100644
+--- a/net/sched/act_sample.c
++++ b/net/sched/act_sample.c
+@@ -55,8 +55,8 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
+                                         sample_policy, NULL);
+       if (ret < 0)
+               return ret;
+-      if (!tb[TCA_SAMPLE_PARMS] || !tb[TCA_SAMPLE_RATE] ||
+-          !tb[TCA_SAMPLE_PSAMPLE_GROUP])
++
++      if (!tb[TCA_SAMPLE_PARMS])
+               return -EINVAL;
+       parm = nla_data(tb[TCA_SAMPLE_PARMS]);
+@@ -80,6 +80,13 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
+               tcf_idr_release(*a, bind);
+               return -EEXIST;
+       }
++
++      if (!tb[TCA_SAMPLE_RATE] || !tb[TCA_SAMPLE_PSAMPLE_GROUP]) {
++              NL_SET_ERR_MSG(extack, "sample rate and group are required");
++              err = -EINVAL;
++              goto release_idr;
++      }
++
+       err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
+       if (err < 0)
+               goto release_idr;
+-- 
+2.39.2
+
diff --git a/queue-5.15/net-sched-transition-act_pedit-to-rcu-and-percpu-sta.patch b/queue-5.15/net-sched-transition-act_pedit-to-rcu-and-percpu-sta.patch
new file mode 100644 (file)
index 0000000..348c327
--- /dev/null
@@ -0,0 +1,437 @@
+From 8809ddb6390d65b3fbb657c2b6413e9aa7110295 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Jan 2023 16:05:11 -0300
+Subject: net/sched: transition act_pedit to rcu and percpu stats
+
+From: Pedro Tammela <pctammela@mojatatu.com>
+
+[ Upstream commit 52cf89f78c01bf39973f3e70d366921d70faff7a ]
+
+The software pedit action didn't get the same love as some of the
+other actions and it's still using spinlocks and shared stats in the
+datapath.
+Transition the action to rcu and percpu stats as this improves the
+action's performance dramatically on multiple cpu deployments.
+
+Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
+Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Stable-dep-of: e9e42292ea76 ("net/sched: act_pedit: fix action bind logic")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/tc_act/tc_pedit.h |  81 +++++++++++++++----
+ net/sched/act_pedit.c         | 148 ++++++++++++++++++++--------------
+ 2 files changed, 153 insertions(+), 76 deletions(-)
+
+diff --git a/include/net/tc_act/tc_pedit.h b/include/net/tc_act/tc_pedit.h
+index 3e02709a1df65..83fe399317818 100644
+--- a/include/net/tc_act/tc_pedit.h
++++ b/include/net/tc_act/tc_pedit.h
+@@ -4,22 +4,29 @@
+ #include <net/act_api.h>
+ #include <linux/tc_act/tc_pedit.h>
++#include <linux/types.h>
+ struct tcf_pedit_key_ex {
+       enum pedit_header_type htype;
+       enum pedit_cmd cmd;
+ };
+-struct tcf_pedit {
+-      struct tc_action        common;
+-      unsigned char           tcfp_nkeys;
+-      unsigned char           tcfp_flags;
+-      u32                     tcfp_off_max_hint;
++struct tcf_pedit_parms {
+       struct tc_pedit_key     *tcfp_keys;
+       struct tcf_pedit_key_ex *tcfp_keys_ex;
++      u32 tcfp_off_max_hint;
++      unsigned char tcfp_nkeys;
++      unsigned char tcfp_flags;
++      struct rcu_head rcu;
++};
++
++struct tcf_pedit {
++      struct tc_action common;
++      struct tcf_pedit_parms __rcu *parms;
+ };
+ #define to_pedit(a) ((struct tcf_pedit *)a)
++#define to_pedit_parms(a) (rcu_dereference(to_pedit(a)->parms))
+ static inline bool is_tcf_pedit(const struct tc_action *a)
+ {
+@@ -32,37 +39,81 @@ static inline bool is_tcf_pedit(const struct tc_action *a)
+ static inline int tcf_pedit_nkeys(const struct tc_action *a)
+ {
+-      return to_pedit(a)->tcfp_nkeys;
++      struct tcf_pedit_parms *parms;
++      int nkeys;
++
++      rcu_read_lock();
++      parms = to_pedit_parms(a);
++      nkeys = parms->tcfp_nkeys;
++      rcu_read_unlock();
++
++      return nkeys;
+ }
+ static inline u32 tcf_pedit_htype(const struct tc_action *a, int index)
+ {
+-      if (to_pedit(a)->tcfp_keys_ex)
+-              return to_pedit(a)->tcfp_keys_ex[index].htype;
++      u32 htype = TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
++      struct tcf_pedit_parms *parms;
++
++      rcu_read_lock();
++      parms = to_pedit_parms(a);
++      if (parms->tcfp_keys_ex)
++              htype = parms->tcfp_keys_ex[index].htype;
++      rcu_read_unlock();
+-      return TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
++      return htype;
+ }
+ static inline u32 tcf_pedit_cmd(const struct tc_action *a, int index)
+ {
+-      if (to_pedit(a)->tcfp_keys_ex)
+-              return to_pedit(a)->tcfp_keys_ex[index].cmd;
++      struct tcf_pedit_parms *parms;
++      u32 cmd = __PEDIT_CMD_MAX;
+-      return __PEDIT_CMD_MAX;
++      rcu_read_lock();
++      parms = to_pedit_parms(a);
++      if (parms->tcfp_keys_ex)
++              cmd = parms->tcfp_keys_ex[index].cmd;
++      rcu_read_unlock();
++
++      return cmd;
+ }
+ static inline u32 tcf_pedit_mask(const struct tc_action *a, int index)
+ {
+-      return to_pedit(a)->tcfp_keys[index].mask;
++      struct tcf_pedit_parms *parms;
++      u32 mask;
++
++      rcu_read_lock();
++      parms = to_pedit_parms(a);
++      mask = parms->tcfp_keys[index].mask;
++      rcu_read_unlock();
++
++      return mask;
+ }
+ static inline u32 tcf_pedit_val(const struct tc_action *a, int index)
+ {
+-      return to_pedit(a)->tcfp_keys[index].val;
++      struct tcf_pedit_parms *parms;
++      u32 val;
++
++      rcu_read_lock();
++      parms = to_pedit_parms(a);
++      val = parms->tcfp_keys[index].val;
++      rcu_read_unlock();
++
++      return val;
+ }
+ static inline u32 tcf_pedit_offset(const struct tc_action *a, int index)
+ {
+-      return to_pedit(a)->tcfp_keys[index].off;
++      struct tcf_pedit_parms *parms;
++      u32 off;
++
++      rcu_read_lock();
++      parms = to_pedit_parms(a);
++      off = parms->tcfp_keys[index].off;
++      rcu_read_unlock();
++
++      return off;
+ }
+ #endif /* __NET_TC_PED_H */
+diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
+index 4f72e6e7dbda5..bd28bb0804162 100644
+--- a/net/sched/act_pedit.c
++++ b/net/sched/act_pedit.c
+@@ -134,6 +134,17 @@ static int tcf_pedit_key_ex_dump(struct sk_buff *skb,
+       return -EINVAL;
+ }
++static void tcf_pedit_cleanup_rcu(struct rcu_head *head)
++{
++      struct tcf_pedit_parms *parms =
++              container_of(head, struct tcf_pedit_parms, rcu);
++
++      kfree(parms->tcfp_keys_ex);
++      kfree(parms->tcfp_keys);
++
++      kfree(parms);
++}
++
+ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+                         struct nlattr *est, struct tc_action **a,
+                         struct tcf_proto *tp, u32 flags,
+@@ -141,10 +152,9 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+ {
+       struct tc_action_net *tn = net_generic(net, pedit_net_id);
+       bool bind = flags & TCA_ACT_FLAGS_BIND;
+-      struct nlattr *tb[TCA_PEDIT_MAX + 1];
+       struct tcf_chain *goto_ch = NULL;
+-      struct tc_pedit_key *keys = NULL;
+-      struct tcf_pedit_key_ex *keys_ex;
++      struct tcf_pedit_parms *oparms, *nparms;
++      struct nlattr *tb[TCA_PEDIT_MAX + 1];
+       struct tc_pedit *parm;
+       struct nlattr *pattr;
+       struct tcf_pedit *p;
+@@ -181,18 +191,25 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+               return -EINVAL;
+       }
+-      keys_ex = tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys);
+-      if (IS_ERR(keys_ex))
+-              return PTR_ERR(keys_ex);
++      nparms = kzalloc(sizeof(*nparms), GFP_KERNEL);
++      if (!nparms)
++              return -ENOMEM;
++
++      nparms->tcfp_keys_ex =
++              tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys);
++      if (IS_ERR(nparms->tcfp_keys_ex)) {
++              ret = PTR_ERR(nparms->tcfp_keys_ex);
++              goto out_free;
++      }
+       index = parm->index;
+       err = tcf_idr_check_alloc(tn, &index, a, bind);
+       if (!err) {
+-              ret = tcf_idr_create(tn, index, est, a,
+-                                   &act_pedit_ops, bind, false, flags);
++              ret = tcf_idr_create_from_flags(tn, index, est, a,
++                                              &act_pedit_ops, bind, flags);
+               if (ret) {
+                       tcf_idr_cleanup(tn, index);
+-                      goto out_free;
++                      goto out_free_ex;
+               }
+               ret = ACT_P_CREATED;
+       } else if (err > 0) {
+@@ -204,7 +221,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+               }
+       } else {
+               ret = err;
+-              goto out_free;
++              goto out_free_ex;
+       }
+       err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
+@@ -212,48 +229,50 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+               ret = err;
+               goto out_release;
+       }
+-      p = to_pedit(*a);
+-      spin_lock_bh(&p->tcf_lock);
+-      if (ret == ACT_P_CREATED ||
+-          (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys)) {
+-              keys = kmalloc(ksize, GFP_ATOMIC);
+-              if (!keys) {
+-                      spin_unlock_bh(&p->tcf_lock);
+-                      ret = -ENOMEM;
+-                      goto put_chain;
+-              }
+-              kfree(p->tcfp_keys);
+-              p->tcfp_keys = keys;
+-              p->tcfp_nkeys = parm->nkeys;
++      nparms->tcfp_off_max_hint = 0;
++      nparms->tcfp_flags = parm->flags;
++      nparms->tcfp_nkeys = parm->nkeys;
++
++      nparms->tcfp_keys = kmalloc(ksize, GFP_KERNEL);
++      if (!nparms->tcfp_keys) {
++              ret = -ENOMEM;
++              goto put_chain;
+       }
+-      memcpy(p->tcfp_keys, parm->keys, ksize);
+-      p->tcfp_off_max_hint = 0;
+-      for (i = 0; i < p->tcfp_nkeys; ++i) {
+-              u32 cur = p->tcfp_keys[i].off;
++
++      memcpy(nparms->tcfp_keys, parm->keys, ksize);
++
++      for (i = 0; i < nparms->tcfp_nkeys; ++i) {
++              u32 cur = nparms->tcfp_keys[i].off;
+               /* sanitize the shift value for any later use */
+-              p->tcfp_keys[i].shift = min_t(size_t, BITS_PER_TYPE(int) - 1,
+-                                            p->tcfp_keys[i].shift);
++              nparms->tcfp_keys[i].shift = min_t(size_t,
++                                                 BITS_PER_TYPE(int) - 1,
++                                                 nparms->tcfp_keys[i].shift);
+               /* The AT option can read a single byte, we can bound the actual
+                * value with uchar max.
+                */
+-              cur += (0xff & p->tcfp_keys[i].offmask) >> p->tcfp_keys[i].shift;
++              cur += (0xff & nparms->tcfp_keys[i].offmask) >> nparms->tcfp_keys[i].shift;
+               /* Each key touches 4 bytes starting from the computed offset */
+-              p->tcfp_off_max_hint = max(p->tcfp_off_max_hint, cur + 4);
++              nparms->tcfp_off_max_hint =
++                      max(nparms->tcfp_off_max_hint, cur + 4);
+       }
+-      p->tcfp_flags = parm->flags;
++      p = to_pedit(*a);
++
++      spin_lock_bh(&p->tcf_lock);
+       goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
++      oparms = rcu_replace_pointer(p->parms, nparms, 1);
++      spin_unlock_bh(&p->tcf_lock);
+-      kfree(p->tcfp_keys_ex);
+-      p->tcfp_keys_ex = keys_ex;
++      if (oparms)
++              call_rcu(&oparms->rcu, tcf_pedit_cleanup_rcu);
+-      spin_unlock_bh(&p->tcf_lock);
+       if (goto_ch)
+               tcf_chain_put_by_act(goto_ch);
++
+       return ret;
+ put_chain:
+@@ -261,19 +280,22 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
+               tcf_chain_put_by_act(goto_ch);
+ out_release:
+       tcf_idr_release(*a, bind);
++out_free_ex:
++      kfree(nparms->tcfp_keys_ex);
+ out_free:
+-      kfree(keys_ex);
++      kfree(nparms);
+       return ret;
+-
+ }
+ static void tcf_pedit_cleanup(struct tc_action *a)
+ {
+       struct tcf_pedit *p = to_pedit(a);
+-      struct tc_pedit_key *keys = p->tcfp_keys;
++      struct tcf_pedit_parms *parms;
+-      kfree(keys);
+-      kfree(p->tcfp_keys_ex);
++      parms = rcu_dereference_protected(p->parms, 1);
++
++      if (parms)
++              call_rcu(&parms->rcu, tcf_pedit_cleanup_rcu);
+ }
+ static bool offset_valid(struct sk_buff *skb, int offset)
+@@ -324,28 +346,30 @@ static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
+                        struct tcf_result *res)
+ {
+       struct tcf_pedit *p = to_pedit(a);
++      struct tcf_pedit_parms *parms;
+       u32 max_offset;
+       int i;
+-      spin_lock(&p->tcf_lock);
++      parms = rcu_dereference_bh(p->parms);
+       max_offset = (skb_transport_header_was_set(skb) ?
+                     skb_transport_offset(skb) :
+                     skb_network_offset(skb)) +
+-                   p->tcfp_off_max_hint;
++                   parms->tcfp_off_max_hint;
+       if (skb_ensure_writable(skb, min(skb->len, max_offset)))
+-              goto unlock;
++              goto done;
+       tcf_lastuse_update(&p->tcf_tm);
++      tcf_action_update_bstats(&p->common, skb);
+-      if (p->tcfp_nkeys > 0) {
+-              struct tc_pedit_key *tkey = p->tcfp_keys;
+-              struct tcf_pedit_key_ex *tkey_ex = p->tcfp_keys_ex;
++      if (parms->tcfp_nkeys > 0) {
++              struct tc_pedit_key *tkey = parms->tcfp_keys;
++              struct tcf_pedit_key_ex *tkey_ex = parms->tcfp_keys_ex;
+               enum pedit_header_type htype =
+                       TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK;
+               enum pedit_cmd cmd = TCA_PEDIT_KEY_EX_CMD_SET;
+-              for (i = p->tcfp_nkeys; i > 0; i--, tkey++) {
++              for (i = parms->tcfp_nkeys; i > 0; i--, tkey++) {
+                       u32 *ptr, hdata;
+                       int offset = tkey->off;
+                       int hoffset;
+@@ -421,11 +445,10 @@ static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
+       }
+ bad:
++      spin_lock(&p->tcf_lock);
+       p->tcf_qstats.overlimits++;
+-done:
+-      bstats_update(&p->tcf_bstats, skb);
+-unlock:
+       spin_unlock(&p->tcf_lock);
++done:
+       return p->tcf_action;
+ }
+@@ -444,30 +467,33 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
+ {
+       unsigned char *b = skb_tail_pointer(skb);
+       struct tcf_pedit *p = to_pedit(a);
++      struct tcf_pedit_parms *parms;
+       struct tc_pedit *opt;
+       struct tcf_t t;
+       int s;
+-      s = struct_size(opt, keys, p->tcfp_nkeys);
++      spin_lock_bh(&p->tcf_lock);
++      parms = rcu_dereference_protected(p->parms, 1);
++      s = struct_size(opt, keys, parms->tcfp_nkeys);
+-      /* netlink spinlocks held above us - must use ATOMIC */
+       opt = kzalloc(s, GFP_ATOMIC);
+-      if (unlikely(!opt))
++      if (unlikely(!opt)) {
++              spin_unlock_bh(&p->tcf_lock);
+               return -ENOBUFS;
++      }
+-      spin_lock_bh(&p->tcf_lock);
+-      memcpy(opt->keys, p->tcfp_keys, flex_array_size(opt, keys, p->tcfp_nkeys));
++      memcpy(opt->keys, parms->tcfp_keys,
++             flex_array_size(opt, keys, parms->tcfp_nkeys));
+       opt->index = p->tcf_index;
+-      opt->nkeys = p->tcfp_nkeys;
+-      opt->flags = p->tcfp_flags;
++      opt->nkeys = parms->tcfp_nkeys;
++      opt->flags = parms->tcfp_flags;
+       opt->action = p->tcf_action;
+       opt->refcnt = refcount_read(&p->tcf_refcnt) - ref;
+       opt->bindcnt = atomic_read(&p->tcf_bindcnt) - bind;
+-      if (p->tcfp_keys_ex) {
+-              if (tcf_pedit_key_ex_dump(skb,
+-                                        p->tcfp_keys_ex,
+-                                        p->tcfp_nkeys))
++      if (parms->tcfp_keys_ex) {
++              if (tcf_pedit_key_ex_dump(skb, parms->tcfp_keys_ex,
++                                        parms->tcfp_nkeys))
+                       goto nla_put_failure;
+               if (nla_put(skb, TCA_PEDIT_PARMS_EX, s, opt))
+-- 
+2.39.2
+
diff --git a/queue-5.15/netfilter-ctnetlink-fix-possible-refcount-leak-in-ct.patch b/queue-5.15/netfilter-ctnetlink-fix-possible-refcount-leak-in-ct.patch
new file mode 100644 (file)
index 0000000..42bc676
--- /dev/null
@@ -0,0 +1,47 @@
+From ccbf617d7ebf0611f7b5200df36372256a6fbeac Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 15:17:30 +0800
+Subject: netfilter: ctnetlink: fix possible refcount leak in
+ ctnetlink_create_conntrack()
+
+From: Hangyu Hua <hbh25y@gmail.com>
+
+[ Upstream commit ac4893980bbe79ce383daf9a0885666a30fe4c83 ]
+
+nf_ct_put() needs to be called to put the refcount got by
+nf_conntrack_find_get() to avoid refcount leak when
+nf_conntrack_hash_check_insert() fails.
+
+Fixes: 7d367e06688d ("netfilter: ctnetlink: fix soft lockup when netlink adds new entries (v2)")
+Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
+Acked-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_conntrack_netlink.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
+index 2cc6092b4f865..18a508783c282 100644
+--- a/net/netfilter/nf_conntrack_netlink.c
++++ b/net/netfilter/nf_conntrack_netlink.c
+@@ -2396,12 +2396,15 @@ ctnetlink_create_conntrack(struct net *net,
+       err = nf_conntrack_hash_check_insert(ct);
+       if (err < 0)
+-              goto err2;
++              goto err3;
+       rcu_read_unlock();
+       return ct;
++err3:
++      if (ct->master)
++              nf_ct_put(ct->master);
+ err2:
+       rcu_read_unlock();
+ err1:
+-- 
+2.39.2
+
diff --git a/queue-5.15/netfilter-ebtables-fix-table-blob-use-after-free.patch b/queue-5.15/netfilter-ebtables-fix-table-blob-use-after-free.patch
new file mode 100644 (file)
index 0000000..f170c6e
--- /dev/null
@@ -0,0 +1,105 @@
+From 6293011fa2cce080d42afb1dd6f5b2e7d48ab4a4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 17 Feb 2023 23:20:06 +0100
+Subject: netfilter: ebtables: fix table blob use-after-free
+
+From: Florian Westphal <fw@strlen.de>
+
+[ Upstream commit e58a171d35e32e6e8c37cfe0e8a94406732a331f ]
+
+We are not allowed to return an error at this point.
+Looking at the code it looks like ret is always 0 at this
+point, but its not.
+
+t = find_table_lock(net, repl->name, &ret, &ebt_mutex);
+
+... this can return a valid table, with ret != 0.
+
+This bug causes update of table->private with the new
+blob, but then frees the blob right away in the caller.
+
+Syzbot report:
+
+BUG: KASAN: vmalloc-out-of-bounds in __ebt_unregister_table+0xc00/0xcd0 net/bridge/netfilter/ebtables.c:1168
+Read of size 4 at addr ffffc90005425000 by task kworker/u4:4/74
+Workqueue: netns cleanup_net
+Call Trace:
+ kasan_report+0xbf/0x1f0 mm/kasan/report.c:517
+ __ebt_unregister_table+0xc00/0xcd0 net/bridge/netfilter/ebtables.c:1168
+ ebt_unregister_table+0x35/0x40 net/bridge/netfilter/ebtables.c:1372
+ ops_exit_list+0xb0/0x170 net/core/net_namespace.c:169
+ cleanup_net+0x4ee/0xb10 net/core/net_namespace.c:613
+...
+
+ip(6)tables appears to be ok (ret should be 0 at this point) but make
+this more obvious.
+
+Fixes: c58dd2dd443c ("netfilter: Can't fail and free after table replacement")
+Reported-by: syzbot+f61594de72d6705aea03@syzkaller.appspotmail.com
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/bridge/netfilter/ebtables.c | 2 +-
+ net/ipv4/netfilter/ip_tables.c  | 3 +--
+ net/ipv6/netfilter/ip6_tables.c | 3 +--
+ 3 files changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
+index 16774559c52cb..a09b2fc11c80e 100644
+--- a/net/bridge/netfilter/ebtables.c
++++ b/net/bridge/netfilter/ebtables.c
+@@ -1090,7 +1090,7 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
+       audit_log_nfcfg(repl->name, AF_BRIDGE, repl->nentries,
+                       AUDIT_XT_OP_REPLACE, GFP_KERNEL);
+-      return ret;
++      return 0;
+ free_unlock:
+       mutex_unlock(&ebt_mutex);
+diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
+index 13acb687c19ab..91301dc3924a2 100644
+--- a/net/ipv4/netfilter/ip_tables.c
++++ b/net/ipv4/netfilter/ip_tables.c
+@@ -1044,7 +1044,6 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
+       struct xt_counters *counters;
+       struct ipt_entry *iter;
+-      ret = 0;
+       counters = xt_counters_alloc(num_counters);
+       if (!counters) {
+               ret = -ENOMEM;
+@@ -1090,7 +1089,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
+               net_warn_ratelimited("iptables: counters copy to user failed while replacing table\n");
+       }
+       vfree(counters);
+-      return ret;
++      return 0;
+  put_module:
+       module_put(t->me);
+diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
+index a579ea14a69b6..7ba68388d2e1f 100644
+--- a/net/ipv6/netfilter/ip6_tables.c
++++ b/net/ipv6/netfilter/ip6_tables.c
+@@ -1062,7 +1062,6 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
+       struct xt_counters *counters;
+       struct ip6t_entry *iter;
+-      ret = 0;
+       counters = xt_counters_alloc(num_counters);
+       if (!counters) {
+               ret = -ENOMEM;
+@@ -1108,7 +1107,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
+               net_warn_ratelimited("ip6tables: counters copy to user failed while replacing table\n");
+       }
+       vfree(counters);
+-      return ret;
++      return 0;
+  put_module:
+       module_put(t->me);
+-- 
+2.39.2
+
diff --git a/queue-5.15/netfilter-nf_tables-allow-to-fetch-set-elements-when.patch b/queue-5.15/netfilter-nf_tables-allow-to-fetch-set-elements-when.patch
new file mode 100644 (file)
index 0000000..0fd7e7b
--- /dev/null
@@ -0,0 +1,37 @@
+From 0f76511d7e718e5170f499bdab971137ed069191 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Feb 2023 11:34:27 +0100
+Subject: netfilter: nf_tables: allow to fetch set elements when table has an
+ owner
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+[ Upstream commit 92f3e96d642f5e05b9dc710c06fedc669f1b4f00 ]
+
+NFT_MSG_GETSETELEM returns -EPERM when fetching set elements that belong
+to table that has an owner. This results in empty set/map listing from
+userspace.
+
+Fixes: 6001a930ce03 ("netfilter: nftables: introduce table ownership")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_tables_api.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
+index a02a25b7eae6d..dc276b6802ca9 100644
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -5342,7 +5342,7 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
+       int rem, err = 0;
+       table = nft_table_lookup(net, nla[NFTA_SET_ELEM_LIST_TABLE], family,
+-                               genmask, NETLINK_CB(skb).portid);
++                               genmask, 0);
+       if (IS_ERR(table)) {
+               NL_SET_BAD_ATTR(extack, nla[NFTA_SET_ELEM_LIST_TABLE]);
+               return PTR_ERR(table);
+-- 
+2.39.2
+
diff --git a/queue-5.15/netfilter-x_tables-fix-percpu-counter-block-leak-on-.patch b/queue-5.15/netfilter-x_tables-fix-percpu-counter-block-leak-on-.patch
new file mode 100644 (file)
index 0000000..b0ca311
--- /dev/null
@@ -0,0 +1,91 @@
+From 3e4464ffe9e7a976bbccaf2fa0c6474830c3dca6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Feb 2023 12:25:05 +0800
+Subject: netfilter: x_tables: fix percpu counter block leak on error path when
+ creating new netns
+
+From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
+
+[ Upstream commit 0af8c09c896810879387decfba8c942994bb61f5 ]
+
+Here is the stack where we allocate percpu counter block:
+
+  +-< __alloc_percpu
+    +-< xt_percpu_counter_alloc
+      +-< find_check_entry # {arp,ip,ip6}_tables.c
+        +-< translate_table
+
+And it can be leaked on this code path:
+
+  +-> ip6t_register_table
+    +-> translate_table # allocates percpu counter block
+    +-> xt_register_table # fails
+
+there is no freeing of the counter block on xt_register_table fail.
+Note: xt_percpu_counter_free should be called to free it like we do in
+do_replace through cleanup_entry helper (or in __ip6t_unregister_table).
+
+Probability of hitting this error path is low AFAICS (xt_register_table
+can only return ENOMEM here, as it is not replacing anything, as we are
+creating new netns, and it is hard to imagine that all previous
+allocations succeeded and after that one in xt_register_table failed).
+But it's worth fixing even the rare leak.
+
+Fixes: 71ae0dff02d7 ("netfilter: xtables: use percpu rule counters")
+Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/netfilter/arp_tables.c | 4 ++++
+ net/ipv4/netfilter/ip_tables.c  | 4 ++++
+ net/ipv6/netfilter/ip6_tables.c | 4 ++++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
+index c53f14b943560..71bf3aeed73c1 100644
+--- a/net/ipv4/netfilter/arp_tables.c
++++ b/net/ipv4/netfilter/arp_tables.c
+@@ -1524,6 +1524,10 @@ int arpt_register_table(struct net *net,
+       new_table = xt_register_table(net, table, &bootstrap, newinfo);
+       if (IS_ERR(new_table)) {
++              struct arpt_entry *iter;
++
++              xt_entry_foreach(iter, loc_cpu_entry, newinfo->size)
++                      cleanup_entry(iter, net);
+               xt_free_table_info(newinfo);
+               return PTR_ERR(new_table);
+       }
+diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
+index 91301dc3924a2..a748a1e754605 100644
+--- a/net/ipv4/netfilter/ip_tables.c
++++ b/net/ipv4/netfilter/ip_tables.c
+@@ -1740,6 +1740,10 @@ int ipt_register_table(struct net *net, const struct xt_table *table,
+       new_table = xt_register_table(net, table, &bootstrap, newinfo);
+       if (IS_ERR(new_table)) {
++              struct ipt_entry *iter;
++
++              xt_entry_foreach(iter, loc_cpu_entry, newinfo->size)
++                      cleanup_entry(iter, net);
+               xt_free_table_info(newinfo);
+               return PTR_ERR(new_table);
+       }
+diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
+index 7ba68388d2e1f..277a5ee887eb3 100644
+--- a/net/ipv6/netfilter/ip6_tables.c
++++ b/net/ipv6/netfilter/ip6_tables.c
+@@ -1750,6 +1750,10 @@ int ip6t_register_table(struct net *net, const struct xt_table *table,
+       new_table = xt_register_table(net, table, &bootstrap, newinfo);
+       if (IS_ERR(new_table)) {
++              struct ip6t_entry *iter;
++
++              xt_entry_foreach(iter, loc_cpu_entry, newinfo->size)
++                      cleanup_entry(iter, net);
+               xt_free_table_info(newinfo);
+               return PTR_ERR(new_table);
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/nfc-fix-memory-leak-of-se_io-context-in-nfc_genl_se_.patch b/queue-5.15/nfc-fix-memory-leak-of-se_io-context-in-nfc_genl_se_.patch
new file mode 100644 (file)
index 0000000..f1e9d85
--- /dev/null
@@ -0,0 +1,85 @@
+From a382a624bda800d5f865897262dae914f2d4f9d3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 25 Feb 2023 13:56:14 +0300
+Subject: nfc: fix memory leak of se_io context in nfc_genl_se_io
+
+From: Fedor Pchelkin <pchelkin@ispras.ru>
+
+[ Upstream commit 25ff6f8a5a3b8dc48e8abda6f013e8cc4b14ffea ]
+
+The callback context for sending/receiving APDUs to/from the selected
+secure element is allocated inside nfc_genl_se_io and supposed to be
+eventually freed in se_io_cb callback function. However, there are several
+error paths where the bwi_timer is not charged to call se_io_cb later, and
+the cb_context is leaked.
+
+The patch proposes to free the cb_context explicitly on those error paths.
+
+At the moment we can't simply check 'dev->ops->se_io()' return value as it
+may be negative in both cases: when the timer was charged and was not.
+
+Fixes: 5ce3f32b5264 ("NFC: netlink: SE API implementation")
+Reported-by: syzbot+df64c0a2e8d68e78a4fa@syzkaller.appspotmail.com
+Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
+Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nfc/st-nci/se.c   | 6 ++++++
+ drivers/nfc/st21nfca/se.c | 6 ++++++
+ net/nfc/netlink.c         | 4 ++++
+ 3 files changed, 16 insertions(+)
+
+diff --git a/drivers/nfc/st-nci/se.c b/drivers/nfc/st-nci/se.c
+index 04a2cea6d6b61..57d09dbf627b4 100644
+--- a/drivers/nfc/st-nci/se.c
++++ b/drivers/nfc/st-nci/se.c
+@@ -674,6 +674,12 @@ int st_nci_se_io(struct nci_dev *ndev, u32 se_idx,
+                                       ST_NCI_EVT_TRANSMIT_DATA, apdu,
+                                       apdu_length);
+       default:
++              /* Need to free cb_context here as at the moment we can't
++               * clearly indicate to the caller if the callback function
++               * would be called (and free it) or not. In both cases a
++               * negative value may be returned to the caller.
++               */
++              kfree(cb_context);
+               return -ENODEV;
+       }
+ }
+diff --git a/drivers/nfc/st21nfca/se.c b/drivers/nfc/st21nfca/se.c
+index d416365042462..6a1d3b2752fbf 100644
+--- a/drivers/nfc/st21nfca/se.c
++++ b/drivers/nfc/st21nfca/se.c
+@@ -236,6 +236,12 @@ int st21nfca_hci_se_io(struct nfc_hci_dev *hdev, u32 se_idx,
+                                       ST21NFCA_EVT_TRANSMIT_DATA,
+                                       apdu, apdu_length);
+       default:
++              /* Need to free cb_context here as at the moment we can't
++               * clearly indicate to the caller if the callback function
++               * would be called (and free it) or not. In both cases a
++               * negative value may be returned to the caller.
++               */
++              kfree(cb_context);
+               return -ENODEV;
+       }
+ }
+diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
+index d928d5a24bbc1..9ba3676ab37f4 100644
+--- a/net/nfc/netlink.c
++++ b/net/nfc/netlink.c
+@@ -1442,7 +1442,11 @@ static int nfc_se_io(struct nfc_dev *dev, u32 se_idx,
+       rc = dev->ops->se_io(dev, se_idx, apdu,
+                       apdu_length, cb, cb_context);
++      device_unlock(&dev->dev);
++      return rc;
++
+ error:
++      kfree(cb_context);
+       device_unlock(&dev->dev);
+       return rc;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/objtool-fix-memory-leak-in-create_static_call_sectio.patch b/queue-5.15/objtool-fix-memory-leak-in-create_static_call_sectio.patch
new file mode 100644 (file)
index 0000000..7eed620
--- /dev/null
@@ -0,0 +1,46 @@
+From d4298c8b8739908136541af3a3db99228b4bf275 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 5 Dec 2022 12:06:42 +0400
+Subject: objtool: Fix memory leak in create_static_call_sections()
+
+From: Miaoqian Lin <linmq006@gmail.com>
+
+[ Upstream commit 3da73f102309fe29150e5c35acd20dd82063ff67 ]
+
+strdup() allocates memory for key_name. We need to release the memory in
+the following error paths. Add free() to avoid memory leak.
+
+Fixes: 1e7e47883830 ("x86/static_call: Add inline static call implementation for x86-64")
+Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Link: https://lore.kernel.org/r/20221205080642.558583-1-linmq006@gmail.com
+Cc: Josh Poimboeuf <jpoimboe@redhat.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/objtool/check.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tools/objtool/check.c b/tools/objtool/check.c
+index 2fc0270e3c1f7..32f119e8c3b2c 100644
+--- a/tools/objtool/check.c
++++ b/tools/objtool/check.c
+@@ -573,6 +573,7 @@ static int create_static_call_sections(struct objtool_file *file)
+               if (strncmp(key_name, STATIC_CALL_TRAMP_PREFIX_STR,
+                           STATIC_CALL_TRAMP_PREFIX_LEN)) {
+                       WARN("static_call: trampoline name malformed: %s", key_name);
++                      free(key_name);
+                       return -1;
+               }
+               tmp = key_name + STATIC_CALL_TRAMP_PREFIX_LEN - STATIC_CALL_KEY_PREFIX_LEN;
+@@ -582,6 +583,7 @@ static int create_static_call_sections(struct objtool_file *file)
+               if (!key_sym) {
+                       if (!module) {
+                               WARN("static_call: can't find static_call_key symbol: %s", tmp);
++                              free(key_name);
+                               return -1;
+                       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/octeontx2-pf-use-correct-struct-reference-in-test-co.patch b/queue-5.15/octeontx2-pf-use-correct-struct-reference-in-test-co.patch
new file mode 100644 (file)
index 0000000..d18e037
--- /dev/null
@@ -0,0 +1,39 @@
+From 9d9fb3431f044b042432566bb6f584bf956a5e69 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Feb 2023 18:58:48 +0530
+Subject: octeontx2-pf: Use correct struct reference in test condition
+
+From: Deepak R Varma <drv@mailo.com>
+
+[ Upstream commit 3acd9db9293f3b33ac04e8d44ed05b604ad1ac26 ]
+
+Fix the typo/copy-paste error by replacing struct variable ah_esp_mask name
+by ah_esp_hdr.
+Issue identified using doublebitand.cocci Coccinelle semantic patch.
+
+Fixes: b7cf966126eb ("octeontx2-pf: Add flow classification using IP next level protocol")
+Link: https://lore.kernel.org/all/20210111112537.3277-1-naveenm@marvell.com/
+Signed-off-by: Deepak R Varma <drv@mailo.com>
+Link: https://lore.kernel.org/r/Y/YYkKddeHOt80cO@ubun2204.myguest.virtualbox.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+index 77a13fb555fb6..63889449b8f61 100644
+--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
++++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+@@ -748,7 +748,7 @@ static int otx2_prepare_ipv6_flow(struct ethtool_rx_flow_spec *fsp,
+               /* NPC profile doesn't extract AH/ESP header fields */
+               if ((ah_esp_mask->spi & ah_esp_hdr->spi) ||
+-                  (ah_esp_mask->tclass & ah_esp_mask->tclass))
++                  (ah_esp_mask->tclass & ah_esp_hdr->tclass))
+                       return -EOPNOTSUPP;
+               if (flow_type == AH_V6_FLOW)
+-- 
+2.39.2
+
diff --git a/queue-5.15/parport_pc-set-up-mode-and-ecr-masks-for-oxford-semi.patch b/queue-5.15/parport_pc-set-up-mode-and-ecr-masks-for-oxford-semi.patch
new file mode 100644 (file)
index 0000000..6ebbbda
--- /dev/null
@@ -0,0 +1,140 @@
+From 46698ecfaab4b13756a72444e98b4afac9646be4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 8 Jan 2023 21:56:55 +0000
+Subject: parport_pc: Set up mode and ECR masks for Oxford Semiconductor
+ devices
+
+From: Maciej W. Rozycki <macro@orcam.me.uk>
+
+[ Upstream commit c087df8d1e7dc2e764d11234d84b5af46d500f16 ]
+
+No Oxford Semiconductor PCI or PCIe parallel port device supports the
+Parallel Port FIFO mode.  All support the PS/2 Parallel Port mode and
+the Enhanced Parallel Port mode via the ECR register.  The original 5V
+PCI OX16PCI954 device does not support the Extended Capabilities Port
+mode, the Test mode or the Configuration mode, but all the other OxSemi
+devices do, including in particular the 3.3V PCI OXmPCI954 device and
+the universal voltage PCI OXuPCI954 device.  All the unsupported modes
+are marked reserved in the relevant datasheets.
+
+Accordingly enable the `base_hi' BAR for the 954 devices to enable PS2
+and EPP mode support via the ECR register, however mask the COMPAT mode
+and, until we have a way to determine what chip variant it is that we
+poke at, also the ECP mode, and mask the COMPAT mode only for all the
+remaining OxSemi devices, fixing errors like:
+
+parport0: FIFO is stuck
+FIFO write timed out
+
+and a non-functional port when the Parallel Port FIFO mode is selected.
+
+Complementing the fix apply an ECR mask for all these devices, which are
+documented to only permit writing to the mode field of the ECR register
+with a bit pattern of 00001 required to be written to bits 4:0 on mode
+field writes.  No nFault or service interrupts are implemented, which
+will therefore never have to be enabled, though bit 2 does report the
+FIFO threshold status to be polled for in the ECP mode where supported.
+
+We have a documented case of writing 1 to bit 2 causing a lock-up with
+at least one OX12PCI840 device (from old drivers/parport/ChangeLog):
+
+2001-10-10  Tim Waugh  <twaugh@redhat.com>
+
+       * parport_pc.c: Support for OX12PCI840 PCI card (reported by
+       mk@daveg.com).  Lock-ups diagnosed by Ronnie Arosa (and now we
+       just don't trust its ECR).
+
+which commit adbd321a17cc ("parport_pc: add base_hi BAR for oxsemi_840")
+must have broken and by applying an ECR mask here we prevent the lock-up
+from triggering.  This could have been the reason for requiring 00001 to
+be written to bits 4:0 of ECR.
+
+Update the inline comment accordingly; it has come from Linux 2.4.12
+back in 2001 and predates the introduction of OXmPCI954 and OXuPCI954
+devices that do support ECP.
+
+References:
+
+[1] "OX16PCI954 Integrated Quad UART and PCI interface", Oxford
+    Semiconductor Ltd., Data Sheet Revision 1.3, Feb. 1999, Chapter 9
+    "Bidirectional Parallel Port", pp. 53-55
+
+[2] "OX16PCI952 Data Sheet, Integrated High Performance Dual UARTs,
+    Parallel Port and 5.0v PCI interface", Oxford Semiconductor Ltd.,
+    DS_B008A_00, Datasheet rev 1.1, June 2001, Chapter 8 "Bi-directional
+    Parallel Port", pp. 52-56
+
+[3] "OXmPCI954 DATA SHEET Integrated High Performance Quad UARTs, 8-bit
+    Local Bus/Parallel Port. 3.3v PCI/miniPCI interface.", Oxford
+    Semiconductor Ltd., DS-0019, June 2005, Chapter 10 "Bidirectional
+    Parallel Port", pp. 86-90
+
+[4] "OXmPCI952 Data Sheet, Integrated High Performance Dual UARTs, 8-bit
+    Local Bus/Parallel Port. 3.3v PCI/miniPCI interface.", Oxford
+    Semiconductor Ltd., DS-0020, June 2005, Chapter 8 "Bidirectional
+    Parallel Port", pp. 73-77
+
+[5] "OX12PCI840 Integrated Parallel Port and PCI interface", Oxford
+    Semiconductor Ltd., DS-0021, Jun 2005, Chapter 5 "Bi-directional
+    Parallel Port", pp. 18-21
+
+[6] "OXPCIe952 PCI Express Bridge to Dual Serial & Parallel Port",
+    Oxford Semiconductor, Inc., DS-0046, Mar 06 08, Chapter "Parallel
+    Port Function", pp. 59-62
+
+[7] "OXPCIe840 PCI Express Bridge to Parallel Port", Oxford
+    Semiconductor, Inc., DS-0049, Mar 06 08, Chapter "Parallel Port
+    Function", pp. 15-18
+
+[8] "OXuPCI954 Data Sheet, Integrated High Performance Quad UARTs, 8-bit
+    Local Bus/Parallel Port, 3.3 V and 5 V (Universal Voltage) PCI
+    Interface.", Oxford Semiconductor, Inc., DS-0058, 26 Jan 2009,
+    Chapter 8 "Bidirectional Parallel Port", pp. 62-65
+
+[9] "OXuPCI952 Data Sheet, Integrated High Performance Dual UARTs, 8-bit
+    Local Bus/Parallel Port, 3.3 V and 5.0 V Universal Voltage PCI
+    Interface.", Oxford Semiconductor, Inc., DS-0059, Sep 2007, Chapter
+    8 "Bidirectional Parallel Port", pp. 61-64
+
+Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
+Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+Link: https://lore.kernel.org/r/20230108215656.6433-6-sudipm.mukherjee@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/parport/parport_pc.c | 19 +++++++++++++------
+ 1 file changed, 13 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
+index 925be41eeebec..c2af2aa6d437c 100644
+--- a/drivers/parport/parport_pc.c
++++ b/drivers/parport/parport_pc.c
+@@ -2657,12 +2657,19 @@ static struct parport_pc_pci {
+       /* titan_010l */                { 1, { { 3, -1 }, } },
+       /* avlab_1p             */      { 1, { { 0, 1}, } },
+       /* avlab_2p             */      { 2, { { 0, 1}, { 2, 3 },} },
+-      /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
+-       * and 840 locks up if you write 1 to bit 2! */
+-      /* oxsemi_952 */                { 1, { { 0, 1 }, } },
+-      /* oxsemi_954 */                { 1, { { 0, -1 }, } },
+-      /* oxsemi_840 */                { 1, { { 0, 1 }, } },
+-      /* oxsemi_pcie_pport */         { 1, { { 0, 1 }, } },
++      /* The Oxford Semi cards are unusual: older variants of 954 don't
++       * support ECP, and 840 locks up if you write 1 to bit 2!  None
++       * implement nFault or service interrupts and all require 00001
++       * bit pattern to be used for bits 4:0 with ECR writes. */
++      /* oxsemi_952 */                { 1, { { 0, 1 }, },
++                                        PARPORT_MODE_COMPAT, ECR_MODE_MASK },
++      /* oxsemi_954 */                { 1, { { 0, 1 }, },
++                                        PARPORT_MODE_ECP |
++                                        PARPORT_MODE_COMPAT, ECR_MODE_MASK },
++      /* oxsemi_840 */                { 1, { { 0, 1 }, },
++                                        PARPORT_MODE_COMPAT, ECR_MODE_MASK },
++      /* oxsemi_pcie_pport */         { 1, { { 0, 1 }, },
++                                        PARPORT_MODE_COMPAT, ECR_MODE_MASK },
+       /* aks_0100 */                  { 1, { { 0, -1 }, } },
+       /* mobility_pp */               { 1, { { 0, 1 }, } },
+-- 
+2.39.2
+
diff --git a/queue-5.15/pci-add-acs-quirk-for-wangxun-nics.patch b/queue-5.15/pci-add-acs-quirk-for-wangxun-nics.patch
new file mode 100644 (file)
index 0000000..155c83d
--- /dev/null
@@ -0,0 +1,81 @@
+From be1bb52c893b4106719ddf796ed3fb2f9704d999 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Feb 2023 18:24:19 +0800
+Subject: PCI: Add ACS quirk for Wangxun NICs
+
+From: Mengyuan Lou <mengyuanlou@net-swift.com>
+
+[ Upstream commit a2b9b123ccac913e9f9b80337d687a2fe786a634 ]
+
+Wangxun has verified there is no peer-to-peer between functions for the
+below selection of SFxxx, RP1000 and RP2000 NICS.  They may be
+multi-function devices, but the hardware does not advertise ACS capability.
+
+Add an ACS quirk for these devices so the functions can be in independent
+IOMMU groups.
+
+Link: https://lore.kernel.org/r/20230207102419.44326-1-mengyuanlou@net-swift.com
+Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/quirks.c    | 22 ++++++++++++++++++++++
+ include/linux/pci_ids.h |  2 ++
+ 2 files changed, 24 insertions(+)
+
+diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
+index 305ff5bd1a20c..643a3b292f0b6 100644
+--- a/drivers/pci/quirks.c
++++ b/drivers/pci/quirks.c
+@@ -4823,6 +4823,26 @@ static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags)
+               PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
+ }
++/*
++ * Wangxun 10G/1G NICs have no ACS capability, and on multi-function
++ * devices, peer-to-peer transactions are not be used between the functions.
++ * So add an ACS quirk for below devices to isolate functions.
++ * SFxxx 1G NICs(em).
++ * RP1000/RP2000 10G NICs(sp).
++ */
++static int  pci_quirk_wangxun_nic_acs(struct pci_dev *dev, u16 acs_flags)
++{
++      switch (dev->device) {
++      case 0x0100 ... 0x010F:
++      case 0x1001:
++      case 0x2001:
++              return pci_acs_ctrl_enabled(acs_flags,
++                      PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
++      }
++
++      return false;
++}
++
+ static const struct pci_dev_acs_enabled {
+       u16 vendor;
+       u16 device;
+@@ -4968,6 +4988,8 @@ static const struct pci_dev_acs_enabled {
+       { PCI_VENDOR_ID_NXP, 0x8d9b, pci_quirk_nxp_rp_acs },
+       /* Zhaoxin Root/Downstream Ports */
+       { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs },
++      /* Wangxun nics */
++      { PCI_VENDOR_ID_WANGXUN, PCI_ANY_ID, pci_quirk_wangxun_nic_acs },
+       { 0 }
+ };
+diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
+index 04f44a4694a2e..4853538bf1561 100644
+--- a/include/linux/pci_ids.h
++++ b/include/linux/pci_ids.h
+@@ -3012,6 +3012,8 @@
+ #define PCI_DEVICE_ID_INTEL_VMD_9A0B  0x9a0b
+ #define PCI_DEVICE_ID_INTEL_S21152BB  0xb152
++#define PCI_VENDOR_ID_WANGXUN         0x8088
++
+ #define PCI_VENDOR_ID_SCALEMP         0x8686
+ #define PCI_DEVICE_ID_SCALEMP_VSMP_CTL        0x1010
+-- 
+2.39.2
+
diff --git a/queue-5.15/pci-align-extra-resources-for-hotplug-bridges-proper.patch b/queue-5.15/pci-align-extra-resources-for-hotplug-bridges-proper.patch
new file mode 100644 (file)
index 0000000..011b2db
--- /dev/null
@@ -0,0 +1,71 @@
+From ccec72e22eaa7d137e2c40d3b1fc2f468bc3a665 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Jan 2023 11:24:03 +0200
+Subject: PCI: Align extra resources for hotplug bridges properly
+
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+
+[ Upstream commit 08f0a15ee8adb4846b08ca5d5c175fbf0f652bc9 ]
+
+After division the extra resource space per hotplug bridge may not be
+aligned according to the window alignment, so align it before passing it
+down for further distribution.
+
+Link: https://lore.kernel.org/r/20230131092405.29121-2-mika.westerberg@linux.intel.com
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/setup-bus.c | 25 +++++++++++++++++++------
+ 1 file changed, 19 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
+index 2ce636937c6ea..4a6b698b5dd10 100644
+--- a/drivers/pci/setup-bus.c
++++ b/drivers/pci/setup-bus.c
+@@ -2004,6 +2004,7 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus,
+        * resource space between hotplug bridges.
+        */
+       for_each_pci_bridge(dev, bus) {
++              struct resource *res;
+               struct pci_bus *b;
+               b = dev->subordinate;
+@@ -2015,16 +2016,28 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus,
+                * hotplug-capable downstream ports taking alignment into
+                * account.
+                */
+-              io.end = io.start + io_per_hp - 1;
+-              mmio.end = mmio.start + mmio_per_hp - 1;
+-              mmio_pref.end = mmio_pref.start + mmio_pref_per_hp - 1;
++              res = &dev->resource[PCI_BRIDGE_IO_WINDOW];
++              align = pci_resource_alignment(dev, res);
++              io.end = align ? io.start + ALIGN_DOWN(io_per_hp, align) - 1
++                             : io.start + io_per_hp - 1;
++
++              res = &dev->resource[PCI_BRIDGE_MEM_WINDOW];
++              align = pci_resource_alignment(dev, res);
++              mmio.end = align ? mmio.start + ALIGN_DOWN(mmio_per_hp, align) - 1
++                               : mmio.start + mmio_per_hp - 1;
++
++              res = &dev->resource[PCI_BRIDGE_PREF_MEM_WINDOW];
++              align = pci_resource_alignment(dev, res);
++              mmio_pref.end = align ? mmio_pref.start +
++                                      ALIGN_DOWN(mmio_pref_per_hp, align) - 1
++                                    : mmio_pref.start + mmio_pref_per_hp - 1;
+               pci_bus_distribute_available_resources(b, add_list, io, mmio,
+                                                      mmio_pref);
+-              io.start += io_per_hp;
+-              mmio.start += mmio_per_hp;
+-              mmio_pref.start += mmio_pref_per_hp;
++              io.start += io.end + 1;
++              mmio.start += mmio.end + 1;
++              mmio_pref.start += mmio_pref.end + 1;
+       }
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/pci-loongson-add-more-devices-that-need-mrrs-quirk.patch b/queue-5.15/pci-loongson-add-more-devices-that-need-mrrs-quirk.patch
new file mode 100644 (file)
index 0000000..9e507e2
--- /dev/null
@@ -0,0 +1,85 @@
+From 1d0a9f7e2b0efa5db2f1423c14ba47be5a3b271c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 11 Feb 2023 10:33:21 +0800
+Subject: PCI: loongson: Add more devices that need MRRS quirk
+
+From: Huacai Chen <chenhuacai@loongson.cn>
+
+[ Upstream commit c768f8c5f40fcdc6f058cc2f02592163d6c6716c ]
+
+Loongson-2K SOC and LS7A2000 chipset add new PCI IDs that need MRRS
+quirk.  Add them.
+
+Link: https://lore.kernel.org/r/20230211023321.3530080-1-chenhuacai@loongson.cn
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/controller/pci-loongson.c | 33 +++++++++++++++++++--------
+ 1 file changed, 24 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c
+index dc7b4e4293ced..e73e18a73833b 100644
+--- a/drivers/pci/controller/pci-loongson.c
++++ b/drivers/pci/controller/pci-loongson.c
+@@ -13,9 +13,14 @@
+ #include "../pci.h"
+ /* Device IDs */
+-#define DEV_PCIE_PORT_0       0x7a09
+-#define DEV_PCIE_PORT_1       0x7a19
+-#define DEV_PCIE_PORT_2       0x7a29
++#define DEV_LS2K_PCIE_PORT0   0x1a05
++#define DEV_LS7A_PCIE_PORT0   0x7a09
++#define DEV_LS7A_PCIE_PORT1   0x7a19
++#define DEV_LS7A_PCIE_PORT2   0x7a29
++#define DEV_LS7A_PCIE_PORT3   0x7a39
++#define DEV_LS7A_PCIE_PORT4   0x7a49
++#define DEV_LS7A_PCIE_PORT5   0x7a59
++#define DEV_LS7A_PCIE_PORT6   0x7a69
+ #define DEV_LS2K_APB  0x7a02
+ #define DEV_LS7A_CONF 0x7a10
+@@ -38,11 +43,11 @@ static void bridge_class_quirk(struct pci_dev *dev)
+       dev->class = PCI_CLASS_BRIDGE_PCI << 8;
+ }
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+-                      DEV_PCIE_PORT_0, bridge_class_quirk);
++                      DEV_LS7A_PCIE_PORT0, bridge_class_quirk);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+-                      DEV_PCIE_PORT_1, bridge_class_quirk);
++                      DEV_LS7A_PCIE_PORT1, bridge_class_quirk);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+-                      DEV_PCIE_PORT_2, bridge_class_quirk);
++                      DEV_LS7A_PCIE_PORT2, bridge_class_quirk);
+ static void system_bus_quirk(struct pci_dev *pdev)
+ {
+@@ -72,11 +77,21 @@ static void loongson_mrrs_quirk(struct pci_dev *pdev)
+       bridge->no_inc_mrrs = 1;
+ }
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+-                      DEV_PCIE_PORT_0, loongson_mrrs_quirk);
++                      DEV_LS2K_PCIE_PORT0, loongson_mrrs_quirk);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+-                      DEV_PCIE_PORT_1, loongson_mrrs_quirk);
++                      DEV_LS7A_PCIE_PORT0, loongson_mrrs_quirk);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+-                      DEV_PCIE_PORT_2, loongson_mrrs_quirk);
++                      DEV_LS7A_PCIE_PORT1, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_LS7A_PCIE_PORT2, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_LS7A_PCIE_PORT3, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_LS7A_PCIE_PORT4, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_LS7A_PCIE_PORT5, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_LS7A_PCIE_PORT6, loongson_mrrs_quirk);
+ static void __iomem *cfg1_map(struct loongson_pci *priv, int bus,
+                               unsigned int devfn, int where)
+-- 
+2.39.2
+
diff --git a/queue-5.15/pci-loongson-prevent-ls7a-mrrs-increases.patch b/queue-5.15/pci-loongson-prevent-ls7a-mrrs-increases.patch
new file mode 100644 (file)
index 0000000..cfb0273
--- /dev/null
@@ -0,0 +1,141 @@
+From 967fb6030b3048e1439296d279de9cb23bb48259 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Feb 2023 12:30:18 +0800
+Subject: PCI: loongson: Prevent LS7A MRRS increases
+
+From: Huacai Chen <chenhuacai@loongson.cn>
+
+[ Upstream commit 8b3517f88ff2983f52698893519227c10aac90b2 ]
+
+Except for isochronous-configured devices, software may set
+Max_Read_Request_Size (MRRS) to any value up to 4096.  If a device issues a
+read request with size greater than the completer's Max_Payload_Size (MPS),
+the completer is required to break the response into multiple completions.
+
+Instead of correctly responding with multiple completions to a large read
+request, some LS7A Root Ports respond with a Completer Abort.  To prevent
+this, the MRRS must be limited to an implementation-specific value.
+
+The OS cannot detect that value, so rely on BIOS to configure MRRS before
+booting, and quirk the Root Ports so we never set an MRRS larger than that
+BIOS value for any downstream device.
+
+N.B. Hot-added devices are not configured by BIOS, and they power up with
+MRRS = 512 bytes, so these devices will be limited to 512 bytes.  If the
+LS7A limit is smaller, those hot-added devices may not work correctly, but
+per [1], hotplug is not supported with this chipset revision.
+
+[1] https://lore.kernel.org/r/073638a7-ae68-2847-ac3d-29e5e760d6af@loongson.cn
+
+[bhelgaas: commit log]
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216884
+Link: https://lore.kernel.org/r/20230201043018.778499-3-chenhuacai@loongson.cn
+Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/controller/pci-loongson.c | 44 +++++++++------------------
+ drivers/pci/pci.c                     | 10 ++++++
+ include/linux/pci.h                   |  1 +
+ 3 files changed, 26 insertions(+), 29 deletions(-)
+
+diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c
+index 48169b1e38171..dc7b4e4293ced 100644
+--- a/drivers/pci/controller/pci-loongson.c
++++ b/drivers/pci/controller/pci-loongson.c
+@@ -60,37 +60,23 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
+                       DEV_LS7A_LPC, system_bus_quirk);
+-static void loongson_mrrs_quirk(struct pci_dev *dev)
++static void loongson_mrrs_quirk(struct pci_dev *pdev)
+ {
+-      struct pci_bus *bus = dev->bus;
+-      struct pci_dev *bridge;
+-      static const struct pci_device_id bridge_devids[] = {
+-              { PCI_VDEVICE(LOONGSON, DEV_PCIE_PORT_0) },
+-              { PCI_VDEVICE(LOONGSON, DEV_PCIE_PORT_1) },
+-              { PCI_VDEVICE(LOONGSON, DEV_PCIE_PORT_2) },
+-              { 0, },
+-      };
+-
+-      /* look for the matching bridge */
+-      while (!pci_is_root_bus(bus)) {
+-              bridge = bus->self;
+-              bus = bus->parent;
+-              /*
+-               * Some Loongson PCIe ports have a h/w limitation of
+-               * 256 bytes maximum read request size. They can't handle
+-               * anything larger than this. So force this limit on
+-               * any devices attached under these ports.
+-               */
+-              if (pci_match_id(bridge_devids, bridge)) {
+-                      if (pcie_get_readrq(dev) > 256) {
+-                              pci_info(dev, "limiting MRRS to 256\n");
+-                              pcie_set_readrq(dev, 256);
+-                      }
+-                      break;
+-              }
+-      }
++      /*
++       * Some Loongson PCIe ports have h/w limitations of maximum read
++       * request size. They can't handle anything larger than this. So
++       * force this limit on any devices attached under these ports.
++       */
++      struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus);
++
++      bridge->no_inc_mrrs = 1;
+ }
+-DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_PCIE_PORT_0, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_PCIE_PORT_1, loongson_mrrs_quirk);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
++                      DEV_PCIE_PORT_2, loongson_mrrs_quirk);
+ static void __iomem *cfg1_map(struct loongson_pci *priv, int bus,
+                               unsigned int devfn, int where)
+diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
+index 778ae3c861f45..ce0988513fdaf 100644
+--- a/drivers/pci/pci.c
++++ b/drivers/pci/pci.c
+@@ -5970,6 +5970,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
+ {
+       u16 v;
+       int ret;
++      struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus);
+       if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
+               return -EINVAL;
+@@ -5988,6 +5989,15 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
+       v = (ffs(rq) - 8) << 12;
++      if (bridge->no_inc_mrrs) {
++              int max_mrrs = pcie_get_readrq(dev);
++
++              if (rq > max_mrrs) {
++                      pci_info(dev, "can't set Max_Read_Request_Size to %d; max is %d\n", rq, max_mrrs);
++                      return -EINVAL;
++              }
++      }
++
+       ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
+                                                 PCI_EXP_DEVCTL_READRQ, v);
+diff --git a/include/linux/pci.h b/include/linux/pci.h
+index 9d6e75222868f..34dd24c991804 100644
+--- a/include/linux/pci.h
++++ b/include/linux/pci.h
+@@ -557,6 +557,7 @@ struct pci_host_bridge {
+       void            *release_data;
+       unsigned int    ignore_reset_delay:1;   /* For entire hierarchy */
+       unsigned int    no_ext_tags:1;          /* No Extended Tags */
++      unsigned int    no_inc_mrrs:1;          /* No Increase MRRS */
+       unsigned int    native_aer:1;           /* OS may use PCIe AER */
+       unsigned int    native_pcie_hotplug:1;  /* OS may use PCIe hotplug */
+       unsigned int    native_shpc_hotplug:1;  /* OS may use SHPC hotplug */
+-- 
+2.39.2
+
diff --git a/queue-5.15/pci-take-other-bus-devices-into-account-when-distrib.patch b/queue-5.15/pci-take-other-bus-devices-into-account-when-distrib.patch
new file mode 100644 (file)
index 0000000..ae47d6d
--- /dev/null
@@ -0,0 +1,281 @@
+From 9ca71d14d56876e374e0756f936b0f133a060853 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Jan 2023 11:24:04 +0200
+Subject: PCI: Take other bus devices into account when distributing resources
+
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+
+[ Upstream commit 9db0b9b6a14249ef65a5f1e5e3b37762af96f425 ]
+
+A PCI bridge may reside on a bus with other devices as well. The resource
+distribution code does not take this into account and therefore it expands
+the bridge resource windows too much, not leaving space for the other
+devices (or functions of a multifunction device).  This leads to an issue
+that Jonathan reported when running QEMU with the following topology (QEMU
+parameters):
+
+  -device pcie-root-port,port=0,id=root_port13,chassis=0,slot=2  \
+  -device x3130-upstream,id=sw1,bus=root_port13,multifunction=on \
+  -device e1000,bus=root_port13,addr=0.1                         \
+  -device xio3130-downstream,id=fun1,bus=sw1,chassis=0,slot=3    \
+  -device e1000,bus=fun1
+
+The first e1000 NIC here is another function in the switch upstream port.
+This leads to following errors:
+
+  pci 0000:00:04.0: bridge window [mem 0x10200000-0x103fffff] to [bus 02-04]
+  pci 0000:02:00.0: bridge window [mem 0x10200000-0x103fffff] to [bus 03-04]
+  pci 0000:02:00.1: BAR 0: failed to assign [mem size 0x00020000]
+  e1000 0000:02:00.1: can't ioremap BAR 0: [??? 0x00000000 flags 0x0]
+
+Fix this by taking into account bridge windows, device BARs and SR-IOV PF
+BARs on the bus (PF BARs include space for VF BARS so only account PF
+BARs), including the ones belonging to bridges themselves if it has any.
+
+Link: https://lore.kernel.org/linux-pci/20221014124553.0000696f@huawei.com/
+Link: https://lore.kernel.org/linux-pci/6053736d-1923-41e7-def9-7585ce1772d9@ixsystems.com/
+Link: https://lore.kernel.org/r/20230131092405.29121-3-mika.westerberg@linux.intel.com
+Reported-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Reported-by: Alexander Motin <mav@ixsystems.com>
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/setup-bus.c | 176 ++++++++++++++++++++++++----------------
+ 1 file changed, 106 insertions(+), 70 deletions(-)
+
+diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
+index 4a6b698b5dd10..16d291e10627b 100644
+--- a/drivers/pci/setup-bus.c
++++ b/drivers/pci/setup-bus.c
+@@ -1878,12 +1878,67 @@ static void adjust_bridge_window(struct pci_dev *bridge, struct resource *res,
+               add_size = size - new_size;
+               pci_dbg(bridge, "bridge window %pR shrunken by %pa\n", res,
+                       &add_size);
++      } else {
++              return;
+       }
+       res->end = res->start + new_size - 1;
+       remove_from_list(add_list, res);
+ }
++static void remove_dev_resource(struct resource *avail, struct pci_dev *dev,
++                              struct resource *res)
++{
++      resource_size_t size, align, tmp;
++
++      size = resource_size(res);
++      if (!size)
++              return;
++
++      align = pci_resource_alignment(dev, res);
++      align = align ? ALIGN(avail->start, align) - avail->start : 0;
++      tmp = align + size;
++      avail->start = min(avail->start + tmp, avail->end + 1);
++}
++
++static void remove_dev_resources(struct pci_dev *dev, struct resource *io,
++                               struct resource *mmio,
++                               struct resource *mmio_pref)
++{
++      int i;
++
++      for (i = 0; i < PCI_NUM_RESOURCES; i++) {
++              struct resource *res = &dev->resource[i];
++
++              if (resource_type(res) == IORESOURCE_IO) {
++                      remove_dev_resource(io, dev, res);
++              } else if (resource_type(res) == IORESOURCE_MEM) {
++
++                      /*
++                       * Make sure prefetchable memory is reduced from
++                       * the correct resource. Specifically we put 32-bit
++                       * prefetchable memory in non-prefetchable window
++                       * if there is an 64-bit pretchable window.
++                       *
++                       * See comments in __pci_bus_size_bridges() for
++                       * more information.
++                       */
++                      if ((res->flags & IORESOURCE_PREFETCH) &&
++                          ((res->flags & IORESOURCE_MEM_64) ==
++                           (mmio_pref->flags & IORESOURCE_MEM_64)))
++                              remove_dev_resource(mmio_pref, dev, res);
++                      else
++                              remove_dev_resource(mmio, dev, res);
++              }
++      }
++}
++
++/*
++ * io, mmio and mmio_pref contain the total amount of bridge window space
++ * available. This includes the minimal space needed to cover all the
++ * existing devices on the bus and the possible extra space that can be
++ * shared with the bridges.
++ */
+ static void pci_bus_distribute_available_resources(struct pci_bus *bus,
+                                           struct list_head *add_list,
+                                           struct resource io,
+@@ -1893,7 +1948,7 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus,
+       unsigned int normal_bridges = 0, hotplug_bridges = 0;
+       struct resource *io_res, *mmio_res, *mmio_pref_res;
+       struct pci_dev *dev, *bridge = bus->self;
+-      resource_size_t io_per_hp, mmio_per_hp, mmio_pref_per_hp, align;
++      resource_size_t io_per_b, mmio_per_b, mmio_pref_per_b, align;
+       io_res = &bridge->resource[PCI_BRIDGE_IO_WINDOW];
+       mmio_res = &bridge->resource[PCI_BRIDGE_MEM_WINDOW];
+@@ -1937,100 +1992,81 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus,
+                       normal_bridges++;
+       }
+-      /*
+-       * There is only one bridge on the bus so it gets all available
+-       * resources which it can then distribute to the possible hotplug
+-       * bridges below.
+-       */
+-      if (hotplug_bridges + normal_bridges == 1) {
+-              dev = list_first_entry(&bus->devices, struct pci_dev, bus_list);
+-              if (dev->subordinate)
+-                      pci_bus_distribute_available_resources(dev->subordinate,
+-                              add_list, io, mmio, mmio_pref);
+-              return;
+-      }
+-
+-      if (hotplug_bridges == 0)
++      if (!(hotplug_bridges + normal_bridges))
+               return;
+       /*
+-       * Calculate the total amount of extra resource space we can
+-       * pass to bridges below this one.  This is basically the
+-       * extra space reduced by the minimal required space for the
+-       * non-hotplug bridges.
++       * Calculate the amount of space we can forward from "bus" to any
++       * downstream buses, i.e., the space left over after assigning the
++       * BARs and windows on "bus".
+        */
+-      for_each_pci_bridge(dev, bus) {
+-              resource_size_t used_size;
+-              struct resource *res;
+-
+-              if (dev->is_hotplug_bridge)
+-                      continue;
+-
+-              /*
+-               * Reduce the available resource space by what the
+-               * bridge and devices below it occupy.
+-               */
+-              res = &dev->resource[PCI_BRIDGE_IO_WINDOW];
+-              align = pci_resource_alignment(dev, res);
+-              align = align ? ALIGN(io.start, align) - io.start : 0;
+-              used_size = align + resource_size(res);
+-              if (!res->parent)
+-                      io.start = min(io.start + used_size, io.end + 1);
+-
+-              res = &dev->resource[PCI_BRIDGE_MEM_WINDOW];
+-              align = pci_resource_alignment(dev, res);
+-              align = align ? ALIGN(mmio.start, align) - mmio.start : 0;
+-              used_size = align + resource_size(res);
+-              if (!res->parent)
+-                      mmio.start = min(mmio.start + used_size, mmio.end + 1);
+-
+-              res = &dev->resource[PCI_BRIDGE_PREF_MEM_WINDOW];
+-              align = pci_resource_alignment(dev, res);
+-              align = align ? ALIGN(mmio_pref.start, align) -
+-                      mmio_pref.start : 0;
+-              used_size = align + resource_size(res);
+-              if (!res->parent)
+-                      mmio_pref.start = min(mmio_pref.start + used_size,
+-                              mmio_pref.end + 1);
++      list_for_each_entry(dev, &bus->devices, bus_list) {
++              if (!dev->is_virtfn)
++                      remove_dev_resources(dev, &io, &mmio, &mmio_pref);
+       }
+-      io_per_hp = div64_ul(resource_size(&io), hotplug_bridges);
+-      mmio_per_hp = div64_ul(resource_size(&mmio), hotplug_bridges);
+-      mmio_pref_per_hp = div64_ul(resource_size(&mmio_pref),
+-              hotplug_bridges);
+-
+       /*
+-       * Go over devices on this bus and distribute the remaining
+-       * resource space between hotplug bridges.
++       * If there is at least one hotplug bridge on this bus it gets all
++       * the extra resource space that was left after the reductions
++       * above.
++       *
++       * If there are no hotplug bridges the extra resource space is
++       * split between non-hotplug bridges. This is to allow possible
++       * hotplug bridges below them to get the extra space as well.
+        */
++      if (hotplug_bridges) {
++              io_per_b = div64_ul(resource_size(&io), hotplug_bridges);
++              mmio_per_b = div64_ul(resource_size(&mmio), hotplug_bridges);
++              mmio_pref_per_b = div64_ul(resource_size(&mmio_pref),
++                                         hotplug_bridges);
++      } else {
++              io_per_b = div64_ul(resource_size(&io), normal_bridges);
++              mmio_per_b = div64_ul(resource_size(&mmio), normal_bridges);
++              mmio_pref_per_b = div64_ul(resource_size(&mmio_pref),
++                                         normal_bridges);
++      }
++
+       for_each_pci_bridge(dev, bus) {
+               struct resource *res;
+               struct pci_bus *b;
+               b = dev->subordinate;
+-              if (!b || !dev->is_hotplug_bridge)
++              if (!b)
+                       continue;
++              if (hotplug_bridges && !dev->is_hotplug_bridge)
++                      continue;
++
++              res = &dev->resource[PCI_BRIDGE_IO_WINDOW];
+               /*
+-               * Distribute available extra resources equally between
+-               * hotplug-capable downstream ports taking alignment into
+-               * account.
++               * Make sure the split resource space is properly aligned
++               * for bridge windows (align it down to avoid going above
++               * what is available).
+                */
+-              res = &dev->resource[PCI_BRIDGE_IO_WINDOW];
+               align = pci_resource_alignment(dev, res);
+-              io.end = align ? io.start + ALIGN_DOWN(io_per_hp, align) - 1
+-                             : io.start + io_per_hp - 1;
++              io.end = align ? io.start + ALIGN_DOWN(io_per_b, align) - 1
++                             : io.start + io_per_b - 1;
++
++              /*
++               * The x_per_b holds the extra resource space that can be
++               * added for each bridge but there is the minimal already
++               * reserved as well so adjust x.start down accordingly to
++               * cover the whole space.
++               */
++              io.start -= resource_size(res);
+               res = &dev->resource[PCI_BRIDGE_MEM_WINDOW];
+               align = pci_resource_alignment(dev, res);
+-              mmio.end = align ? mmio.start + ALIGN_DOWN(mmio_per_hp, align) - 1
+-                               : mmio.start + mmio_per_hp - 1;
++              mmio.end = align ? mmio.start + ALIGN_DOWN(mmio_per_b, align) - 1
++                               : mmio.start + mmio_per_b - 1;
++              mmio.start -= resource_size(res);
+               res = &dev->resource[PCI_BRIDGE_PREF_MEM_WINDOW];
+               align = pci_resource_alignment(dev, res);
+               mmio_pref.end = align ? mmio_pref.start +
+-                                      ALIGN_DOWN(mmio_pref_per_hp, align) - 1
+-                                    : mmio_pref.start + mmio_pref_per_hp - 1;
++                                      ALIGN_DOWN(mmio_pref_per_b, align) - 1
++                                    : mmio_pref.start + mmio_pref_per_b - 1;
++              mmio_pref.start -= resource_size(res);
+               pci_bus_distribute_available_resources(b, add_list, io, mmio,
+                                                      mmio_pref);
+-- 
+2.39.2
+
diff --git a/queue-5.15/phy-rockchip-typec-fix-unsigned-comparison-with-less.patch b/queue-5.15/phy-rockchip-typec-fix-unsigned-comparison-with-less.patch
new file mode 100644 (file)
index 0000000..c5daeb1
--- /dev/null
@@ -0,0 +1,43 @@
+From 21f024aa596d72b8c38ce86f82859f48388746b2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Feb 2023 11:57:09 +0800
+Subject: phy: rockchip-typec: Fix unsigned comparison with less than zero
+
+From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
+
+[ Upstream commit f765c59c5a72546a2d74a92ae5d0eb0329d8e247 ]
+
+The dp and ufp are defined as bool type, the return value type of
+function extcon_get_state should be int, so the type of dp and ufp
+are modified to int.
+
+./drivers/phy/rockchip/phy-rockchip-typec.c:827:12-14: WARNING: Unsigned expression compared with zero: dp > 0.
+
+Reported-by: Abaci Robot <abaci@linux.alibaba.com>
+Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3962
+Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
+Link: https://lore.kernel.org/r/20230213035709.99027-1-jiapeng.chong@linux.alibaba.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/phy/rockchip/phy-rockchip-typec.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
+index 5b9a254c45524..062821410ee4f 100644
+--- a/drivers/phy/rockchip/phy-rockchip-typec.c
++++ b/drivers/phy/rockchip/phy-rockchip-typec.c
+@@ -808,9 +808,8 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)
+       struct extcon_dev *edev = tcphy->extcon;
+       union extcon_property_value property;
+       unsigned int id;
+-      bool ufp, dp;
+       u8 mode;
+-      int ret;
++      int ret, ufp, dp;
+       if (!edev)
+               return MODE_DFP_USB;
+-- 
+2.39.2
+
diff --git a/queue-5.15/pwm-sifive-always-let-the-first-pwm_apply_state-succ.patch b/queue-5.15/pwm-sifive-always-let-the-first-pwm_apply_state-succ.patch
new file mode 100644 (file)
index 0000000..5e42091
--- /dev/null
@@ -0,0 +1,69 @@
+From fd45fc7a589d54b3163f84f59ba5d3c07da4d9c9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 9 Nov 2022 12:37:24 +0100
+Subject: pwm: sifive: Always let the first pwm_apply_state succeed
+
+From: Emil Renner Berthing <emil.renner.berthing@canonical.com>
+
+[ Upstream commit 334c7b13d38321e47d1a51dba0bef9f4c403ec75 ]
+
+Commit 2cfe9bbec56ea579135cdd92409fff371841904f added support for the
+RGB and green PWM controlled LEDs on the HiFive Unmatched board
+managed by the leds-pwm-multicolor and leds-pwm drivers respectively.
+All three colours of the RGB LED and the green LED run from different
+lines of the same PWM, but with the same period so this works fine when
+the LED drivers are loaded one after the other.
+
+Unfortunately it does expose a race in the PWM driver when both LED
+drivers are loaded at roughly the same time. Here is an example:
+
+  |          Thread A           |          Thread B           |
+  |  led_pwm_mc_probe           |  led_pwm_probe              |
+  |    devm_fwnode_pwm_get      |                             |
+  |      pwm_sifive_request     |                             |
+  |        ddata->user_count++  |                             |
+  |                             |    devm_fwnode_pwm_get      |
+  |                             |      pwm_sifive_request     |
+  |                             |        ddata->user_count++  |
+  |         ...                 |          ...                |
+  |    pwm_state_apply          |    pwm_state_apply          |
+  |      pwm_sifive_apply       |      pwm_sifive_apply       |
+
+Now both calls to pwm_sifive_apply will see that ddata->approx_period,
+initially 0, is different from the requested period and the clock needs
+to be updated. But since ddata->user_count >= 2 both calls will fail
+with -EBUSY, which will then cause both LED drivers to fail to probe.
+
+Fix it by letting the first call to pwm_sifive_apply update the clock
+even when ddata->user_count != 1.
+
+Fixes: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM")
+Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-sifive.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
+index 85760c90278c0..41a6fc47cc163 100644
+--- a/drivers/pwm/pwm-sifive.c
++++ b/drivers/pwm/pwm-sifive.c
+@@ -184,7 +184,13 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+       mutex_lock(&ddata->lock);
+       if (state->period != ddata->approx_period) {
+-              if (ddata->user_count != 1) {
++              /*
++               * Don't let a 2nd user change the period underneath the 1st user.
++               * However if ddate->approx_period == 0 this is the first time we set
++               * any period, so let whoever gets here first set the period so other
++               * users who agree on the period won't fail.
++               */
++              if (ddata->user_count != 1 && ddata->approx_period) {
+                       mutex_unlock(&ddata->lock);
+                       ret = -EBUSY;
+                       goto exit;
+-- 
+2.39.2
+
diff --git a/queue-5.15/pwm-sifive-reduce-time-the-controller-lock-is-held.patch b/queue-5.15/pwm-sifive-reduce-time-the-controller-lock-is-held.patch
new file mode 100644 (file)
index 0000000..074226c
--- /dev/null
@@ -0,0 +1,84 @@
+From d32275b478aea94adec6a25d369b07e8726105fc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 21 Jul 2022 12:31:25 +0200
+Subject: pwm: sifive: Reduce time the controller lock is held
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+
+[ Upstream commit 0f02f491b786143f08eb19840f1cf4f12aec6dee ]
+
+The lock is only to serialize access and update to user_count and
+approx_period between different PWMs served by the same pwm_chip.
+So the lock needs only to be taken during the check if the (chip global)
+period can and/or needs to be changed.
+
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Tested-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Stable-dep-of: 334c7b13d383 ("pwm: sifive: Always let the first pwm_apply_state succeed")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-sifive.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
+index 07e9fc58354f4..85760c90278c0 100644
+--- a/drivers/pwm/pwm-sifive.c
++++ b/drivers/pwm/pwm-sifive.c
+@@ -41,7 +41,7 @@
+ struct pwm_sifive_ddata {
+       struct pwm_chip chip;
+-      struct mutex lock; /* lock to protect user_count */
++      struct mutex lock; /* lock to protect user_count and approx_period */
+       struct notifier_block notifier;
+       struct clk *clk;
+       void __iomem *regs;
+@@ -76,6 +76,7 @@ static void pwm_sifive_free(struct pwm_chip *chip, struct pwm_device *pwm)
+       mutex_unlock(&ddata->lock);
+ }
++/* Called holding ddata->lock */
+ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata,
+                                   unsigned long rate)
+ {
+@@ -163,7 +164,6 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+               return ret;
+       }
+-      mutex_lock(&ddata->lock);
+       cur_state = pwm->state;
+       enabled = cur_state.enabled;
+@@ -182,14 +182,17 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+       /* The hardware cannot generate a 100% duty cycle */
+       frac = min(frac, (1U << PWM_SIFIVE_CMPWIDTH) - 1);
++      mutex_lock(&ddata->lock);
+       if (state->period != ddata->approx_period) {
+               if (ddata->user_count != 1) {
++                      mutex_unlock(&ddata->lock);
+                       ret = -EBUSY;
+                       goto exit;
+               }
+               ddata->approx_period = state->period;
+               pwm_sifive_update_clock(ddata, clk_get_rate(ddata->clk));
+       }
++      mutex_unlock(&ddata->lock);
+       writel(frac, ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm));
+@@ -198,7 +201,6 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ exit:
+       clk_disable(ddata->clk);
+-      mutex_unlock(&ddata->lock);
+       return ret;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/pwm-stm32-lp-fix-the-check-on-arr-and-cmp-registers-.patch b/queue-5.15/pwm-stm32-lp-fix-the-check-on-arr-and-cmp-registers-.patch
new file mode 100644 (file)
index 0000000..e0c3751
--- /dev/null
@@ -0,0 +1,44 @@
+From dec7c8bbab57bb3c726b3e251a38fc63d17a625a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 23 Nov 2022 14:36:52 +0100
+Subject: pwm: stm32-lp: fix the check on arr and cmp registers update
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
+
+[ Upstream commit 3066bc2d58be31275afb51a589668f265e419c37 ]
+
+The ARR (auto reload register) and CMP (compare) registers are
+successively written. The status bits to check the update of these
+registers are polled together with regmap_read_poll_timeout().
+The condition to end the loop may become true, even if one of the
+register isn't correctly updated.
+So ensure both status bits are set before clearing them.
+
+Fixes: e70a540b4e02 ("pwm: Add STM32 LPTimer PWM driver")
+Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
+Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-stm32-lp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
+index 3115abb3f52ab..61a1c87cd5016 100644
+--- a/drivers/pwm/pwm-stm32-lp.c
++++ b/drivers/pwm/pwm-stm32-lp.c
+@@ -127,7 +127,7 @@ static int stm32_pwm_lp_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+       /* ensure CMP & ARR registers are properly written */
+       ret = regmap_read_poll_timeout(priv->regmap, STM32_LPTIM_ISR, val,
+-                                     (val & STM32_LPTIM_CMPOK_ARROK),
++                                     (val & STM32_LPTIM_CMPOK_ARROK) == STM32_LPTIM_CMPOK_ARROK,
+                                      100, 1000);
+       if (ret) {
+               dev_err(priv->chip.dev, "ARR/CMP registers write issue\n");
+-- 
+2.39.2
+
diff --git a/queue-5.15/rtc-allow-rtc_read_alarm-without-read_alarm-callback.patch b/queue-5.15/rtc-allow-rtc_read_alarm-without-read_alarm-callback.patch
new file mode 100644 (file)
index 0000000..7eeea06
--- /dev/null
@@ -0,0 +1,40 @@
+From 6ba6bcfe0a97e993f580147d688ee0c1722f0306 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 14 Feb 2023 23:27:53 +0100
+Subject: rtc: allow rtc_read_alarm without read_alarm callback
+
+From: Alexandre Belloni <alexandre.belloni@bootlin.com>
+
+[ Upstream commit a783c962619271a8b905efad1d89adfec11ae0c8 ]
+
+.read_alarm is not necessary to read the current alarm because it is
+recorded in the aie_timer and so rtc_read_alarm() will never call
+rtc_read_alarm_internal() which is the only function calling the callback.
+
+Reported-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
+Reported-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
+Fixes: 7ae41220ef58 ("rtc: introduce features bitfield")
+Tested-by: Philippe Schenker <philippe.schenker@toradex.com>
+Link: https://lore.kernel.org/r/20230214222754.582582-1-alexandre.belloni@bootlin.com
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/rtc/interface.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
+index 3ee17c4d72987..f49ab45455d7c 100644
+--- a/drivers/rtc/interface.c
++++ b/drivers/rtc/interface.c
+@@ -392,7 +392,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
+               return err;
+       if (!rtc->ops) {
+               err = -ENODEV;
+-      } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->read_alarm) {
++      } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) {
+               err = -EINVAL;
+       } else {
+               memset(alarm, 0, sizeof(struct rtc_wkalrm));
+-- 
+2.39.2
+
diff --git a/queue-5.15/rtc-sun6i-always-export-the-internal-oscillator.patch b/queue-5.15/rtc-sun6i-always-export-the-internal-oscillator.patch
new file mode 100644 (file)
index 0000000..c0c1825
--- /dev/null
@@ -0,0 +1,83 @@
+From 34df4380b5a9df00e86267b830f236b201583d0a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 29 Dec 2022 15:53:19 -0600
+Subject: rtc: sun6i: Always export the internal oscillator
+
+From: Samuel Holland <samuel@sholland.org>
+
+[ Upstream commit 344f4030f6c50a9db2d03021884c4bf36191b53a ]
+
+On all variants of the hardware, the internal oscillator is one possible
+parent for the AR100 clock. It needs to be exported so we can model that
+relationship correctly in the devicetree.
+
+Fixes: c56afc1844d6 ("rtc: sun6i: Expose internal oscillator through device tree")
+Signed-off-by: Samuel Holland <samuel@sholland.org>
+Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
+Link: https://lore.kernel.org/r/20221229215319.14145-1-samuel@sholland.org
+Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/rtc/rtc-sun6i.c | 16 ++++------------
+ 1 file changed, 4 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
+index c551ebf0ac00f..536bd023c4800 100644
+--- a/drivers/rtc/rtc-sun6i.c
++++ b/drivers/rtc/rtc-sun6i.c
+@@ -128,7 +128,6 @@ struct sun6i_rtc_clk_data {
+       unsigned int fixed_prescaler : 16;
+       unsigned int has_prescaler : 1;
+       unsigned int has_out_clk : 1;
+-      unsigned int export_iosc : 1;
+       unsigned int has_losc_en : 1;
+       unsigned int has_auto_swt : 1;
+ };
+@@ -260,10 +259,8 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
+       /* Yes, I know, this is ugly. */
+       sun6i_rtc = rtc;
+-      /* Only read IOSC name from device tree if it is exported */
+-      if (rtc->data->export_iosc)
+-              of_property_read_string_index(node, "clock-output-names", 2,
+-                                            &iosc_name);
++      of_property_read_string_index(node, "clock-output-names", 2,
++                                    &iosc_name);
+       rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL,
+                                                               iosc_name,
+@@ -304,13 +301,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
+               goto err_register;
+       }
+-      clk_data->num = 2;
++      clk_data->num = 3;
+       clk_data->hws[0] = &rtc->hw;
+       clk_data->hws[1] = __clk_get_hw(rtc->ext_losc);
+-      if (rtc->data->export_iosc) {
+-              clk_data->hws[2] = rtc->int_osc;
+-              clk_data->num = 3;
+-      }
++      clk_data->hws[2] = rtc->int_osc;
+       of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       return;
+@@ -350,7 +344,6 @@ static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = {
+       .fixed_prescaler = 32,
+       .has_prescaler = 1,
+       .has_out_clk = 1,
+-      .export_iosc = 1,
+ };
+ static void __init sun8i_h3_rtc_clk_init(struct device_node *node)
+@@ -368,7 +361,6 @@ static const struct sun6i_rtc_clk_data sun50i_h6_rtc_data = {
+       .fixed_prescaler = 32,
+       .has_prescaler = 1,
+       .has_out_clk = 1,
+-      .export_iosc = 1,
+       .has_losc_en = 1,
+       .has_auto_swt = 1,
+ };
+-- 
+2.39.2
+
diff --git a/queue-5.15/scsi-ipr-work-around-fortify-string-warning.patch b/queue-5.15/scsi-ipr-work-around-fortify-string-warning.patch
new file mode 100644 (file)
index 0000000..c198b4d
--- /dev/null
@@ -0,0 +1,114 @@
+From cc3a169f24476e40eabb10f25ed61f094b37a314 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 14 Feb 2023 14:28:08 +0100
+Subject: scsi: ipr: Work around fortify-string warning
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit ee4e7dfe4ffc9ca50c6875757bd119abfe22b5c5 ]
+
+The ipr_log_vpd_compact() function triggers a fortified memcpy() warning
+about a potential string overflow with all versions of clang:
+
+In file included from drivers/scsi/ipr.c:43:
+In file included from include/linux/string.h:254:
+include/linux/fortify-string.h:520:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
+                        __write_overflow_field(p_size_field, size);
+                        ^
+include/linux/fortify-string.h:520:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
+2 errors generated.
+
+I don't see anything actually wrong with the function, but this is the only
+instance I can reproduce of the fortification going wrong in the kernel at
+the moment, so the easiest solution may be to rewrite the function into
+something that does not trigger the warning.
+
+Instead of having a combined buffer for vendor/device/serial strings, use
+three separate local variables and just truncate the whitespace
+individually.
+
+Link: https://lore.kernel.org/r/20230214132831.2118392-1-arnd@kernel.org
+Cc: Kees Cook <keescook@chromium.org>
+Fixes: 8cf093e275d0 ("[SCSI] ipr: Improved dual adapter errors")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
+Reviewed-by: Kees Cook <keescook@chromium.org>
+Acked-by: Brian King <brking@linux.vnet.ibm.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/scsi/ipr.c | 41 +++++++++++++++++++++--------------------
+ 1 file changed, 21 insertions(+), 20 deletions(-)
+
+diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
+index 04fb7fc012264..e5e38431c5c73 100644
+--- a/drivers/scsi/ipr.c
++++ b/drivers/scsi/ipr.c
+@@ -1516,23 +1516,22 @@ static void ipr_process_ccn(struct ipr_cmnd *ipr_cmd)
+ }
+ /**
+- * strip_and_pad_whitespace - Strip and pad trailing whitespace.
+- * @i:                index into buffer
+- * @buf:              string to modify
++ * strip_whitespace - Strip and pad trailing whitespace.
++ * @i:                size of buffer
++ * @buf:      string to modify
+  *
+- * This function will strip all trailing whitespace, pad the end
+- * of the string with a single space, and NULL terminate the string.
++ * This function will strip all trailing whitespace and
++ * NUL terminate the string.
+  *
+- * Return value:
+- *    new length of string
+  **/
+-static int strip_and_pad_whitespace(int i, char *buf)
++static void strip_whitespace(int i, char *buf)
+ {
++      if (i < 1)
++              return;
++      i--;
+       while (i && buf[i] == ' ')
+               i--;
+-      buf[i+1] = ' ';
+-      buf[i+2] = '\0';
+-      return i + 2;
++      buf[i+1] = '\0';
+ }
+ /**
+@@ -1547,19 +1546,21 @@ static int strip_and_pad_whitespace(int i, char *buf)
+ static void ipr_log_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb,
+                               struct ipr_vpd *vpd)
+ {
+-      char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN + IPR_SERIAL_NUM_LEN + 3];
+-      int i = 0;
++      char vendor_id[IPR_VENDOR_ID_LEN + 1];
++      char product_id[IPR_PROD_ID_LEN + 1];
++      char sn[IPR_SERIAL_NUM_LEN + 1];
+-      memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
+-      i = strip_and_pad_whitespace(IPR_VENDOR_ID_LEN - 1, buffer);
++      memcpy(vendor_id, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
++      strip_whitespace(IPR_VENDOR_ID_LEN, vendor_id);
+-      memcpy(&buffer[i], vpd->vpids.product_id, IPR_PROD_ID_LEN);
+-      i = strip_and_pad_whitespace(i + IPR_PROD_ID_LEN - 1, buffer);
++      memcpy(product_id, vpd->vpids.product_id, IPR_PROD_ID_LEN);
++      strip_whitespace(IPR_PROD_ID_LEN, product_id);
+-      memcpy(&buffer[i], vpd->sn, IPR_SERIAL_NUM_LEN);
+-      buffer[IPR_SERIAL_NUM_LEN + i] = '\0';
++      memcpy(sn, vpd->sn, IPR_SERIAL_NUM_LEN);
++      strip_whitespace(IPR_SERIAL_NUM_LEN, sn);
+-      ipr_hcam_err(hostrcb, "%s VPID/SN: %s\n", prefix, buffer);
++      ipr_hcam_err(hostrcb, "%s VPID/SN: %s %s %s\n", prefix,
++                   vendor_id, product_id, sn);
+ }
+ /**
+-- 
+2.39.2
+
diff --git a/queue-5.15/sctp-add-a-refcnt-in-sctp_stream_priorities-to-avoid.patch b/queue-5.15/sctp-add-a-refcnt-in-sctp_stream_priorities-to-avoid.patch
new file mode 100644 (file)
index 0000000..cdfa4b7
--- /dev/null
@@ -0,0 +1,166 @@
+From 856e83f7a4775f8e536bb510b34ce18857a12f63 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 22 Feb 2023 12:07:21 -0500
+Subject: sctp: add a refcnt in sctp_stream_priorities to avoid a nested loop
+
+From: Xin Long <lucien.xin@gmail.com>
+
+[ Upstream commit 68ba44639537de6f91fe32783766322d41848127 ]
+
+With this refcnt added in sctp_stream_priorities, we don't need to
+traverse all streams to check if the prio is used by other streams
+when freeing one stream's prio in sctp_sched_prio_free_sid(). This
+can avoid a nested loop (up to 65535 * 65535), which may cause a
+stuck as Ying reported:
+
+    watchdog: BUG: soft lockup - CPU#23 stuck for 26s! [ksoftirqd/23:136]
+    Call Trace:
+     <TASK>
+     sctp_sched_prio_free_sid+0xab/0x100 [sctp]
+     sctp_stream_free_ext+0x64/0xa0 [sctp]
+     sctp_stream_free+0x31/0x50 [sctp]
+     sctp_association_free+0xa5/0x200 [sctp]
+
+Note that it doesn't need to use refcount_t type for this counter,
+as its accessing is always protected under the sock lock.
+
+v1->v2:
+ - add a check in sctp_sched_prio_set to avoid the possible prio_head
+   refcnt overflow.
+
+Fixes: 9ed7bfc79542 ("sctp: fix memory leak in sctp_stream_outq_migrate()")
+Reported-by: Ying Xu <yinxu@redhat.com>
+Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Signed-off-by: Xin Long <lucien.xin@gmail.com>
+Link: https://lore.kernel.org/r/825eb0c905cb864991eba335f4a2b780e543f06b.1677085641.git.lucien.xin@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/sctp/structs.h   |  1 +
+ net/sctp/stream_sched_prio.c | 52 +++++++++++++++---------------------
+ 2 files changed, 22 insertions(+), 31 deletions(-)
+
+diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
+index 8d2c3dd9f5953..790252c1478b0 100644
+--- a/include/net/sctp/structs.h
++++ b/include/net/sctp/structs.h
+@@ -1420,6 +1420,7 @@ struct sctp_stream_priorities {
+       /* The next stream in line */
+       struct sctp_stream_out_ext *next;
+       __u16 prio;
++      __u16 users;
+ };
+ struct sctp_stream_out_ext {
+diff --git a/net/sctp/stream_sched_prio.c b/net/sctp/stream_sched_prio.c
+index 4fc9f2923ed11..7dd9f8b387cca 100644
+--- a/net/sctp/stream_sched_prio.c
++++ b/net/sctp/stream_sched_prio.c
+@@ -25,6 +25,18 @@
+ static void sctp_sched_prio_unsched_all(struct sctp_stream *stream);
++static struct sctp_stream_priorities *sctp_sched_prio_head_get(struct sctp_stream_priorities *p)
++{
++      p->users++;
++      return p;
++}
++
++static void sctp_sched_prio_head_put(struct sctp_stream_priorities *p)
++{
++      if (p && --p->users == 0)
++              kfree(p);
++}
++
+ static struct sctp_stream_priorities *sctp_sched_prio_new_head(
+                       struct sctp_stream *stream, int prio, gfp_t gfp)
+ {
+@@ -38,6 +50,7 @@ static struct sctp_stream_priorities *sctp_sched_prio_new_head(
+       INIT_LIST_HEAD(&p->active);
+       p->next = NULL;
+       p->prio = prio;
++      p->users = 1;
+       return p;
+ }
+@@ -53,7 +66,7 @@ static struct sctp_stream_priorities *sctp_sched_prio_get_head(
+        */
+       list_for_each_entry(p, &stream->prio_list, prio_sched) {
+               if (p->prio == prio)
+-                      return p;
++                      return sctp_sched_prio_head_get(p);
+               if (p->prio > prio)
+                       break;
+       }
+@@ -70,7 +83,7 @@ static struct sctp_stream_priorities *sctp_sched_prio_get_head(
+                        */
+                       break;
+               if (p->prio == prio)
+-                      return p;
++                      return sctp_sched_prio_head_get(p);
+       }
+       /* If not even there, allocate a new one. */
+@@ -154,32 +167,21 @@ static int sctp_sched_prio_set(struct sctp_stream *stream, __u16 sid,
+       struct sctp_stream_out_ext *soute = sout->ext;
+       struct sctp_stream_priorities *prio_head, *old;
+       bool reschedule = false;
+-      int i;
++
++      old = soute->prio_head;
++      if (old && old->prio == prio)
++              return 0;
+       prio_head = sctp_sched_prio_get_head(stream, prio, gfp);
+       if (!prio_head)
+               return -ENOMEM;
+       reschedule = sctp_sched_prio_unsched(soute);
+-      old = soute->prio_head;
+       soute->prio_head = prio_head;
+       if (reschedule)
+               sctp_sched_prio_sched(stream, soute);
+-      if (!old)
+-              /* Happens when we set the priority for the first time */
+-              return 0;
+-
+-      for (i = 0; i < stream->outcnt; i++) {
+-              soute = SCTP_SO(stream, i)->ext;
+-              if (soute && soute->prio_head == old)
+-                      /* It's still in use, nothing else to do here. */
+-                      return 0;
+-      }
+-
+-      /* No hits, we are good to free it. */
+-      kfree(old);
+-
++      sctp_sched_prio_head_put(old);
+       return 0;
+ }
+@@ -206,20 +208,8 @@ static int sctp_sched_prio_init_sid(struct sctp_stream *stream, __u16 sid,
+ static void sctp_sched_prio_free_sid(struct sctp_stream *stream, __u16 sid)
+ {
+-      struct sctp_stream_priorities *prio = SCTP_SO(stream, sid)->ext->prio_head;
+-      int i;
+-
+-      if (!prio)
+-              return;
+-
++      sctp_sched_prio_head_put(SCTP_SO(stream, sid)->ext->prio_head);
+       SCTP_SO(stream, sid)->ext->prio_head = NULL;
+-      for (i = 0; i < stream->outcnt; i++) {
+-              if (SCTP_SO(stream, i)->ext &&
+-                  SCTP_SO(stream, i)->ext->prio_head == prio)
+-                      return;
+-      }
+-
+-      kfree(prio);
+ }
+ static void sctp_sched_prio_free(struct sctp_stream *stream)
+-- 
+2.39.2
+
diff --git a/queue-5.15/serial-sc16is7xx-setup-gpio-controller-later-in-prob.patch b/queue-5.15/serial-sc16is7xx-setup-gpio-controller-later-in-prob.patch
new file mode 100644 (file)
index 0000000..a6bcaec
--- /dev/null
@@ -0,0 +1,142 @@
+From ecf02537090d9041abfa22e6b1dcb23ffd6f558a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 30 Nov 2022 11:55:30 +0100
+Subject: serial: sc16is7xx: setup GPIO controller later in probe
+
+From: Isaac True <isaac.true@canonical.com>
+
+[ Upstream commit c8f71b49ee4d28930c4a6798d1969fa91dc4ef3e ]
+
+The GPIO controller component of the sc16is7xx driver is setup too
+early, which can result in a race condition where another device tries
+to utilise the GPIO lines before the sc16is7xx device has finished
+initialising.
+
+This issue manifests itself as an Oops when the GPIO lines are configured:
+
+    Unable to handle kernel read from unreadable memory at virtual address
+    ...
+    pc : sc16is7xx_gpio_direction_output+0x68/0x108 [sc16is7xx]
+    lr : sc16is7xx_gpio_direction_output+0x4c/0x108 [sc16is7xx]
+    ...
+    Call trace:
+    sc16is7xx_gpio_direction_output+0x68/0x108 [sc16is7xx]
+    gpiod_direction_output_raw_commit+0x64/0x318
+    gpiod_direction_output+0xb0/0x170
+    create_gpio_led+0xec/0x198
+    gpio_led_probe+0x16c/0x4f0
+    platform_drv_probe+0x5c/0xb0
+    really_probe+0xe8/0x448
+    driver_probe_device+0xe8/0x138
+    __device_attach_driver+0x94/0x118
+    bus_for_each_drv+0x8c/0xe0
+    __device_attach+0x100/0x1b8
+    device_initial_probe+0x28/0x38
+    bus_probe_device+0xa4/0xb0
+    deferred_probe_work_func+0x90/0xe0
+    process_one_work+0x1c4/0x480
+    worker_thread+0x54/0x430
+    kthread+0x138/0x150
+    ret_from_fork+0x10/0x1c
+
+This patch moves the setup of the GPIO controller functions to later in the
+probe function, ensuring the sc16is7xx device has already finished
+initialising by the time other devices try to make use of the GPIO lines.
+The error handling has also been reordered to reflect the new
+initialisation order.
+
+Co-developed-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
+Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
+Signed-off-by: Isaac True <isaac.true@canonical.com>
+Link: https://lore.kernel.org/r/20221130105529.698385-1-isaac.true@canonical.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/sc16is7xx.c | 51 +++++++++++++++++-----------------
+ 1 file changed, 26 insertions(+), 25 deletions(-)
+
+diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
+index 0ab788058fa2a..b57cf8ddbf63b 100644
+--- a/drivers/tty/serial/sc16is7xx.c
++++ b/drivers/tty/serial/sc16is7xx.c
+@@ -1245,25 +1245,6 @@ static int sc16is7xx_probe(struct device *dev,
+       }
+       sched_set_fifo(s->kworker_task);
+-#ifdef CONFIG_GPIOLIB
+-      if (devtype->nr_gpio) {
+-              /* Setup GPIO cotroller */
+-              s->gpio.owner            = THIS_MODULE;
+-              s->gpio.parent           = dev;
+-              s->gpio.label            = dev_name(dev);
+-              s->gpio.direction_input  = sc16is7xx_gpio_direction_input;
+-              s->gpio.get              = sc16is7xx_gpio_get;
+-              s->gpio.direction_output = sc16is7xx_gpio_direction_output;
+-              s->gpio.set              = sc16is7xx_gpio_set;
+-              s->gpio.base             = -1;
+-              s->gpio.ngpio            = devtype->nr_gpio;
+-              s->gpio.can_sleep        = 1;
+-              ret = gpiochip_add_data(&s->gpio, s);
+-              if (ret)
+-                      goto out_thread;
+-      }
+-#endif
+-
+       /* reset device, purging any pending irq / data */
+       regmap_write(s->regmap, SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT,
+                       SC16IS7XX_IOCONTROL_SRESET_BIT);
+@@ -1329,6 +1310,25 @@ static int sc16is7xx_probe(struct device *dev,
+                               s->p[u].irda_mode = true;
+       }
++#ifdef CONFIG_GPIOLIB
++      if (devtype->nr_gpio) {
++              /* Setup GPIO cotroller */
++              s->gpio.owner            = THIS_MODULE;
++              s->gpio.parent           = dev;
++              s->gpio.label            = dev_name(dev);
++              s->gpio.direction_input  = sc16is7xx_gpio_direction_input;
++              s->gpio.get              = sc16is7xx_gpio_get;
++              s->gpio.direction_output = sc16is7xx_gpio_direction_output;
++              s->gpio.set              = sc16is7xx_gpio_set;
++              s->gpio.base             = -1;
++              s->gpio.ngpio            = devtype->nr_gpio;
++              s->gpio.can_sleep        = 1;
++              ret = gpiochip_add_data(&s->gpio, s);
++              if (ret)
++                      goto out_thread;
++      }
++#endif
++
+       /*
+        * Setup interrupt. We first try to acquire the IRQ line as level IRQ.
+        * If that succeeds, we can allow sharing the interrupt as well.
+@@ -1348,18 +1348,19 @@ static int sc16is7xx_probe(struct device *dev,
+       if (!ret)
+               return 0;
+-out_ports:
+-      for (i--; i >= 0; i--) {
+-              uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port);
+-              clear_bit(s->p[i].port.line, &sc16is7xx_lines);
+-      }
+-
+ #ifdef CONFIG_GPIOLIB
+       if (devtype->nr_gpio)
+               gpiochip_remove(&s->gpio);
+ out_thread:
+ #endif
++
++out_ports:
++      for (i--; i >= 0; i--) {
++              uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port);
++              clear_bit(s->p[i].port.line, &sc16is7xx_lines);
++      }
++
+       kthread_stop(s->kworker_task);
+ out_clk:
+-- 
+2.39.2
+
index e0e5729ed47bb3d500a3c12fe849a2d1038b24fa..0c82216ea6c75e605208ed0df91994006fdf5a07 100644 (file)
@@ -1 +1,124 @@
 net-sched-retire-tcindex-classifier.patch
+auxdisplay-hd44780-fix-potential-memory-leak-in-hd44.patch
+fs-jfs-fix-shift-exponent-db_agl2size-negative.patch
+objtool-fix-memory-leak-in-create_static_call_sectio.patch
+pwm-sifive-reduce-time-the-controller-lock-is-held.patch
+pwm-sifive-always-let-the-first-pwm_apply_state-succ.patch
+pwm-stm32-lp-fix-the-check-on-arr-and-cmp-registers-.patch
+f2fs-use-memcpy_-to-from-_page-where-possible.patch
+fs-f2fs-initialize-fsdata-in-pagecache_write.patch
+f2fs-allow-set-compression-option-of-files-without-b.patch
+um-vector-fix-memory-leak-in-vector_config.patch
+ubi-ensure-that-vid-header-offset-vid-header-size-al.patch
+ubifs-fix-build-errors-as-symbol-undefined.patch
+ubifs-rectify-space-budget-for-ubifs_symlink-if-syml.patch
+ubifs-rectify-space-budget-for-ubifs_xrename.patch
+ubifs-fix-wrong-dirty-space-budget-for-dirty-inode.patch
+ubifs-do_rename-fix-wrong-space-budget-when-target-i.patch
+ubifs-reserve-one-leb-for-each-journal-head-while-do.patch
+ubi-fix-use-after-free-when-volume-resizing-failed.patch
+ubi-fix-unreferenced-object-reported-by-kmemleak-in-.patch
+ubifs-fix-memory-leak-in-alloc_wbufs.patch
+ubi-fix-possible-null-ptr-deref-in-ubi_free_volume.patch
+ubifs-re-statistic-cleaned-znode-count-if-commit-fai.patch
+ubifs-dirty_cow_znode-fix-memleak-in-error-handling-.patch
+ubifs-ubifs_writepage-mark-page-dirty-after-writing-.patch
+ubi-fastmap-fix-missed-fm_anchor-peb-in-wear-levelin.patch
+ubi-fix-uaf-wear-leveling-entry-in-eraseblk_count_se.patch
+ubi-ubi_wl_put_peb-fix-infinite-loop-when-wear-level.patch
+f2fs-fix-to-avoid-potential-memory-corruption-in-__u.patch
+ext4-use-ext4_fc_tl_mem-in-fast-commit-replay-path.patch
+netfilter-nf_tables-allow-to-fetch-set-elements-when.patch
+x86-um-vdso-add-rcx-and-r11-to-the-syscall-clobber-l.patch
+um-virtio_uml-free-command-if-adding-to-virtqueue-fa.patch
+um-virtio_uml-mark-device-as-unregistered-when-break.patch
+um-virtio_uml-move-device-breaking-into-workqueue.patch
+um-virt-pci-properly-remove-pci-device-from-bus.patch
+watchdog-at91sam9_wdt-use-devm_request_irq-to-avoid-.patch
+watchdog-fix-kmemleak-in-watchdog_cdev_register.patch
+watchdog-pcwd_usb-fix-attempting-to-access-uninitial.patch
+watchdog-sbsa_wdog-make-sure-the-timeout-programming.patch
+netfilter-ctnetlink-fix-possible-refcount-leak-in-ct.patch
+netfilter-ebtables-fix-table-blob-use-after-free.patch
+netfilter-x_tables-fix-percpu-counter-block-leak-on-.patch
+ipv6-add-lwtunnel-encap-size-of-all-siblings-in-next.patch
+sctp-add-a-refcnt-in-sctp_stream_priorities-to-avoid.patch
+octeontx2-pf-use-correct-struct-reference-in-test-co.patch
+net-fix-__dev_kfree_skb_any-vs-drop-monitor.patch
+9p-xen-fix-version-parsing.patch
+9p-xen-fix-connection-sequence.patch
+9p-rdma-unmap-receive-dma-buffer-in-rdma_request-pos.patch
+net-mlx5e-verify-flow_source-cap-before-using-it.patch
+net-mlx5-geneve-fix-handling-of-geneve-object-id-as-.patch
+nfc-fix-memory-leak-of-se_io-context-in-nfc_genl_se_.patch
+net-sched-transition-act_pedit-to-rcu-and-percpu-sta.patch
+net-sched-act_pedit-fix-action-bind-logic.patch
+net-sched-act_mpls-fix-action-bind-logic.patch
+net-sched-act_sample-fix-action-bind-logic.patch
+arm-dts-spear320-hmi-correct-stmpe-gpio-compatible.patch
+tcp-tcp_check_req-can-be-called-from-process-context.patch
+vc_screen-modify-vcs_size-handling-in-vcs_read.patch
+rtc-sun6i-always-export-the-internal-oscillator.patch
+genirq-refactor-accessors-to-use-irq_data_get_affini.patch
+genirq-add-and-use-an-irq_data_update_affinity-helpe.patch
+scsi-ipr-work-around-fortify-string-warning.patch
+rtc-allow-rtc_read_alarm-without-read_alarm-callback.patch
+loop-loop_set_status_from_info-check-before-assignme.patch
+asoc-adau7118-don-t-disable-regulators-on-device-unb.patch
+asoc-zl38060-remove-spurious-gpiolib-select.patch
+asoc-zl38060-add-gpiolib-dependency.patch
+asoc-mediatek-mt8195-add-missing-initialization.patch
+thermal-intel-quark_dts-fix-error-pointer-dereferenc.patch
+thermal-intel-bxt_pmic-select-regmap-instead-of-depe.patch
+tracing-add-null-checks-for-buffer-in-ring_buffer_fr.patch
+kernel-printk-index.c-fix-memory-leak-with-using-deb.patch
+firmware-efi-sysfb_efi-add-quirk-for-lenovo-ideapad-.patch
+bootconfig-increase-max-nodes-of-bootconfig-from-102.patch
+mfd-arizona-use-pm_runtime_resume_and_get-to-prevent.patch
+ib-hfi1-update-rmt-size-calculation.patch
+iommu-amd-fix-error-handling-for-pdev_pri_ats_enable.patch
+media-uvcvideo-remove-format-descriptions.patch
+media-uvcvideo-handle-cameras-with-invalid-descripto.patch
+media-uvcvideo-handle-errors-from-calls-to-usb_strin.patch
+media-uvcvideo-quirk-for-autosuspend-in-logitech-b91.patch
+media-uvcvideo-silence-memcpy-run-time-false-positiv.patch
+usb-fix-memory-leak-with-using-debugfs_lookup.patch
+staging-emxx_udc-add-checks-for-dma_alloc_coherent.patch
+tty-fix-out-of-bounds-access-in-tty_driver_lookup_tt.patch
+tty-serial-fsl_lpuart-disable-the-cts-when-send-brea.patch
+serial-sc16is7xx-setup-gpio-controller-later-in-prob.patch
+mei-bus-fixup-upon-error-print-return-values-of-send.patch
+parport_pc-set-up-mode-and-ecr-masks-for-oxford-semi.patch
+tools-iio-iio_utils-fix-memory-leak.patch
+iio-accel-mma9551_core-prevent-uninitialized-variabl.patch
+iio-accel-mma9551_core-prevent-uninitialized-variabl.patch-31264
+soundwire-bus_type-avoid-lockdep-assert-in-sdw_drv_p.patch
+pci-loongson-prevent-ls7a-mrrs-increases.patch
+usb-dwc3-fix-memory-leak-with-using-debugfs_lookup.patch
+usb-chipidea-fix-memory-leak-with-using-debugfs_look.patch
+usb-uhci-fix-memory-leak-with-using-debugfs_lookup.patch
+usb-sl811-fix-memory-leak-with-using-debugfs_lookup.patch
+usb-fotg210-fix-memory-leak-with-using-debugfs_looku.patch
+usb-isp116x-fix-memory-leak-with-using-debugfs_looku.patch
+usb-isp1362-fix-memory-leak-with-using-debugfs_looku.patch
+usb-gadget-gr_udc-fix-memory-leak-with-using-debugfs.patch
+usb-gadget-bcm63xx_udc-fix-memory-leak-with-using-de.patch
+usb-gadget-lpc32xx_udc-fix-memory-leak-with-using-de.patch
+usb-gadget-pxa25x_udc-fix-memory-leak-with-using-deb.patch
+usb-gadget-pxa27x_udc-fix-memory-leak-with-using-deb.patch
+usb-host-xhci-mvebu-iterate-over-array-indexes-inste.patch
+usb-ene_usb6250-allocate-enough-memory-for-full-obje.patch
+usb-uvc-enumerate-valid-values-for-color-matching.patch
+usb-gadget-uvc-make-bsourceid-read-write.patch
+pci-align-extra-resources-for-hotplug-bridges-proper.patch
+pci-take-other-bus-devices-into-account-when-distrib.patch
+tty-pcn_uart-fix-memory-leak-with-using-debugfs_look.patch
+misc-vmw_balloon-fix-memory-leak-with-using-debugfs_.patch
+drivers-base-component-fix-memory-leak-with-using-de.patch
+drivers-base-dd-fix-memory-leak-with-using-debugfs_l.patch
+kernel-fail_function-fix-memory-leak-with-using-debu.patch
+pci-loongson-add-more-devices-that-need-mrrs-quirk.patch
+pci-add-acs-quirk-for-wangxun-nics.patch
+phy-rockchip-typec-fix-unsigned-comparison-with-less.patch
+soundwire-cadence-remove-wasted-space-in-response_bu.patch
+soundwire-cadence-drain-the-rx-fifo-after-an-io-time.patch
diff --git a/queue-5.15/soundwire-bus_type-avoid-lockdep-assert-in-sdw_drv_p.patch b/queue-5.15/soundwire-bus_type-avoid-lockdep-assert-in-sdw_drv_p.patch
new file mode 100644 (file)
index 0000000..473031c
--- /dev/null
@@ -0,0 +1,277 @@
+From 5bd958d8077a7f48398d7f431d3512b88937fd32 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 Jan 2023 17:25:20 +0000
+Subject: soundwire: bus_type: Avoid lockdep assert in sdw_drv_probe()
+
+From: Richard Fitzgerald <rf@opensource.cirrus.com>
+
+[ Upstream commit 3dca1f89ae3455963d7b53245ecf298ea9bae857 ]
+
+Don't hold sdw_dev_lock while calling the peripheral driver
+probe() and remove() callbacks.
+
+Holding sdw_dev_lock around the probe() and remove() calls causes
+a theoretical mutex inversion which lockdep will assert on.
+
+During probe() the sdw_dev_lock mutex is taken first and then
+ASoC/ALSA locks are taken by the probe() implementation.
+
+During normal operation ASoC can take its locks and then trigger
+a runtime resume of the component. The SoundWire resume will then
+take sdw_dev_lock. This is the reverse order compared to probe().
+
+It's not necessary to hold sdw_dev_lock when calling the probe()
+and remove(), it is only used to prevent the bus core calling the
+driver callbacks if there isn't a driver or the driver is removing.
+
+All calls to the driver callbacks are guarded by the 'probed' flag.
+So if sdw_dev_lock is held while setting and clearing the 'probed'
+flag this is sufficient to guarantee the safety of callback
+functions.
+
+Removing the mutex from around the call to probe() means that it
+is now possible for a bus event (PING response) to be handled in
+parallel with the probe(). But sdw_bus_probe() already has
+handling for this by calling the device update_status() after
+the probe() has completed.
+
+Example lockdep assert:
+[   46.098514] ======================================================
+[   46.104736] WARNING: possible circular locking dependency detected
+[   46.110961] 6.1.0-rc4-jamerson #1 Tainted: G            E
+[   46.116842] ------------------------------------------------------
+[   46.123063] mpg123/1130 is trying to acquire lock:
+[   46.127883] ffff8b445031fb80 (&slave->sdw_dev_lock){+.+.}-{3:3}, at: sdw_update_slave_status+0x26/0x70
+[   46.137225]
+               but task is already holding lock:
+[   46.143074] ffffffffc1455310 (&card->pcm_mutex){+.+.}-{3:3}, at: dpcm_fe_dai_open+0x49/0x830
+[   46.151536]
+               which lock already depends on the new lock.[   46.159732]
+               the existing dependency chain (in reverse order) is:
+[   46.167231]
+               -> #4 (&card->pcm_mutex){+.+.}-{3:3}:
+[   46.173428]        __mutex_lock+0x94/0x920
+[   46.177542]        snd_soc_dpcm_runtime_update+0x2e/0x100
+[   46.182958]        snd_soc_dapm_put_enum_double+0x1c2/0x200
+[   46.188548]        snd_ctl_elem_write+0x10c/0x1d0
+[   46.193268]        snd_ctl_ioctl+0x126/0x850
+[   46.197556]        __x64_sys_ioctl+0x87/0xc0
+[   46.201845]        do_syscall_64+0x38/0x90
+[   46.205959]        entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[   46.211553]
+               -> #3 (&card->controls_rwsem){++++}-{3:3}:
+[   46.218188]        down_write+0x2b/0xd0
+[   46.222038]        snd_ctl_add_replace+0x39/0xb0
+[   46.226672]        snd_soc_add_controls+0x53/0x80
+[   46.231393]        soc_probe_component+0x1e4/0x2a0
+[   46.236202]        snd_soc_bind_card+0x51a/0xc80
+[   46.240836]        devm_snd_soc_register_card+0x43/0x90
+[   46.246079]        mc_probe+0x982/0xfe0 [snd_soc_sof_sdw]
+[   46.251500]        platform_probe+0x3c/0xa0
+[   46.255700]        really_probe+0xde/0x390
+[   46.259814]        __driver_probe_device+0x78/0x180
+[   46.264710]        driver_probe_device+0x1e/0x90
+[   46.269347]        __driver_attach+0x9f/0x1f0
+[   46.273721]        bus_for_each_dev+0x78/0xc0
+[   46.278098]        bus_add_driver+0x1ac/0x200
+[   46.282473]        driver_register+0x8f/0xf0
+[   46.286759]        do_one_initcall+0x58/0x310
+[   46.291136]        do_init_module+0x4c/0x1f0
+[   46.295422]        __do_sys_finit_module+0xb4/0x130
+[   46.300321]        do_syscall_64+0x38/0x90
+[   46.304434]        entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[   46.310027]
+               -> #2 (&card->mutex){+.+.}-{3:3}:
+[   46.315883]        __mutex_lock+0x94/0x920
+[   46.320000]        snd_soc_bind_card+0x3e/0xc80
+[   46.324551]        devm_snd_soc_register_card+0x43/0x90
+[   46.329798]        mc_probe+0x982/0xfe0 [snd_soc_sof_sdw]
+[   46.335219]        platform_probe+0x3c/0xa0
+[   46.339420]        really_probe+0xde/0x390
+[   46.343532]        __driver_probe_device+0x78/0x180
+[   46.348430]        driver_probe_device+0x1e/0x90
+[   46.353065]        __driver_attach+0x9f/0x1f0
+[   46.357437]        bus_for_each_dev+0x78/0xc0
+[   46.361812]        bus_add_driver+0x1ac/0x200
+[   46.366716]        driver_register+0x8f/0xf0
+[   46.371528]        do_one_initcall+0x58/0x310
+[   46.376424]        do_init_module+0x4c/0x1f0
+[   46.381239]        __do_sys_finit_module+0xb4/0x130
+[   46.386665]        do_syscall_64+0x38/0x90
+[   46.391299]        entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[   46.397416]
+               -> #1 (client_mutex){+.+.}-{3:3}:
+[   46.404307]        __mutex_lock+0x94/0x920
+[   46.408941]        snd_soc_add_component+0x24/0x2c0
+[   46.414345]        devm_snd_soc_register_component+0x54/0xa0
+[   46.420522]        cs35l56_common_probe+0x280/0x370 [snd_soc_cs35l56]
+[   46.427487]        cs35l56_sdw_probe+0xf4/0x170 [snd_soc_cs35l56_sdw]
+[   46.434442]        sdw_drv_probe+0x80/0x1a0
+[   46.439136]        really_probe+0xde/0x390
+[   46.443738]        __driver_probe_device+0x78/0x180
+[   46.449120]        driver_probe_device+0x1e/0x90
+[   46.454247]        __driver_attach+0x9f/0x1f0
+[   46.459106]        bus_for_each_dev+0x78/0xc0
+[   46.463971]        bus_add_driver+0x1ac/0x200
+[   46.468825]        driver_register+0x8f/0xf0
+[   46.473592]        do_one_initcall+0x58/0x310
+[   46.478441]        do_init_module+0x4c/0x1f0
+[   46.483202]        __do_sys_finit_module+0xb4/0x130
+[   46.488572]        do_syscall_64+0x38/0x90
+[   46.493158]        entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[   46.499229]
+               -> #0 (&slave->sdw_dev_lock){+.+.}-{3:3}:
+[   46.506737]        __lock_acquire+0x1121/0x1df0
+[   46.511765]        lock_acquire+0xd5/0x300
+[   46.516360]        __mutex_lock+0x94/0x920
+[   46.520949]        sdw_update_slave_status+0x26/0x70
+[   46.526409]        sdw_clear_slave_status+0xd8/0xe0
+[   46.531783]        intel_resume_runtime+0x139/0x2a0
+[   46.537155]        __rpm_callback+0x41/0x120
+[   46.541919]        rpm_callback+0x5d/0x70
+[   46.546422]        rpm_resume+0x531/0x7e0
+[   46.550920]        __pm_runtime_resume+0x4a/0x80
+[   46.556024]        snd_soc_pcm_component_pm_runtime_get+0x2f/0xc0
+[   46.562611]        __soc_pcm_open+0x62/0x520
+[   46.567375]        dpcm_be_dai_startup+0x116/0x210
+[   46.572661]        dpcm_fe_dai_open+0xf7/0x830
+[   46.577597]        snd_pcm_open_substream+0x54a/0x8b0
+[   46.583145]        snd_pcm_open.part.0+0xdc/0x200
+[   46.588341]        snd_pcm_playback_open+0x51/0x80
+[   46.593625]        chrdev_open+0xc0/0x250
+[   46.598129]        do_dentry_open+0x15f/0x430
+[   46.602981]        path_openat+0x75e/0xa80
+[   46.607575]        do_filp_open+0xb2/0x160
+[   46.612162]        do_sys_openat2+0x9a/0x160
+[   46.616922]        __x64_sys_openat+0x53/0xa0
+[   46.621767]        do_syscall_64+0x38/0x90
+[   46.626352]        entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[   46.632414]
+               other info that might help us debug this:[   46.641862] Chain exists of:
+                 &slave->sdw_dev_lock --> &card->controls_rwsem --> &card->pcm_mutex[   46.655145]  Possible unsafe locking scenario:[   46.662048]        CPU0                    CPU1
+[   46.667080]        ----                    ----
+[   46.672108]   lock(&card->pcm_mutex);
+[   46.676267]                                lock(&card->controls_rwsem);
+[   46.683382]                                lock(&card->pcm_mutex);
+[   46.690063]   lock(&slave->sdw_dev_lock);
+[   46.694574]
+                *** DEADLOCK ***[   46.701942] 2 locks held by mpg123/1130:
+[   46.706356]  #0: ffff8b4457b22b90 (&pcm->open_mutex){+.+.}-{3:3}, at: snd_pcm_open.part.0+0xc9/0x200
+[   46.715999]  #1: ffffffffc1455310 (&card->pcm_mutex){+.+.}-{3:3}, at: dpcm_fe_dai_open+0x49/0x830
+[   46.725390]
+               stack backtrace:
+[   46.730752] CPU: 0 PID: 1130 Comm: mpg123 Tainted: G            E      6.1.0-rc4-jamerson #1
+[   46.739703] Hardware name: AAEON UP-WHL01/UP-WHL01, BIOS UPW1AM19 11/10/2020
+[   46.747270] Call Trace:
+[   46.750239]  <TASK>
+[   46.752857]  dump_stack_lvl+0x56/0x73
+[   46.757045]  check_noncircular+0x102/0x120
+[   46.761664]  __lock_acquire+0x1121/0x1df0
+[   46.766197]  lock_acquire+0xd5/0x300
+[   46.770292]  ? sdw_update_slave_status+0x26/0x70
+[   46.775432]  ? lock_is_held_type+0xe2/0x140
+[   46.780143]  __mutex_lock+0x94/0x920
+[   46.784241]  ? sdw_update_slave_status+0x26/0x70
+[   46.789387]  ? find_held_lock+0x2b/0x80
+[   46.793750]  ? sdw_update_slave_status+0x26/0x70
+[   46.798894]  ? lock_release+0x147/0x2f0
+[   46.803262]  ? lockdep_init_map_type+0x47/0x250
+[   46.808315]  ? sdw_update_slave_status+0x26/0x70
+[   46.813456]  sdw_update_slave_status+0x26/0x70
+[   46.818422]  sdw_clear_slave_status+0xd8/0xe0
+[   46.823302]  ? pm_generic_runtime_suspend+0x30/0x30
+[   46.828706]  intel_resume_runtime+0x139/0x2a0
+[   46.833583]  ? _raw_spin_unlock_irq+0x24/0x50
+[   46.838462]  ? pm_generic_runtime_suspend+0x30/0x30
+[   46.843866]  __rpm_callback+0x41/0x120
+[   46.848142]  ? pm_generic_runtime_suspend+0x30/0x30
+[   46.853550]  rpm_callback+0x5d/0x70
+[   46.857568]  rpm_resume+0x531/0x7e0
+[   46.861578]  ? _raw_spin_lock_irqsave+0x62/0x70
+[   46.866634]  __pm_runtime_resume+0x4a/0x80
+[   46.871258]  snd_soc_pcm_component_pm_runtime_get+0x2f/0xc0
+[   46.877358]  __soc_pcm_open+0x62/0x520
+[   46.881634]  ? dpcm_add_paths.isra.0+0x35d/0x4c0
+[   46.886784]  dpcm_be_dai_startup+0x116/0x210
+[   46.891592]  dpcm_fe_dai_open+0xf7/0x830
+[   46.896046]  ? debug_mutex_init+0x33/0x50
+[   46.900591]  snd_pcm_open_substream+0x54a/0x8b0
+[   46.905658]  snd_pcm_open.part.0+0xdc/0x200
+[   46.910376]  ? wake_up_q+0x90/0x90
+[   46.914312]  snd_pcm_playback_open+0x51/0x80
+[   46.919118]  chrdev_open+0xc0/0x250
+[   46.923147]  ? cdev_device_add+0x90/0x90
+[   46.927608]  do_dentry_open+0x15f/0x430
+[   46.931976]  path_openat+0x75e/0xa80
+[   46.936086]  do_filp_open+0xb2/0x160
+[   46.940194]  ? lock_release+0x147/0x2f0
+[   46.944563]  ? _raw_spin_unlock+0x29/0x50
+[   46.949101]  do_sys_openat2+0x9a/0x160
+[   46.953377]  __x64_sys_openat+0x53/0xa0
+[   46.957733]  do_syscall_64+0x38/0x90
+[   46.961829]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[   46.967402] RIP: 0033:0x7fa6397ccd3b
+[   46.971506] Code: 25 00 00 41 00 3d 00 00 41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0 75 67 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 4c 24 28 64 48 33 0c 25
+[   46.991413] RSP: 002b:00007fff838e8990 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
+[   46.999580] RAX: ffffffffffffffda RBX: 0000000000080802 RCX: 00007fa6397ccd3b
+[   47.007311] RDX: 0000000000080802 RSI: 00007fff838e8b50 RDI: 00000000ffffff9c
+[   47.015047] RBP: 00007fff838e8b50 R08: 0000000000000000 R09: 0000000000000011
+[   47.022787] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000080802
+[   47.030539] R13: 0000000000000004 R14: 0000000000000000 R15: 00007fff838e8b50
+[   47.038289]  </TASK>
+
+Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
+Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Link: https://lore.kernel.org/r/20230123172520.339367-1-rf@opensource.cirrus.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/soundwire/bus_type.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
+index 04b3529f89293..963498db0fd22 100644
+--- a/drivers/soundwire/bus_type.c
++++ b/drivers/soundwire/bus_type.c
+@@ -105,20 +105,19 @@ static int sdw_drv_probe(struct device *dev)
+       if (ret)
+               return ret;
+-      mutex_lock(&slave->sdw_dev_lock);
+-
+       ret = drv->probe(slave, id);
+       if (ret) {
+               name = drv->name;
+               if (!name)
+                       name = drv->driver.name;
+-              mutex_unlock(&slave->sdw_dev_lock);
+               dev_err(dev, "Probe of %s failed: %d\n", name, ret);
+               dev_pm_domain_detach(dev, false);
+               return ret;
+       }
++      mutex_lock(&slave->sdw_dev_lock);
++
+       /* device is probed so let's read the properties now */
+       if (drv->ops && drv->ops->read_prop)
+               drv->ops->read_prop(slave);
+@@ -167,14 +166,12 @@ static int sdw_drv_remove(struct device *dev)
+       int ret = 0;
+       mutex_lock(&slave->sdw_dev_lock);
+-
+       slave->probed = false;
++      mutex_unlock(&slave->sdw_dev_lock);
+       if (drv->remove)
+               ret = drv->remove(slave);
+-      mutex_unlock(&slave->sdw_dev_lock);
+-
+       dev_pm_domain_detach(dev, false);
+       return ret;
+-- 
+2.39.2
+
diff --git a/queue-5.15/soundwire-cadence-drain-the-rx-fifo-after-an-io-time.patch b/queue-5.15/soundwire-cadence-drain-the-rx-fifo-after-an-io-time.patch
new file mode 100644 (file)
index 0000000..a299d5e
--- /dev/null
@@ -0,0 +1,112 @@
+From 0a6d22b36cd519d5aa12d38362d5d46caf62e1b8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 2 Dec 2022 16:18:12 +0000
+Subject: soundwire: cadence: Drain the RX FIFO after an IO timeout
+
+From: Richard Fitzgerald <rf@opensource.cirrus.com>
+
+[ Upstream commit 0603a47bd3a8f439d7844b841eee1819353063e0 ]
+
+If wait_for_completion_timeout() times-out in _cdns_xfer_msg() it
+is possible that something could have been written to the RX FIFO.
+In this case, we should drain the RX FIFO so that anything in it
+doesn't carry over and mess up the next transfer.
+
+Obviously, if we got to this state something went wrong, and we
+don't really know the state of everything. The cleanup in this
+situation cannot be bullet-proof but we should attempt to avoid
+breaking future transaction, if only to reduce the amount of
+error noise when debugging the failure from a kernel log.
+
+Note that this patch only implements the draining for blocking
+(non-deferred) transfers. The deferred API doesn't have any proper
+handling of error conditions and would need some re-design before
+implementing cleanup. That is a task for a separate patch...
+
+Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
+Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Link: https://lore.kernel.org/r/20221202161812.4186897-4-rf@opensource.cirrus.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/soundwire/cadence_master.c | 50 ++++++++++++++++--------------
+ 1 file changed, 27 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
+index 74af111f39127..7b340f3832133 100644
+--- a/drivers/soundwire/cadence_master.c
++++ b/drivers/soundwire/cadence_master.c
+@@ -556,6 +556,29 @@ cdns_fill_msg_resp(struct sdw_cdns *cdns,
+       return SDW_CMD_OK;
+ }
++static void cdns_read_response(struct sdw_cdns *cdns)
++{
++      u32 num_resp, cmd_base;
++      int i;
++
++      /* RX_FIFO_AVAIL can be 2 entries more than the FIFO size */
++      BUILD_BUG_ON(ARRAY_SIZE(cdns->response_buf) < CDNS_MCP_CMD_LEN + 2);
++
++      num_resp = cdns_readl(cdns, CDNS_MCP_FIFOSTAT);
++      num_resp &= CDNS_MCP_RX_FIFO_AVAIL;
++      if (num_resp > ARRAY_SIZE(cdns->response_buf)) {
++              dev_warn(cdns->dev, "RX AVAIL %d too long\n", num_resp);
++              num_resp = ARRAY_SIZE(cdns->response_buf);
++      }
++
++      cmd_base = CDNS_MCP_CMD_BASE;
++
++      for (i = 0; i < num_resp; i++) {
++              cdns->response_buf[i] = cdns_readl(cdns, cmd_base);
++              cmd_base += CDNS_MCP_CMD_WORD_LEN;
++      }
++}
++
+ static enum sdw_command_response
+ _cdns_xfer_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int cmd,
+              int offset, int count, bool defer)
+@@ -597,6 +620,10 @@ _cdns_xfer_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int cmd,
+               dev_err(cdns->dev, "IO transfer timed out, cmd %d device %d addr %x len %d\n",
+                       cmd, msg->dev_num, msg->addr, msg->len);
+               msg->len = 0;
++
++              /* Drain anything in the RX_FIFO */
++              cdns_read_response(cdns);
++
+               return SDW_CMD_TIMEOUT;
+       }
+@@ -765,29 +792,6 @@ EXPORT_SYMBOL(cdns_reset_page_addr);
+  * IRQ handling
+  */
+-static void cdns_read_response(struct sdw_cdns *cdns)
+-{
+-      u32 num_resp, cmd_base;
+-      int i;
+-
+-      /* RX_FIFO_AVAIL can be 2 entries more than the FIFO size */
+-      BUILD_BUG_ON(ARRAY_SIZE(cdns->response_buf) < CDNS_MCP_CMD_LEN + 2);
+-
+-      num_resp = cdns_readl(cdns, CDNS_MCP_FIFOSTAT);
+-      num_resp &= CDNS_MCP_RX_FIFO_AVAIL;
+-      if (num_resp > ARRAY_SIZE(cdns->response_buf)) {
+-              dev_warn(cdns->dev, "RX AVAIL %d too long\n", num_resp);
+-              num_resp = ARRAY_SIZE(cdns->response_buf);
+-      }
+-
+-      cmd_base = CDNS_MCP_CMD_BASE;
+-
+-      for (i = 0; i < num_resp; i++) {
+-              cdns->response_buf[i] = cdns_readl(cdns, cmd_base);
+-              cmd_base += CDNS_MCP_CMD_WORD_LEN;
+-      }
+-}
+-
+ static int cdns_update_slave_status(struct sdw_cdns *cdns,
+                                   u64 slave_intstat)
+ {
+-- 
+2.39.2
+
diff --git a/queue-5.15/soundwire-cadence-remove-wasted-space-in-response_bu.patch b/queue-5.15/soundwire-cadence-remove-wasted-space-in-response_bu.patch
new file mode 100644 (file)
index 0000000..824231b
--- /dev/null
@@ -0,0 +1,82 @@
+From e4a4ec85d77696de439add50f32030de93b8f0bc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 2 Dec 2022 16:18:11 +0000
+Subject: soundwire: cadence: Remove wasted space in response_buf
+
+From: Richard Fitzgerald <rf@opensource.cirrus.com>
+
+[ Upstream commit 827c32d0df4bbe0d1c47d79f6a5eabfe9ac75216 ]
+
+The response_buf was declared much larger (128 entries) than the number
+of responses that could ever be written into it. The Cadence IP is
+configurable up to a maximum of 32 entries, and the datasheet says
+that RX_FIFO_AVAIL can be 2 larger than this. So allow up to 34
+responses.
+
+Also add checking in cdns_read_response() to prevent overflowing
+reponse_buf if RX_FIFO_AVAIL contains an unexpectedly large number.
+
+Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
+Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Link: https://lore.kernel.org/r/20221202161812.4186897-3-rf@opensource.cirrus.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/soundwire/cadence_master.c |  7 +++++++
+ drivers/soundwire/cadence_master.h | 13 ++++++++++++-
+ 2 files changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
+index 0339e6df6eb78..74af111f39127 100644
+--- a/drivers/soundwire/cadence_master.c
++++ b/drivers/soundwire/cadence_master.c
+@@ -770,8 +770,15 @@ static void cdns_read_response(struct sdw_cdns *cdns)
+       u32 num_resp, cmd_base;
+       int i;
++      /* RX_FIFO_AVAIL can be 2 entries more than the FIFO size */
++      BUILD_BUG_ON(ARRAY_SIZE(cdns->response_buf) < CDNS_MCP_CMD_LEN + 2);
++
+       num_resp = cdns_readl(cdns, CDNS_MCP_FIFOSTAT);
+       num_resp &= CDNS_MCP_RX_FIFO_AVAIL;
++      if (num_resp > ARRAY_SIZE(cdns->response_buf)) {
++              dev_warn(cdns->dev, "RX AVAIL %d too long\n", num_resp);
++              num_resp = ARRAY_SIZE(cdns->response_buf);
++      }
+       cmd_base = CDNS_MCP_CMD_BASE;
+diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
+index e587aede63bf0..e437a604429fa 100644
+--- a/drivers/soundwire/cadence_master.h
++++ b/drivers/soundwire/cadence_master.h
+@@ -8,6 +8,12 @@
+ #define SDW_CADENCE_GSYNC_KHZ         4 /* 4 kHz */
+ #define SDW_CADENCE_GSYNC_HZ          (SDW_CADENCE_GSYNC_KHZ * 1000)
++/*
++ * The Cadence IP supports up to 32 entries in the FIFO, though implementations
++ * can configure the IP to have a smaller FIFO.
++ */
++#define CDNS_MCP_IP_MAX_CMD_LEN               32
++
+ /**
+  * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance
+  *
+@@ -119,7 +125,12 @@ struct sdw_cdns {
+       struct sdw_bus bus;
+       unsigned int instance;
+-      u32 response_buf[0x80];
++      /*
++       * The datasheet says the RX FIFO AVAIL can be 2 entries more
++       * than the FIFO capacity, so allow for this.
++       */
++      u32 response_buf[CDNS_MCP_IP_MAX_CMD_LEN + 2];
++
+       struct completion tx_complete;
+       struct sdw_defer *defer;
+-- 
+2.39.2
+
diff --git a/queue-5.15/staging-emxx_udc-add-checks-for-dma_alloc_coherent.patch b/queue-5.15/staging-emxx_udc-add-checks-for-dma_alloc_coherent.patch
new file mode 100644 (file)
index 0000000..a1a61b1
--- /dev/null
@@ -0,0 +1,45 @@
+From 70e38cf2bd9860e5ba838a12bc55c9a6fab33724 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 19 Jan 2023 08:31:19 +0000
+Subject: staging: emxx_udc: Add checks for dma_alloc_coherent()
+
+From: Yuan Can <yuancan@huawei.com>
+
+[ Upstream commit f6510a93cfd8c6c79b4dda0f2967cdc6df42eff4 ]
+
+As the dma_alloc_coherent may return NULL, the return value needs to be
+checked to avoid NULL poineter dereference.
+
+Signed-off-by: Yuan Can <yuancan@huawei.com>
+Reviewed-by: Simon Horman <horms@verge.net.au>
+Link: https://lore.kernel.org/r/20230119083119.16956-1-yuancan@huawei.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/staging/emxx_udc/emxx_udc.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
+index b6abd3770e81c..edd20a03f7a26 100644
+--- a/drivers/staging/emxx_udc/emxx_udc.c
++++ b/drivers/staging/emxx_udc/emxx_udc.c
+@@ -2590,10 +2590,15 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep,
+               req->unaligned = false;
+       if (req->unaligned) {
+-              if (!ep->virt_buf)
++              if (!ep->virt_buf) {
+                       ep->virt_buf = dma_alloc_coherent(udc->dev, PAGE_SIZE,
+                                                         &ep->phys_buf,
+                                                         GFP_ATOMIC | GFP_DMA);
++                      if (!ep->virt_buf) {
++                              spin_unlock_irqrestore(&udc->lock, flags);
++                              return -ENOMEM;
++                      }
++              }
+               if (ep->epnum > 0)  {
+                       if (ep->direct == USB_DIR_IN)
+                               memcpy(ep->virt_buf, req->req.buf,
+-- 
+2.39.2
+
diff --git a/queue-5.15/tcp-tcp_check_req-can-be-called-from-process-context.patch b/queue-5.15/tcp-tcp_check_req-can-be-called-from-process-context.patch
new file mode 100644 (file)
index 0000000..b87f5f5
--- /dev/null
@@ -0,0 +1,68 @@
+From f8659469d26416d5c847ed8e411fcc3ba4d8d546 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 27 Feb 2023 08:33:36 +0000
+Subject: tcp: tcp_check_req() can be called from process context
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 580f98cc33a260bb8c6a39ae2921b29586b84fdf ]
+
+This is a follow up of commit 0a375c822497 ("tcp: tcp_rtx_synack()
+can be called from process context").
+
+Frederick Lawler reported another "__this_cpu_add() in preemptible"
+warning caused by the same reason.
+
+In my former patch I took care of tcp_rtx_synack()
+but forgot that tcp_check_req() also contained some SNMP updates.
+
+Note that some parts of tcp_check_req() always run in BH context,
+I added a comment to clarify this.
+
+Fixes: 8336886f786f ("tcp: TCP Fast Open Server - support TFO listeners")
+Link: https://lore.kernel.org/netdev/8cd33923-a21d-397c-e46b-2a068c287b03@cloudflare.com/T/
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reported-by: Frederick Lawler <fred@cloudflare.com>
+Tested-by: Frederick Lawler <fred@cloudflare.com>
+Link: https://lore.kernel.org/r/20230227083336.4153089-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/tcp_minisocks.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
+index 41368e77fbb81..aa67d5adcbca9 100644
+--- a/net/ipv4/tcp_minisocks.c
++++ b/net/ipv4/tcp_minisocks.c
+@@ -565,6 +565,9 @@ EXPORT_SYMBOL(tcp_create_openreq_child);
+  * validation and inside tcp_v4_reqsk_send_ack(). Can we do better?
+  *
+  * We don't need to initialize tmp_opt.sack_ok as we don't use the results
++ *
++ * Note: If @fastopen is true, this can be called from process context.
++ *       Otherwise, this is from BH context.
+  */
+ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
+@@ -717,7 +720,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
+                                         &tcp_rsk(req)->last_oow_ack_time))
+                       req->rsk_ops->send_ack(sk, skb, req);
+               if (paws_reject)
+-                      __NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED);
++                      NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED);
+               return NULL;
+       }
+@@ -736,7 +739,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
+        *         "fourth, check the SYN bit"
+        */
+       if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN)) {
+-              __TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
++              TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
+               goto embryonic_reset;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/thermal-intel-bxt_pmic-select-regmap-instead-of-depe.patch b/queue-5.15/thermal-intel-bxt_pmic-select-regmap-instead-of-depe.patch
new file mode 100644 (file)
index 0000000..b790497
--- /dev/null
@@ -0,0 +1,43 @@
+From f3d6b0c44e86fcdae61947f4eabf5848c71e4287 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 25 Feb 2023 21:39:52 -0800
+Subject: thermal: intel: BXT_PMIC: select REGMAP instead of depending on it
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+[ Upstream commit 1467fb960349dfa5e300658f1a409dde2cfb0c51 ]
+
+REGMAP is a hidden (not user visible) symbol. Users cannot set it
+directly thru "make *config", so drivers should select it instead of
+depending on it if they need it.
+
+Consistently using "select" or "depends on" can also help reduce
+Kconfig circular dependency issues.
+
+Therefore, change the use of "depends on REGMAP" to "select REGMAP".
+
+Fixes: b474303ffd57 ("thermal: add Intel BXT WhiskeyCove PMIC thermal driver")
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/thermal/intel/Kconfig | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/thermal/intel/Kconfig b/drivers/thermal/intel/Kconfig
+index c83ea5d04a1da..e0d65e450c89e 100644
+--- a/drivers/thermal/intel/Kconfig
++++ b/drivers/thermal/intel/Kconfig
+@@ -64,7 +64,8 @@ endmenu
+ config INTEL_BXT_PMIC_THERMAL
+       tristate "Intel Broxton PMIC thermal driver"
+-      depends on X86 && INTEL_SOC_PMIC_BXTWC && REGMAP
++      depends on X86 && INTEL_SOC_PMIC_BXTWC
++      select REGMAP
+       help
+         Select this driver for Intel Broxton PMIC with ADC channels monitoring
+         system temperature measurements and alerts.
+-- 
+2.39.2
+
diff --git a/queue-5.15/thermal-intel-quark_dts-fix-error-pointer-dereferenc.patch b/queue-5.15/thermal-intel-quark_dts-fix-error-pointer-dereferenc.patch
new file mode 100644 (file)
index 0000000..cd9fcb6
--- /dev/null
@@ -0,0 +1,52 @@
+From a5a822053b302720d2df06701889656fcd9bc474 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 27 Feb 2023 13:06:50 +0300
+Subject: thermal: intel: quark_dts: fix error pointer dereference
+
+From: Dan Carpenter <error27@gmail.com>
+
+[ Upstream commit f1b930e740811d416de4d2074da48b6633a672c8 ]
+
+If alloc_soc_dts() fails, then we can just return.  Trying to free
+"soc_dts" will lead to an Oops.
+
+Fixes: 8c1876939663 ("thermal: intel Quark SoC X1000 DTS thermal driver")
+Signed-off-by: Dan Carpenter <error27@gmail.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/thermal/intel/intel_quark_dts_thermal.c | 12 ++----------
+ 1 file changed, 2 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c
+index 3eafc6b0e6c30..b43fbd5eaa6b4 100644
+--- a/drivers/thermal/intel/intel_quark_dts_thermal.c
++++ b/drivers/thermal/intel/intel_quark_dts_thermal.c
+@@ -415,22 +415,14 @@ MODULE_DEVICE_TABLE(x86cpu, qrk_thermal_ids);
+ static int __init intel_quark_thermal_init(void)
+ {
+-      int err = 0;
+-
+       if (!x86_match_cpu(qrk_thermal_ids) || !iosf_mbi_available())
+               return -ENODEV;
+       soc_dts = alloc_soc_dts();
+-      if (IS_ERR(soc_dts)) {
+-              err = PTR_ERR(soc_dts);
+-              goto err_free;
+-      }
++      if (IS_ERR(soc_dts))
++              return PTR_ERR(soc_dts);
+       return 0;
+-
+-err_free:
+-      free_soc_dts(soc_dts);
+-      return err;
+ }
+ static void __exit intel_quark_thermal_exit(void)
+-- 
+2.39.2
+
diff --git a/queue-5.15/tools-iio-iio_utils-fix-memory-leak.patch b/queue-5.15/tools-iio-iio_utils-fix-memory-leak.patch
new file mode 100644 (file)
index 0000000..189411f
--- /dev/null
@@ -0,0 +1,154 @@
+From c94e6bf1595db170d5eedcf6e15e21b25bde363e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 17 Jan 2023 10:51:47 +0800
+Subject: tools/iio/iio_utils:fix memory leak
+
+From: Yulong Zhang <yulong.zhang@metoak.net>
+
+[ Upstream commit f2edf0c819a4823cd6c288801ce737e8d4fcde06 ]
+
+1. fopen sysfs without fclose.
+2. asprintf filename without free.
+3. if asprintf return error,do not need to free the buffer.
+
+Signed-off-by: Yulong Zhang <yulong.zhang@metoak.net>
+Link: https://lore.kernel.org/r/20230117025147.69890-1-yulong.zhang@metoak.net
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/iio/iio_utils.c | 23 ++++++-----------------
+ 1 file changed, 6 insertions(+), 17 deletions(-)
+
+diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
+index 8d35893b2fa85..6a00a6eecaef0 100644
+--- a/tools/iio/iio_utils.c
++++ b/tools/iio/iio_utils.c
+@@ -264,6 +264,7 @@ int iioutils_get_param_float(float *output, const char *param_name,
+                       if (fscanf(sysfsfp, "%f", output) != 1)
+                               ret = errno ? -errno : -ENODATA;
++                      fclose(sysfsfp);
+                       break;
+               }
+ error_free_filename:
+@@ -345,9 +346,9 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                       }
+                       sysfsfp = fopen(filename, "r");
++                      free(filename);
+                       if (!sysfsfp) {
+                               ret = -errno;
+-                              free(filename);
+                               goto error_close_dir;
+                       }
+@@ -357,7 +358,6 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                               if (fclose(sysfsfp))
+                                       perror("build_channel_array(): Failed to close file");
+-                              free(filename);
+                               goto error_close_dir;
+                       }
+                       if (ret == 1)
+@@ -365,11 +365,9 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                       if (fclose(sysfsfp)) {
+                               ret = -errno;
+-                              free(filename);
+                               goto error_close_dir;
+                       }
+-                      free(filename);
+               }
+       *ci_array = malloc(sizeof(**ci_array) * (*counter));
+@@ -395,9 +393,9 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                       }
+                       sysfsfp = fopen(filename, "r");
++                      free(filename);
+                       if (!sysfsfp) {
+                               ret = -errno;
+-                              free(filename);
+                               count--;
+                               goto error_cleanup_array;
+                       }
+@@ -405,20 +403,17 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                       errno = 0;
+                       if (fscanf(sysfsfp, "%i", &current_enabled) != 1) {
+                               ret = errno ? -errno : -ENODATA;
+-                              free(filename);
+                               count--;
+                               goto error_cleanup_array;
+                       }
+                       if (fclose(sysfsfp)) {
+                               ret = -errno;
+-                              free(filename);
+                               count--;
+                               goto error_cleanup_array;
+                       }
+                       if (!current_enabled) {
+-                              free(filename);
+                               count--;
+                               continue;
+                       }
+@@ -429,7 +424,6 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                                               strlen(ent->d_name) -
+                                               strlen("_en"));
+                       if (!current->name) {
+-                              free(filename);
+                               ret = -ENOMEM;
+                               count--;
+                               goto error_cleanup_array;
+@@ -439,7 +433,6 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                       ret = iioutils_break_up_name(current->name,
+                                                    &current->generic_name);
+                       if (ret) {
+-                              free(filename);
+                               free(current->name);
+                               count--;
+                               goto error_cleanup_array;
+@@ -450,17 +443,16 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                                      scan_el_dir,
+                                      current->name);
+                       if (ret < 0) {
+-                              free(filename);
+                               ret = -ENOMEM;
+                               goto error_cleanup_array;
+                       }
+                       sysfsfp = fopen(filename, "r");
++                      free(filename);
+                       if (!sysfsfp) {
+                               ret = -errno;
+-                              fprintf(stderr, "failed to open %s\n",
+-                                      filename);
+-                              free(filename);
++                              fprintf(stderr, "failed to open %s/%s_index\n",
++                                      scan_el_dir, current->name);
+                               goto error_cleanup_array;
+                       }
+@@ -470,17 +462,14 @@ int build_channel_array(const char *device_dir, int buffer_idx,
+                               if (fclose(sysfsfp))
+                                       perror("build_channel_array(): Failed to close file");
+-                              free(filename);
+                               goto error_cleanup_array;
+                       }
+                       if (fclose(sysfsfp)) {
+                               ret = -errno;
+-                              free(filename);
+                               goto error_cleanup_array;
+                       }
+-                      free(filename);
+                       /* Find the scale */
+                       ret = iioutils_get_param_float(&current->scale,
+                                                      "scale",
+-- 
+2.39.2
+
diff --git a/queue-5.15/tracing-add-null-checks-for-buffer-in-ring_buffer_fr.patch b/queue-5.15/tracing-add-null-checks-for-buffer-in-ring_buffer_fr.patch
new file mode 100644 (file)
index 0000000..a95f179
--- /dev/null
@@ -0,0 +1,62 @@
+From 29ebff16cdcf25288001ae46a757fe4a40de3893 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 13 Jan 2023 20:55:01 +0800
+Subject: tracing: Add NULL checks for buffer in ring_buffer_free_read_page()
+
+From: Jia-Ju Bai <baijiaju1990@gmail.com>
+
+[ Upstream commit 3e4272b9954094907f16861199728f14002fcaf6 ]
+
+In a previous commit 7433632c9ff6, buffer, buffer->buffers and
+buffer->buffers[cpu] in ring_buffer_wake_waiters() can be NULL,
+and thus the related checks are added.
+
+However, in the same call stack, these variables are also used in
+ring_buffer_free_read_page():
+
+tracing_buffers_release()
+  ring_buffer_wake_waiters(iter->array_buffer->buffer)
+    cpu_buffer = buffer->buffers[cpu] -> Add checks by previous commit
+  ring_buffer_free_read_page(iter->array_buffer->buffer)
+    cpu_buffer = buffer->buffers[cpu] -> No check
+
+Thus, to avod possible null-pointer derefernces, the related checks
+should be added.
+
+These results are reported by a static tool designed by myself.
+
+Link: https://lkml.kernel.org/r/20230113125501.760324-1-baijiaju1990@gmail.com
+
+Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
+Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
+Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/trace/ring_buffer.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
+index 4590556963551..58b8e8b1fea2e 100644
+--- a/kernel/trace/ring_buffer.c
++++ b/kernel/trace/ring_buffer.c
+@@ -5546,11 +5546,16 @@ EXPORT_SYMBOL_GPL(ring_buffer_alloc_read_page);
+  */
+ void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu, void *data)
+ {
+-      struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
++      struct ring_buffer_per_cpu *cpu_buffer;
+       struct buffer_data_page *bpage = data;
+       struct page *page = virt_to_page(bpage);
+       unsigned long flags;
++      if (!buffer || !buffer->buffers || !buffer->buffers[cpu])
++              return;
++
++      cpu_buffer = buffer->buffers[cpu];
++
+       /* If the page is still in use someplace else, we can't reuse it */
+       if (page_ref_count(page) > 1)
+               goto out;
+-- 
+2.39.2
+
diff --git a/queue-5.15/tty-fix-out-of-bounds-access-in-tty_driver_lookup_tt.patch b/queue-5.15/tty-fix-out-of-bounds-access-in-tty_driver_lookup_tt.patch
new file mode 100644 (file)
index 0000000..471ecb0
--- /dev/null
@@ -0,0 +1,75 @@
+From 1394d814565ec14a73218fd32bfea02b99236226 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 9 Dec 2022 12:27:36 +0100
+Subject: tty: fix out-of-bounds access in tty_driver_lookup_tty()
+
+From: Sven Schnelle <svens@linux.ibm.com>
+
+[ Upstream commit db4df8e9d79e7d37732c1a1b560958e8dadfefa1 ]
+
+When specifying an invalid console= device like console=tty3270,
+tty_driver_lookup_tty() returns the tty struct without checking
+whether index is a valid number.
+
+To reproduce:
+
+qemu-system-x86_64 -enable-kvm -nographic -serial mon:stdio \
+-kernel ../linux-build-x86/arch/x86/boot/bzImage \
+-append "console=ttyS0 console=tty3270"
+
+This crashes with:
+
+[    0.770599] BUG: kernel NULL pointer dereference, address: 00000000000000ef
+[    0.771265] #PF: supervisor read access in kernel mode
+[    0.771773] #PF: error_code(0x0000) - not-present page
+[    0.772609] Oops: 0000 [#1] PREEMPT SMP PTI
+[    0.774878] RIP: 0010:tty_open+0x268/0x6f0
+[    0.784013]  chrdev_open+0xbd/0x230
+[    0.784444]  ? cdev_device_add+0x80/0x80
+[    0.784920]  do_dentry_open+0x1e0/0x410
+[    0.785389]  path_openat+0xca9/0x1050
+[    0.785813]  do_filp_open+0xaa/0x150
+[    0.786240]  file_open_name+0x133/0x1b0
+[    0.786746]  filp_open+0x27/0x50
+[    0.787244]  console_on_rootfs+0x14/0x4d
+[    0.787800]  kernel_init_freeable+0x1e4/0x20d
+[    0.788383]  ? rest_init+0xc0/0xc0
+[    0.788881]  kernel_init+0x11/0x120
+[    0.789356]  ret_from_fork+0x22/0x30
+
+Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
+Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
+Link: https://lore.kernel.org/r/20221209112737.3222509-2-svens@linux.ibm.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/tty_io.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
+index 6616d4a0d41de..64dd6439d1797 100644
+--- a/drivers/tty/tty_io.c
++++ b/drivers/tty/tty_io.c
+@@ -1244,14 +1244,16 @@ static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
+ {
+       struct tty_struct *tty;
+-      if (driver->ops->lookup)
++      if (driver->ops->lookup) {
+               if (!file)
+                       tty = ERR_PTR(-EIO);
+               else
+                       tty = driver->ops->lookup(driver, file, idx);
+-      else
++      } else {
++              if (idx >= driver->num)
++                      return ERR_PTR(-EINVAL);
+               tty = driver->ttys[idx];
+-
++      }
+       if (!IS_ERR(tty))
+               tty_kref_get(tty);
+       return tty;
+-- 
+2.39.2
+
diff --git a/queue-5.15/tty-pcn_uart-fix-memory-leak-with-using-debugfs_look.patch b/queue-5.15/tty-pcn_uart-fix-memory-leak-with-using-debugfs_look.patch
new file mode 100644 (file)
index 0000000..b24f589
--- /dev/null
@@ -0,0 +1,38 @@
+From b2adabe807543404ae8399c50463134628319507 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 15:12:21 +0100
+Subject: tty: pcn_uart: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 04a189c720aa2b6091442113ce9b9bc93552dff8 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Jiri Slaby <jirislaby@kernel.org>
+Link: https://lore.kernel.org/r/20230202141221.2293012-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/pch_uart.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
+index 49bc5a4b28327..e783a4225bf04 100644
+--- a/drivers/tty/serial/pch_uart.c
++++ b/drivers/tty/serial/pch_uart.c
+@@ -1821,7 +1821,7 @@ static void pch_uart_exit_port(struct eg20t_port *priv)
+       char name[32];
+       snprintf(name, sizeof(name), "uart%d_regs", priv->port.line);
+-      debugfs_remove(debugfs_lookup(name, NULL));
++      debugfs_lookup_and_remove(name, NULL);
+       uart_remove_one_port(&pch_uart_driver, &priv->port);
+       free_page((unsigned long)priv->rxbuf.buf);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/tty-serial-fsl_lpuart-disable-the-cts-when-send-brea.patch b/queue-5.15/tty-serial-fsl_lpuart-disable-the-cts-when-send-brea.patch
new file mode 100644 (file)
index 0000000..24ffc1b
--- /dev/null
@@ -0,0 +1,76 @@
+From bbba80a6798e4e2b3fb167eddeeadd33f395b1cc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 14 Dec 2022 11:11:35 +0800
+Subject: tty: serial: fsl_lpuart: disable the CTS when send break signal
+
+From: Sherry Sun <sherry.sun@nxp.com>
+
+[ Upstream commit c4c81db5cf8bc53d6160c3abf26d382c841aa434 ]
+
+LPUART IP has a bug that it treats the CTS as higher priority than the
+break signal, which cause the break signal sending through UARTCTRL_SBK
+may impacted by the CTS input if the HW flow control is enabled.
+
+Add this workaround patch to fix the IP bug, we can disable CTS before
+asserting SBK to avoid any interference from CTS, and re-enable it when
+break off.
+
+Such as for the bluetooth chip power save feature, host can let the BT
+chip get into sleep state by sending a UART break signal, and wake it up
+by turning off the UART break. If the BT chip enters the sleep mode
+successfully, it will pull up the CTS line, if the BT chip is woken up,
+it will pull down the CTS line. If without this workaround patch, the
+UART TX pin cannot send the break signal successfully as it affected by
+the BT CTS pin. After adding this patch, the BT power save feature can
+work well.
+
+Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
+Link: https://lore.kernel.org/r/20221214031137.28815-2-sherry.sun@nxp.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/fsl_lpuart.c | 24 ++++++++++++++++++++++--
+ 1 file changed, 22 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
+index f4d9dc4648da4..8a1d5c5d4c09f 100644
+--- a/drivers/tty/serial/fsl_lpuart.c
++++ b/drivers/tty/serial/fsl_lpuart.c
+@@ -1484,12 +1484,32 @@ static void lpuart_break_ctl(struct uart_port *port, int break_state)
+ static void lpuart32_break_ctl(struct uart_port *port, int break_state)
+ {
+-      unsigned long temp;
++      unsigned long temp, modem;
++      struct tty_struct *tty;
++      unsigned int cflag = 0;
++
++      tty = tty_port_tty_get(&port->state->port);
++      if (tty) {
++              cflag = tty->termios.c_cflag;
++              tty_kref_put(tty);
++      }
+       temp = lpuart32_read(port, UARTCTRL) & ~UARTCTRL_SBK;
++      modem = lpuart32_read(port, UARTMODIR);
+-      if (break_state != 0)
++      if (break_state != 0) {
+               temp |= UARTCTRL_SBK;
++              /*
++               * LPUART CTS has higher priority than SBK, need to disable CTS before
++               * asserting SBK to avoid any interference if flow control is enabled.
++               */
++              if (cflag & CRTSCTS && modem & UARTMODIR_TXCTSE)
++                      lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR);
++      } else {
++              /* Re-enable the CTS when break off. */
++              if (cflag & CRTSCTS && !(modem & UARTMODIR_TXCTSE))
++                      lpuart32_write(port, modem | UARTMODIR_TXCTSE, UARTMODIR);
++      }
+       lpuart32_write(port, temp, UARTCTRL);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-ensure-that-vid-header-offset-vid-header-size-al.patch b/queue-5.15/ubi-ensure-that-vid-header-offset-vid-header-size-al.patch
new file mode 100644 (file)
index 0000000..74c6e41
--- /dev/null
@@ -0,0 +1,131 @@
+From 33a1aac9a81f9407e05c9f790e419717b4a314ed Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Nov 2022 10:14:44 -0500
+Subject: ubi: ensure that VID header offset + VID header size <= alloc, size
+
+From: George Kennedy <george.kennedy@oracle.com>
+
+[ Upstream commit 1b42b1a36fc946f0d7088425b90d491b4257ca3e ]
+
+Ensure that the VID header offset + VID header size does not exceed
+the allocated area to avoid slab OOB.
+
+BUG: KASAN: slab-out-of-bounds in crc32_body lib/crc32.c:111 [inline]
+BUG: KASAN: slab-out-of-bounds in crc32_le_generic lib/crc32.c:179 [inline]
+BUG: KASAN: slab-out-of-bounds in crc32_le_base+0x58c/0x626 lib/crc32.c:197
+Read of size 4 at addr ffff88802bb36f00 by task syz-executor136/1555
+
+CPU: 2 PID: 1555 Comm: syz-executor136 Tainted: G        W
+6.0.0-1868 #1
+Hardware name: Red Hat KVM, BIOS 1.13.0-2.module+el8.3.0+7860+a7792d29
+04/01/2014
+Call Trace:
+  <TASK>
+  __dump_stack lib/dump_stack.c:88 [inline]
+  dump_stack_lvl+0x85/0xad lib/dump_stack.c:106
+  print_address_description mm/kasan/report.c:317 [inline]
+  print_report.cold.13+0xb6/0x6bb mm/kasan/report.c:433
+  kasan_report+0xa7/0x11b mm/kasan/report.c:495
+  crc32_body lib/crc32.c:111 [inline]
+  crc32_le_generic lib/crc32.c:179 [inline]
+  crc32_le_base+0x58c/0x626 lib/crc32.c:197
+  ubi_io_write_vid_hdr+0x1b7/0x472 drivers/mtd/ubi/io.c:1067
+  create_vtbl+0x4d5/0x9c4 drivers/mtd/ubi/vtbl.c:317
+  create_empty_lvol drivers/mtd/ubi/vtbl.c:500 [inline]
+  ubi_read_volume_table+0x67b/0x288a drivers/mtd/ubi/vtbl.c:812
+  ubi_attach+0xf34/0x1603 drivers/mtd/ubi/attach.c:1601
+  ubi_attach_mtd_dev+0x6f3/0x185e drivers/mtd/ubi/build.c:965
+  ctrl_cdev_ioctl+0x2db/0x347 drivers/mtd/ubi/cdev.c:1043
+  vfs_ioctl fs/ioctl.c:51 [inline]
+  __do_sys_ioctl fs/ioctl.c:870 [inline]
+  __se_sys_ioctl fs/ioctl.c:856 [inline]
+  __x64_sys_ioctl+0x193/0x213 fs/ioctl.c:856
+  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+  do_syscall_64+0x3e/0x86 arch/x86/entry/common.c:80
+  entry_SYSCALL_64_after_hwframe+0x63/0x0
+RIP: 0033:0x7f96d5cf753d
+Code:
+RSP: 002b:00007fffd72206f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
+RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f96d5cf753d
+RDX: 0000000020000080 RSI: 0000000040186f40 RDI: 0000000000000003
+RBP: 0000000000400cd0 R08: 0000000000000000 R09: 0000000000000000
+R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000400be0
+R13: 00007fffd72207e0 R14: 0000000000000000 R15: 0000000000000000
+  </TASK>
+
+Allocated by task 1555:
+  kasan_save_stack+0x20/0x3d mm/kasan/common.c:38
+  kasan_set_track mm/kasan/common.c:45 [inline]
+  set_alloc_info mm/kasan/common.c:437 [inline]
+  ____kasan_kmalloc mm/kasan/common.c:516 [inline]
+  __kasan_kmalloc+0x88/0xa3 mm/kasan/common.c:525
+  kasan_kmalloc include/linux/kasan.h:234 [inline]
+  __kmalloc+0x138/0x257 mm/slub.c:4429
+  kmalloc include/linux/slab.h:605 [inline]
+  ubi_alloc_vid_buf drivers/mtd/ubi/ubi.h:1093 [inline]
+  create_vtbl+0xcc/0x9c4 drivers/mtd/ubi/vtbl.c:295
+  create_empty_lvol drivers/mtd/ubi/vtbl.c:500 [inline]
+  ubi_read_volume_table+0x67b/0x288a drivers/mtd/ubi/vtbl.c:812
+  ubi_attach+0xf34/0x1603 drivers/mtd/ubi/attach.c:1601
+  ubi_attach_mtd_dev+0x6f3/0x185e drivers/mtd/ubi/build.c:965
+  ctrl_cdev_ioctl+0x2db/0x347 drivers/mtd/ubi/cdev.c:1043
+  vfs_ioctl fs/ioctl.c:51 [inline]
+  __do_sys_ioctl fs/ioctl.c:870 [inline]
+  __se_sys_ioctl fs/ioctl.c:856 [inline]
+  __x64_sys_ioctl+0x193/0x213 fs/ioctl.c:856
+  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+  do_syscall_64+0x3e/0x86 arch/x86/entry/common.c:80
+  entry_SYSCALL_64_after_hwframe+0x63/0x0
+
+The buggy address belongs to the object at ffff88802bb36e00
+  which belongs to the cache kmalloc-256 of size 256
+The buggy address is located 0 bytes to the right of
+  256-byte region [ffff88802bb36e00, ffff88802bb36f00)
+
+The buggy address belongs to the physical page:
+page:00000000ea4d1263 refcount:1 mapcount:0 mapping:0000000000000000
+index:0x0 pfn:0x2bb36
+head:00000000ea4d1263 order:1 compound_mapcount:0 compound_pincount:0
+flags: 0xfffffc0010200(slab|head|node=0|zone=1|lastcpupid=0x1fffff)
+raw: 000fffffc0010200 ffffea000066c300 dead000000000003 ffff888100042b40
+raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
+page dumped because: kasan: bad access detected
+
+Memory state around the buggy address:
+  ffff88802bb36e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  ffff88802bb36e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+>ffff88802bb36f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
+                    ^
+  ffff88802bb36f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
+  ffff88802bb37000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
+==================================================================
+
+Fixes: 801c135ce73d ("UBI: Unsorted Block Images")
+Reported-by: syzkaller <syzkaller@googlegroups.com>
+Signed-off-by: George Kennedy <george.kennedy@oracle.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/build.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
+index a32050fecabf3..53aa4de6b963f 100644
+--- a/drivers/mtd/ubi/build.c
++++ b/drivers/mtd/ubi/build.c
+@@ -663,6 +663,12 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
+       ubi->ec_hdr_alsize = ALIGN(UBI_EC_HDR_SIZE, ubi->hdrs_min_io_size);
+       ubi->vid_hdr_alsize = ALIGN(UBI_VID_HDR_SIZE, ubi->hdrs_min_io_size);
++      if (ubi->vid_hdr_offset && ((ubi->vid_hdr_offset + UBI_VID_HDR_SIZE) >
++          ubi->vid_hdr_alsize)) {
++              ubi_err(ubi, "VID header offset %d too large.", ubi->vid_hdr_offset);
++              return -EINVAL;
++      }
++
+       dbg_gen("min_io_size      %d", ubi->min_io_size);
+       dbg_gen("max_write_size   %d", ubi->max_write_size);
+       dbg_gen("hdrs_min_io_size %d", ubi->hdrs_min_io_size);
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-fastmap-fix-missed-fm_anchor-peb-in-wear-levelin.patch b/queue-5.15/ubi-fastmap-fix-missed-fm_anchor-peb-in-wear-levelin.patch
new file mode 100644 (file)
index 0000000..775d3ff
--- /dev/null
@@ -0,0 +1,64 @@
+From d4860a9225e1f541f174e2490db977387342edb3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 9 Aug 2022 15:06:19 +0800
+Subject: ubi: fastmap: Fix missed fm_anchor PEB in wear-leveling after
+ disabling fastmap
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit 76f9476ece445a07aeb72df9d896cd563fb5b50f ]
+
+After disabling fastmap(ubi->fm_disabled = 1), fastmap won't be updated,
+fm_anchor PEB is missed being scheduled for erasing. Besides, fm_anchor
+PEB may have smallest erase count, it doesn't participate wear-leveling.
+The difference of erase count between fm_anchor PEB and other PEBs will
+be larger and larger later on.
+
+In which situation fastmap can be disabled? Initially, we have an UBI
+image with fastmap. Then the image will be atttached without module
+parameter 'fm_autoconvert', ubi turns to full scanning mode in one
+random attaching process(eg. bad fastmap caused by powercut), ubi
+fastmap is disabled since then.
+
+Fix it by not getting fm_anchor if fastmap is disabled in
+ubi_refill_pools().
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216341
+Fixes: 4b68bf9a69d22d ("ubi: Select fastmap anchor PEBs considering ...")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/fastmap-wl.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
+index 053ab52668e8b..69592be33adfc 100644
+--- a/drivers/mtd/ubi/fastmap-wl.c
++++ b/drivers/mtd/ubi/fastmap-wl.c
+@@ -146,13 +146,15 @@ void ubi_refill_pools(struct ubi_device *ubi)
+       if (ubi->fm_anchor) {
+               wl_tree_add(ubi->fm_anchor, &ubi->free);
+               ubi->free_count++;
++              ubi->fm_anchor = NULL;
+       }
+-      /*
+-       * All available PEBs are in ubi->free, now is the time to get
+-       * the best anchor PEBs.
+-       */
+-      ubi->fm_anchor = ubi_wl_get_fm_peb(ubi, 1);
++      if (!ubi->fm_disabled)
++              /*
++               * All available PEBs are in ubi->free, now is the time to get
++               * the best anchor PEBs.
++               */
++              ubi->fm_anchor = ubi_wl_get_fm_peb(ubi, 1);
+       for (;;) {
+               enough = 0;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-fix-possible-null-ptr-deref-in-ubi_free_volume.patch b/queue-5.15/ubi-fix-possible-null-ptr-deref-in-ubi_free_volume.patch
new file mode 100644 (file)
index 0000000..55573fb
--- /dev/null
@@ -0,0 +1,89 @@
+From b71d8f01dce36b8a110d77a56f2366b6b4e3bd1e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 14 Nov 2022 18:26:24 +0800
+Subject: ubi: Fix possible null-ptr-deref in ubi_free_volume()
+
+From: Yang Yingliang <yangyingliang@huawei.com>
+
+[ Upstream commit c15859bfd326c10230f09cb48a17f8a35f190342 ]
+
+It willl cause null-ptr-deref in the following case:
+
+uif_init()
+  ubi_add_volume()
+    cdev_add() -> if it fails, call kill_volumes()
+    device_register()
+
+kill_volumes() -> if ubi_add_volume() fails call this function
+  ubi_free_volume()
+    cdev_del()
+    device_unregister() -> trying to delete a not added device,
+                          it causes null-ptr-deref
+
+So in ubi_free_volume(), it delete devices whether they are added
+or not, it will causes null-ptr-deref.
+
+Handle the error case whlie calling ubi_add_volume() to fix this
+problem. If add volume fails, set the corresponding vol to null,
+so it can not be accessed in kill_volumes() and release the
+resource in ubi_add_volume() error path.
+
+Fixes: 801c135ce73d ("UBI: Unsorted Block Images")
+Suggested-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/build.c |  1 +
+ drivers/mtd/ubi/vmt.c   | 12 ++++++------
+ 2 files changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
+index 53aa4de6b963f..3499ff2649d54 100644
+--- a/drivers/mtd/ubi/build.c
++++ b/drivers/mtd/ubi/build.c
+@@ -468,6 +468,7 @@ static int uif_init(struct ubi_device *ubi)
+                       err = ubi_add_volume(ubi, ubi->volumes[i]);
+                       if (err) {
+                               ubi_err(ubi, "cannot add volume %d", i);
++                              ubi->volumes[i] = NULL;
+                               goto out_volumes;
+                       }
+               }
+diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
+index 2e5bd473e5e25..d79323e8ea29d 100644
+--- a/drivers/mtd/ubi/vmt.c
++++ b/drivers/mtd/ubi/vmt.c
+@@ -582,6 +582,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
+       if (err) {
+               ubi_err(ubi, "cannot add character device for volume %d, error %d",
+                       vol_id, err);
++              vol_release(&vol->dev);
+               return err;
+       }
+@@ -592,15 +593,14 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
+       vol->dev.groups = volume_dev_groups;
+       dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id);
+       err = device_register(&vol->dev);
+-      if (err)
+-              goto out_cdev;
++      if (err) {
++              cdev_del(&vol->cdev);
++              put_device(&vol->dev);
++              return err;
++      }
+       self_check_volumes(ubi);
+       return err;
+-
+-out_cdev:
+-      cdev_del(&vol->cdev);
+-      return err;
+ }
+ /**
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-fix-uaf-wear-leveling-entry-in-eraseblk_count_se.patch b/queue-5.15/ubi-fix-uaf-wear-leveling-entry-in-eraseblk_count_se.patch
new file mode 100644 (file)
index 0000000..e3fa081
--- /dev/null
@@ -0,0 +1,76 @@
+From c86c0e66e67d1570886e7604fd1191dd5bf1305a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 30 Jul 2022 19:28:37 +0800
+Subject: ubi: Fix UAF wear-leveling entry in eraseblk_count_seq_show()
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit a240bc5c43130c6aa50831d7caaa02a1d84e1bce ]
+
+Wear-leveling entry could be freed in error path, which may be accessed
+again in eraseblk_count_seq_show(), for example:
+
+__erase_worker                eraseblk_count_seq_show
+                                wl = ubi->lookuptbl[*block_number]
+                               if (wl)
+  wl_entry_destroy
+    ubi->lookuptbl[e->pnum] = NULL
+    kmem_cache_free(ubi_wl_entry_slab, e)
+                                  erase_count = wl->ec  // UAF!
+
+Wear-leveling entry updating/accessing in ubi->lookuptbl should be
+protected by ubi->wl_lock, fix it by adding ubi->wl_lock to serialize
+wl entry accessing between wl_entry_destroy() and
+eraseblk_count_seq_show().
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216305
+Fixes: 7bccd12d27b7e3 ("ubi: Add debugfs file for tracking PEB state")
+Fixes: 801c135ce73d5d ("UBI: Unsorted Block Images")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/wl.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
+index afcdacb9d0e99..4a672e925d869 100644
+--- a/drivers/mtd/ubi/wl.c
++++ b/drivers/mtd/ubi/wl.c
+@@ -886,8 +886,11 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
+       err = do_sync_erase(ubi, e1, vol_id, lnum, 0);
+       if (err) {
+-              if (e2)
++              if (e2) {
++                      spin_lock(&ubi->wl_lock);
+                       wl_entry_destroy(ubi, e2);
++                      spin_unlock(&ubi->wl_lock);
++              }
+               goto out_ro;
+       }
+@@ -1120,14 +1123,18 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)
+               /* Re-schedule the LEB for erasure */
+               err1 = schedule_erase(ubi, e, vol_id, lnum, 0, false);
+               if (err1) {
++                      spin_lock(&ubi->wl_lock);
+                       wl_entry_destroy(ubi, e);
++                      spin_unlock(&ubi->wl_lock);
+                       err = err1;
+                       goto out_ro;
+               }
+               return err;
+       }
++      spin_lock(&ubi->wl_lock);
+       wl_entry_destroy(ubi, e);
++      spin_unlock(&ubi->wl_lock);
+       if (err != -EIO)
+               /*
+                * If this is not %-EIO, we have no idea what to do. Scheduling
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-fix-unreferenced-object-reported-by-kmemleak-in-.patch b/queue-5.15/ubi-fix-unreferenced-object-reported-by-kmemleak-in-.patch
new file mode 100644 (file)
index 0000000..5b47c3e
--- /dev/null
@@ -0,0 +1,59 @@
+From 4f4b52f0db35c2d2ffa9dfd569cbccee2a02b8d6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 Oct 2022 18:21:57 +0800
+Subject: ubi: Fix unreferenced object reported by kmemleak in
+ ubi_resize_volume()
+
+From: Li Zetao <lizetao1@huawei.com>
+
+[ Upstream commit 1e591ea072df7211f64542a09482b5f81cb3ad27 ]
+
+There is a memory leaks problem reported by kmemleak:
+
+unreferenced object 0xffff888102007a00 (size 128):
+  comm "ubirsvol", pid 32090, jiffies 4298464136 (age 2361.231s)
+  hex dump (first 32 bytes):
+ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
+ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
+  backtrace:
+[<ffffffff8176cecd>] __kmalloc+0x4d/0x150
+[<ffffffffa02a9a36>] ubi_eba_create_table+0x76/0x170 [ubi]
+[<ffffffffa029764e>] ubi_resize_volume+0x1be/0xbc0 [ubi]
+[<ffffffffa02a3321>] ubi_cdev_ioctl+0x701/0x1850 [ubi]
+[<ffffffff81975d2d>] __x64_sys_ioctl+0x11d/0x170
+[<ffffffff83c142a5>] do_syscall_64+0x35/0x80
+[<ffffffff83e0006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
+
+This is due to a mismatch between create and destroy interfaces, and
+in detail that "new_eba_tbl" created by ubi_eba_create_table() but
+destroyed by kfree(), while will causing "new_eba_tbl->entries" not
+freed.
+
+Fix it by replacing kfree(new_eba_tbl) with
+ubi_eba_destroy_table(new_eba_tbl)
+
+Fixes: 799dca34ac54 ("UBI: hide EBA internals")
+Signed-off-by: Li Zetao <lizetao1@huawei.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/vmt.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
+index 6c7822c1cc451..2e5bd473e5e25 100644
+--- a/drivers/mtd/ubi/vmt.c
++++ b/drivers/mtd/ubi/vmt.c
+@@ -515,7 +515,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
+       return err;
+ out_free:
+-      kfree(new_eba_tbl);
++      ubi_eba_destroy_table(new_eba_tbl);
+       return err;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-fix-use-after-free-when-volume-resizing-failed.patch b/queue-5.15/ubi-fix-use-after-free-when-volume-resizing-failed.patch
new file mode 100644 (file)
index 0000000..b078d26
--- /dev/null
@@ -0,0 +1,74 @@
+From 7180a853445e445a3e2a075d0580f60c067ff19d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 Oct 2022 18:21:56 +0800
+Subject: ubi: Fix use-after-free when volume resizing failed
+
+From: Li Zetao <lizetao1@huawei.com>
+
+[ Upstream commit 9af31d6ec1a4be4caab2550096c6bd2ba8fba472 ]
+
+There is an use-after-free problem reported by KASAN:
+  ==================================================================
+  BUG: KASAN: use-after-free in ubi_eba_copy_table+0x11f/0x1c0 [ubi]
+  Read of size 8 at addr ffff888101eec008 by task ubirsvol/4735
+
+  CPU: 2 PID: 4735 Comm: ubirsvol
+  Not tainted 6.1.0-rc1-00003-g84fa3304a7fc-dirty #14
+  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
+  BIOS 1.14.0-1.fc33 04/01/2014
+  Call Trace:
+   <TASK>
+   dump_stack_lvl+0x34/0x44
+   print_report+0x171/0x472
+   kasan_report+0xad/0x130
+   ubi_eba_copy_table+0x11f/0x1c0 [ubi]
+   ubi_resize_volume+0x4f9/0xbc0 [ubi]
+   ubi_cdev_ioctl+0x701/0x1850 [ubi]
+   __x64_sys_ioctl+0x11d/0x170
+   do_syscall_64+0x35/0x80
+   entry_SYSCALL_64_after_hwframe+0x46/0xb0
+   </TASK>
+
+When ubi_change_vtbl_record() returns an error in ubi_resize_volume(),
+"new_eba_tbl" will be freed on error handing path, but it is holded
+by "vol->eba_tbl" in ubi_eba_replace_table(). It means that the liftcycle
+of "vol->eba_tbl" and "vol" are different, so when resizing volume in
+next time, it causing an use-after-free fault.
+
+Fix it by not freeing "new_eba_tbl" after it replaced in
+ubi_eba_replace_table(), while will be freed in next volume resizing.
+
+Fixes: 801c135ce73d ("UBI: Unsorted Block Images")
+Signed-off-by: Li Zetao <lizetao1@huawei.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/vmt.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
+index 6ea95ade4ca6b..6c7822c1cc451 100644
+--- a/drivers/mtd/ubi/vmt.c
++++ b/drivers/mtd/ubi/vmt.c
+@@ -464,7 +464,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
+               for (i = 0; i < -pebs; i++) {
+                       err = ubi_eba_unmap_leb(ubi, vol, reserved_pebs + i);
+                       if (err)
+-                              goto out_acc;
++                              goto out_free;
+               }
+               spin_lock(&ubi->volumes_lock);
+               ubi->rsvd_pebs += pebs;
+@@ -512,6 +512,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
+               ubi->avail_pebs += pebs;
+               spin_unlock(&ubi->volumes_lock);
+       }
++      return err;
++
+ out_free:
+       kfree(new_eba_tbl);
+       return err;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubi-ubi_wl_put_peb-fix-infinite-loop-when-wear-level.patch b/queue-5.15/ubi-ubi_wl_put_peb-fix-infinite-loop-when-wear-level.patch
new file mode 100644 (file)
index 0000000..f6add21
--- /dev/null
@@ -0,0 +1,90 @@
+From cf459d653dfb4e6be5f3394bf9d6b4aa445067e5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Jun 2022 14:59:04 +0800
+Subject: ubi: ubi_wl_put_peb: Fix infinite loop when wear-leveling work failed
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit 4d57a7333e26040f2b583983e1970d9d460e56b0 ]
+
+Following process will trigger an infinite loop in ubi_wl_put_peb():
+
+       ubifs_bgt               ubi_bgt
+ubifs_leb_unmap
+  ubi_leb_unmap
+    ubi_eba_unmap_leb
+      ubi_wl_put_peb   wear_leveling_worker
+                          e1 = rb_entry(rb_first(&ubi->used)
+                         e2 = get_peb_for_wl(ubi)
+                         ubi_io_read_vid_hdr  // return err (flash fault)
+                         out_error:
+                           ubi->move_from = ubi->move_to = NULL
+                           wl_entry_destroy(ubi, e1)
+                             ubi->lookuptbl[e->pnum] = NULL
+      retry:
+        e = ubi->lookuptbl[pnum];      // return NULL
+       if (e == ubi->move_from) {      // NULL == NULL gets true
+         goto retry;                   // infinite loop !!!
+
+$ top
+  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     COMMAND
+  7676 root     20   0       0      0      0 R 100.0  0.0  ubifs_bgt0_0
+
+Fix it by:
+ 1) Letting ubi_wl_put_peb() returns directly if wearl leveling entry has
+    been removed from 'ubi->lookuptbl'.
+ 2) Using 'ubi->wl_lock' protecting wl entry deletion to preventing an
+    use-after-free problem for wl entry in ubi_wl_put_peb().
+
+Fetch a reproducer in [Link].
+
+Fixes: 43f9b25a9cdd7b1 ("UBI: bugfix: protect from volume removal")
+Fixes: ee59ba8b064f692 ("UBI: Fix stale pointers in ubi->lookuptbl")
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216111
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/ubi/wl.c | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
+index 4a672e925d869..2ee0e60c43c2e 100644
+--- a/drivers/mtd/ubi/wl.c
++++ b/drivers/mtd/ubi/wl.c
+@@ -972,11 +972,11 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
+       spin_lock(&ubi->wl_lock);
+       ubi->move_from = ubi->move_to = NULL;
+       ubi->move_to_put = ubi->wl_scheduled = 0;
++      wl_entry_destroy(ubi, e1);
++      wl_entry_destroy(ubi, e2);
+       spin_unlock(&ubi->wl_lock);
+       ubi_free_vid_buf(vidb);
+-      wl_entry_destroy(ubi, e1);
+-      wl_entry_destroy(ubi, e2);
+ out_ro:
+       ubi_ro_mode(ubi);
+@@ -1250,6 +1250,18 @@ int ubi_wl_put_peb(struct ubi_device *ubi, int vol_id, int lnum,
+ retry:
+       spin_lock(&ubi->wl_lock);
+       e = ubi->lookuptbl[pnum];
++      if (!e) {
++              /*
++               * This wl entry has been removed for some errors by other
++               * process (eg. wear leveling worker), corresponding process
++               * (except __erase_worker, which cannot concurrent with
++               * ubi_wl_put_peb) will set ubi ro_mode at the same time,
++               * just ignore this wl entry.
++               */
++              spin_unlock(&ubi->wl_lock);
++              up_read(&ubi->fm_protect);
++              return 0;
++      }
+       if (e == ubi->move_from) {
+               /*
+                * User is putting the physical eraseblock which was selected to
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-dirty_cow_znode-fix-memleak-in-error-handling-.patch b/queue-5.15/ubifs-dirty_cow_znode-fix-memleak-in-error-handling-.patch
new file mode 100644 (file)
index 0000000..e3cb474
--- /dev/null
@@ -0,0 +1,58 @@
+From 21c9180319e5a1839ffcbd8165fcc1e4d51d933a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Nov 2022 17:02:36 +0800
+Subject: ubifs: dirty_cow_znode: Fix memleak in error handling path
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit 122deabfe1428bffe95e2bf364ff8a5059bdf089 ]
+
+Following process will cause a memleak for copied up znode:
+
+dirty_cow_znode
+  zn = copy_znode(c, znode);
+  err = insert_old_idx(c, zbr->lnum, zbr->offs);
+  if (unlikely(err))
+     return ERR_PTR(err);   // No one refers to zn.
+
+Fix it by adding copied znode back to tnc, then it will be freed
+by ubifs_destroy_tnc_subtree() while closing tnc.
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216705
+Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/tnc.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
+index 2df56bbc68657..2469f72eeaabb 100644
+--- a/fs/ubifs/tnc.c
++++ b/fs/ubifs/tnc.c
+@@ -267,11 +267,18 @@ static struct ubifs_znode *dirty_cow_znode(struct ubifs_info *c,
+       if (zbr->len) {
+               err = insert_old_idx(c, zbr->lnum, zbr->offs);
+               if (unlikely(err))
+-                      return ERR_PTR(err);
++                      /*
++                       * Obsolete znodes will be freed by tnc_destroy_cnext()
++                       * or free_obsolete_znodes(), copied up znodes should
++                       * be added back to tnc and freed by
++                       * ubifs_destroy_tnc_subtree().
++                       */
++                      goto out;
+               err = add_idx_dirt(c, zbr->lnum, zbr->len);
+       } else
+               err = 0;
++out:
+       zbr->znode = zn;
+       zbr->lnum = 0;
+       zbr->offs = 0;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-do_rename-fix-wrong-space-budget-when-target-i.patch b/queue-5.15/ubifs-do_rename-fix-wrong-space-budget-when-target-i.patch
new file mode 100644 (file)
index 0000000..9864616
--- /dev/null
@@ -0,0 +1,43 @@
+From 48dd138409247f08a6c0fd0c9b9b1271115a869d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Oct 2022 11:47:31 +0800
+Subject: ubifs: do_rename: Fix wrong space budget when target inode's nlink >
+ 1
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit 25fce616a61fc2f1821e4a9ce212d0e064707093 ]
+
+If target inode is a special file (eg. block/char device) with nlink
+count greater than 1, the inode with ui->data will be re-written on
+disk. However, UBIFS losts target inode's data_len while doing space
+budget. Bad space budget may let make_reservation() return with -ENOSPC,
+which could turn ubifs to read-only mode in do_writepage() process.
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216494
+Fixes: 1e51764a3c2ac0 ("UBIFS: add new flash file system")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/dir.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
+index f193caae69c20..e7c36e3a9b9e1 100644
+--- a/fs/ubifs/dir.c
++++ b/fs/ubifs/dir.c
+@@ -1320,6 +1320,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
+       if (unlink) {
+               ubifs_assert(c, inode_is_locked(new_inode));
++              /* Budget for old inode's data when its nlink > 1. */
++              req.dirtied_ino_d = ALIGN(ubifs_inode(new_inode)->data_len, 8);
+               err = ubifs_purge_xattrs(new_inode);
+               if (err)
+                       return err;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-fix-build-errors-as-symbol-undefined.patch b/queue-5.15/ubifs-fix-build-errors-as-symbol-undefined.patch
new file mode 100644 (file)
index 0000000..279327c
--- /dev/null
@@ -0,0 +1,49 @@
+From c4905759f75d279bba266c7a421b6b91705cef41 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 21 Nov 2022 19:18:47 +0800
+Subject: ubifs: Fix build errors as symbol undefined
+
+From: Li Hua <hucool.lihua@huawei.com>
+
+[ Upstream commit aa6d148e6d6270274e3d5a529b71c54cd329d17f ]
+
+With CONFIG_UBIFS_FS_AUTHENTICATION not set, the compiler can assume that
+ubifs_node_check_hash() is never true and drops the call to ubifs_bad_hash().
+Is CONFIG_CC_OPTIMIZE_FOR_SIZE enabled this optimization does not happen anymore.
+
+So When CONFIG_UBIFS_FS and CONFIG_CC_OPTIMIZE_FOR_SIZE is enabled but
+CONFIG_UBIFS_FS_AUTHENTICATION is not set, the build errors is as followd:
+    ERROR: modpost: "ubifs_bad_hash" [fs/ubifs/ubifs.ko] undefined!
+
+Fix it by add no-op ubifs_bad_hash() for the CONFIG_UBIFS_FS_AUTHENTICATION=n case.
+
+Fixes: 16a26b20d2af ("ubifs: authentication: Add hashes to index nodes")
+Signed-off-by: Li Hua <hucool.lihua@huawei.com>
+Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/ubifs.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
+index c38066ce9ab03..efbb4554a4a6f 100644
+--- a/fs/ubifs/ubifs.h
++++ b/fs/ubifs/ubifs.h
+@@ -1594,8 +1594,13 @@ static inline int ubifs_check_hmac(const struct ubifs_info *c,
+       return crypto_memneq(expected, got, c->hmac_desc_len);
+ }
++#ifdef CONFIG_UBIFS_FS_AUTHENTICATION
+ void ubifs_bad_hash(const struct ubifs_info *c, const void *node,
+                   const u8 *hash, int lnum, int offs);
++#else
++static inline void ubifs_bad_hash(const struct ubifs_info *c, const void *node,
++                                const u8 *hash, int lnum, int offs) {};
++#endif
+ int __ubifs_node_check_hash(const struct ubifs_info *c, const void *buf,
+                         const u8 *expected);
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-fix-memory-leak-in-alloc_wbufs.patch b/queue-5.15/ubifs-fix-memory-leak-in-alloc_wbufs.patch
new file mode 100644 (file)
index 0000000..563e859
--- /dev/null
@@ -0,0 +1,104 @@
+From e3bdbf9c3609186b3fc1cd7186d4b66e0ba84baa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 22 Oct 2022 19:52:11 +0800
+Subject: ubifs: Fix memory leak in alloc_wbufs()
+
+From: Li Zetao <lizetao1@huawei.com>
+
+[ Upstream commit 4a1ff3c5d04b9079b4f768d9a71b51c4af578dd2 ]
+
+kmemleak reported a sequence of memory leaks, and show them as following:
+
+  unreferenced object 0xffff8881575f8400 (size 1024):
+    comm "mount", pid 19625, jiffies 4297119604 (age 20.383s)
+    hex dump (first 32 bytes):
+      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
+      00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
+    backtrace:
+      [<ffffffff8176cecd>] __kmalloc+0x4d/0x150
+      [<ffffffffa0406b2b>] ubifs_mount+0x307b/0x7170 [ubifs]
+      [<ffffffff819fa8fd>] legacy_get_tree+0xed/0x1d0
+      [<ffffffff81936f2d>] vfs_get_tree+0x7d/0x230
+      [<ffffffff819b2bd4>] path_mount+0xdd4/0x17b0
+      [<ffffffff819b37aa>] __x64_sys_mount+0x1fa/0x270
+      [<ffffffff83c14295>] do_syscall_64+0x35/0x80
+      [<ffffffff83e0006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
+
+  unreferenced object 0xffff8881798a6e00 (size 512):
+    comm "mount", pid 19677, jiffies 4297121912 (age 37.816s)
+    hex dump (first 32 bytes):
+      6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
+      6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
+    backtrace:
+      [<ffffffff8176cecd>] __kmalloc+0x4d/0x150
+      [<ffffffffa0418342>] ubifs_wbuf_init+0x52/0x480 [ubifs]
+      [<ffffffffa0406ca5>] ubifs_mount+0x31f5/0x7170 [ubifs]
+      [<ffffffff819fa8fd>] legacy_get_tree+0xed/0x1d0
+      [<ffffffff81936f2d>] vfs_get_tree+0x7d/0x230
+      [<ffffffff819b2bd4>] path_mount+0xdd4/0x17b0
+      [<ffffffff819b37aa>] __x64_sys_mount+0x1fa/0x270
+      [<ffffffff83c14295>] do_syscall_64+0x35/0x80
+      [<ffffffff83e0006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
+
+The problem is that the ubifs_wbuf_init() returns an error in the
+loop which in the alloc_wbufs(), then the wbuf->buf and wbuf->inodes
+that were successfully alloced before are not freed.
+
+Fix it by adding error hanging path in alloc_wbufs() which frees
+the memory alloced before when ubifs_wbuf_init() returns an error.
+
+Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
+Signed-off-by: Li Zetao <lizetao1@huawei.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/super.c | 17 +++++++++++++----
+ 1 file changed, 13 insertions(+), 4 deletions(-)
+
+diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
+index eb05038b71911..32c1f428054b7 100644
+--- a/fs/ubifs/super.c
++++ b/fs/ubifs/super.c
+@@ -833,7 +833,7 @@ static int alloc_wbufs(struct ubifs_info *c)
+               INIT_LIST_HEAD(&c->jheads[i].buds_list);
+               err = ubifs_wbuf_init(c, &c->jheads[i].wbuf);
+               if (err)
+-                      return err;
++                      goto out_wbuf;
+               c->jheads[i].wbuf.sync_callback = &bud_wbuf_callback;
+               c->jheads[i].wbuf.jhead = i;
+@@ -841,7 +841,7 @@ static int alloc_wbufs(struct ubifs_info *c)
+               c->jheads[i].log_hash = ubifs_hash_get_desc(c);
+               if (IS_ERR(c->jheads[i].log_hash)) {
+                       err = PTR_ERR(c->jheads[i].log_hash);
+-                      goto out;
++                      goto out_log_hash;
+               }
+       }
+@@ -854,9 +854,18 @@ static int alloc_wbufs(struct ubifs_info *c)
+       return 0;
+-out:
+-      while (i--)
++out_log_hash:
++      kfree(c->jheads[i].wbuf.buf);
++      kfree(c->jheads[i].wbuf.inodes);
++
++out_wbuf:
++      while (i--) {
++              kfree(c->jheads[i].wbuf.buf);
++              kfree(c->jheads[i].wbuf.inodes);
+               kfree(c->jheads[i].log_hash);
++      }
++      kfree(c->jheads);
++      c->jheads = NULL;
+       return err;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-fix-wrong-dirty-space-budget-for-dirty-inode.patch b/queue-5.15/ubifs-fix-wrong-dirty-space-budget-for-dirty-inode.patch
new file mode 100644 (file)
index 0000000..e07c187
--- /dev/null
@@ -0,0 +1,37 @@
+From 54aa1e03d52f1c0fb18d907d0f3eb83672f4274c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Oct 2022 11:47:30 +0800
+Subject: ubifs: Fix wrong dirty space budget for dirty inode
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit b248eaf049d9cdc5eb76b59399e4d3de233f02ac ]
+
+Each dirty inode should reserve 'c->bi.inode_budget' bytes in space
+budget calculation. Currently, space budget for dirty inode reports
+more space than what UBIFS actually needs to write.
+
+Fixes: 1e51764a3c2ac0 ("UBIFS: add new flash file system")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/budget.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
+index c0b84e960b20c..bdb79be6dc0e2 100644
+--- a/fs/ubifs/budget.c
++++ b/fs/ubifs/budget.c
+@@ -403,7 +403,7 @@ static int calc_dd_growth(const struct ubifs_info *c,
+       dd_growth = req->dirtied_page ? c->bi.page_budget : 0;
+       if (req->dirtied_ino)
+-              dd_growth += c->bi.inode_budget << (req->dirtied_ino - 1);
++              dd_growth += c->bi.inode_budget * req->dirtied_ino;
+       if (req->mod_dent)
+               dd_growth += c->bi.dent_budget;
+       dd_growth += req->dirtied_ino_d;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-re-statistic-cleaned-znode-count-if-commit-fai.patch b/queue-5.15/ubifs-re-statistic-cleaned-znode-count-if-commit-fai.patch
new file mode 100644 (file)
index 0000000..77f5761
--- /dev/null
@@ -0,0 +1,86 @@
+From 4cded9e0ff1c5d912c202f129ce783811f8c8922 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 18 Nov 2022 17:02:35 +0800
+Subject: ubifs: Re-statistic cleaned znode count if commit failed
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit 944e096aa24071d3fe22822f6249d3ae309e39ea ]
+
+Dirty znodes will be written on flash in committing process with
+following states:
+
+             process A                 |  znode state
+------------------------------------------------------
+do_commit                              | DIRTY_ZNODE
+  ubifs_tnc_start_commit               | DIRTY_ZNODE
+   get_znodes_to_commit                        | DIRTY_ZNODE | COW_ZNODE
+    layout_commit                      | DIRTY_ZNODE | COW_ZNODE
+     fill_gap                           | 0
+  write master                         | 0 or OBSOLETE_ZNODE
+
+             process B                 |  znode state
+------------------------------------------------------
+do_commit                              | DIRTY_ZNODE[1]
+  ubifs_tnc_start_commit               | DIRTY_ZNODE
+   get_znodes_to_commit                        | DIRTY_ZNODE | COW_ZNODE
+  ubifs_tnc_end_commit                 | DIRTY_ZNODE | COW_ZNODE
+   write_index                          | 0
+  write master                         | 0 or OBSOLETE_ZNODE[2] or
+                                       | DIRTY_ZNODE[3]
+
+[1] znode is dirtied without concurrent committing process
+[2] znode is copied up (re-dirtied by other process) before cleaned
+    up in committing process
+[3] znode is re-dirtied after cleaned up in committing process
+
+Currently, the clean znode count is updated in free_obsolete_znodes(),
+which is called only in normal path. If do_commit failed, clean znode
+count won't be updated, which triggers a failure ubifs assertion[4] in
+ubifs_tnc_close():
+ ubifs_assert_failed [ubifs]: UBIFS assert failed: freed == n
+
+[4] Commit 380347e9ca7682 ("UBIFS: Add an assertion for clean_zn_cnt").
+
+Fix it by re-statisticing cleaned znode count in tnc_destroy_cnext().
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216704
+Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/tnc.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
+index 488f3da7a6c6c..2df56bbc68657 100644
+--- a/fs/ubifs/tnc.c
++++ b/fs/ubifs/tnc.c
+@@ -3053,6 +3053,21 @@ static void tnc_destroy_cnext(struct ubifs_info *c)
+               cnext = cnext->cnext;
+               if (ubifs_zn_obsolete(znode))
+                       kfree(znode);
++              else if (!ubifs_zn_cow(znode)) {
++                      /*
++                       * Don't forget to update clean znode count after
++                       * committing failed, because ubifs will check this
++                       * count while closing tnc. Non-obsolete znode could
++                       * be re-dirtied during committing process, so dirty
++                       * flag is untrustable. The flag 'COW_ZNODE' is set
++                       * for each dirty znode before committing, and it is
++                       * cleared as long as the znode become clean, so we
++                       * can statistic clean znode count according to this
++                       * flag.
++                       */
++                      atomic_long_inc(&c->clean_zn_cnt);
++                      atomic_long_inc(&ubifs_clean_zn_cnt);
++              }
+       } while (cnext && cnext != c->cnext);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-rectify-space-budget-for-ubifs_symlink-if-syml.patch b/queue-5.15/ubifs-rectify-space-budget-for-ubifs_symlink-if-syml.patch
new file mode 100644 (file)
index 0000000..b5d9424
--- /dev/null
@@ -0,0 +1,48 @@
+From 26dee744bad88301277bdffd934cade9f61c9ccf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Oct 2022 11:47:27 +0800
+Subject: ubifs: Rectify space budget for ubifs_symlink() if symlink is
+ encrypted
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit c2c36cc6ca23e614f9e4238d0ecf48549ee9002a ]
+
+Fix bad space budget when symlink file is encrypted. Bad space budget
+may let make_reservation() return with -ENOSPC, which could turn ubifs
+to read-only mode in do_writepage() process.
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216490
+Fixes: ca7f85be8d6cf9 ("ubifs: Add support for encrypted symlinks")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/dir.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
+index 79e371bc15e1e..a72e2ac4fdcd1 100644
+--- a/fs/ubifs/dir.c
++++ b/fs/ubifs/dir.c
+@@ -1147,7 +1147,6 @@ static int ubifs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
+       int err, sz_change, len = strlen(symname);
+       struct fscrypt_str disk_link;
+       struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
+-                                      .new_ino_d = ALIGN(len, 8),
+                                       .dirtied_ino = 1 };
+       struct fscrypt_name nm;
+@@ -1163,6 +1162,7 @@ static int ubifs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
+        * Budget request settings: new inode, new direntry and changing parent
+        * directory inode.
+        */
++      req.new_ino_d = ALIGN(disk_link.len - 1, 8);
+       err = ubifs_budget_space(c, &req);
+       if (err)
+               return err;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-rectify-space-budget-for-ubifs_xrename.patch b/queue-5.15/ubifs-rectify-space-budget-for-ubifs_xrename.patch
new file mode 100644 (file)
index 0000000..de7e856
--- /dev/null
@@ -0,0 +1,51 @@
+From fe287e233a682b1e8c545d72c7d4968a24f89000 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Oct 2022 11:47:28 +0800
+Subject: ubifs: Rectify space budget for ubifs_xrename()
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit 1b2ba09060e41adb356b9ae58ef94a7390928004 ]
+
+There is no space budget for ubifs_xrename(). It may let
+make_reservation() return with -ENOSPC, which could turn
+ubifs to read-only mode in do_writepage() process.
+Fix it by adding space budget for ubifs_xrename().
+
+Fetch a reproducer in [Link].
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216569
+Fixes: 9ec64962afb170 ("ubifs: Implement RENAME_EXCHANGE")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/dir.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
+index a72e2ac4fdcd1..f193caae69c20 100644
+--- a/fs/ubifs/dir.c
++++ b/fs/ubifs/dir.c
+@@ -1572,6 +1572,10 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
+               return err;
+       }
++      err = ubifs_budget_space(c, &req);
++      if (err)
++              goto out;
++
+       lock_4_inodes(old_dir, new_dir, NULL, NULL);
+       time = current_time(old_dir);
+@@ -1597,6 +1601,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
+       unlock_4_inodes(old_dir, new_dir, NULL, NULL);
+       ubifs_release_budget(c, &req);
++out:
+       fscrypt_free_filename(&fst_nm);
+       fscrypt_free_filename(&snd_nm);
+       return err;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-reserve-one-leb-for-each-journal-head-while-do.patch b/queue-5.15/ubifs-reserve-one-leb-for-each-journal-head-while-do.patch
new file mode 100644 (file)
index 0000000..a0f817e
--- /dev/null
@@ -0,0 +1,65 @@
+From b094c374b7d32b88d27001de099c6901f118977b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Oct 2022 11:47:32 +0800
+Subject: ubifs: Reserve one leb for each journal head while doing budget
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit e874dcde1cbf82c786c0e7f2899811c02630cc52 ]
+
+UBIFS calculates available space by c->main_bytes - c->lst.total_used
+(which means non-index lebs' free and dirty space is accounted into
+total available), then index lebs and four lebs (one for gc_lnum, one
+for deletions, two for journal heads) are deducted.
+In following situation, ubifs may get -ENOSPC from make_reservation():
+ LEB 84: DATAHD   free 122880 used 1920  dirty 2176  dark 6144
+ LEB 110:DELETION free 126976 used 0     dirty 0     dark 6144 (empty)
+ LEB 201:gc_lnum  free 126976 used 0     dirty 0     dark 6144
+ LEB 272:GCHD     free 77824  used 47672 dirty 1480  dark 6144
+ LEB 356:BASEHD   free 0      used 39776 dirty 87200 dark 6144
+ OTHERS: index lebs, zero-available non-index lebs
+
+UBIFS calculates the available bytes is 6888 (How to calculate it:
+126976 * 5[remain main bytes] - 1920[used] - 47672[used] - 39776[used] -
+126976 * 1[deletions] - 126976 * 1[gc_lnum] - 126976 * 2[journal heads]
+- 6144 * 5[dark] = 6888) after doing budget, however UBIFS cannot use
+BASEHD's dirty space(87200), because UBIFS cannot find next BASEHD to
+reclaim current BASEHD. (c->bi.min_idx_lebs equals to c->lst.idx_lebs,
+the empty leb won't be found by ubifs_find_free_space(), and dirty index
+lebs won't be picked as gced lebs. All non-index lebs has dirty space
+less then c->dead_wm, non-index lebs won't be picked as gced lebs
+either. So new free lebs won't be produced.). See more details in Link.
+
+To fix it, reserve one leb for each journal head while doing budget.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216562
+Fixes: 1e51764a3c2ac0 ("UBIFS: add new flash file system")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/budget.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
+index bdb79be6dc0e2..9cb05ef9b9dd9 100644
+--- a/fs/ubifs/budget.c
++++ b/fs/ubifs/budget.c
+@@ -212,11 +212,10 @@ long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs)
+       subtract_lebs += 1;
+       /*
+-       * The GC journal head LEB is not really accessible. And since
+-       * different write types go to different heads, we may count only on
+-       * one head's space.
++       * Since different write types go to different heads, we should
++       * reserve one leb for each head.
+        */
+-      subtract_lebs += c->jhead_cnt - 1;
++      subtract_lebs += c->jhead_cnt;
+       /* We also reserve one LEB for deletions, which bypass budgeting */
+       subtract_lebs += 1;
+-- 
+2.39.2
+
diff --git a/queue-5.15/ubifs-ubifs_writepage-mark-page-dirty-after-writing-.patch b/queue-5.15/ubifs-ubifs_writepage-mark-page-dirty-after-writing-.patch
new file mode 100644 (file)
index 0000000..54b29dd
--- /dev/null
@@ -0,0 +1,114 @@
+From 1ccb43db8d054d7db0be738d8de67bedb80aa51a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Jun 2022 10:59:59 +0800
+Subject: ubifs: ubifs_writepage: Mark page dirty after writing inode failed
+
+From: Zhihao Cheng <chengzhihao1@huawei.com>
+
+[ Upstream commit fb8bc4c74ae4526d9489362ab2793a936d072b84 ]
+
+There are two states for ubifs writing pages:
+1. Dirty, Private
+2. Not Dirty, Not Private
+
+There is a third possibility which maybe related to [1] that page is
+private but not dirty caused by following process:
+
+          PA
+lock(page)
+ubifs_write_end
+  attach_page_private          // set Private
+    __set_page_dirty_nobuffers // set Dirty
+unlock(page)
+
+write_cache_pages
+  lock(page)
+  clear_page_dirty_for_io(page)        // clear Dirty
+  ubifs_writepage
+    write_inode
+    // fail, goto out, following codes are not executed
+    // do_writepage
+    //   set_page_writeback    // set Writeback
+    //   detach_page_private   // clear Private
+    //   end_page_writeback    // clear Writeback
+    out:
+    unlock(page)               // Private, Not Dirty
+
+                                       PB
+                               ksys_fadvise64_64
+                                 generic_fadvise
+                                    invalidate_inode_page
+                                    // page is neither Dirty nor Writeback
+                                      invalidate_complete_page
+                                      // page_has_private is true
+                                        try_to_release_page
+                                          ubifs_releasepage
+                                            ubifs_assert(c, 0) !!!
+
+Then we may get following assertion failed:
+  UBIFS error (ubi0:0 pid 1492): ubifs_assert_failed [ubifs]:
+  UBIFS assert failed: 0, in fs/ubifs/file.c:1499
+  UBIFS warning (ubi0:0 pid 1492): ubifs_ro_mode [ubifs]:
+  switched to read-only mode, error -22
+  CPU: 2 PID: 1492 Comm: aa Not tainted 5.16.0-rc2-00012-g7bb767dee0ba-dirty
+  Call Trace:
+    dump_stack+0x13/0x1b
+    ubifs_ro_mode+0x54/0x60 [ubifs]
+    ubifs_assert_failed+0x4b/0x80 [ubifs]
+    ubifs_releasepage+0x7e/0x1e0 [ubifs]
+    try_to_release_page+0x57/0xe0
+    invalidate_inode_page+0xfb/0x130
+    invalidate_mapping_pagevec+0x12/0x20
+    generic_fadvise+0x303/0x3c0
+    vfs_fadvise+0x35/0x40
+    ksys_fadvise64_64+0x4c/0xb0
+
+Jump [2] to find a reproducer.
+
+[1] https://linux-mtd.infradead.narkive.com/NQoBeT1u/patch-rfc-ubifs-fix-assert-failed-in-ubifs-set-page-dirty
+[2] https://bugzilla.kernel.org/show_bug.cgi?id=215357
+
+Fixes: 1e51764a3c2ac0 ("UBIFS: add new flash file system")
+Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ubifs/file.c | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
+index 6b45a037a0471..7cc2abcb70ae8 100644
+--- a/fs/ubifs/file.c
++++ b/fs/ubifs/file.c
+@@ -1031,7 +1031,7 @@ static int ubifs_writepage(struct page *page, struct writeback_control *wbc)
+               if (page->index >= synced_i_size >> PAGE_SHIFT) {
+                       err = inode->i_sb->s_op->write_inode(inode, NULL);
+                       if (err)
+-                              goto out_unlock;
++                              goto out_redirty;
+                       /*
+                        * The inode has been written, but the write-buffer has
+                        * not been synchronized, so in case of an unclean
+@@ -1059,11 +1059,17 @@ static int ubifs_writepage(struct page *page, struct writeback_control *wbc)
+       if (i_size > synced_i_size) {
+               err = inode->i_sb->s_op->write_inode(inode, NULL);
+               if (err)
+-                      goto out_unlock;
++                      goto out_redirty;
+       }
+       return do_writepage(page, len);
+-
++out_redirty:
++      /*
++       * redirty_page_for_writepage() won't call ubifs_dirty_inode() because
++       * it passes I_DIRTY_PAGES flag while calling __mark_inode_dirty(), so
++       * there is no need to do space budget for dirty inode.
++       */
++      redirty_page_for_writepage(wbc, page);
+ out_unlock:
+       unlock_page(page);
+       return err;
+-- 
+2.39.2
+
diff --git a/queue-5.15/um-vector-fix-memory-leak-in-vector_config.patch b/queue-5.15/um-vector-fix-memory-leak-in-vector_config.patch
new file mode 100644 (file)
index 0000000..9750599
--- /dev/null
@@ -0,0 +1,36 @@
+From a02a4682225216949ae04c8102e09b2817a8c5df Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Nov 2022 15:32:25 +0800
+Subject: um: vector: Fix memory leak in vector_config
+
+From: Xiang Yang <xiangyang3@huawei.com>
+
+[ Upstream commit 8f88c73afe481f93d40801596927e8c0047b6d96 ]
+
+If the return value of the uml_parse_vector_ifspec function is NULL,
+we should call kfree(params) to prevent memory leak.
+
+Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
+Signed-off-by: Xiang Yang <xiangyang3@huawei.com>
+Acked-By: Anton Ivanov <anton.ivanov@kot-begemot.co.uk>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/drivers/vector_kern.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
+index cde6db184c26b..45a4bcd27a39b 100644
+--- a/arch/um/drivers/vector_kern.c
++++ b/arch/um/drivers/vector_kern.c
+@@ -770,6 +770,7 @@ static int vector_config(char *str, char **error_out)
+       if (parsed == NULL) {
+               *error_out = "vector_config failed to parse parameters";
++              kfree(params);
+               return -EINVAL;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/um-virt-pci-properly-remove-pci-device-from-bus.patch b/queue-5.15/um-virt-pci-properly-remove-pci-device-from-bus.patch
new file mode 100644 (file)
index 0000000..6e70b4d
--- /dev/null
@@ -0,0 +1,66 @@
+From e69b3aa604b36346acc9a1720729ba1eaedbd75b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 10:00:05 +0100
+Subject: um: virt-pci: properly remove PCI device from bus
+
+From: Benjamin Berg <benjamin.berg@intel.com>
+
+[ Upstream commit 339b84dcd7113dd076419ea2a47128cc53450305 ]
+
+Triggering a bus rescan will not cause the PCI device to be removed. It
+is required to explicitly stop and remove the device from the bus.
+
+Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
+Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/drivers/virt-pci.c | 21 ++++++++++++++++-----
+ 1 file changed, 16 insertions(+), 5 deletions(-)
+
+diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
+index 2829347d1e906..d762d726b66cf 100644
+--- a/arch/um/drivers/virt-pci.c
++++ b/arch/um/drivers/virt-pci.c
+@@ -618,22 +618,33 @@ static void um_pci_virtio_remove(struct virtio_device *vdev)
+       struct um_pci_device *dev = vdev->priv;
+       int i;
+-        /* Stop all virtqueues */
+-        vdev->config->reset(vdev);
+-        vdev->config->del_vqs(vdev);
+-
+       device_set_wakeup_enable(&vdev->dev, false);
+       mutex_lock(&um_pci_mtx);
+       for (i = 0; i < MAX_DEVICES; i++) {
+               if (um_pci_devices[i].dev != dev)
+                       continue;
++
+               um_pci_devices[i].dev = NULL;
+               irq_free_desc(dev->irq);
++
++              break;
+       }
+       mutex_unlock(&um_pci_mtx);
+-      um_pci_rescan();
++      if (i < MAX_DEVICES) {
++              struct pci_dev *pci_dev;
++
++              pci_dev = pci_get_slot(bridge->bus, i);
++              if (pci_dev)
++                      pci_stop_and_remove_bus_device_locked(pci_dev);
++      }
++
++      /* Stop all virtqueues */
++      virtio_reset_device(vdev);
++      dev->cmd_vq = NULL;
++      dev->irq_vq = NULL;
++      vdev->config->del_vqs(vdev);
+       kfree(dev);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/um-virtio_uml-free-command-if-adding-to-virtqueue-fa.patch b/queue-5.15/um-virtio_uml-free-command-if-adding-to-virtqueue-fa.patch
new file mode 100644 (file)
index 0000000..eec9ea4
--- /dev/null
@@ -0,0 +1,40 @@
+From 17965b196feaf65b147ea05feae8f41f62c43c7e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 10:00:02 +0100
+Subject: um: virtio_uml: free command if adding to virtqueue failed
+
+From: Benjamin Berg <benjamin.berg@intel.com>
+
+[ Upstream commit 8a6ca543646f2940832665dbf4e04105262505e2 ]
+
+If adding the command fails (i.e. the virtqueue is broken) then free it
+again if the function allocated a new buffer for it.
+
+Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
+Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/drivers/virt-pci.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
+index 0ab58016db22f..2829347d1e906 100644
+--- a/arch/um/drivers/virt-pci.c
++++ b/arch/um/drivers/virt-pci.c
+@@ -131,8 +131,11 @@ static int um_pci_send_cmd(struct um_pci_device *dev,
+                               out ? 1 : 0,
+                               posted ? cmd : HANDLE_NO_FREE(cmd),
+                               GFP_ATOMIC);
+-      if (ret)
++      if (ret) {
++              if (posted)
++                      kfree(cmd);
+               goto out;
++      }
+       if (posted) {
+               virtqueue_kick(dev->cmd_vq);
+-- 
+2.39.2
+
diff --git a/queue-5.15/um-virtio_uml-mark-device-as-unregistered-when-break.patch b/queue-5.15/um-virtio_uml-mark-device-as-unregistered-when-break.patch
new file mode 100644 (file)
index 0000000..cbacaa3
--- /dev/null
@@ -0,0 +1,37 @@
+From a8237e8f225192a70684a0f329e64c4ea77a51f9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 10:00:03 +0100
+Subject: um: virtio_uml: mark device as unregistered when breaking it
+
+From: Benjamin Berg <benjamin.berg@intel.com>
+
+[ Upstream commit 8e9cd85139a2149d5a7c121b05e0cdb8287311f9 ]
+
+Mark the device as not registered anymore when scheduling the work to
+remove it. Otherwise we could end up scheduling the work multiple times
+in a row, including scheduling it while it is already running.
+
+Fixes: af9fb41ed315 ("um: virtio_uml: Fix broken device handling in time-travel")
+Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/drivers/virtio_uml.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
+index 82ff3785bf69f..c16ae3676ee08 100644
+--- a/arch/um/drivers/virtio_uml.c
++++ b/arch/um/drivers/virtio_uml.c
+@@ -168,6 +168,8 @@ static void vhost_user_check_reset(struct virtio_uml_device *vu_dev,
+       if (!vu_dev->registered)
+               return;
++      vu_dev->registered = 0;
++
+       virtio_break_device(&vu_dev->vdev);
+       schedule_work(&pdata->conn_broken_wk);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/um-virtio_uml-move-device-breaking-into-workqueue.patch b/queue-5.15/um-virtio_uml-move-device-breaking-into-workqueue.patch
new file mode 100644 (file)
index 0000000..8f65b11
--- /dev/null
@@ -0,0 +1,67 @@
+From fcf6a929355a73fc51a9e76f342ff9421bf7827e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 10:00:04 +0100
+Subject: um: virtio_uml: move device breaking into workqueue
+
+From: Benjamin Berg <benjamin.berg@intel.com>
+
+[ Upstream commit abdeb4fa5e1b5b4918034f02236fd886f40c20c1 ]
+
+We should not be calling virtio_break_device from an IRQ context.
+Move breaking the device into the workqueue so that it is done from
+a reasonable context.
+
+Fixes: af9fb41ed315 ("um: virtio_uml: Fix broken device handling in time-travel")
+Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/um/drivers/virtio_uml.c | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
+index c16ae3676ee08..204e9dfbff1a0 100644
+--- a/arch/um/drivers/virtio_uml.c
++++ b/arch/um/drivers/virtio_uml.c
+@@ -170,7 +170,6 @@ static void vhost_user_check_reset(struct virtio_uml_device *vu_dev,
+       vu_dev->registered = 0;
+-      virtio_break_device(&vu_dev->vdev);
+       schedule_work(&pdata->conn_broken_wk);
+ }
+@@ -1134,6 +1133,15 @@ void virtio_uml_set_no_vq_suspend(struct virtio_device *vdev,
+ static void vu_of_conn_broken(struct work_struct *wk)
+ {
++      struct virtio_uml_platform_data *pdata;
++      struct virtio_uml_device *vu_dev;
++
++      pdata = container_of(wk, struct virtio_uml_platform_data, conn_broken_wk);
++
++      vu_dev = platform_get_drvdata(pdata->pdev);
++
++      virtio_break_device(&vu_dev->vdev);
++
+       /*
+        * We can't remove the device from the devicetree so the only thing we
+        * can do is warn.
+@@ -1264,8 +1272,14 @@ static int vu_unregister_cmdline_device(struct device *dev, void *data)
+ static void vu_conn_broken(struct work_struct *wk)
+ {
+       struct virtio_uml_platform_data *pdata;
++      struct virtio_uml_device *vu_dev;
+       pdata = container_of(wk, struct virtio_uml_platform_data, conn_broken_wk);
++
++      vu_dev = platform_get_drvdata(pdata->pdev);
++
++      virtio_break_device(&vu_dev->vdev);
++
+       vu_unregister_cmdline_device(&pdata->pdev->dev, NULL);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-chipidea-fix-memory-leak-with-using-debugfs_look.patch b/queue-5.15/usb-chipidea-fix-memory-leak-with-using-debugfs_look.patch
new file mode 100644 (file)
index 0000000..075b31b
--- /dev/null
@@ -0,0 +1,36 @@
+From 32ec6b2356f0434eafe103ec0bcc16708180cb98 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:23 +0100
+Subject: USB: chipidea: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit ff35f3ea3baba5b81416ac02d005cfbf6dd182fa ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Peter Chen <peter.chen@kernel.org>
+Link: https://lore.kernel.org/r/20230202153235.2412790-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/chipidea/debug.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
+index faf6b078b6c44..bbc610e5bd69c 100644
+--- a/drivers/usb/chipidea/debug.c
++++ b/drivers/usb/chipidea/debug.c
+@@ -364,5 +364,5 @@ void dbg_create_files(struct ci_hdrc *ci)
+  */
+ void dbg_remove_files(struct ci_hdrc *ci)
+ {
+-      debugfs_remove(debugfs_lookup(dev_name(ci->dev), usb_debug_root));
++      debugfs_lookup_and_remove(dev_name(ci->dev), usb_debug_root);
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-dwc3-fix-memory-leak-with-using-debugfs_lookup.patch b/queue-5.15/usb-dwc3-fix-memory-leak-with-using-debugfs_lookup.patch
new file mode 100644 (file)
index 0000000..ea0e3d4
--- /dev/null
@@ -0,0 +1,143 @@
+From 80abb15660ba3b9eadae604dd357cb3cc09f3a26 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:28:20 +0100
+Subject: USB: dwc3: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit be308d68785b205e483b3a0c61ba3a82da468f2c ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Note, the root dentry for the debugfs directory for the device needs to
+be saved so we don't have to keep looking it up, which required a bit
+more refactoring to properly create and remove it when needed.
+
+Reported-by: Bruce Chen <bruce.chen@unisoc.com>
+Reported-by: Cixi Geng <cixi.geng1@unisoc.com>
+Tested-by: Cixi Geng <gengcixi@gmail.com>
+Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
+Link: https://lore.kernel.org/r/20230202152820.2409908-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/dwc3/core.h    |  2 ++
+ drivers/usb/dwc3/debug.h   |  3 +++
+ drivers/usb/dwc3/debugfs.c | 19 ++++++++-----------
+ drivers/usb/dwc3/gadget.c  |  4 +---
+ 4 files changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
+index e82e4cbe4ec70..725653711411d 100644
+--- a/drivers/usb/dwc3/core.h
++++ b/drivers/usb/dwc3/core.h
+@@ -1092,6 +1092,7 @@ struct dwc3_scratchpad_array {
+  *                 address.
+  * @num_ep_resized: carries the current number endpoints which have had its tx
+  *                fifo resized.
++ * @debug_root: root debugfs directory for this device to put its files in.
+  */
+ struct dwc3 {
+       struct work_struct      drd_work;
+@@ -1303,6 +1304,7 @@ struct dwc3 {
+       int                     max_cfg_eps;
+       int                     last_fifo_depth;
+       int                     num_ep_resized;
++      struct dentry           *debug_root;
+ };
+ #define INCRX_BURST_MODE 0
+diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
+index d223c54115f4a..01d0366bf93ae 100644
+--- a/drivers/usb/dwc3/debug.h
++++ b/drivers/usb/dwc3/debug.h
+@@ -414,11 +414,14 @@ static inline const char *dwc3_gadget_generic_cmd_status_string(int status)
+ #ifdef CONFIG_DEBUG_FS
+ extern void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep);
++extern void dwc3_debugfs_remove_endpoint_dir(struct dwc3_ep *dep);
+ extern void dwc3_debugfs_init(struct dwc3 *d);
+ extern void dwc3_debugfs_exit(struct dwc3 *d);
+ #else
+ static inline void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep)
+ {  }
++static inline void dwc3_debugfs_remove_endpoint_dir(struct dwc3_ep *dep)
++{  }
+ static inline void dwc3_debugfs_init(struct dwc3 *d)
+ {  }
+ static inline void dwc3_debugfs_exit(struct dwc3 *d)
+diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
+index f2b7675c7f621..850df0e6bcabf 100644
+--- a/drivers/usb/dwc3/debugfs.c
++++ b/drivers/usb/dwc3/debugfs.c
+@@ -873,27 +873,23 @@ static const struct dwc3_ep_file_map dwc3_ep_file_map[] = {
+       { "GDBGEPINFO", &dwc3_ep_info_register_fops, },
+ };
+-static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep,
+-              struct dentry *parent)
++void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep)
+ {
++      struct dentry           *dir;
+       int                     i;
++      dir = debugfs_create_dir(dep->name, dep->dwc->debug_root);
+       for (i = 0; i < ARRAY_SIZE(dwc3_ep_file_map); i++) {
+               const struct file_operations *fops = dwc3_ep_file_map[i].fops;
+               const char *name = dwc3_ep_file_map[i].name;
+-              debugfs_create_file(name, 0444, parent, dep, fops);
++              debugfs_create_file(name, 0444, dir, dep, fops);
+       }
+ }
+-void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep)
++void dwc3_debugfs_remove_endpoint_dir(struct dwc3_ep *dep)
+ {
+-      struct dentry           *dir;
+-      struct dentry           *root;
+-
+-      root = debugfs_lookup(dev_name(dep->dwc->dev), usb_debug_root);
+-      dir = debugfs_create_dir(dep->name, root);
+-      dwc3_debugfs_create_endpoint_files(dep, dir);
++      debugfs_lookup_and_remove(dep->name, dep->dwc->debug_root);
+ }
+ void dwc3_debugfs_init(struct dwc3 *dwc)
+@@ -911,6 +907,7 @@ void dwc3_debugfs_init(struct dwc3 *dwc)
+       dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START;
+       root = debugfs_create_dir(dev_name(dwc->dev), usb_debug_root);
++      dwc->debug_root = root;
+       debugfs_create_regset32("regdump", 0444, root, dwc->regset);
+       debugfs_create_file("lsp_dump", 0644, root, dwc, &dwc3_lsp_fops);
+@@ -929,6 +926,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc)
+ void dwc3_debugfs_exit(struct dwc3 *dwc)
+ {
+-      debugfs_remove(debugfs_lookup(dev_name(dwc->dev), usb_debug_root));
++      debugfs_lookup_and_remove(dev_name(dwc->dev), usb_debug_root);
+       kfree(dwc->regset);
+ }
+diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
+index 4812ba4bbedd7..a0100d26de8e1 100644
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -3081,9 +3081,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
+                       list_del(&dep->endpoint.ep_list);
+               }
+-              debugfs_remove_recursive(debugfs_lookup(dep->name,
+-                              debugfs_lookup(dev_name(dep->dwc->dev),
+-                                             usb_debug_root)));
++              dwc3_debugfs_remove_endpoint_dir(dep);
+               kfree(dep);
+       }
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-ene_usb6250-allocate-enough-memory-for-full-obje.patch b/queue-5.15/usb-ene_usb6250-allocate-enough-memory-for-full-obje.patch
new file mode 100644 (file)
index 0000000..ee855b7
--- /dev/null
@@ -0,0 +1,61 @@
+From e537e9aae0c64a6a999583f5d074980ad85bb16b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 4 Feb 2023 10:35:46 -0800
+Subject: USB: ene_usb6250: Allocate enough memory for full object
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit ce33e64c1788912976b61314b56935abd4bc97ef ]
+
+The allocation of PageBuffer is 512 bytes in size, but the dereferencing
+of struct ms_bootblock_idi (also size 512) happens at a calculated offset
+within the allocation, which means the object could potentially extend
+beyond the end of the allocation. Avoid this case by just allocating
+enough space to catch any accesses beyond the end. Seen with GCC 13:
+
+../drivers/usb/storage/ene_ub6250.c: In function 'ms_lib_process_bootblock':
+../drivers/usb/storage/ene_ub6250.c:1050:44: warning: array subscript 'struct ms_bootblock_idi[0]' is partly outside array bounds of 'unsigned char[512]' [-Warray-bounds=]
+ 1050 |                         if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
+      |                                            ^~
+../include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
+   37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
+      |                                                   ^
+../drivers/usb/storage/ene_ub6250.c:1050:29: note: in expansion of macro 'le16_to_cpu'
+ 1050 |                         if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
+      |                             ^~~~~~~~~~~
+In file included from ../drivers/usb/storage/ene_ub6250.c:5:
+In function 'kmalloc',
+    inlined from 'ms_lib_process_bootblock' at ../drivers/usb/storage/ene_ub6250.c:942:15:
+../include/linux/slab.h:580:24: note: at offset [256, 512] into object of size 512 allocated by 'kmalloc_trace'
+  580 |                 return kmalloc_trace(
+      |                        ^~~~~~~~~~~~~~
+  581 |                                 kmalloc_caches[kmalloc_type(flags)][index],
+      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  582 |                                 flags, size);
+      |                                 ~~~~~~~~~~~~
+
+Cc: Alan Stern <stern@rowland.harvard.edu>
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Link: https://lore.kernel.org/r/20230204183546.never.849-kees@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/storage/ene_ub6250.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
+index 6012603f3630e..97c66c0d91f4d 100644
+--- a/drivers/usb/storage/ene_ub6250.c
++++ b/drivers/usb/storage/ene_ub6250.c
+@@ -939,7 +939,7 @@ static int ms_lib_process_bootblock(struct us_data *us, u16 PhyBlock, u8 *PageDa
+       struct ms_lib_type_extdat ExtraData;
+       struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
+-      PageBuffer = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL);
++      PageBuffer = kzalloc(MS_BYTES_PER_PAGE * 2, GFP_KERNEL);
+       if (PageBuffer == NULL)
+               return (u32)-1;
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-fix-memory-leak-with-using-debugfs_lookup.patch b/queue-5.15/usb-fix-memory-leak-with-using-debugfs_lookup.patch
new file mode 100644 (file)
index 0000000..b7486b1
--- /dev/null
@@ -0,0 +1,39 @@
+From ad3fb94ba7019fa9426277f00ee87f670944729f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 6 Jan 2023 16:28:28 +0100
+Subject: USB: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 30374434edab20e25776f8ecb4bc9d1e54309487 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic at
+once.
+
+Cc: Alan Stern <stern@rowland.harvard.edu>
+Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
+Link: https://lore.kernel.org/r/20230106152828.3790902-1-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/core/usb.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
+index 62368c4ed37af..cc36f9f228148 100644
+--- a/drivers/usb/core/usb.c
++++ b/drivers/usb/core/usb.c
+@@ -1036,7 +1036,7 @@ static void usb_debugfs_init(void)
+ static void usb_debugfs_cleanup(void)
+ {
+-      debugfs_remove(debugfs_lookup("devices", usb_debug_root));
++      debugfs_lookup_and_remove("devices", usb_debug_root);
+ }
+ /*
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-fotg210-fix-memory-leak-with-using-debugfs_looku.patch b/queue-5.15/usb-fotg210-fix-memory-leak-with-using-debugfs_looku.patch
new file mode 100644 (file)
index 0000000..9f6a33f
--- /dev/null
@@ -0,0 +1,38 @@
+From e19ecf2435988ef11a93a6a3fbc6fcc7ced2c49d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:27 +0100
+Subject: USB: fotg210: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 6b4040f452037a7e95472577891d57c6b18c89c5 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
+Link: https://lore.kernel.org/r/20230202153235.2412790-5-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/fotg210-hcd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
+index 4b02ace09f3dc..d9a3fd8af7a01 100644
+--- a/drivers/usb/host/fotg210-hcd.c
++++ b/drivers/usb/host/fotg210-hcd.c
+@@ -862,7 +862,7 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210)
+ {
+       struct usb_bus *bus = &fotg210_to_hcd(fotg210)->self;
+-      debugfs_remove(debugfs_lookup(bus->bus_name, fotg210_debug_root));
++      debugfs_lookup_and_remove(bus->bus_name, fotg210_debug_root);
+ }
+ /* handshake - spin reading hc until handshake completes or fails
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-gadget-bcm63xx_udc-fix-memory-leak-with-using-de.patch b/queue-5.15/usb-gadget-bcm63xx_udc-fix-memory-leak-with-using-de.patch
new file mode 100644 (file)
index 0000000..d2afad2
--- /dev/null
@@ -0,0 +1,38 @@
+From 428e161cfeac8ad3eb77e4033abe857130b7e9ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:31 +0100
+Subject: USB: gadget: bcm63xx_udc: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit a91c99b1fe5c6f7e52fb932ad9e57ec7cfe913ec ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Kevin Cernekee <cernekee@gmail.com>
+Link: https://lore.kernel.org/r/20230202153235.2412790-9-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/bcm63xx_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c
+index a9f07c59fc377..5c7dff6bc638f 100644
+--- a/drivers/usb/gadget/udc/bcm63xx_udc.c
++++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
+@@ -2259,7 +2259,7 @@ static void bcm63xx_udc_init_debugfs(struct bcm63xx_udc *udc)
+  */
+ static void bcm63xx_udc_cleanup_debugfs(struct bcm63xx_udc *udc)
+ {
+-      debugfs_remove(debugfs_lookup(udc->gadget.name, usb_debug_root));
++      debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root);
+ }
+ /***********************************************************************
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-gadget-gr_udc-fix-memory-leak-with-using-debugfs.patch b/queue-5.15/usb-gadget-gr_udc-fix-memory-leak-with-using-debugfs.patch
new file mode 100644 (file)
index 0000000..96fb0d5
--- /dev/null
@@ -0,0 +1,38 @@
+From 53ae0eef768d6a100cb7b6a185084b79de8916a8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:30 +0100
+Subject: USB: gadget: gr_udc: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 73f4451368663ad28daa67980c6dd11d83b303eb ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Jakob Koschel <jakobkoschel@gmail.com>
+Link: https://lore.kernel.org/r/20230202153235.2412790-8-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/gr_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
+index 4b35739d36951..d1febde6f2c4a 100644
+--- a/drivers/usb/gadget/udc/gr_udc.c
++++ b/drivers/usb/gadget/udc/gr_udc.c
+@@ -215,7 +215,7 @@ static void gr_dfs_create(struct gr_udc *dev)
+ static void gr_dfs_delete(struct gr_udc *dev)
+ {
+-      debugfs_remove(debugfs_lookup(dev_name(dev->dev), usb_debug_root));
++      debugfs_lookup_and_remove(dev_name(dev->dev), usb_debug_root);
+ }
+ #else /* !CONFIG_USB_GADGET_DEBUG_FS */
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-gadget-lpc32xx_udc-fix-memory-leak-with-using-de.patch b/queue-5.15/usb-gadget-lpc32xx_udc-fix-memory-leak-with-using-de.patch
new file mode 100644 (file)
index 0000000..608a3eb
--- /dev/null
@@ -0,0 +1,40 @@
+From 5a86a6d2f275f34eab505c76abe10ad354315ae5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:32 +0100
+Subject: USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit e3965acaf3739fde9d74ad82979b46d37c6c208f ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Jakob Koschel <jakobkoschel@gmail.com>
+Cc: Miaoqian Lin <linmq006@gmail.com>
+Acked-by: Vladimir Zapolskiy <vz@mleia.com>
+Link: https://lore.kernel.org/r/20230202153235.2412790-10-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
+index 865de8db998a9..ec0d3d74d66e2 100644
+--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
++++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
+@@ -532,7 +532,7 @@ static void create_debug_file(struct lpc32xx_udc *udc)
+ static void remove_debug_file(struct lpc32xx_udc *udc)
+ {
+-      debugfs_remove(debugfs_lookup(debug_filename, NULL));
++      debugfs_lookup_and_remove(debug_filename, NULL);
+ }
+ #else
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-gadget-pxa25x_udc-fix-memory-leak-with-using-deb.patch b/queue-5.15/usb-gadget-pxa25x_udc-fix-memory-leak-with-using-deb.patch
new file mode 100644 (file)
index 0000000..2dff49c
--- /dev/null
@@ -0,0 +1,40 @@
+From 9e7c4e24d7448d28c2bd78bac3af7327f10875cf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:33 +0100
+Subject: USB: gadget: pxa25x_udc: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 7a038a681b7df78362d9fc7013e5395a694a9d3a ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Daniel Mack <daniel@zonque.org>
+Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
+Cc: Robert Jarzmik <robert.jarzmik@free.fr>
+Link: https://lore.kernel.org/r/20230202153235.2412790-11-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/pxa25x_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
+index a09ec1d826b21..e4d2ab5768ba2 100644
+--- a/drivers/usb/gadget/udc/pxa25x_udc.c
++++ b/drivers/usb/gadget/udc/pxa25x_udc.c
+@@ -1341,7 +1341,7 @@ DEFINE_SHOW_ATTRIBUTE(udc_debug);
+               debugfs_create_file(dev->gadget.name, \
+                       S_IRUGO, NULL, dev, &udc_debug_fops); \
+       } while (0)
+-#define remove_debug_files(dev) debugfs_remove(debugfs_lookup(dev->gadget.name, NULL))
++#define remove_debug_files(dev) debugfs_lookup_and_remove(dev->gadget.name, NULL)
+ #else /* !CONFIG_USB_GADGET_DEBUG_FILES */
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-gadget-pxa27x_udc-fix-memory-leak-with-using-deb.patch b/queue-5.15/usb-gadget-pxa27x_udc-fix-memory-leak-with-using-deb.patch
new file mode 100644 (file)
index 0000000..f44ab45
--- /dev/null
@@ -0,0 +1,40 @@
+From ae15491739e6ec4f010583721a1cc440fd505a05 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:34 +0100
+Subject: USB: gadget: pxa27x_udc: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 7a6952fa0366d4408eb8695af1a0578c39ec718a ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Daniel Mack <daniel@zonque.org>
+Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
+Cc: Robert Jarzmik <robert.jarzmik@free.fr>
+Link: https://lore.kernel.org/r/20230202153235.2412790-12-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/pxa27x_udc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
+index f4b7a2a3e7114..282b114f382f8 100644
+--- a/drivers/usb/gadget/udc/pxa27x_udc.c
++++ b/drivers/usb/gadget/udc/pxa27x_udc.c
+@@ -215,7 +215,7 @@ static void pxa_init_debugfs(struct pxa_udc *udc)
+ static void pxa_cleanup_debugfs(struct pxa_udc *udc)
+ {
+-      debugfs_remove(debugfs_lookup(udc->gadget.name, usb_debug_root));
++      debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root);
+ }
+ #else
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-gadget-uvc-make-bsourceid-read-write.patch b/queue-5.15/usb-gadget-uvc-make-bsourceid-read-write.patch
new file mode 100644 (file)
index 0000000..12246a8
--- /dev/null
@@ -0,0 +1,113 @@
+From 8ea3afade48a114c4300861f864ba5da6acd76aa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 6 Feb 2023 16:17:52 +0000
+Subject: usb: gadget: uvc: Make bSourceID read/write
+
+From: Daniel Scally <dan.scally@ideasonboard.com>
+
+[ Upstream commit b3c839bd8a07d303bc59a900d55dd35c7826562c ]
+
+At the moment, the UVC function graph is hardcoded IT -> PU -> OT.
+To add XU support we need the ability to insert the XU descriptors
+into the chain. To facilitate that, make the output terminal's
+bSourceID attribute writeable so that we can configure its source.
+
+Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
+Link: https://lore.kernel.org/r/20230206161802.892954-2-dan.scally@ideasonboard.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../ABI/testing/configfs-usb-gadget-uvc       |  2 +-
+ drivers/usb/gadget/function/uvc_configfs.c    | 59 ++++++++++++++++++-
+ 2 files changed, 59 insertions(+), 2 deletions(-)
+
+diff --git a/Documentation/ABI/testing/configfs-usb-gadget-uvc b/Documentation/ABI/testing/configfs-usb-gadget-uvc
+index 889ed45be4ca6..2d5a5913b5f28 100644
+--- a/Documentation/ABI/testing/configfs-usb-gadget-uvc
++++ b/Documentation/ABI/testing/configfs-usb-gadget-uvc
+@@ -51,7 +51,7 @@ Date:                Dec 2014
+ KernelVersion:        4.0
+ Description:  Default output terminal descriptors
+-              All attributes read only:
++              All attributes read only except bSourceID:
+               ==============  =============================================
+               iTerminal       index of string descriptor
+diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
+index 77d64031aa9c2..9a285592a947c 100644
+--- a/drivers/usb/gadget/function/uvc_configfs.c
++++ b/drivers/usb/gadget/function/uvc_configfs.c
+@@ -505,11 +505,68 @@ UVC_ATTR_RO(uvcg_default_output_, cname, aname)
+ UVCG_DEFAULT_OUTPUT_ATTR(b_terminal_id, bTerminalID, 8);
+ UVCG_DEFAULT_OUTPUT_ATTR(w_terminal_type, wTerminalType, 16);
+ UVCG_DEFAULT_OUTPUT_ATTR(b_assoc_terminal, bAssocTerminal, 8);
+-UVCG_DEFAULT_OUTPUT_ATTR(b_source_id, bSourceID, 8);
+ UVCG_DEFAULT_OUTPUT_ATTR(i_terminal, iTerminal, 8);
+ #undef UVCG_DEFAULT_OUTPUT_ATTR
++static ssize_t uvcg_default_output_b_source_id_show(struct config_item *item,
++                                                  char *page)
++{
++      struct config_group *group = to_config_group(item);
++      struct f_uvc_opts *opts;
++      struct config_item *opts_item;
++      struct mutex *su_mutex = &group->cg_subsys->su_mutex;
++      struct uvc_output_terminal_descriptor *cd;
++      int result;
++
++      mutex_lock(su_mutex); /* for navigating configfs hierarchy */
++
++      opts_item = group->cg_item.ci_parent->ci_parent->
++                      ci_parent->ci_parent;
++      opts = to_f_uvc_opts(opts_item);
++      cd = &opts->uvc_output_terminal;
++
++      mutex_lock(&opts->lock);
++      result = sprintf(page, "%u\n", le8_to_cpu(cd->bSourceID));
++      mutex_unlock(&opts->lock);
++
++      mutex_unlock(su_mutex);
++
++      return result;
++}
++
++static ssize_t uvcg_default_output_b_source_id_store(struct config_item *item,
++                                                   const char *page, size_t len)
++{
++      struct config_group *group = to_config_group(item);
++      struct f_uvc_opts *opts;
++      struct config_item *opts_item;
++      struct mutex *su_mutex = &group->cg_subsys->su_mutex;
++      struct uvc_output_terminal_descriptor *cd;
++      int result;
++      u8 num;
++
++      mutex_lock(su_mutex); /* for navigating configfs hierarchy */
++
++      opts_item = group->cg_item.ci_parent->ci_parent->
++                      ci_parent->ci_parent;
++      opts = to_f_uvc_opts(opts_item);
++      cd = &opts->uvc_output_terminal;
++
++      result = kstrtou8(page, 0, &num);
++      if (result)
++              return result;
++
++      mutex_lock(&opts->lock);
++      cd->bSourceID = num;
++      mutex_unlock(&opts->lock);
++
++      mutex_unlock(su_mutex);
++
++      return len;
++}
++UVC_ATTR(uvcg_default_output_, b_source_id, bSourceID);
++
+ static struct configfs_attribute *uvcg_default_output_attrs[] = {
+       &uvcg_default_output_attr_b_terminal_id,
+       &uvcg_default_output_attr_w_terminal_type,
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-host-xhci-mvebu-iterate-over-array-indexes-inste.patch b/queue-5.15/usb-host-xhci-mvebu-iterate-over-array-indexes-inste.patch
new file mode 100644 (file)
index 0000000..b4b7019
--- /dev/null
@@ -0,0 +1,46 @@
+From 6abd186d6c46ed3f0d58f911fdcf72d95eb91e5e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 4 Feb 2023 10:36:52 -0800
+Subject: usb: host: xhci: mvebu: Iterate over array indexes instead of using
+ pointer math
+
+From: Kees Cook <keescook@chromium.org>
+
+[ Upstream commit 0fbd2cda92cdb00f72080665554a586f88bca821 ]
+
+Walking the dram->cs array was seen as accesses beyond the first array
+item by the compiler. Instead, use the array index directly. This allows
+for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen
+with GCC 13 with -fstrict-flex-arrays:
+
+In function 'xhci_mvebu_mbus_config',
+    inlined from 'xhci_mvebu_mbus_init_quirk' at ../drivers/usb/host/xhci-mvebu.c:66:2:
+../drivers/usb/host/xhci-mvebu.c:37:28: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
+   37 |                 writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
+      |                          ~~^~~~~~
+
+Cc: Mathias Nyman <mathias.nyman@intel.com>
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Link: https://lore.kernel.org/r/20230204183651.never.663-kees@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/xhci-mvebu.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
+index 8ca1a235d1645..eabccf25796b2 100644
+--- a/drivers/usb/host/xhci-mvebu.c
++++ b/drivers/usb/host/xhci-mvebu.c
+@@ -33,7 +33,7 @@ static void xhci_mvebu_mbus_config(void __iomem *base,
+       /* Program each DRAM CS in a seperate window */
+       for (win = 0; win < dram->num_cs; win++) {
+-              const struct mbus_dram_window *cs = dram->cs + win;
++              const struct mbus_dram_window *cs = &dram->cs[win];
+               writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
+                      (dram->mbus_dram_target_id << 4) | 1,
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-isp116x-fix-memory-leak-with-using-debugfs_looku.patch b/queue-5.15/usb-isp116x-fix-memory-leak-with-using-debugfs_looku.patch
new file mode 100644 (file)
index 0000000..02a16aa
--- /dev/null
@@ -0,0 +1,38 @@
+From 6ee5482d5b62979b0f813b9be40935b761765682 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:28 +0100
+Subject: USB: isp116x: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit a95f62d5813facbec20ec087472eb313ee5fa8af ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Olav Kongas <ok@artecdesign.ee>
+Link: https://lore.kernel.org/r/20230202153235.2412790-6-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/isp116x-hcd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
+index 8c7f0991c21b5..9c3e12f2f25d8 100644
+--- a/drivers/usb/host/isp116x-hcd.c
++++ b/drivers/usb/host/isp116x-hcd.c
+@@ -1206,7 +1206,7 @@ static void create_debug_file(struct isp116x *isp116x)
+ static void remove_debug_file(struct isp116x *isp116x)
+ {
+-      debugfs_remove(debugfs_lookup(hcd_name, usb_debug_root));
++      debugfs_lookup_and_remove(hcd_name, usb_debug_root);
+ }
+ #else
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-isp1362-fix-memory-leak-with-using-debugfs_looku.patch b/queue-5.15/usb-isp1362-fix-memory-leak-with-using-debugfs_looku.patch
new file mode 100644 (file)
index 0000000..d0b5130
--- /dev/null
@@ -0,0 +1,38 @@
+From 649208fb4c56a9a76ac1817982f94492a0e96481 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:29 +0100
+Subject: USB: isp1362: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit c26e682afc14caa87d44beed271eec8991e93c65 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+Link: https://lore.kernel.org/r/20230202153235.2412790-7-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/isp1362-hcd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
+index d8610ce8f2ecd..bc68669dfc50c 100644
+--- a/drivers/usb/host/isp1362-hcd.c
++++ b/drivers/usb/host/isp1362-hcd.c
+@@ -2170,7 +2170,7 @@ static void create_debug_file(struct isp1362_hcd *isp1362_hcd)
+ static void remove_debug_file(struct isp1362_hcd *isp1362_hcd)
+ {
+-      debugfs_remove(debugfs_lookup("isp1362", usb_debug_root));
++      debugfs_lookup_and_remove("isp1362", usb_debug_root);
+ }
+ /*-------------------------------------------------------------------------*/
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-sl811-fix-memory-leak-with-using-debugfs_lookup.patch b/queue-5.15/usb-sl811-fix-memory-leak-with-using-debugfs_lookup.patch
new file mode 100644 (file)
index 0000000..70787c5
--- /dev/null
@@ -0,0 +1,38 @@
+From 4e9090b6a89a4e996b6499799c53bacaee153e34 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:26 +0100
+Subject: USB: sl811: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit e1523c4dbc54e164638ff8729d511cf91e27be04 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
+Link: https://lore.kernel.org/r/20230202153235.2412790-4-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/sl811-hcd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
+index 85623731a5162..825ff67273102 100644
+--- a/drivers/usb/host/sl811-hcd.c
++++ b/drivers/usb/host/sl811-hcd.c
+@@ -1501,7 +1501,7 @@ static void create_debug_file(struct sl811 *sl811)
+ static void remove_debug_file(struct sl811 *sl811)
+ {
+-      debugfs_remove(debugfs_lookup("sl811h", usb_debug_root));
++      debugfs_lookup_and_remove("sl811h", usb_debug_root);
+ }
+ /*-------------------------------------------------------------------------*/
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-uhci-fix-memory-leak-with-using-debugfs_lookup.patch b/queue-5.15/usb-uhci-fix-memory-leak-with-using-debugfs_lookup.patch
new file mode 100644 (file)
index 0000000..09529c1
--- /dev/null
@@ -0,0 +1,49 @@
+From 8d0a20b7e9099a848fe042fdee7f7110edb988c9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 16:32:25 +0100
+Subject: USB: uhci: fix memory leak with using debugfs_lookup()
+
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+[ Upstream commit 0a3f82c79c86278e7f144564b1cb6cc5c3657144 ]
+
+When calling debugfs_lookup() the result must have dput() called on it,
+otherwise the memory will leak over time.  To make things simpler, just
+call debugfs_lookup_and_remove() instead which handles all of the logic
+at once.
+
+Cc: Alan Stern <stern@rowland.harvard.edu>
+Link: https://lore.kernel.org/r/20230202153235.2412790-3-gregkh@linuxfoundation.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/host/uhci-hcd.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
+index d90b869f5f409..d138f62ce84d7 100644
+--- a/drivers/usb/host/uhci-hcd.c
++++ b/drivers/usb/host/uhci-hcd.c
+@@ -536,8 +536,8 @@ static void release_uhci(struct uhci_hcd *uhci)
+       uhci->is_initialized = 0;
+       spin_unlock_irq(&uhci->lock);
+-      debugfs_remove(debugfs_lookup(uhci_to_hcd(uhci)->self.bus_name,
+-                                    uhci_debugfs_root));
++      debugfs_lookup_and_remove(uhci_to_hcd(uhci)->self.bus_name,
++                                uhci_debugfs_root);
+       for (i = 0; i < UHCI_NUM_SKELQH; i++)
+               uhci_free_qh(uhci, uhci->skelqh[i]);
+@@ -700,7 +700,7 @@ static int uhci_start(struct usb_hcd *hcd)
+                       uhci->frame, uhci->frame_dma_handle);
+ err_alloc_frame:
+-      debugfs_remove(debugfs_lookup(hcd->self.bus_name, uhci_debugfs_root));
++      debugfs_lookup_and_remove(hcd->self.bus_name, uhci_debugfs_root);
+       return retval;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.15/usb-uvc-enumerate-valid-values-for-color-matching.patch b/queue-5.15/usb-uvc-enumerate-valid-values-for-color-matching.patch
new file mode 100644 (file)
index 0000000..f9ec170
--- /dev/null
@@ -0,0 +1,67 @@
+From 220981148eb3db6d3f215f32d9f402e6d2912daa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Feb 2023 11:41:37 +0000
+Subject: usb: uvc: Enumerate valid values for color matching
+
+From: Daniel Scally <dan.scally@ideasonboard.com>
+
+[ Upstream commit e16cab9c1596e251761d2bfb5e1467950d616963 ]
+
+The color matching descriptors defined in the UVC Specification
+contain 3 fields with discrete numeric values representing particular
+settings. Enumerate those values so that later code setting them can
+be more readable.
+
+Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
+Link: https://lore.kernel.org/r/20230202114142.300858-2-dan.scally@ideasonboard.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/uapi/linux/usb/video.h | 30 ++++++++++++++++++++++++++++++
+ 1 file changed, 30 insertions(+)
+
+diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h
+index bfdae12cdacf8..c58854fb7d94a 100644
+--- a/include/uapi/linux/usb/video.h
++++ b/include/uapi/linux/usb/video.h
+@@ -179,6 +179,36 @@
+ #define UVC_CONTROL_CAP_AUTOUPDATE                    (1 << 3)
+ #define UVC_CONTROL_CAP_ASYNCHRONOUS                  (1 << 4)
++/* 3.9.2.6 Color Matching Descriptor Values */
++enum uvc_color_primaries_values {
++      UVC_COLOR_PRIMARIES_UNSPECIFIED,
++      UVC_COLOR_PRIMARIES_BT_709_SRGB,
++      UVC_COLOR_PRIMARIES_BT_470_2_M,
++      UVC_COLOR_PRIMARIES_BT_470_2_B_G,
++      UVC_COLOR_PRIMARIES_SMPTE_170M,
++      UVC_COLOR_PRIMARIES_SMPTE_240M,
++};
++
++enum uvc_transfer_characteristics_values {
++      UVC_TRANSFER_CHARACTERISTICS_UNSPECIFIED,
++      UVC_TRANSFER_CHARACTERISTICS_BT_709,
++      UVC_TRANSFER_CHARACTERISTICS_BT_470_2_M,
++      UVC_TRANSFER_CHARACTERISTICS_BT_470_2_B_G,
++      UVC_TRANSFER_CHARACTERISTICS_SMPTE_170M,
++      UVC_TRANSFER_CHARACTERISTICS_SMPTE_240M,
++      UVC_TRANSFER_CHARACTERISTICS_LINEAR,
++      UVC_TRANSFER_CHARACTERISTICS_SRGB,
++};
++
++enum uvc_matrix_coefficients {
++      UVC_MATRIX_COEFFICIENTS_UNSPECIFIED,
++      UVC_MATRIX_COEFFICIENTS_BT_709,
++      UVC_MATRIX_COEFFICIENTS_FCC,
++      UVC_MATRIX_COEFFICIENTS_BT_470_2_B_G,
++      UVC_MATRIX_COEFFICIENTS_SMPTE_170M,
++      UVC_MATRIX_COEFFICIENTS_SMPTE_240M,
++};
++
+ /* ------------------------------------------------------------------------
+  * UVC structures
+  */
+-- 
+2.39.2
+
diff --git a/queue-5.15/vc_screen-modify-vcs_size-handling-in-vcs_read.patch b/queue-5.15/vc_screen-modify-vcs_size-handling-in-vcs_read.patch
new file mode 100644 (file)
index 0000000..61f8e91
--- /dev/null
@@ -0,0 +1,40 @@
+From 4522e40cbba93d1c39fde3f12725e5872483b74c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 27 Feb 2023 15:21:41 -0500
+Subject: vc_screen: modify vcs_size() handling in vcs_read()
+
+From: George Kennedy <george.kennedy@oracle.com>
+
+[ Upstream commit 46d733d0efc79bc8430d63b57ab88011806d5180 ]
+
+Restore the vcs_size() handling in vcs_read() to what
+it had been in previous version.
+
+Fixes: 226fae124b2d ("vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF")
+Suggested-by: Jiri Slaby <jirislaby@kernel.org>
+Signed-off-by: George Kennedy <george.kennedy@oracle.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/vt/vc_screen.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
+index 71e091f879f0e..1dc07f9214d57 100644
+--- a/drivers/tty/vt/vc_screen.c
++++ b/drivers/tty/vt/vc_screen.c
+@@ -415,10 +415,8 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+                */
+               size = vcs_size(vc, attr, uni_mode);
+               if (size < 0) {
+-                      if (read)
+-                              break;
+                       ret = size;
+-                      goto unlock_out;
++                      break;
+               }
+               if (pos >= size)
+                       break;
+-- 
+2.39.2
+
diff --git a/queue-5.15/watchdog-at91sam9_wdt-use-devm_request_irq-to-avoid-.patch b/queue-5.15/watchdog-at91sam9_wdt-use-devm_request_irq-to-avoid-.patch
new file mode 100644 (file)
index 0000000..684302d
--- /dev/null
@@ -0,0 +1,46 @@
+From c015bdf6a2a3ee478d1b8fd21ee8bb6f40a504e2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Nov 2022 17:49:50 +0800
+Subject: watchdog: at91sam9_wdt: use devm_request_irq to avoid missing
+ free_irq() in error path
+
+From: ruanjinjie <ruanjinjie@huawei.com>
+
+[ Upstream commit 07bec0e09c1afbab4c5674fd2341f4f52d594f30 ]
+
+free_irq() is missing in case of error in at91_wdt_init(), use
+devm_request_irq to fix that.
+
+Fixes: 5161b31dc39a ("watchdog: at91sam9_wdt: better watchdog support")
+Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Link: https://lore.kernel.org/r/20221116094950.3141943-1-ruanjinjie@huawei.com
+[groeck: Adjust multi-line alignment]
+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/at91sam9_wdt.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
+index 292b5a1ca8318..fed7be2464420 100644
+--- a/drivers/watchdog/at91sam9_wdt.c
++++ b/drivers/watchdog/at91sam9_wdt.c
+@@ -206,10 +206,9 @@ static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
+                        "min heartbeat and max heartbeat might be too close for the system to handle it correctly\n");
+       if ((tmp & AT91_WDT_WDFIEN) && wdt->irq) {
+-              err = request_irq(wdt->irq, wdt_interrupt,
+-                                IRQF_SHARED | IRQF_IRQPOLL |
+-                                IRQF_NO_SUSPEND,
+-                                pdev->name, wdt);
++              err = devm_request_irq(dev, wdt->irq, wdt_interrupt,
++                                     IRQF_SHARED | IRQF_IRQPOLL | IRQF_NO_SUSPEND,
++                                     pdev->name, wdt);
+               if (err)
+                       return err;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/watchdog-fix-kmemleak-in-watchdog_cdev_register.patch b/queue-5.15/watchdog-fix-kmemleak-in-watchdog_cdev_register.patch
new file mode 100644 (file)
index 0000000..049c53c
--- /dev/null
@@ -0,0 +1,91 @@
+From 9425c68865a6a78cfaaf001d58aeab69943fd40b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Nov 2022 01:27:14 +0000
+Subject: watchdog: Fix kmemleak in watchdog_cdev_register
+
+From: Chen Jun <chenjun102@huawei.com>
+
+[ Upstream commit 13721a2ac66b246f5802ba1b75ad8637e53eeecc ]
+
+kmemleak reports memory leaks in watchdog_dev_register, as follows:
+unreferenced object 0xffff888116233000 (size 2048):
+  comm ""modprobe"", pid 28147, jiffies 4353426116 (age 61.741s)
+  hex dump (first 32 bytes):
+    80 fa b9 05 81 88 ff ff 08 30 23 16 81 88 ff ff  .........0#.....
+    08 30 23 16 81 88 ff ff 00 00 00 00 00 00 00 00  .0#.............
+  backtrace:
+    [<000000007f001ffd>] __kmem_cache_alloc_node+0x157/0x220
+    [<000000006a389304>] kmalloc_trace+0x21/0x110
+    [<000000008d640eea>] watchdog_dev_register+0x4e/0x780 [watchdog]
+    [<0000000053c9f248>] __watchdog_register_device+0x4f0/0x680 [watchdog]
+    [<00000000b2979824>] watchdog_register_device+0xd2/0x110 [watchdog]
+    [<000000001f730178>] 0xffffffffc10880ae
+    [<000000007a1a8bcc>] do_one_initcall+0xcb/0x4d0
+    [<00000000b98be325>] do_init_module+0x1ca/0x5f0
+    [<0000000046d08e7c>] load_module+0x6133/0x70f0
+    ...
+
+unreferenced object 0xffff888105b9fa80 (size 16):
+  comm ""modprobe"", pid 28147, jiffies 4353426116 (age 61.741s)
+  hex dump (first 16 bytes):
+    77 61 74 63 68 64 6f 67 31 00 b9 05 81 88 ff ff  watchdog1.......
+  backtrace:
+    [<000000007f001ffd>] __kmem_cache_alloc_node+0x157/0x220
+    [<00000000486ab89b>] __kmalloc_node_track_caller+0x44/0x1b0
+    [<000000005a39aab0>] kvasprintf+0xb5/0x140
+    [<0000000024806f85>] kvasprintf_const+0x55/0x180
+    [<000000009276cb7f>] kobject_set_name_vargs+0x56/0x150
+    [<00000000a92e820b>] dev_set_name+0xab/0xe0
+    [<00000000cec812c6>] watchdog_dev_register+0x285/0x780 [watchdog]
+    [<0000000053c9f248>] __watchdog_register_device+0x4f0/0x680 [watchdog]
+    [<00000000b2979824>] watchdog_register_device+0xd2/0x110 [watchdog]
+    [<000000001f730178>] 0xffffffffc10880ae
+    [<000000007a1a8bcc>] do_one_initcall+0xcb/0x4d0
+    [<00000000b98be325>] do_init_module+0x1ca/0x5f0
+    [<0000000046d08e7c>] load_module+0x6133/0x70f0
+    ...
+
+The reason is that put_device is not be called if cdev_device_add fails
+and wdd->id != 0.
+
+watchdog_cdev_register
+  wd_data = kzalloc                             [1]
+  err = dev_set_name                            [2]
+  ..
+  err = cdev_device_add
+  if (err) {
+    if (wdd->id == 0) {  // wdd->id != 0
+      ..
+    }
+    return err;  // [1],[2] would be leaked
+
+To fix it, call put_device in all wdd->id cases.
+
+Fixes: 72139dfa2464 ("watchdog: Fix the race between the release of watchdog_core_data and cdev")
+Signed-off-by: Chen Jun <chenjun102@huawei.com>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Link: https://lore.kernel.org/r/20221116012714.102066-1-chenjun102@huawei.com
+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/watchdog_dev.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
+index 3a3d8b5c7ad59..5eec84fa65170 100644
+--- a/drivers/watchdog/watchdog_dev.c
++++ b/drivers/watchdog/watchdog_dev.c
+@@ -1044,8 +1044,8 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
+               if (wdd->id == 0) {
+                       misc_deregister(&watchdog_miscdev);
+                       old_wd_data = NULL;
+-                      put_device(&wd_data->dev);
+               }
++              put_device(&wd_data->dev);
+               return err;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.15/watchdog-pcwd_usb-fix-attempting-to-access-uninitial.patch b/queue-5.15/watchdog-pcwd_usb-fix-attempting-to-access-uninitial.patch
new file mode 100644 (file)
index 0000000..cad9673
--- /dev/null
@@ -0,0 +1,64 @@
+From 791731bed951151eb981020b766eac777d757afa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Nov 2022 10:07:06 +0800
+Subject: watchdog: pcwd_usb: Fix attempting to access uninitialized memory
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Li Hua <hucool.lihua@huawei.com>
+
+[ Upstream commit 7d06c07c67100fd0f8e6b3ab7145ce789f788117 ]
+
+The stack variable msb and lsb may be used uninitialized in function
+usb_pcwd_get_temperature and usb_pcwd_get_timeleft when usb card no response.
+
+The build waring is:
+drivers/watchdog/pcwd_usb.c:336:22: error: ‘lsb’ is used uninitialized in this function [-Werror=uninitialized]
+  *temperature = (lsb * 9 / 5) + 32;
+                  ~~~~^~~
+drivers/watchdog/pcwd_usb.c:328:21: note: ‘lsb’ was declared here
+  unsigned char msb, lsb;
+                     ^~~
+cc1: all warnings being treated as errors
+scripts/Makefile.build:250: recipe for target 'drivers/watchdog/pcwd_usb.o' failed
+make[3]: *** [drivers/watchdog/pcwd_usb.o] Error 1
+
+Fixes: b7e04f8c61a4 ("mv watchdog tree under drivers")
+Signed-off-by: Li Hua <hucool.lihua@huawei.com>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Link: https://lore.kernel.org/r/20221116020706.70847-1-hucool.lihua@huawei.com
+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/pcwd_usb.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
+index 1bdaf17c1d38d..8202f0a6b0935 100644
+--- a/drivers/watchdog/pcwd_usb.c
++++ b/drivers/watchdog/pcwd_usb.c
+@@ -325,7 +325,8 @@ static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t)
+ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
+                                                       int *temperature)
+ {
+-      unsigned char msb, lsb;
++      unsigned char msb = 0x00;
++      unsigned char lsb = 0x00;
+       usb_pcwd_send_command(usb_pcwd, CMD_READ_TEMP, &msb, &lsb);
+@@ -341,7 +342,8 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
+ static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
+                                                               int *time_left)
+ {
+-      unsigned char msb, lsb;
++      unsigned char msb = 0x00;
++      unsigned char lsb = 0x00;
+       /* Read the time that's left before rebooting */
+       /* Note: if the board is not yet armed then we will read 0xFFFF */
+-- 
+2.39.2
+
diff --git a/queue-5.15/watchdog-sbsa_wdog-make-sure-the-timeout-programming.patch b/queue-5.15/watchdog-sbsa_wdog-make-sure-the-timeout-programming.patch
new file mode 100644 (file)
index 0000000..6a240c1
--- /dev/null
@@ -0,0 +1,41 @@
+From c93579b9ea742f5017265c8daea7ba471844bef3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 9 Feb 2023 02:11:17 +0000
+Subject: watchdog: sbsa_wdog: Make sure the timeout programming is within the
+ limits
+
+From: George Cherian <george.cherian@marvell.com>
+
+[ Upstream commit 000987a38b53c172f435142a4026dd71378ca464 ]
+
+Make sure to honour the max_hw_heartbeat_ms while programming the timeout
+value to WOR. Clamp the timeout passed to sbsa_gwdt_set_timeout() to
+make sure the programmed value is within the permissible range.
+
+Fixes: abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")
+
+Signed-off-by: George Cherian <george.cherian@marvell.com>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Link: https://lore.kernel.org/r/20230209021117.1512097-1-george.cherian@marvell.com
+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/sbsa_gwdt.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
+index 9791c74aebd48..63862803421f1 100644
+--- a/drivers/watchdog/sbsa_gwdt.c
++++ b/drivers/watchdog/sbsa_gwdt.c
+@@ -150,6 +150,7 @@ static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd,
+       struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
+       wdd->timeout = timeout;
++      timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000);
+       if (action)
+               sbsa_gwdt_reg_write(gwdt->clk * timeout, gwdt);
+-- 
+2.39.2
+
diff --git a/queue-5.15/x86-um-vdso-add-rcx-and-r11-to-the-syscall-clobber-l.patch b/queue-5.15/x86-um-vdso-add-rcx-and-r11-to-the-syscall-clobber-l.patch
new file mode 100644 (file)
index 0000000..d1f6152
--- /dev/null
@@ -0,0 +1,59 @@
+From 78786ad050dbc6d0ac3ca514bfe9a8e97b372abb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 24 Dec 2022 00:23:38 +0700
+Subject: x86: um: vdso: Add '%rcx' and '%r11' to the syscall clobber list
+
+From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
+
+[ Upstream commit 5541992e512de8c9133110809f767bd1b54ee10d ]
+
+The 'syscall' instruction clobbers '%rcx' and '%r11', but they are not
+listed in the inline Assembly that performs the syscall instruction.
+
+No real bug is found. It wasn't buggy by luck because '%rcx' and '%r11'
+are caller-saved registers, and not used in the functions, and the
+functions are never inlined.
+
+Add them to the clobber list for code correctness.
+
+Fixes: f1c2bb8b9964ed31de988910f8b1cfb586d30091 ("um: implement a x86_64 vDSO")
+Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/x86/um/vdso/um_vdso.c | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/arch/x86/um/vdso/um_vdso.c b/arch/x86/um/vdso/um_vdso.c
+index 2112b8d146688..ff0f3b4b6c45e 100644
+--- a/arch/x86/um/vdso/um_vdso.c
++++ b/arch/x86/um/vdso/um_vdso.c
+@@ -17,8 +17,10 @@ int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
+ {
+       long ret;
+-      asm("syscall" : "=a" (ret) :
+-              "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
++      asm("syscall"
++              : "=a" (ret)
++              : "0" (__NR_clock_gettime), "D" (clock), "S" (ts)
++              : "rcx", "r11", "memory");
+       return ret;
+ }
+@@ -29,8 +31,10 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
+ {
+       long ret;
+-      asm("syscall" : "=a" (ret) :
+-              "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
++      asm("syscall"
++              : "=a" (ret)
++              : "0" (__NR_gettimeofday), "D" (tv), "S" (tz)
++              : "rcx", "r11", "memory");
+       return ret;
+ }
+-- 
+2.39.2
+