]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Sat, 20 May 2023 01:27:30 +0000 (21:27 -0400)
committerSasha Levin <sashal@kernel.org>
Sat, 20 May 2023 01:27:30 +0000 (21:27 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
43 files changed:
queue-5.4/acpi-ec-fix-oops-when-removing-custom-query-handlers.patch [new file with mode: 0644]
queue-5.4/acpica-acpica-check-null-return-of-acpi_allocate_zer.patch [new file with mode: 0644]
queue-5.4/acpica-avoid-undefined-behavior-applying-zero-offset.patch [new file with mode: 0644]
queue-5.4/bluetooth-l2cap-fix-bad-unlock-balance-in-l2cap_disc.patch [new file with mode: 0644]
queue-5.4/clk-tegra20-fix-gcc-7-constant-overflow-warning.patch [new file with mode: 0644]
queue-5.4/drm-amd-display-use-dc_log_dc-in-the-trasform-pixel-.patch [new file with mode: 0644]
queue-5.4/drm-tegra-avoid-potential-32-bit-integer-overflow.patch [new file with mode: 0644]
queue-5.4/ext2-check-block-size-validity-during-mount.patch [new file with mode: 0644]
queue-5.4/ext4-fix-best-extent-lstart-adjustment-logic-in-ext4.patch [new file with mode: 0644]
queue-5.4/ext4-set-goal-start-correctly-in-ext4_mb_normalize_r.patch [new file with mode: 0644]
queue-5.4/f2fs-fix-to-drop-all-dirty-pages-during-umount-if-cp.patch [new file with mode: 0644]
queue-5.4/firmware-arm_sdei-fix-sleep-from-invalid-context-bug.patch [new file with mode: 0644]
queue-5.4/fs-hfsplus-remove-warn_on-from-hfsplus_cat_-read-wri.patch [new file with mode: 0644]
queue-5.4/gfs2-fix-inode-height-consistency-check.patch [new file with mode: 0644]
queue-5.4/hid-logitech-hidpp-don-t-use-the-usb-serial-for-usb-.patch [new file with mode: 0644]
queue-5.4/hid-logitech-hidpp-reconcile-usb-and-unifying-serial.patch [new file with mode: 0644]
queue-5.4/hid-wacom-generic-set-battery-quirk-only-when-we-see.patch [new file with mode: 0644]
queue-5.4/input-xpad-add-constants-for-gip-interface-numbers.patch [new file with mode: 0644]
queue-5.4/iommu-arm-smmu-v3-acknowledge-pri-event-queue-overfl.patch [new file with mode: 0644]
queue-5.4/lib-cpu_rmap-avoid-use-after-free-on-rmap-obj-array-.patch [new file with mode: 0644]
queue-5.4/mcb-pci-reallocate-memory-region-to-avoid-memory-ove.patch [new file with mode: 0644]
queue-5.4/memstick-r592-fix-uaf-bug-in-r592_remove-due-to-race.patch [new file with mode: 0644]
queue-5.4/mfd-dln2-fix-memory-leak-in-dln2_probe.patch [new file with mode: 0644]
queue-5.4/net-catch-invalid-index-in-xps-mapping.patch [new file with mode: 0644]
queue-5.4/net-pasemi-fix-return-type-of-pasemi_mac_start_tx.patch [new file with mode: 0644]
queue-5.4/phy-st-miphy28lp-use-_poll_timeout-functions-for-wai.patch [new file with mode: 0644]
queue-5.4/rdma-core-fix-multiple-warray-bounds-warnings.patch [new file with mode: 0644]
queue-5.4/recordmcount-fix-memory-leaks-in-the-uwrite-function.patch [new file with mode: 0644]
queue-5.4/regmap-cache-return-error-in-cache-sync-operations-f.patch [new file with mode: 0644]
queue-5.4/samples-bpf-fix-fout-leak-in-hbm-s-run_bpf_prog.patch [new file with mode: 0644]
queue-5.4/sched-fix-kcsan-noinstr-violation.patch [new file with mode: 0644]
queue-5.4/scsi-lpfc-prevent-lpfc_debugfs_lockstat_write-buffer.patch [new file with mode: 0644]
queue-5.4/scsi-message-mptlan-fix-use-after-free-bug-in-mptlan.patch [new file with mode: 0644]
queue-5.4/scsi-target-iscsit-free-cmds-before-session-free.patch [new file with mode: 0644]
queue-5.4/serial-8250-reinit-port-pm-on-port-specific-driver-u.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/spi-spi-imx-fix-mx51_ecspi_-macros-when-cs-3.patch [new file with mode: 0644]
queue-5.4/staging-rtl8192e-replace-macro-rtl_pci_device-with-p.patch [new file with mode: 0644]
queue-5.4/usb-typec-tcpm-fix-multiple-times-discover-svids-err.patch [new file with mode: 0644]
queue-5.4/wifi-brcmfmac-cfg80211-pass-the-pmk-in-binary-instea.patch [new file with mode: 0644]
queue-5.4/wifi-iwlwifi-dvm-fix-memcpy-detected-field-spanning-.patch [new file with mode: 0644]
queue-5.4/wifi-iwlwifi-pcie-fix-integer-overflow-in-iwl_write_.patch [new file with mode: 0644]
queue-5.4/wifi-iwlwifi-pcie-fix-possible-null-pointer-derefere.patch [new file with mode: 0644]

diff --git a/queue-5.4/acpi-ec-fix-oops-when-removing-custom-query-handlers.patch b/queue-5.4/acpi-ec-fix-oops-when-removing-custom-query-handlers.patch
new file mode 100644 (file)
index 0000000..b7eec04
--- /dev/null
@@ -0,0 +1,40 @@
+From 5744c48e68de65a447398a753b295d02477760ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 24 Mar 2023 21:26:27 +0100
+Subject: ACPI: EC: Fix oops when removing custom query handlers
+
+From: Armin Wolf <W_Armin@gmx.de>
+
+[ Upstream commit e5b492c6bb900fcf9722e05f4a10924410e170c1 ]
+
+When removing custom query handlers, the handler might still
+be used inside the EC query workqueue, causing a kernel oops
+if the module holding the callback function was already unloaded.
+
+Fix this by flushing the EC query workqueue when removing
+custom query handlers.
+
+Tested on a Acer Travelmate 4002WLMi
+
+Signed-off-by: Armin Wolf <W_Armin@gmx.de>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/ec.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
+index defc5796b5084..c7baccd47b89f 100644
+--- a/drivers/acpi/ec.c
++++ b/drivers/acpi/ec.c
+@@ -1118,6 +1118,7 @@ static void acpi_ec_remove_query_handlers(struct acpi_ec *ec,
+ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
+ {
+       acpi_ec_remove_query_handlers(ec, false, query_bit);
++      flush_workqueue(ec_query_wq);
+ }
+ EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
+-- 
+2.39.2
+
diff --git a/queue-5.4/acpica-acpica-check-null-return-of-acpi_allocate_zer.patch b/queue-5.4/acpica-acpica-check-null-return-of-acpi_allocate_zer.patch
new file mode 100644 (file)
index 0000000..68e670a
--- /dev/null
@@ -0,0 +1,40 @@
+From 5d6476cb72e7f2f46ae38e0547915ca9a9e4024b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 5 Apr 2023 15:57:57 +0200
+Subject: ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in
+ acpi_db_display_objects
+
+From: void0red <30990023+void0red@users.noreply.github.com>
+
+[ Upstream commit ae5a0eccc85fc960834dd66e3befc2728284b86c ]
+
+ACPICA commit 0d5f467d6a0ba852ea3aad68663cbcbd43300fd4
+
+ACPI_ALLOCATE_ZEROED may fails, object_info might be null and will cause
+null pointer dereference later.
+
+Link: https://github.com/acpica/acpica/commit/0d5f467d
+Signed-off-by: Bob Moore <robert.moore@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/acpica/dbnames.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
+index 63fe30e868075..7f14403165dd1 100644
+--- a/drivers/acpi/acpica/dbnames.c
++++ b/drivers/acpi/acpica/dbnames.c
+@@ -571,6 +571,9 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
+               object_info =
+                   ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
++              if (!object_info)
++                      return (AE_NO_MEMORY);
++
+               /* Walk the namespace from the root */
+               (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
+-- 
+2.39.2
+
diff --git a/queue-5.4/acpica-avoid-undefined-behavior-applying-zero-offset.patch b/queue-5.4/acpica-avoid-undefined-behavior-applying-zero-offset.patch
new file mode 100644 (file)
index 0000000..d4fd44c
--- /dev/null
@@ -0,0 +1,68 @@
+From 334feea4b960e33cf571411a2cf505f417a22f39 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 5 Apr 2023 15:42:43 +0200
+Subject: ACPICA: Avoid undefined behavior: applying zero offset to null
+ pointer
+
+From: Tamir Duberstein <tamird@google.com>
+
+[ Upstream commit 05bb0167c80b8f93c6a4e0451b7da9b96db990c2 ]
+
+ACPICA commit 770653e3ba67c30a629ca7d12e352d83c2541b1e
+
+Before this change we see the following UBSAN stack trace in Fuchsia:
+
+  #0    0x000021e4213b3302 in acpi_ds_init_aml_walk(struct acpi_walk_state*, union acpi_parse_object*, struct acpi_namespace_node*, u8*, u32, struct acpi_evaluate_info*, u8) ../../third_party/acpica/source/components/dispatcher/dswstate.c:682 <platform-bus-x86.so>+0x233302
+  #1.2  0x000020d0f660777f in ubsan_get_stack_trace() compiler-rt/lib/ubsan/ubsan_diag.cpp:41 <libclang_rt.asan.so>+0x3d77f
+  #1.1  0x000020d0f660777f in maybe_print_stack_trace() compiler-rt/lib/ubsan/ubsan_diag.cpp:51 <libclang_rt.asan.so>+0x3d77f
+  #1    0x000020d0f660777f in ~scoped_report() compiler-rt/lib/ubsan/ubsan_diag.cpp:387 <libclang_rt.asan.so>+0x3d77f
+  #2    0x000020d0f660b96d in handlepointer_overflow_impl() compiler-rt/lib/ubsan/ubsan_handlers.cpp:809 <libclang_rt.asan.so>+0x4196d
+  #3    0x000020d0f660b50d in compiler-rt/lib/ubsan/ubsan_handlers.cpp:815 <libclang_rt.asan.so>+0x4150d
+  #4    0x000021e4213b3302 in acpi_ds_init_aml_walk(struct acpi_walk_state*, union acpi_parse_object*, struct acpi_namespace_node*, u8*, u32, struct acpi_evaluate_info*, u8) ../../third_party/acpica/source/components/dispatcher/dswstate.c:682 <platform-bus-x86.so>+0x233302
+  #5    0x000021e4213e2369 in acpi_ds_call_control_method(struct acpi_thread_state*, struct acpi_walk_state*, union acpi_parse_object*) ../../third_party/acpica/source/components/dispatcher/dsmethod.c:605 <platform-bus-x86.so>+0x262369
+  #6    0x000021e421437fac in acpi_ps_parse_aml(struct acpi_walk_state*) ../../third_party/acpica/source/components/parser/psparse.c:550 <platform-bus-x86.so>+0x2b7fac
+  #7    0x000021e4214464d2 in acpi_ps_execute_method(struct acpi_evaluate_info*) ../../third_party/acpica/source/components/parser/psxface.c:244 <platform-bus-x86.so>+0x2c64d2
+  #8    0x000021e4213aa052 in acpi_ns_evaluate(struct acpi_evaluate_info*) ../../third_party/acpica/source/components/namespace/nseval.c:250 <platform-bus-x86.so>+0x22a052
+  #9    0x000021e421413dd8 in acpi_ns_init_one_device(acpi_handle, u32, void*, void**) ../../third_party/acpica/source/components/namespace/nsinit.c:735 <platform-bus-x86.so>+0x293dd8
+  #10   0x000021e421429e98 in acpi_ns_walk_namespace(acpi_object_type, acpi_handle, u32, u32, acpi_walk_callback, acpi_walk_callback, void*, void**) ../../third_party/acpica/source/components/namespace/nswalk.c:298 <platform-bus-x86.so>+0x2a9e98
+  #11   0x000021e4214131ac in acpi_ns_initialize_devices(u32) ../../third_party/acpica/source/components/namespace/nsinit.c:268 <platform-bus-x86.so>+0x2931ac
+  #12   0x000021e42147c40d in acpi_initialize_objects(u32) ../../third_party/acpica/source/components/utilities/utxfinit.c:304 <platform-bus-x86.so>+0x2fc40d
+  #13   0x000021e42126d603 in acpi::acpi_impl::initialize_acpi(acpi::acpi_impl*) ../../src/devices/board/lib/acpi/acpi-impl.cc:224 <platform-bus-x86.so>+0xed603
+
+Add a simple check that avoids incrementing a pointer by zero, but
+otherwise behaves as before. Note that our findings are against ACPICA
+20221020, but the same code exists on master.
+
+Link: https://github.com/acpica/acpica/commit/770653e3
+Signed-off-by: Bob Moore <robert.moore@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/acpica/dswstate.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
+index de79f835a3737..7979d52dfbc96 100644
+--- a/drivers/acpi/acpica/dswstate.c
++++ b/drivers/acpi/acpica/dswstate.c
+@@ -576,9 +576,14 @@ acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
+       ACPI_FUNCTION_TRACE(ds_init_aml_walk);
+       walk_state->parser_state.aml =
+-          walk_state->parser_state.aml_start = aml_start;
+-      walk_state->parser_state.aml_end =
+-          walk_state->parser_state.pkg_end = aml_start + aml_length;
++          walk_state->parser_state.aml_start =
++          walk_state->parser_state.aml_end =
++          walk_state->parser_state.pkg_end = aml_start;
++      /* Avoid undefined behavior: applying zero offset to null pointer */
++      if (aml_length != 0) {
++              walk_state->parser_state.aml_end += aml_length;
++              walk_state->parser_state.pkg_end += aml_length;
++      }
+       /* The next_op of the next_walk will be the beginning of the method */
+-- 
+2.39.2
+
diff --git a/queue-5.4/bluetooth-l2cap-fix-bad-unlock-balance-in-l2cap_disc.patch b/queue-5.4/bluetooth-l2cap-fix-bad-unlock-balance-in-l2cap_disc.patch
new file mode 100644 (file)
index 0000000..e535393
--- /dev/null
@@ -0,0 +1,37 @@
+From 6dc099b44d26e1ce5027e04c6c223d2f18435e12 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 17 Apr 2023 10:27:54 +0800
+Subject: Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp
+
+From: Min Li <lm0963hack@gmail.com>
+
+[ Upstream commit 25e97f7b1866e6b8503be349eeea44bb52d661ce ]
+
+conn->chan_lock isn't acquired before l2cap_get_chan_by_scid,
+if l2cap_get_chan_by_scid returns NULL, then 'bad unlock balance'
+is triggered.
+
+Reported-by: syzbot+9519d6b5b79cf7787cf3@syzkaller.appspotmail.com
+Link: https://lore.kernel.org/all/000000000000894f5f05f95e9f4d@google.com/
+Signed-off-by: Min Li <lm0963hack@gmail.com>
+Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/bluetooth/l2cap_core.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
+index 3c559a177761b..5f53e75d83024 100644
+--- a/net/bluetooth/l2cap_core.c
++++ b/net/bluetooth/l2cap_core.c
+@@ -4410,7 +4410,6 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
+       chan = l2cap_get_chan_by_scid(conn, scid);
+       if (!chan) {
+-              mutex_unlock(&conn->chan_lock);
+               return 0;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.4/clk-tegra20-fix-gcc-7-constant-overflow-warning.patch b/queue-5.4/clk-tegra20-fix-gcc-7-constant-overflow-warning.patch
new file mode 100644 (file)
index 0000000..ef90528
--- /dev/null
@@ -0,0 +1,75 @@
+From ea0cae14a59da4180fa5bd5b25f07d9568a01a15 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 27 Feb 2023 09:59:10 +0100
+Subject: clk: tegra20: fix gcc-7 constant overflow warning
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+[ Upstream commit b4a2adbf3586efa12fe78b9dec047423e01f3010 ]
+
+Older gcc versions get confused by comparing a u32 value to a negative
+constant in a switch()/case block:
+
+drivers/clk/tegra/clk-tegra20.c: In function 'tegra20_clk_measure_input_freq':
+drivers/clk/tegra/clk-tegra20.c:581:2: error: case label does not reduce to an integer constant
+  case OSC_CTRL_OSC_FREQ_12MHZ:
+  ^~~~
+drivers/clk/tegra/clk-tegra20.c:593:2: error: case label does not reduce to an integer constant
+  case OSC_CTRL_OSC_FREQ_26MHZ:
+
+Make the constants unsigned instead.
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Link: https://lore.kernel.org/r/20230227085914.2560984-1-arnd@kernel.org
+Signed-off-by: Stephen Boyd <sboyd@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/tegra/clk-tegra20.c | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
+index 3e0f04f0e16e5..3f74497d73e58 100644
+--- a/drivers/clk/tegra/clk-tegra20.c
++++ b/drivers/clk/tegra/clk-tegra20.c
+@@ -18,24 +18,24 @@
+ #define MISC_CLK_ENB 0x48
+ #define OSC_CTRL 0x50
+-#define OSC_CTRL_OSC_FREQ_MASK (3<<30)
+-#define OSC_CTRL_OSC_FREQ_13MHZ (0<<30)
+-#define OSC_CTRL_OSC_FREQ_19_2MHZ (1<<30)
+-#define OSC_CTRL_OSC_FREQ_12MHZ (2<<30)
+-#define OSC_CTRL_OSC_FREQ_26MHZ (3<<30)
+-#define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK)
+-
+-#define OSC_CTRL_PLL_REF_DIV_MASK (3<<28)
+-#define OSC_CTRL_PLL_REF_DIV_1                (0<<28)
+-#define OSC_CTRL_PLL_REF_DIV_2                (1<<28)
+-#define OSC_CTRL_PLL_REF_DIV_4                (2<<28)
++#define OSC_CTRL_OSC_FREQ_MASK (3u<<30)
++#define OSC_CTRL_OSC_FREQ_13MHZ (0u<<30)
++#define OSC_CTRL_OSC_FREQ_19_2MHZ (1u<<30)
++#define OSC_CTRL_OSC_FREQ_12MHZ (2u<<30)
++#define OSC_CTRL_OSC_FREQ_26MHZ (3u<<30)
++#define OSC_CTRL_MASK (0x3f2u | OSC_CTRL_OSC_FREQ_MASK)
++
++#define OSC_CTRL_PLL_REF_DIV_MASK     (3u<<28)
++#define OSC_CTRL_PLL_REF_DIV_1                (0u<<28)
++#define OSC_CTRL_PLL_REF_DIV_2                (1u<<28)
++#define OSC_CTRL_PLL_REF_DIV_4                (2u<<28)
+ #define OSC_FREQ_DET 0x58
+-#define OSC_FREQ_DET_TRIG (1<<31)
++#define OSC_FREQ_DET_TRIG (1u<<31)
+ #define OSC_FREQ_DET_STATUS 0x5c
+-#define OSC_FREQ_DET_BUSY (1<<31)
+-#define OSC_FREQ_DET_CNT_MASK 0xFFFF
++#define OSC_FREQ_DET_BUSYu (1<<31)
++#define OSC_FREQ_DET_CNT_MASK 0xFFFFu
+ #define TEGRA20_CLK_PERIPH_BANKS      3
+-- 
+2.39.2
+
diff --git a/queue-5.4/drm-amd-display-use-dc_log_dc-in-the-trasform-pixel-.patch b/queue-5.4/drm-amd-display-use-dc_log_dc-in-the-trasform-pixel-.patch
new file mode 100644 (file)
index 0000000..3c0269b
--- /dev/null
@@ -0,0 +1,109 @@
+From dfd06f0470a5a71d7d03648b7fd3c8c3f4fba201 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 1 Nov 2022 10:20:09 -0400
+Subject: drm/amd/display: Use DC_LOG_DC in the trasform pixel function
+
+From: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
+
+[ Upstream commit 7222f5841ff49709ca666b05ff336776e0664a20 ]
+
+[Why & How]
+DC now uses a new commit sequence which is more robust since it
+addresses cases where we need to reorganize pipes based on planes and
+other parameters. As a result, this new commit sequence reset the DC
+state by cleaning plane states and re-creating them accordingly with the
+need. For this reason, the dce_transform_set_pixel_storage_depth can be
+invoked after a plane state is destroyed and before its re-creation. In
+this situation and on DCE devices, DC will hit a condition that will
+trigger a dmesg log that looks like this:
+
+Console: switching to colour frame buffer device 240x67
+------------[ cut here ]------------
+[..]
+Hardware name: System manufacturer System Product Name/PRIME X370-PRO, BIOS 5603 07/28/2020
+RIP: 0010:dce_transform_set_pixel_storage_depth+0x3f8/0x480 [amdgpu]
+[..]
+RSP: 0018:ffffc9000202b850 EFLAGS: 00010293
+RAX: ffffffffa081d100 RBX: ffff888110790000 RCX: 000000000000000c
+RDX: ffff888100bedbf8 RSI: 0000000000001a50 RDI: ffff88810463c900
+RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000007
+R10: 0000000000000001 R11: 0000000000000f00 R12: ffff88810f500010
+R13: ffff888100bedbf8 R14: ffff88810f515688 R15: 0000000000000000
+FS:  00007ff0159249c0(0000) GS:ffff88840e940000(0000) knlGS:0000000000000000
+CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+CR2: 00007ff01528e550 CR3: 0000000002a10000 CR4: 00000000003506e0
+Call Trace:
+ <TASK>
+ ? dm_write_reg_func+0x21/0x80 [amdgpu 340dadd3f7c8cf4be11cf0bdc850245e99abe0e8]
+ dc_stream_set_dither_option+0xfb/0x130 [amdgpu 340dadd3f7c8cf4be11cf0bdc850245e99abe0e8]
+ amdgpu_dm_crtc_configure_crc_source+0x10b/0x190 [amdgpu 340dadd3f7c8cf4be11cf0bdc850245e99abe0e8]
+ amdgpu_dm_atomic_commit_tail+0x20a8/0x2a90 [amdgpu 340dadd3f7c8cf4be11cf0bdc850245e99abe0e8]
+ ? free_unref_page_commit+0x98/0x170
+ ? free_unref_page+0xcc/0x150
+ commit_tail+0x94/0x120
+ drm_atomic_helper_commit+0x10f/0x140
+ drm_atomic_commit+0x94/0xc0
+ ? drm_plane_get_damage_clips.cold+0x1c/0x1c
+ drm_client_modeset_commit_atomic+0x203/0x250
+ drm_client_modeset_commit_locked+0x56/0x150
+ drm_client_modeset_commit+0x21/0x40
+ drm_fb_helper_lastclose+0x42/0x70
+ amdgpu_driver_lastclose_kms+0xa/0x10 [amdgpu 340dadd3f7c8cf4be11cf0bdc850245e99abe0e8]
+ drm_release+0xda/0x110
+ __fput+0x89/0x240
+ task_work_run+0x5c/0x90
+ do_exit+0x333/0xae0
+ do_group_exit+0x2d/0x90
+ __x64_sys_exit_group+0x14/0x20
+ do_syscall_64+0x5b/0x80
+ ? exit_to_user_mode_prepare+0x1e/0x140
+ entry_SYSCALL_64_after_hwframe+0x44/0xae
+RIP: 0033:0x7ff016ceaca1
+Code: Unable to access opcode bytes at RIP 0x7ff016ceac77.
+RSP: 002b:00007ffe7a2357e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
+RAX: ffffffffffffffda RBX: 00007ff016e15a00 RCX: 00007ff016ceaca1
+RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
+RBP: 0000000000000000 R08: ffffffffffffff78 R09: 0000000000000000
+R10: 0000000000000000 R11: 0000000000000246 R12: 00007ff016e15a00
+R13: 0000000000000000 R14: 00007ff016e1aee8 R15: 00007ff016e1af00
+ </TASK>
+
+Since this issue only happens in a transition state on DC, this commit
+replace BREAK_TO_DEBUGGER with DC_LOG_DC.
+
+Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
+Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
+Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
+Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/amd/display/dc/dce/dce_transform.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
+index 6fd57cfb112f5..96fdc18ecb3bf 100644
+--- a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
++++ b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
+@@ -778,7 +778,7 @@ static void dce_transform_set_pixel_storage_depth(
+               color_depth = COLOR_DEPTH_101010;
+               pixel_depth = 0;
+               expan_mode  = 1;
+-              BREAK_TO_DEBUGGER();
++              DC_LOG_DC("The pixel depth %d is not valid, set COLOR_DEPTH_101010 instead.", depth);
+               break;
+       }
+@@ -792,8 +792,7 @@ static void dce_transform_set_pixel_storage_depth(
+       if (!(xfm_dce->lb_pixel_depth_supported & depth)) {
+               /*we should use unsupported capabilities
+                *  unless it is required by w/a*/
+-              DC_LOG_WARNING("%s: Capability not supported",
+-                      __func__);
++              DC_LOG_DC("%s: Capability not supported", __func__);
+       }
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.4/drm-tegra-avoid-potential-32-bit-integer-overflow.patch b/queue-5.4/drm-tegra-avoid-potential-32-bit-integer-overflow.patch
new file mode 100644 (file)
index 0000000..2fc5515
--- /dev/null
@@ -0,0 +1,37 @@
+From 58d990d19239f3ee4113745a0be56858e5c8011a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 6 Apr 2023 04:25:59 +0800
+Subject: drm/tegra: Avoid potential 32-bit integer overflow
+
+From: Nur Hussein <hussein@unixcat.org>
+
+[ Upstream commit 2429b3c529da29d4277d519bd66d034842dcd70c ]
+
+In tegra_sor_compute_config(), the 32-bit value mode->clock is
+multiplied by 1000, and assigned to the u64 variable pclk. We can avoid
+a potential 32-bit integer overflow by casting mode->clock to u64 before
+we do the arithmetic and assignment.
+
+Signed-off-by: Nur Hussein <hussein@unixcat.org>
+Signed-off-by: Thierry Reding <treding@nvidia.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/tegra/sor.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
+index 0419b6105c8a5..ccd084abc8c94 100644
+--- a/drivers/gpu/drm/tegra/sor.c
++++ b/drivers/gpu/drm/tegra/sor.c
+@@ -906,7 +906,7 @@ static int tegra_sor_compute_config(struct tegra_sor *sor,
+                                   struct drm_dp_link *link)
+ {
+       const u64 f = 100000, link_rate = link->rate * 1000;
+-      const u64 pclk = mode->clock * 1000;
++      const u64 pclk = (u64)mode->clock * 1000;
+       u64 input, output, watermark, num;
+       struct tegra_sor_params params;
+       u32 num_syms_per_line;
+-- 
+2.39.2
+
diff --git a/queue-5.4/ext2-check-block-size-validity-during-mount.patch b/queue-5.4/ext2-check-block-size-validity-during-mount.patch
new file mode 100644 (file)
index 0000000..bc8c8cd
--- /dev/null
@@ -0,0 +1,54 @@
+From cfcdf253c08ca3be3f1e2363fc960cb959609959 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Mar 2023 11:59:39 +0100
+Subject: ext2: Check block size validity during mount
+
+From: Jan Kara <jack@suse.cz>
+
+[ Upstream commit 62aeb94433fcec80241754b70d0d1836d5926b0a ]
+
+Check that log of block size stored in the superblock has sensible
+value. Otherwise the shift computing the block size can overflow leading
+to undefined behavior.
+
+Reported-by: syzbot+4fec412f59eba8c01b77@syzkaller.appspotmail.com
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ext2/ext2.h  | 1 +
+ fs/ext2/super.c | 7 +++++++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
+index 10ab238de9a65..a89b43d759052 100644
+--- a/fs/ext2/ext2.h
++++ b/fs/ext2/ext2.h
+@@ -177,6 +177,7 @@ static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
+ #define EXT2_MIN_BLOCK_SIZE           1024
+ #define       EXT2_MAX_BLOCK_SIZE             4096
+ #define EXT2_MIN_BLOCK_LOG_SIZE                 10
++#define EXT2_MAX_BLOCK_LOG_SIZE                 16
+ #define EXT2_BLOCK_SIZE(s)            ((s)->s_blocksize)
+ #define       EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
+ #define EXT2_BLOCK_SIZE_BITS(s)               ((s)->s_blocksize_bits)
+diff --git a/fs/ext2/super.c b/fs/ext2/super.c
+index 644c83c115bc2..6e8e47871fa26 100644
+--- a/fs/ext2/super.c
++++ b/fs/ext2/super.c
+@@ -967,6 +967,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
+               goto failed_mount;
+       }
++      if (le32_to_cpu(es->s_log_block_size) >
++          (EXT2_MAX_BLOCK_LOG_SIZE - BLOCK_SIZE_BITS)) {
++              ext2_msg(sb, KERN_ERR,
++                       "Invalid log block size: %u",
++                       le32_to_cpu(es->s_log_block_size));
++              goto failed_mount;
++      }
+       blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
+       if (test_opt(sb, DAX)) {
+-- 
+2.39.2
+
diff --git a/queue-5.4/ext4-fix-best-extent-lstart-adjustment-logic-in-ext4.patch b/queue-5.4/ext4-fix-best-extent-lstart-adjustment-logic-in-ext4.patch
new file mode 100644 (file)
index 0000000..462c9fc
--- /dev/null
@@ -0,0 +1,129 @@
+From 3b072c8f8b2e3e35c5547b7406912d0e7c264c13 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 25 Mar 2023 13:43:39 +0530
+Subject: ext4: Fix best extent lstart adjustment logic in
+ ext4_mb_new_inode_pa()
+
+From: Ojaswin Mujoo <ojaswin@linux.ibm.com>
+
+[ Upstream commit 93cdf49f6eca5e23f6546b8f28457b2e6a6961d9 ]
+
+When the length of best extent found is less than the length of goal extent
+we need to make sure that the best extent atleast covers the start of the
+original request. This is done by adjusting the ac_b_ex.fe_logical (logical
+start) of the extent.
+
+While doing so, the current logic sometimes results in the best extent's
+logical range overflowing the goal extent. Since this best extent is later
+added to the inode preallocation list, we have a possibility of introducing
+overlapping preallocations. This is discussed in detail here [1].
+
+As per Jan's suggestion, to fix this, replace the existing logic with the
+below logic for adjusting best extent as it keeps fragmentation in check
+while ensuring logical range of best extent doesn't overflow out of goal
+extent:
+
+1. Check if best extent can be kept at end of goal range and still cover
+   original start.
+2. Else, check if best extent can be kept at start of goal range and still
+   cover original start.
+3. Else, keep the best extent at start of original request.
+
+Also, add a few extra BUG_ONs that might help catch errors faster.
+
+[1] https://lore.kernel.org/r/Y+OGkVvzPN0RMv0O@li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com
+
+Suggested-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
+Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/f96aca6d415b36d1f90db86c1a8cd7e2e9d7ab0e.1679731817.git.ojaswin@linux.ibm.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ext4/mballoc.c | 49 ++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 31 insertions(+), 18 deletions(-)
+
+diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
+index bdab18942e302..92c37fbbabc15 100644
+--- a/fs/ext4/mballoc.c
++++ b/fs/ext4/mballoc.c
+@@ -3378,6 +3378,7 @@ static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac,
+       BUG_ON(start < pa->pa_pstart);
+       BUG_ON(end > pa->pa_pstart + EXT4_C2B(sbi, pa->pa_len));
+       BUG_ON(pa->pa_free < len);
++      BUG_ON(ac->ac_b_ex.fe_len <= 0);
+       pa->pa_free -= len;
+       mb_debug(1, "use %llu/%u from inode pa %p\n", start, len, pa);
+@@ -3682,10 +3683,8 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
+               return -ENOMEM;
+       if (ac->ac_b_ex.fe_len < ac->ac_g_ex.fe_len) {
+-              int winl;
+-              int wins;
+-              int win;
+-              int offs;
++              int new_bex_start;
++              int new_bex_end;
+               /* we can't allocate as much as normalizer wants.
+                * so, found space must get proper lstart
+@@ -3693,26 +3692,40 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
+               BUG_ON(ac->ac_g_ex.fe_logical > ac->ac_o_ex.fe_logical);
+               BUG_ON(ac->ac_g_ex.fe_len < ac->ac_o_ex.fe_len);
+-              /* we're limited by original request in that
+-               * logical block must be covered any way
+-               * winl is window we can move our chunk within */
+-              winl = ac->ac_o_ex.fe_logical - ac->ac_g_ex.fe_logical;
++              /*
++               * Use the below logic for adjusting best extent as it keeps
++               * fragmentation in check while ensuring logical range of best
++               * extent doesn't overflow out of goal extent:
++               *
++               * 1. Check if best ex can be kept at end of goal and still
++               *    cover original start
++               * 2. Else, check if best ex can be kept at start of goal and
++               *    still cover original start
++               * 3. Else, keep the best ex at start of original request.
++               */
++              new_bex_end = ac->ac_g_ex.fe_logical +
++                      EXT4_C2B(sbi, ac->ac_g_ex.fe_len);
++              new_bex_start = new_bex_end - EXT4_C2B(sbi, ac->ac_b_ex.fe_len);
++              if (ac->ac_o_ex.fe_logical >= new_bex_start)
++                      goto adjust_bex;
+-              /* also, we should cover whole original request */
+-              wins = EXT4_C2B(sbi, ac->ac_b_ex.fe_len - ac->ac_o_ex.fe_len);
++              new_bex_start = ac->ac_g_ex.fe_logical;
++              new_bex_end =
++                      new_bex_start + EXT4_C2B(sbi, ac->ac_b_ex.fe_len);
++              if (ac->ac_o_ex.fe_logical < new_bex_end)
++                      goto adjust_bex;
+-              /* the smallest one defines real window */
+-              win = min(winl, wins);
++              new_bex_start = ac->ac_o_ex.fe_logical;
++              new_bex_end =
++                      new_bex_start + EXT4_C2B(sbi, ac->ac_b_ex.fe_len);
+-              offs = ac->ac_o_ex.fe_logical %
+-                      EXT4_C2B(sbi, ac->ac_b_ex.fe_len);
+-              if (offs && offs < win)
+-                      win = offs;
++adjust_bex:
++              ac->ac_b_ex.fe_logical = new_bex_start;
+-              ac->ac_b_ex.fe_logical = ac->ac_o_ex.fe_logical -
+-                      EXT4_NUM_B2C(sbi, win);
+               BUG_ON(ac->ac_o_ex.fe_logical < ac->ac_b_ex.fe_logical);
+               BUG_ON(ac->ac_o_ex.fe_len > ac->ac_b_ex.fe_len);
++              BUG_ON(new_bex_end > (ac->ac_g_ex.fe_logical +
++                                    EXT4_C2B(sbi, ac->ac_g_ex.fe_len)));
+       }
+       /* preallocation can change ac_b_ex, thus we store actually
+-- 
+2.39.2
+
diff --git a/queue-5.4/ext4-set-goal-start-correctly-in-ext4_mb_normalize_r.patch b/queue-5.4/ext4-set-goal-start-correctly-in-ext4_mb_normalize_r.patch
new file mode 100644 (file)
index 0000000..316f3e1
--- /dev/null
@@ -0,0 +1,72 @@
+From 7e607392d6952e2263dba008db2a8da96be26418 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 4 Mar 2023 01:21:01 +0800
+Subject: ext4: set goal start correctly in ext4_mb_normalize_request
+
+From: Kemeng Shi <shikemeng@huaweicloud.com>
+
+[ Upstream commit b07ffe6927c75d99af534d685282ea188d9f71a6 ]
+
+We need to set ac_g_ex to notify the goal start used in
+ext4_mb_find_by_goal. Set ac_g_ex instead of ac_f_ex in
+ext4_mb_normalize_request.
+Besides we should assure goal start is in range [first_data_block,
+blocks_count) as ext4_mb_initialize_context does.
+
+[ Added a check to make sure size is less than ar->pright; otherwise
+  we could end up passing an underflowed value of ar->pright - size to
+  ext4_get_group_no_and_offset(), which will trigger a BUG_ON later on.
+  - TYT ]
+
+Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
+Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
+Link: https://lore.kernel.org/r/20230303172120.3800725-2-shikemeng@huaweicloud.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ext4/mballoc.c | 16 ++++++++++------
+ 1 file changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
+index caab9781bee7d..bdab18942e302 100644
+--- a/fs/ext4/mballoc.c
++++ b/fs/ext4/mballoc.c
+@@ -3091,6 +3091,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
+                               struct ext4_allocation_request *ar)
+ {
+       struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
++      struct ext4_super_block *es = sbi->s_es;
+       int bsbits, max;
+       ext4_lblk_t end;
+       loff_t size, start_off;
+@@ -3271,18 +3272,21 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
+       ac->ac_g_ex.fe_len = EXT4_NUM_B2C(sbi, size);
+       /* define goal start in order to merge */
+-      if (ar->pright && (ar->lright == (start + size))) {
++      if (ar->pright && (ar->lright == (start + size)) &&
++          ar->pright >= size &&
++          ar->pright - size >= le32_to_cpu(es->s_first_data_block)) {
+               /* merge to the right */
+               ext4_get_group_no_and_offset(ac->ac_sb, ar->pright - size,
+-                                              &ac->ac_f_ex.fe_group,
+-                                              &ac->ac_f_ex.fe_start);
++                                              &ac->ac_g_ex.fe_group,
++                                              &ac->ac_g_ex.fe_start);
+               ac->ac_flags |= EXT4_MB_HINT_TRY_GOAL;
+       }
+-      if (ar->pleft && (ar->lleft + 1 == start)) {
++      if (ar->pleft && (ar->lleft + 1 == start) &&
++          ar->pleft + 1 < ext4_blocks_count(es)) {
+               /* merge to the left */
+               ext4_get_group_no_and_offset(ac->ac_sb, ar->pleft + 1,
+-                                              &ac->ac_f_ex.fe_group,
+-                                              &ac->ac_f_ex.fe_start);
++                                              &ac->ac_g_ex.fe_group,
++                                              &ac->ac_g_ex.fe_start);
+               ac->ac_flags |= EXT4_MB_HINT_TRY_GOAL;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.4/f2fs-fix-to-drop-all-dirty-pages-during-umount-if-cp.patch b/queue-5.4/f2fs-fix-to-drop-all-dirty-pages-during-umount-if-cp.patch
new file mode 100644 (file)
index 0000000..8931602
--- /dev/null
@@ -0,0 +1,93 @@
+From 9e618009424131cbc2862a8c2b9e31c06402c2e5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 10 Apr 2023 10:12:22 +0800
+Subject: f2fs: fix to drop all dirty pages during umount() if cp_error is set
+
+From: Chao Yu <chao@kernel.org>
+
+[ Upstream commit c9b3649a934d131151111354bcbb638076f03a30 ]
+
+xfstest generic/361 reports a bug as below:
+
+f2fs_bug_on(sbi, sbi->fsync_node_num);
+
+kernel BUG at fs/f2fs/super.c:1627!
+RIP: 0010:f2fs_put_super+0x3a8/0x3b0
+Call Trace:
+ generic_shutdown_super+0x8c/0x1b0
+ kill_block_super+0x2b/0x60
+ kill_f2fs_super+0x87/0x110
+ deactivate_locked_super+0x39/0x80
+ deactivate_super+0x46/0x50
+ cleanup_mnt+0x109/0x170
+ __cleanup_mnt+0x16/0x20
+ task_work_run+0x65/0xa0
+ exit_to_user_mode_prepare+0x175/0x190
+ syscall_exit_to_user_mode+0x25/0x50
+ do_syscall_64+0x4c/0x90
+ entry_SYSCALL_64_after_hwframe+0x72/0xdc
+
+During umount(), if cp_error is set, f2fs_wait_on_all_pages() should
+not stop waiting all F2FS_WB_CP_DATA pages to be writebacked, otherwise,
+fsync_node_num can be non-zero after f2fs_wait_on_all_pages() causing
+this bug.
+
+In this case, to avoid deadloop in f2fs_wait_on_all_pages(), it needs
+to drop all dirty pages rather than redirtying them.
+
+Signed-off-by: Chao Yu <chao@kernel.org>
+Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/f2fs/checkpoint.c | 12 ++++++++++--
+ fs/f2fs/data.c       |  3 ++-
+ 2 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
+index 57318010f8e6a..84e98dacd4524 100644
+--- a/fs/f2fs/checkpoint.c
++++ b/fs/f2fs/checkpoint.c
+@@ -306,8 +306,15 @@ static int __f2fs_write_meta_page(struct page *page,
+       trace_f2fs_writepage(page, META);
+-      if (unlikely(f2fs_cp_error(sbi)))
++      if (unlikely(f2fs_cp_error(sbi))) {
++              if (is_sbi_flag_set(sbi, SBI_IS_CLOSE)) {
++                      ClearPageUptodate(page);
++                      dec_page_count(sbi, F2FS_DIRTY_META);
++                      unlock_page(page);
++                      return 0;
++              }
+               goto redirty_out;
++      }
+       if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
+               goto redirty_out;
+       if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
+@@ -1277,7 +1284,8 @@ void f2fs_wait_on_all_pages(struct f2fs_sb_info *sbi, int type)
+               if (!get_pages(sbi, type))
+                       break;
+-              if (unlikely(f2fs_cp_error(sbi)))
++              if (unlikely(f2fs_cp_error(sbi) &&
++                      !is_sbi_flag_set(sbi, SBI_IS_CLOSE)))
+                       break;
+               io_schedule_timeout(HZ/50);
+diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
+index 03dffb126d5cc..8f78050c935d7 100644
+--- a/fs/f2fs/data.c
++++ b/fs/f2fs/data.c
+@@ -2130,7 +2130,8 @@ static int __write_data_page(struct page *page, bool *submitted,
+                * don't drop any dirty dentry pages for keeping lastest
+                * directory structure.
+                */
+-              if (S_ISDIR(inode->i_mode))
++              if (S_ISDIR(inode->i_mode) &&
++                              !is_sbi_flag_set(sbi, SBI_IS_CLOSE))
+                       goto redirty_out;
+               goto out;
+       }
+-- 
+2.39.2
+
diff --git a/queue-5.4/firmware-arm_sdei-fix-sleep-from-invalid-context-bug.patch b/queue-5.4/firmware-arm_sdei-fix-sleep-from-invalid-context-bug.patch
new file mode 100644 (file)
index 0000000..8d59e22
--- /dev/null
@@ -0,0 +1,236 @@
+From 30fca6c2d8c03ecb8c006744ba9ec6a53ed2046a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 16 Feb 2023 09:49:19 +0100
+Subject: firmware: arm_sdei: Fix sleep from invalid context BUG
+
+From: Pierre Gondois <pierre.gondois@arm.com>
+
+[ Upstream commit d2c48b2387eb89e0bf2a2e06e30987cf410acad4 ]
+
+Running a preempt-rt (v6.2-rc3-rt1) based kernel on an Ampere Altra
+triggers:
+
+  BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
+  in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 24, name: cpuhp/0
+  preempt_count: 0, expected: 0
+  RCU nest depth: 0, expected: 0
+  3 locks held by cpuhp/0/24:
+    #0: ffffda30217c70d0 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x5c/0x248
+    #1: ffffda30217c7120 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x5c/0x248
+    #2: ffffda3021c711f0 (sdei_list_lock){....}-{3:3}, at: sdei_cpuhp_up+0x3c/0x130
+  irq event stamp: 36
+  hardirqs last  enabled at (35): [<ffffda301e85b7bc>] finish_task_switch+0xb4/0x2b0
+  hardirqs last disabled at (36): [<ffffda301e812fec>] cpuhp_thread_fun+0x21c/0x248
+  softirqs last  enabled at (0): [<ffffda301e80b184>] copy_process+0x63c/0x1ac0
+  softirqs last disabled at (0): [<0000000000000000>] 0x0
+  CPU: 0 PID: 24 Comm: cpuhp/0 Not tainted 5.19.0-rc3-rt5-[...]
+  Hardware name: WIWYNN Mt.Jade Server [...]
+  Call trace:
+    dump_backtrace+0x114/0x120
+    show_stack+0x20/0x70
+    dump_stack_lvl+0x9c/0xd8
+    dump_stack+0x18/0x34
+    __might_resched+0x188/0x228
+    rt_spin_lock+0x70/0x120
+    sdei_cpuhp_up+0x3c/0x130
+    cpuhp_invoke_callback+0x250/0xf08
+    cpuhp_thread_fun+0x120/0x248
+    smpboot_thread_fn+0x280/0x320
+    kthread+0x130/0x140
+    ret_from_fork+0x10/0x20
+
+sdei_cpuhp_up() is called in the STARTING hotplug section,
+which runs with interrupts disabled. Use a CPUHP_AP_ONLINE_DYN entry
+instead to execute the cpuhp cb later, with preemption enabled.
+
+SDEI originally got its own cpuhp slot to allow interacting
+with perf. It got superseded by pNMI and this early slot is not
+relevant anymore. [1]
+
+Some SDEI calls (e.g. SDEI_1_0_FN_SDEI_PE_MASK) take actions on the
+calling CPU. It is checked that preemption is disabled for them.
+_ONLINE cpuhp cb are executed in the 'per CPU hotplug thread'.
+Preemption is enabled in those threads, but their cpumask is limited
+to 1 CPU.
+Move 'WARN_ON_ONCE(preemptible())' statements so that SDEI cpuhp cb
+don't trigger them.
+
+Also add a check for the SDEI_1_0_FN_SDEI_PRIVATE_RESET SDEI call
+which acts on the calling CPU.
+
+[1]:
+https://lore.kernel.org/all/5813b8c5-ae3e-87fd-fccc-94c9cd08816d@arm.com/
+
+Suggested-by: James Morse <james.morse@arm.com>
+Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
+Reviewed-by: James Morse <james.morse@arm.com>
+Link: https://lore.kernel.org/r/20230216084920.144064-1-pierre.gondois@arm.com
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/firmware/arm_sdei.c | 37 ++++++++++++++++++++-----------------
+ include/linux/cpuhotplug.h  |  1 -
+ 2 files changed, 20 insertions(+), 18 deletions(-)
+
+diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c
+index e497785cd99fe..b0e8752174c6f 100644
+--- a/drivers/firmware/arm_sdei.c
++++ b/drivers/firmware/arm_sdei.c
+@@ -44,6 +44,8 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
+ /* entry point from firmware to arch asm code */
+ static unsigned long sdei_entry_point;
++static int sdei_hp_state;
++
+ struct sdei_event {
+       /* These three are protected by the sdei_list_lock */
+       struct list_head        list;
+@@ -305,8 +307,6 @@ int sdei_mask_local_cpu(void)
+ {
+       int err;
+-      WARN_ON_ONCE(preemptible());
+-
+       err = invoke_sdei_fn(SDEI_1_0_FN_SDEI_PE_MASK, 0, 0, 0, 0, 0, NULL);
+       if (err && err != -EIO) {
+               pr_warn_once("failed to mask CPU[%u]: %d\n",
+@@ -319,6 +319,7 @@ int sdei_mask_local_cpu(void)
+ static void _ipi_mask_cpu(void *ignored)
+ {
++      WARN_ON_ONCE(preemptible());
+       sdei_mask_local_cpu();
+ }
+@@ -326,8 +327,6 @@ int sdei_unmask_local_cpu(void)
+ {
+       int err;
+-      WARN_ON_ONCE(preemptible());
+-
+       err = invoke_sdei_fn(SDEI_1_0_FN_SDEI_PE_UNMASK, 0, 0, 0, 0, 0, NULL);
+       if (err && err != -EIO) {
+               pr_warn_once("failed to unmask CPU[%u]: %d\n",
+@@ -340,6 +339,7 @@ int sdei_unmask_local_cpu(void)
+ static void _ipi_unmask_cpu(void *ignored)
+ {
++      WARN_ON_ONCE(preemptible());
+       sdei_unmask_local_cpu();
+ }
+@@ -347,6 +347,8 @@ static void _ipi_private_reset(void *ignored)
+ {
+       int err;
++      WARN_ON_ONCE(preemptible());
++
+       err = invoke_sdei_fn(SDEI_1_0_FN_SDEI_PRIVATE_RESET, 0, 0, 0, 0, 0,
+                            NULL);
+       if (err && err != -EIO)
+@@ -393,8 +395,6 @@ static void _local_event_enable(void *data)
+       int err;
+       struct sdei_crosscall_args *arg = data;
+-      WARN_ON_ONCE(preemptible());
+-
+       err = sdei_api_event_enable(arg->event->event_num);
+       sdei_cross_call_return(arg, err);
+@@ -485,8 +485,6 @@ static void _local_event_unregister(void *data)
+       int err;
+       struct sdei_crosscall_args *arg = data;
+-      WARN_ON_ONCE(preemptible());
+-
+       err = sdei_api_event_unregister(arg->event->event_num);
+       sdei_cross_call_return(arg, err);
+@@ -575,8 +573,6 @@ static void _local_event_register(void *data)
+       struct sdei_registered_event *reg;
+       struct sdei_crosscall_args *arg = data;
+-      WARN_ON(preemptible());
+-
+       reg = per_cpu_ptr(arg->event->private_registered, smp_processor_id());
+       err = sdei_api_event_register(arg->event->event_num, sdei_entry_point,
+                                     reg, 0, 0);
+@@ -756,6 +752,8 @@ static int sdei_pm_notifier(struct notifier_block *nb, unsigned long action,
+ {
+       int rv;
++      WARN_ON_ONCE(preemptible());
++
+       switch (action) {
+       case CPU_PM_ENTER:
+               rv = sdei_mask_local_cpu();
+@@ -804,7 +802,7 @@ static int sdei_device_freeze(struct device *dev)
+       int err;
+       /* unregister private events */
+-      cpuhp_remove_state(CPUHP_AP_ARM_SDEI_STARTING);
++      cpuhp_remove_state(sdei_entry_point);
+       err = sdei_unregister_shared();
+       if (err)
+@@ -825,12 +823,15 @@ static int sdei_device_thaw(struct device *dev)
+               return err;
+       }
+-      err = cpuhp_setup_state(CPUHP_AP_ARM_SDEI_STARTING, "SDEI",
++      err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "SDEI",
+                               &sdei_cpuhp_up, &sdei_cpuhp_down);
+-      if (err)
++      if (err < 0) {
+               pr_warn("Failed to re-register CPU hotplug notifier...\n");
++              return err;
++      }
+-      return err;
++      sdei_hp_state = err;
++      return 0;
+ }
+ static int sdei_device_restore(struct device *dev)
+@@ -862,7 +863,7 @@ static int sdei_reboot_notifier(struct notifier_block *nb, unsigned long action,
+        * We are going to reset the interface, after this there is no point
+        * doing work when we take CPUs offline.
+        */
+-      cpuhp_remove_state(CPUHP_AP_ARM_SDEI_STARTING);
++      cpuhp_remove_state(sdei_hp_state);
+       sdei_platform_reset();
+@@ -1044,13 +1045,15 @@ static int sdei_probe(struct platform_device *pdev)
+               goto remove_cpupm;
+       }
+-      err = cpuhp_setup_state(CPUHP_AP_ARM_SDEI_STARTING, "SDEI",
++      err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "SDEI",
+                               &sdei_cpuhp_up, &sdei_cpuhp_down);
+-      if (err) {
++      if (err < 0) {
+               pr_warn("Failed to register CPU hotplug notifier...\n");
+               goto remove_reboot;
+       }
++      sdei_hp_state = err;
++
+       return 0;
+ remove_reboot:
+diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
+index 15835f37bd5f2..8134cc3b99cdc 100644
+--- a/include/linux/cpuhotplug.h
++++ b/include/linux/cpuhotplug.h
+@@ -111,7 +111,6 @@ enum cpuhp_state {
+       CPUHP_AP_PERF_X86_CSTATE_STARTING,
+       CPUHP_AP_PERF_XTENSA_STARTING,
+       CPUHP_AP_MIPS_OP_LOONGSON3_STARTING,
+-      CPUHP_AP_ARM_SDEI_STARTING,
+       CPUHP_AP_ARM_VFP_STARTING,
+       CPUHP_AP_ARM64_DEBUG_MONITORS_STARTING,
+       CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING,
+-- 
+2.39.2
+
diff --git a/queue-5.4/fs-hfsplus-remove-warn_on-from-hfsplus_cat_-read-wri.patch b/queue-5.4/fs-hfsplus-remove-warn_on-from-hfsplus_cat_-read-wri.patch
new file mode 100644 (file)
index 0000000..754309c
--- /dev/null
@@ -0,0 +1,108 @@
+From cebdf9b169ea903e0b00fc96bd7f3a3023ba3010 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Apr 2023 19:57:33 +0900
+Subject: fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode()
+
+From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+
+[ Upstream commit 81b21c0f0138ff5a499eafc3eb0578ad2a99622c ]
+
+syzbot is hitting WARN_ON() in hfsplus_cat_{read,write}_inode(), for
+crafted filesystem image can contain bogus length. There conditions are
+not kernel bugs that can justify kernel to panic.
+
+Reported-by: syzbot <syzbot+e2787430e752a92b8750@syzkaller.appspotmail.com>
+Link: https://syzkaller.appspot.com/bug?extid=e2787430e752a92b8750
+Reported-by: syzbot <syzbot+4913dca2ea6e4d43f3f1@syzkaller.appspotmail.com>
+Link: https://syzkaller.appspot.com/bug?extid=4913dca2ea6e4d43f3f1
+Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
+Message-Id: <15308173-5252-d6a3-ae3b-e96d46cb6f41@I-love.SAKURA.ne.jp>
+Signed-off-by: Christian Brauner <brauner@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/hfsplus/inode.c | 28 +++++++++++++++++++++++-----
+ 1 file changed, 23 insertions(+), 5 deletions(-)
+
+diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
+index 76501d905099b..15c14a6a9f7fe 100644
+--- a/fs/hfsplus/inode.c
++++ b/fs/hfsplus/inode.c
+@@ -497,7 +497,11 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
+       if (type == HFSPLUS_FOLDER) {
+               struct hfsplus_cat_folder *folder = &entry.folder;
+-              WARN_ON(fd->entrylength < sizeof(struct hfsplus_cat_folder));
++              if (fd->entrylength < sizeof(struct hfsplus_cat_folder)) {
++                      pr_err("bad catalog folder entry\n");
++                      res = -EIO;
++                      goto out;
++              }
+               hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
+                                       sizeof(struct hfsplus_cat_folder));
+               hfsplus_get_perms(inode, &folder->permissions, 1);
+@@ -517,7 +521,11 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
+       } else if (type == HFSPLUS_FILE) {
+               struct hfsplus_cat_file *file = &entry.file;
+-              WARN_ON(fd->entrylength < sizeof(struct hfsplus_cat_file));
++              if (fd->entrylength < sizeof(struct hfsplus_cat_file)) {
++                      pr_err("bad catalog file entry\n");
++                      res = -EIO;
++                      goto out;
++              }
+               hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
+                                       sizeof(struct hfsplus_cat_file));
+@@ -548,6 +556,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
+               pr_err("bad catalog entry used to create inode\n");
+               res = -EIO;
+       }
++out:
+       return res;
+ }
+@@ -556,6 +565,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
+       struct inode *main_inode = inode;
+       struct hfs_find_data fd;
+       hfsplus_cat_entry entry;
++      int res = 0;
+       if (HFSPLUS_IS_RSRC(inode))
+               main_inode = HFSPLUS_I(inode)->rsrc_inode;
+@@ -574,7 +584,11 @@ int hfsplus_cat_write_inode(struct inode *inode)
+       if (S_ISDIR(main_inode->i_mode)) {
+               struct hfsplus_cat_folder *folder = &entry.folder;
+-              WARN_ON(fd.entrylength < sizeof(struct hfsplus_cat_folder));
++              if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) {
++                      pr_err("bad catalog folder entry\n");
++                      res = -EIO;
++                      goto out;
++              }
+               hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
+                                       sizeof(struct hfsplus_cat_folder));
+               /* simple node checks? */
+@@ -599,7 +613,11 @@ int hfsplus_cat_write_inode(struct inode *inode)
+       } else {
+               struct hfsplus_cat_file *file = &entry.file;
+-              WARN_ON(fd.entrylength < sizeof(struct hfsplus_cat_file));
++              if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
++                      pr_err("bad catalog file entry\n");
++                      res = -EIO;
++                      goto out;
++              }
+               hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
+                                       sizeof(struct hfsplus_cat_file));
+               hfsplus_inode_write_fork(inode, &file->data_fork);
+@@ -620,5 +638,5 @@ int hfsplus_cat_write_inode(struct inode *inode)
+       set_bit(HFSPLUS_I_CAT_DIRTY, &HFSPLUS_I(inode)->flags);
+ out:
+       hfs_find_exit(&fd);
+-      return 0;
++      return res;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.4/gfs2-fix-inode-height-consistency-check.patch b/queue-5.4/gfs2-fix-inode-height-consistency-check.patch
new file mode 100644 (file)
index 0000000..3accf8a
--- /dev/null
@@ -0,0 +1,49 @@
+From 7894af4cb7cd349cb4e0b66edab1cec9a993d955 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 28 Mar 2023 00:43:16 +0200
+Subject: gfs2: Fix inode height consistency check
+
+From: Andreas Gruenbacher <agruenba@redhat.com>
+
+[ Upstream commit cfcdb5bad34f600aed7613c3c1a5e618111f77b7 ]
+
+The maximum allowed height of an inode's metadata tree depends on the
+filesystem block size; it is lower for bigger-block filesystems.  When
+reading in an inode, make sure that the height doesn't exceed the
+maximum allowed height.
+
+Arrays like sd_heightsize are sized to be big enough for any filesystem
+block size; they will often be slightly bigger than what's needed for a
+specific filesystem.
+
+Reported-by: syzbot+45d4691b1ed3c48eba05@syzkaller.appspotmail.com
+Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/gfs2/glops.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
+index 69106a1545fad..092223a8b1201 100644
+--- a/fs/gfs2/glops.c
++++ b/fs/gfs2/glops.c
+@@ -362,6 +362,7 @@ static int inode_go_demote_ok(const struct gfs2_glock *gl)
+ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
+ {
++      struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       const struct gfs2_dinode *str = buf;
+       struct timespec64 atime;
+       u16 height, depth;
+@@ -401,7 +402,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
+       /* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */
+       gfs2_set_inode_flags(&ip->i_inode);
+       height = be16_to_cpu(str->di_height);
+-      if (unlikely(height > GFS2_MAX_META_HEIGHT))
++      if (unlikely(height > sdp->sd_max_height))
+               goto corrupt;
+       ip->i_height = (u8)height;
+-- 
+2.39.2
+
diff --git a/queue-5.4/hid-logitech-hidpp-don-t-use-the-usb-serial-for-usb-.patch b/queue-5.4/hid-logitech-hidpp-don-t-use-the-usb-serial-for-usb-.patch
new file mode 100644 (file)
index 0000000..243eee9
--- /dev/null
@@ -0,0 +1,101 @@
+From 2798155b57bd57d532a8a5495f15afd5420c8a54 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Mar 2023 14:01:16 +0100
+Subject: HID: logitech-hidpp: Don't use the USB serial for USB devices
+
+From: Bastien Nocera <hadess@hadess.net>
+
+[ Upstream commit 7ad1fe0da0fa91bf920b79ab05ae97bfabecc4f4 ]
+
+For devices that support the 0x0003 feature (Device Information) version 4,
+set the serial based on the output of that feature, rather than relying
+on the usbhid code setting the USB serial.
+
+This should allow the serial when connected through USB to (nearly)
+match the one when connected through a unifying receiver.
+
+For example, on the serials on a G903 wired/wireless mouse:
+- Unifying: 4067-e8-ce-cd-45
+- USB before patch: 017C385C3837
+- USB after patch: c086-e8-ce-cd-45
+
+Signed-off-by: Bastien Nocera <hadess@hadess.net>
+Link: https://lore.kernel.org/r/20230302130117.3975-1-hadess@hadess.net
+Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hid-logitech-hidpp.c | 51 ++++++++++++++++++++++++++++++++
+ 1 file changed, 51 insertions(+)
+
+diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
+index 919551ed5809c..2fd64361884cf 100644
+--- a/drivers/hid/hid-logitech-hidpp.c
++++ b/drivers/hid/hid-logitech-hidpp.c
+@@ -903,6 +903,55 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
+       return 0;
+ }
++/* -------------------------------------------------------------------------- */
++/* 0x0003: Device Information                                                 */
++/* -------------------------------------------------------------------------- */
++
++#define HIDPP_PAGE_DEVICE_INFORMATION                 0x0003
++
++#define CMD_GET_DEVICE_INFO                           0x00
++
++static int hidpp_get_serial(struct hidpp_device *hidpp, u32 *serial)
++{
++      struct hidpp_report response;
++      u8 feature_type;
++      u8 feature_index;
++      int ret;
++
++      ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_DEVICE_INFORMATION,
++                                   &feature_index,
++                                   &feature_type);
++      if (ret)
++              return ret;
++
++      ret = hidpp_send_fap_command_sync(hidpp, feature_index,
++                                        CMD_GET_DEVICE_INFO,
++                                        NULL, 0, &response);
++      if (ret)
++              return ret;
++
++      /* See hidpp_unifying_get_serial() */
++      *serial = *((u32 *)&response.rap.params[1]);
++      return 0;
++}
++
++static int hidpp_serial_init(struct hidpp_device *hidpp)
++{
++      struct hid_device *hdev = hidpp->hid_dev;
++      u32 serial;
++      int ret;
++
++      ret = hidpp_get_serial(hidpp, &serial);
++      if (ret)
++              return ret;
++
++      snprintf(hdev->uniq, sizeof(hdev->uniq), "%04x-%4phD",
++               hdev->product, &serial);
++      dbg_hid("HID++ DeviceInformation: Got serial: %s\n", hdev->uniq);
++
++      return 0;
++}
++
+ /* -------------------------------------------------------------------------- */
+ /* 0x0005: GetDeviceNameType                                                  */
+ /* -------------------------------------------------------------------------- */
+@@ -3651,6 +3700,8 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
+       if (hidpp->quirks & HIDPP_QUIRK_UNIFYING)
+               hidpp_unifying_init(hidpp);
++      else if (hid_is_usb(hidpp->hid_dev))
++              hidpp_serial_init(hidpp);
+       connected = hidpp_root_get_protocol_version(hidpp) == 0;
+       atomic_set(&hidpp->connected, connected);
+-- 
+2.39.2
+
diff --git a/queue-5.4/hid-logitech-hidpp-reconcile-usb-and-unifying-serial.patch b/queue-5.4/hid-logitech-hidpp-reconcile-usb-and-unifying-serial.patch
new file mode 100644 (file)
index 0000000..a418043
--- /dev/null
@@ -0,0 +1,55 @@
+From 3418d24f48e6dda998b17943036b179a79aa58d4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 2 Mar 2023 14:01:17 +0100
+Subject: HID: logitech-hidpp: Reconcile USB and Unifying serials
+
+From: Bastien Nocera <hadess@hadess.net>
+
+[ Upstream commit 5b3691d15e04b6d5a32c915577b8dbc5cfb56382 ]
+
+Now that USB HID++ devices can gather a serial number that matches the
+one that would be gathered when connected through a Unifying receiver,
+remove the last difference by dropping the product ID as devices
+usually have different product IDs when connected through USB or
+Unifying.
+
+For example, on the serials on a G903 wired/wireless mouse:
+- Unifying before patch: 4067-e8-ce-cd-45
+- USB before patch: c086-e8-ce-cd-45
+- Unifying and USB after patch: e8-ce-cd-45
+
+Signed-off-by: Bastien Nocera <hadess@hadess.net>
+Link: https://lore.kernel.org/r/20230302130117.3975-2-hadess@hadess.net
+Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hid-logitech-hidpp.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
+index 2fd64361884cf..b8558292801ec 100644
+--- a/drivers/hid/hid-logitech-hidpp.c
++++ b/drivers/hid/hid-logitech-hidpp.c
+@@ -809,8 +809,7 @@ static int hidpp_unifying_init(struct hidpp_device *hidpp)
+       if (ret)
+               return ret;
+-      snprintf(hdev->uniq, sizeof(hdev->uniq), "%04x-%4phD",
+-               hdev->product, &serial);
++      snprintf(hdev->uniq, sizeof(hdev->uniq), "%4phD", &serial);
+       dbg_hid("HID++ Unifying: Got serial: %s\n", hdev->uniq);
+       name = hidpp_unifying_get_name(hidpp);
+@@ -945,8 +944,7 @@ static int hidpp_serial_init(struct hidpp_device *hidpp)
+       if (ret)
+               return ret;
+-      snprintf(hdev->uniq, sizeof(hdev->uniq), "%04x-%4phD",
+-               hdev->product, &serial);
++      snprintf(hdev->uniq, sizeof(hdev->uniq), "%4phD", &serial);
+       dbg_hid("HID++ DeviceInformation: Got serial: %s\n", hdev->uniq);
+       return 0;
+-- 
+2.39.2
+
diff --git a/queue-5.4/hid-wacom-generic-set-battery-quirk-only-when-we-see.patch b/queue-5.4/hid-wacom-generic-set-battery-quirk-only-when-we-see.patch
new file mode 100644 (file)
index 0000000..ea28e94
--- /dev/null
@@ -0,0 +1,104 @@
+From 9bc283b5e6a575fc0392669e1824a9d19aacccca Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 Apr 2023 11:17:43 -0700
+Subject: HID: wacom: generic: Set battery quirk only when we see battery data
+
+From: Jason Gerecke <killertofu@gmail.com>
+
+[ Upstream commit bea407a427baa019758f29f4d31b26f008bb8cc6 ]
+
+Some devices will include battery status usages in the HID descriptor
+but we won't see that battery data for one reason or another. For example,
+AES sensors won't send battery data unless an AES pen is in proximity.
+If a user does not have an AES pen but instead only interacts with the
+AES touchscreen with their fingers then there is no need for us to create
+a battery object. Similarly, if a family of peripherals shares the same
+HID descriptor between wired-only and wireless-capable SKUs, users of the
+former may never see a battery event and will not want a power_supply
+object created.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=217062
+Link: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/2354
+Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
+Tested-by: Mario Limonciello <mario.limonciello@amd.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/wacom_wac.c | 33 +++++++++++----------------------
+ 1 file changed, 11 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
+index 339bc7f1fcedb..819e6d2ca2f3e 100644
+--- a/drivers/hid/wacom_wac.c
++++ b/drivers/hid/wacom_wac.c
+@@ -1927,18 +1927,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
+ static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
+               struct hid_field *field, struct hid_usage *usage)
+ {
+-      struct wacom *wacom = hid_get_drvdata(hdev);
+-      struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+-      struct wacom_features *features = &wacom_wac->features;
+-      unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
+-
+-      switch (equivalent_usage) {
+-      case HID_DG_BATTERYSTRENGTH:
+-      case WACOM_HID_WD_BATTERY_LEVEL:
+-      case WACOM_HID_WD_BATTERY_CHARGING:
+-              features->quirks |= WACOM_QUIRK_BATTERY;
+-              break;
+-      }
++      return;
+ }
+ static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
+@@ -1959,18 +1948,21 @@ static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *f
+                       wacom_wac->hid_data.bat_connected = 1;
+                       wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
+               }
++              wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
+               break;
+       case WACOM_HID_WD_BATTERY_LEVEL:
+               value = value * 100 / (field->logical_maximum - field->logical_minimum);
+               wacom_wac->hid_data.battery_capacity = value;
+               wacom_wac->hid_data.bat_connected = 1;
+               wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
++              wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
+               break;
+       case WACOM_HID_WD_BATTERY_CHARGING:
+               wacom_wac->hid_data.bat_charging = value;
+               wacom_wac->hid_data.ps_connected = value;
+               wacom_wac->hid_data.bat_connected = 1;
+               wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
++              wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
+               break;
+       }
+ }
+@@ -1986,18 +1978,15 @@ static void wacom_wac_battery_report(struct hid_device *hdev,
+ {
+       struct wacom *wacom = hid_get_drvdata(hdev);
+       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+-      struct wacom_features *features = &wacom_wac->features;
+-      if (features->quirks & WACOM_QUIRK_BATTERY) {
+-              int status = wacom_wac->hid_data.bat_status;
+-              int capacity = wacom_wac->hid_data.battery_capacity;
+-              bool charging = wacom_wac->hid_data.bat_charging;
+-              bool connected = wacom_wac->hid_data.bat_connected;
+-              bool powered = wacom_wac->hid_data.ps_connected;
++      int status = wacom_wac->hid_data.bat_status;
++      int capacity = wacom_wac->hid_data.battery_capacity;
++      bool charging = wacom_wac->hid_data.bat_charging;
++      bool connected = wacom_wac->hid_data.bat_connected;
++      bool powered = wacom_wac->hid_data.ps_connected;
+-              wacom_notify_battery(wacom_wac, status, capacity, charging,
+-                                   connected, powered);
+-      }
++      wacom_notify_battery(wacom_wac, status, capacity, charging,
++                           connected, powered);
+ }
+ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
+-- 
+2.39.2
+
diff --git a/queue-5.4/input-xpad-add-constants-for-gip-interface-numbers.patch b/queue-5.4/input-xpad-add-constants-for-gip-interface-numbers.patch
new file mode 100644 (file)
index 0000000..5a9f050
--- /dev/null
@@ -0,0 +1,47 @@
+From 35046ca25a6c8d7acde04497081d2c2a3d8a3a08 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 Apr 2023 23:57:42 -0700
+Subject: Input: xpad - add constants for GIP interface numbers
+
+From: Vicki Pfau <vi@endrift.com>
+
+[ Upstream commit f9b2e603c6216824e34dc9a67205d98ccc9a41ca ]
+
+Wired GIP devices present multiple interfaces with the same USB identification
+other than the interface number. This adds constants for differentiating two of
+them and uses them where appropriate
+
+Signed-off-by: Vicki Pfau <vi@endrift.com>
+Link: https://lore.kernel.org/r/20230411031650.960322-2-vi@endrift.com
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/joystick/xpad.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 70dedc0f7827c..0bd55e1fca372 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -489,6 +489,9 @@ struct xboxone_init_packet {
+       }
++#define GIP_WIRED_INTF_DATA 0
++#define GIP_WIRED_INTF_AUDIO 1
++
+ /*
+  * This packet is required for all Xbox One pads with 2015
+  * or later firmware installed (or present from the factory).
+@@ -1813,7 +1816,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
+       }
+       if (xpad->xtype == XTYPE_XBOXONE &&
+-          intf->cur_altsetting->desc.bInterfaceNumber != 0) {
++          intf->cur_altsetting->desc.bInterfaceNumber != GIP_WIRED_INTF_DATA) {
+               /*
+                * The Xbox One controller lists three interfaces all with the
+                * same interface class, subclass and protocol. Differentiate by
+-- 
+2.39.2
+
diff --git a/queue-5.4/iommu-arm-smmu-v3-acknowledge-pri-event-queue-overfl.patch b/queue-5.4/iommu-arm-smmu-v3-acknowledge-pri-event-queue-overfl.patch
new file mode 100644 (file)
index 0000000..f4b11c5
--- /dev/null
@@ -0,0 +1,90 @@
+From 8eb35f24160476b9e1edf09f3bb81c2a162c00b6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 29 Mar 2023 12:34:19 +0000
+Subject: iommu/arm-smmu-v3: Acknowledge pri/event queue overflow if any
+
+From: Tomas Krcka <krckatom@amazon.de>
+
+[ Upstream commit 67ea0b7ce41844eae7c10bb04dfe66a23318c224 ]
+
+When an overflow occurs in the PRI queue, the SMMU toggles the overflow
+flag in the PROD register. To exit the overflow condition, the PRI thread
+is supposed to acknowledge it by toggling this flag in the CONS register.
+Unacknowledged overflow causes the queue to stop adding anything new.
+
+Currently, the priq thread always writes the CONS register back to the
+SMMU after clearing the queue.
+
+The writeback is not necessary if the OVFLG in the PROD register has not
+been changed, no overflow has occured.
+
+This commit checks the difference of the overflow flag between CONS and
+PROD register. If it's different, toggles the OVACKFLG flag in the CONS
+register and write it to the SMMU.
+
+The situation is similar for the event queue.
+The acknowledge register is also toggled after clearing the event
+queue but never propagated to the hardware. This would only be done the
+next time when executing evtq thread.
+
+Unacknowledged event queue overflow doesn't affect the event
+queue, because the SMMU still adds elements to that queue when the
+overflow condition is active.
+But it feel nicer to keep SMMU in sync when possible, so use the same
+way here as well.
+
+Signed-off-by: Tomas Krcka <krckatom@amazon.de>
+Link: https://lore.kernel.org/r/20230329123420.34641-1-tomas.krcka@gmail.com
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/iommu/arm-smmu-v3.c | 19 ++++++++++++++-----
+ 1 file changed, 14 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
+index 4f64c3a9ee88d..b3c5d7b4547a4 100644
+--- a/drivers/iommu/arm-smmu-v3.c
++++ b/drivers/iommu/arm-smmu-v3.c
+@@ -760,6 +760,18 @@ static void queue_inc_cons(struct arm_smmu_ll_queue *q)
+       q->cons = Q_OVF(q->cons) | Q_WRP(q, cons) | Q_IDX(q, cons);
+ }
++static void queue_sync_cons_ovf(struct arm_smmu_queue *q)
++{
++      struct arm_smmu_ll_queue *llq = &q->llq;
++
++      if (likely(Q_OVF(llq->prod) == Q_OVF(llq->cons)))
++              return;
++
++      llq->cons = Q_OVF(llq->prod) | Q_WRP(llq, llq->cons) |
++                    Q_IDX(llq, llq->cons);
++      queue_sync_cons_out(q);
++}
++
+ static int queue_sync_prod_in(struct arm_smmu_queue *q)
+ {
+       int ret = 0;
+@@ -1720,8 +1732,7 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
+       } while (!queue_empty(llq));
+       /* Sync our overflow flag, as we believe we're up to speed */
+-      llq->cons = Q_OVF(llq->prod) | Q_WRP(llq, llq->cons) |
+-                  Q_IDX(llq, llq->cons);
++      queue_sync_cons_ovf(q);
+       return IRQ_HANDLED;
+ }
+@@ -1779,9 +1790,7 @@ static irqreturn_t arm_smmu_priq_thread(int irq, void *dev)
+       } while (!queue_empty(llq));
+       /* Sync our overflow flag, as we believe we're up to speed */
+-      llq->cons = Q_OVF(llq->prod) | Q_WRP(llq, llq->cons) |
+-                    Q_IDX(llq, llq->cons);
+-      queue_sync_cons_out(q);
++      queue_sync_cons_ovf(q);
+       return IRQ_HANDLED;
+ }
+-- 
+2.39.2
+
diff --git a/queue-5.4/lib-cpu_rmap-avoid-use-after-free-on-rmap-obj-array-.patch b/queue-5.4/lib-cpu_rmap-avoid-use-after-free-on-rmap-obj-array-.patch
new file mode 100644 (file)
index 0000000..209cce7
--- /dev/null
@@ -0,0 +1,67 @@
+From 38bee755dcb45e4918444349c850c52b05b4d852 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Feb 2023 07:51:02 +0200
+Subject: lib: cpu_rmap: Avoid use after free on rmap->obj array entries
+
+From: Eli Cohen <elic@nvidia.com>
+
+[ Upstream commit 4e0473f1060aa49621d40a113afde24818101d37 ]
+
+When calling irq_set_affinity_notifier() with NULL at the notify
+argument, it will cause freeing of the glue pointer in the
+corresponding array entry but will leave the pointer in the array. A
+subsequent call to free_irq_cpu_rmap() will try to free this entry again
+leading to possible use after free.
+
+Fix that by setting NULL to the array entry and checking that we have
+non-zero at the array entry when iterating over the array in
+free_irq_cpu_rmap().
+
+The current code does not suffer from this since there are no cases
+where irq_set_affinity_notifier(irq, NULL) (note the NULL passed for the
+notify arg) is called, followed by a call to free_irq_cpu_rmap() so we
+don't hit and issue. Subsequent patches in this series excersize this
+flow, hence the required fix.
+
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Eli Cohen <elic@nvidia.com>
+Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
+Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ lib/cpu_rmap.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
+index 075f3788bbe4d..920403fa5b0de 100644
+--- a/lib/cpu_rmap.c
++++ b/lib/cpu_rmap.c
+@@ -232,7 +232,8 @@ void free_irq_cpu_rmap(struct cpu_rmap *rmap)
+       for (index = 0; index < rmap->used; index++) {
+               glue = rmap->obj[index];
+-              irq_set_affinity_notifier(glue->notify.irq, NULL);
++              if (glue)
++                      irq_set_affinity_notifier(glue->notify.irq, NULL);
+       }
+       cpu_rmap_put(rmap);
+@@ -268,6 +269,7 @@ static void irq_cpu_rmap_release(struct kref *ref)
+               container_of(ref, struct irq_glue, notify.kref);
+       cpu_rmap_put(glue->rmap);
++      glue->rmap->obj[glue->index] = NULL;
+       kfree(glue);
+ }
+@@ -297,6 +299,7 @@ int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq)
+       rc = irq_set_affinity_notifier(irq, &glue->notify);
+       if (rc) {
+               cpu_rmap_put(glue->rmap);
++              rmap->obj[glue->index] = NULL;
+               kfree(glue);
+       }
+       return rc;
+-- 
+2.39.2
+
diff --git a/queue-5.4/mcb-pci-reallocate-memory-region-to-avoid-memory-ove.patch b/queue-5.4/mcb-pci-reallocate-memory-region-to-avoid-memory-ove.patch
new file mode 100644 (file)
index 0000000..dce28af
--- /dev/null
@@ -0,0 +1,78 @@
+From b13ad9b789580a6261592ebc232efab4bd426fad Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Apr 2023 10:33:28 +0200
+Subject: mcb-pci: Reallocate memory region to avoid memory overlapping
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Rodríguez Barbarin, José Javier <JoseJavier.Rodriguez@duagon.com>
+
+[ Upstream commit 9be24faadd085c284890c3afcec7a0184642315a ]
+
+mcb-pci requests a fixed-size memory region to parse the chameleon
+table, however, if the chameleon table is smaller that the allocated
+region, it could overlap with the IP Cores' memory regions.
+
+After parsing the chameleon table, drop/reallocate the memory region
+with the actual chameleon table size.
+
+Co-developed-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
+Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
+Signed-off-by: Javier Rodriguez <josejavier.rodriguez@duagon.com>
+Signed-off-by: Johannes Thumshirn <jth@kernel.org>
+Link: https://lore.kernel.org/r/20230411083329.4506-3-jth@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mcb/mcb-pci.c | 27 +++++++++++++++++++++++++--
+ 1 file changed, 25 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
+index 14866aa22f753..22927c80ff469 100644
+--- a/drivers/mcb/mcb-pci.c
++++ b/drivers/mcb/mcb-pci.c
+@@ -31,7 +31,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+ {
+       struct resource *res;
+       struct priv *priv;
+-      int ret;
++      int ret, table_size;
+       unsigned long flags;
+       priv = devm_kzalloc(&pdev->dev, sizeof(struct priv), GFP_KERNEL);
+@@ -90,7 +90,30 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+       if (ret < 0)
+               goto out_mcb_bus;
+-      dev_dbg(&pdev->dev, "Found %d cells\n", ret);
++      table_size = ret;
++
++      if (table_size < CHAM_HEADER_SIZE) {
++              /* Release the previous resources */
++              devm_iounmap(&pdev->dev, priv->base);
++              devm_release_mem_region(&pdev->dev, priv->mapbase, CHAM_HEADER_SIZE);
++
++              /* Then, allocate it again with the actual chameleon table size */
++              res = devm_request_mem_region(&pdev->dev, priv->mapbase,
++                                              table_size,
++                                              KBUILD_MODNAME);
++              if (!res) {
++                      dev_err(&pdev->dev, "Failed to request PCI memory\n");
++                      ret = -EBUSY;
++                      goto out_mcb_bus;
++              }
++
++              priv->base = devm_ioremap(&pdev->dev, priv->mapbase, table_size);
++              if (!priv->base) {
++                      dev_err(&pdev->dev, "Cannot ioremap\n");
++                      ret = -ENOMEM;
++                      goto out_mcb_bus;
++              }
++      }
+       mcb_bus_add_devices(priv->bus);
+-- 
+2.39.2
+
diff --git a/queue-5.4/memstick-r592-fix-uaf-bug-in-r592_remove-due-to-race.patch b/queue-5.4/memstick-r592-fix-uaf-bug-in-r592_remove-due-to-race.patch
new file mode 100644 (file)
index 0000000..421a29e
--- /dev/null
@@ -0,0 +1,53 @@
+From 287159354abadac74381aa3478027fbbf10a67da Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Mar 2023 00:43:38 +0800
+Subject: memstick: r592: Fix UAF bug in r592_remove due to race condition
+
+From: Zheng Wang <zyytlz.wz@163.com>
+
+[ Upstream commit 63264422785021704c39b38f65a78ab9e4a186d7 ]
+
+In r592_probe, dev->detect_timer was bound with r592_detect_timer.
+In r592_irq function, the timer function will be invoked by mod_timer.
+
+If we remove the module which will call hantro_release to make cleanup,
+there may be a unfinished work. The possible sequence is as follows,
+which will cause a typical UAF bug.
+
+Fix it by canceling the work before cleanup in r592_remove.
+
+CPU0                  CPU1
+
+                    |r592_detect_timer
+r592_remove         |
+  memstick_free_host|
+  put_device;       |
+  kfree(host);      |
+                    |
+                    | queue_work
+                    |   &host->media_checker //use
+
+Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
+Link: https://lore.kernel.org/r/20230307164338.1246287-1-zyytlz.wz@163.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/memstick/host/r592.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
+index eaa2a94d18be4..dd06c18495eb6 100644
+--- a/drivers/memstick/host/r592.c
++++ b/drivers/memstick/host/r592.c
+@@ -828,7 +828,7 @@ static void r592_remove(struct pci_dev *pdev)
+       /* Stop the processing thread.
+       That ensures that we won't take any more requests */
+       kthread_stop(dev->io_thread);
+-
++      del_timer_sync(&dev->detect_timer);
+       r592_enable_device(dev, false);
+       while (!error && dev->req) {
+-- 
+2.39.2
+
diff --git a/queue-5.4/mfd-dln2-fix-memory-leak-in-dln2_probe.patch b/queue-5.4/mfd-dln2-fix-memory-leak-in-dln2_probe.patch
new file mode 100644 (file)
index 0000000..fe03991
--- /dev/null
@@ -0,0 +1,38 @@
+From 16a492e46eaadc73a85d0b7919f6ac0aa2d6bfd2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 30 Mar 2023 10:43:53 +0800
+Subject: mfd: dln2: Fix memory leak in dln2_probe()
+
+From: Qiang Ning <qning0106@126.com>
+
+[ Upstream commit 96da8f148396329ba769246cb8ceaa35f1ddfc48 ]
+
+When dln2_setup_rx_urbs() in dln2_probe() fails, error out_free forgets
+to call usb_put_dev() to decrease the refcount of dln2->usb_dev.
+
+Fix this by adding usb_put_dev() in the error handling code of
+dln2_probe().
+
+Signed-off-by: Qiang Ning <qning0106@126.com>
+Signed-off-by: Lee Jones <lee@kernel.org>
+Link: https://lore.kernel.org/r/20230330024353.4503-1-qning0106@126.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mfd/dln2.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
+index 707f4287ab4a0..80952237e4b43 100644
+--- a/drivers/mfd/dln2.c
++++ b/drivers/mfd/dln2.c
+@@ -797,6 +797,7 @@ static int dln2_probe(struct usb_interface *interface,
+       dln2_stop_rx_urbs(dln2);
+ out_free:
++      usb_put_dev(dln2->usb_dev);
+       dln2_free(dln2);
+       return ret;
+-- 
+2.39.2
+
diff --git a/queue-5.4/net-catch-invalid-index-in-xps-mapping.patch b/queue-5.4/net-catch-invalid-index-in-xps-mapping.patch
new file mode 100644 (file)
index 0000000..f260c25
--- /dev/null
@@ -0,0 +1,43 @@
+From 856352a7d5fc163a7f04d4ed1c0043ae4092c58f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 21 Mar 2023 10:07:24 -0500
+Subject: net: Catch invalid index in XPS mapping
+
+From: Nick Child <nnac123@linux.ibm.com>
+
+[ Upstream commit 5dd0dfd55baec0742ba8f5625a0dd064aca7db16 ]
+
+When setting the XPS value of a TX queue, warn the user once if the
+index of the queue is greater than the number of allocated TX queues.
+
+Previously, this scenario went uncaught. In the best case, it resulted
+in unnecessary allocations. In the worst case, it resulted in
+out-of-bounds memory references through calls to `netdev_get_tx_queue(
+dev, index)`. Therefore, it is important to inform the user but not
+worth returning an error and risk downing the netdevice.
+
+Signed-off-by: Nick Child <nnac123@linux.ibm.com>
+Reviewed-by: Piotr Raczynski <piotr.raczynski@intel.com>
+Link: https://lore.kernel.org/r/20230321150725.127229-1-nnac123@linux.ibm.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/dev.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/net/core/dev.c b/net/core/dev.c
+index c5561c88a8364..0cc0809628b08 100644
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -2244,6 +2244,8 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
+       bool active = false;
+       unsigned int nr_ids;
++      WARN_ON_ONCE(index >= dev->num_tx_queues);
++
+       if (dev->num_tc) {
+               /* Do not allow XPS on subordinate device directly */
+               num_tc = dev->num_tc;
+-- 
+2.39.2
+
diff --git a/queue-5.4/net-pasemi-fix-return-type-of-pasemi_mac_start_tx.patch b/queue-5.4/net-pasemi-fix-return-type-of-pasemi_mac_start_tx.patch
new file mode 100644 (file)
index 0000000..90154b9
--- /dev/null
@@ -0,0 +1,54 @@
+From 9629e7b88bab72b8c21eeb9ad39995933d570dbd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 19 Mar 2023 16:41:08 -0700
+Subject: net: pasemi: Fix return type of pasemi_mac_start_tx()
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+[ Upstream commit c8384d4a51e7cb0e6587f3143f29099f202c5de1 ]
+
+With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
+indirect call targets are validated against the expected function
+pointer prototype to make sure the call target is valid to help mitigate
+ROP attacks. If they are not identical, there is a failure at run time,
+which manifests as either a kernel panic or thread getting killed. A
+warning in clang aims to catch these at compile time, which reveals:
+
+  drivers/net/ethernet/pasemi/pasemi_mac.c:1665:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
+          .ndo_start_xmit         = pasemi_mac_start_tx,
+                                    ^~~~~~~~~~~~~~~~~~~
+  1 error generated.
+
+->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
+'netdev_tx_t', not 'int'. Adjust the return type of
+pasemi_mac_start_tx() to match the prototype's to resolve the warning.
+While PowerPC does not currently implement support for kCFI, it could in
+the future, which means this warning becomes a fatal CFI failure at run
+time.
+
+Link: https://github.com/ClangBuiltLinux/linux/issues/1750
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
+Link: https://lore.kernel.org/r/20230319-pasemi-incompatible-pointer-types-strict-v1-1-1b9459d8aef0@kernel.org
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/pasemi/pasemi_mac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
+index 040a15a828b41..c1d7bd168f1d1 100644
+--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
++++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
+@@ -1423,7 +1423,7 @@ static void pasemi_mac_queue_csdesc(const struct sk_buff *skb,
+       write_dma_reg(PAS_DMA_TXCHAN_INCR(txring->chan.chno), 2);
+ }
+-static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
++static netdev_tx_t pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
+ {
+       struct pasemi_mac * const mac = netdev_priv(dev);
+       struct pasemi_mac_txring * const txring = tx_ring(mac);
+-- 
+2.39.2
+
diff --git a/queue-5.4/phy-st-miphy28lp-use-_poll_timeout-functions-for-wai.patch b/queue-5.4/phy-st-miphy28lp-use-_poll_timeout-functions-for-wai.patch
new file mode 100644 (file)
index 0000000..25b6248
--- /dev/null
@@ -0,0 +1,113 @@
+From c0a5dce2b4a4336cd43e425b8ca95759a57a3bf8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 23:43:08 +0100
+Subject: phy: st: miphy28lp: use _poll_timeout functions for waits
+
+From: Alain Volmat <avolmat@me.com>
+
+[ Upstream commit e3be4dd2c8d8aabfd2c3127d0e2e5754d3ae82d6 ]
+
+This commit introduces _poll_timeout functions usage instead of
+wait loops waiting for a status bit.
+
+Signed-off-by: Alain Volmat <avolmat@me.com>
+Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
+Link: https://lore.kernel.org/r/20230210224309.98452-1-avolmat@me.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/phy/st/phy-miphy28lp.c | 42 ++++++++--------------------------
+ 1 file changed, 10 insertions(+), 32 deletions(-)
+
+diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
+index 068160a34f5cc..e30305b77f0d1 100644
+--- a/drivers/phy/st/phy-miphy28lp.c
++++ b/drivers/phy/st/phy-miphy28lp.c
+@@ -9,6 +9,7 @@
+ #include <linux/platform_device.h>
+ #include <linux/io.h>
++#include <linux/iopoll.h>
+ #include <linux/kernel.h>
+ #include <linux/module.h>
+ #include <linux/of.h>
+@@ -484,19 +485,11 @@ static inline void miphy28lp_pcie_config_gen(struct miphy28lp_phy *miphy_phy)
+ static inline int miphy28lp_wait_compensation(struct miphy28lp_phy *miphy_phy)
+ {
+-      unsigned long finish = jiffies + 5 * HZ;
+       u8 val;
+       /* Waiting for Compensation to complete */
+-      do {
+-              val = readb_relaxed(miphy_phy->base + MIPHY_COMP_FSM_6);
+-
+-              if (time_after_eq(jiffies, finish))
+-                      return -EBUSY;
+-              cpu_relax();
+-      } while (!(val & COMP_DONE));
+-
+-      return 0;
++      return readb_relaxed_poll_timeout(miphy_phy->base + MIPHY_COMP_FSM_6,
++                                        val, val & COMP_DONE, 1, 5 * USEC_PER_SEC);
+ }
+@@ -805,7 +798,6 @@ static inline void miphy28lp_configure_usb3(struct miphy28lp_phy *miphy_phy)
+ static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)
+ {
+-      unsigned long finish = jiffies + 5 * HZ;
+       u8 mask = HFC_PLL | HFC_RDY;
+       u8 val;
+@@ -816,21 +808,14 @@ static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)
+       if (miphy_phy->type == PHY_TYPE_SATA)
+               mask |= PHY_RDY;
+-      do {
+-              val = readb_relaxed(miphy_phy->base + MIPHY_STATUS_1);
+-              if ((val & mask) != mask)
+-                      cpu_relax();
+-              else
+-                      return 0;
+-      } while (!time_after_eq(jiffies, finish));
+-
+-      return -EBUSY;
++      return readb_relaxed_poll_timeout(miphy_phy->base + MIPHY_STATUS_1,
++                                        val, (val & mask) == mask, 1,
++                                        5 * USEC_PER_SEC);
+ }
+ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
+ {
+       struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
+-      unsigned long finish = jiffies + 5 * HZ;
+       u32 val;
+       if (!miphy_phy->osc_rdy)
+@@ -839,17 +824,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
+       if (!miphy_phy->syscfg_reg[SYSCFG_STATUS])
+               return -EINVAL;
+-      do {
+-              regmap_read(miphy_dev->regmap,
+-                              miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
+-
+-              if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
+-                      cpu_relax();
+-              else
+-                      return 0;
+-      } while (!time_after_eq(jiffies, finish));
+-
+-      return -EBUSY;
++      return regmap_read_poll_timeout(miphy_dev->regmap,
++                                      miphy_phy->syscfg_reg[SYSCFG_STATUS],
++                                      val, val & MIPHY_OSC_RDY, 1,
++                                      5 * USEC_PER_SEC);
+ }
+ static int miphy28lp_get_resource_byname(struct device_node *child,
+-- 
+2.39.2
+
diff --git a/queue-5.4/rdma-core-fix-multiple-warray-bounds-warnings.patch b/queue-5.4/rdma-core-fix-multiple-warray-bounds-warnings.patch
new file mode 100644 (file)
index 0000000..f303001
--- /dev/null
@@ -0,0 +1,187 @@
+From d572663b99896ea7943223867cc022ee769626a5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 21 Mar 2023 17:47:03 -0600
+Subject: RDMA/core: Fix multiple -Warray-bounds warnings
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Gustavo A. R. Silva <gustavoars@kernel.org>
+
+[ Upstream commit aa4d540b4150052ae3b36d286b9c833a961ce291 ]
+
+GCC-13 (and Clang)[1] does not like to access a partially allocated
+object, since it cannot reason about it for bounds checking.
+
+In this case 140 bytes are allocated for an object of type struct
+ib_umad_packet:
+
+        packet = kzalloc(sizeof(*packet) + IB_MGMT_RMPP_HDR, GFP_KERNEL);
+
+However, notice that sizeof(*packet) is only 104 bytes:
+
+struct ib_umad_packet {
+        struct ib_mad_send_buf *   msg;                  /*     0     8 */
+        struct ib_mad_recv_wc *    recv_wc;              /*     8     8 */
+        struct list_head           list;                 /*    16    16 */
+        int                        length;               /*    32     4 */
+
+        /* XXX 4 bytes hole, try to pack */
+
+        struct ib_user_mad         mad __attribute__((__aligned__(8))); /*    40    64 */
+
+        /* size: 104, cachelines: 2, members: 5 */
+        /* sum members: 100, holes: 1, sum holes: 4 */
+        /* forced alignments: 1, forced holes: 1, sum forced holes: 4 */
+        /* last cacheline: 40 bytes */
+} __attribute__((__aligned__(8)));
+
+and 36 bytes extra bytes are allocated for a flexible-array member in
+struct ib_user_mad:
+
+include/rdma/ib_mad.h:
+120 enum {
+...
+123         IB_MGMT_RMPP_HDR = 36,
+... }
+
+struct ib_user_mad {
+        struct ib_user_mad_hdr     hdr;                  /*     0    64 */
+        /* --- cacheline 1 boundary (64 bytes) --- */
+        __u64                      data[] __attribute__((__aligned__(8))); /*    64     0 */
+
+        /* size: 64, cachelines: 1, members: 2 */
+        /* forced alignments: 1 */
+} __attribute__((__aligned__(8)));
+
+So we have sizeof(*packet) + IB_MGMT_RMPP_HDR == 140 bytes
+
+Then the address of the flex-array member (for which only 36 bytes were
+allocated) is casted and copied into a pointer to struct ib_rmpp_mad,
+which, in turn, is of size 256 bytes:
+
+        rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
+
+struct ib_rmpp_mad {
+        struct ib_mad_hdr          mad_hdr;              /*     0    24 */
+        struct ib_rmpp_hdr         rmpp_hdr;             /*    24    12 */
+        u8                         data[220];            /*    36   220 */
+
+        /* size: 256, cachelines: 4, members: 3 */
+};
+
+The thing is that those 36 bytes allocated for flex-array member data
+in struct ib_user_mad onlly account for the size of both struct ib_mad_hdr
+and struct ib_rmpp_hdr, but nothing is left for array u8 data[220].
+So, the compiler is legitimately complaining about accessing an object
+for which not enough memory was allocated.
+
+Apparently, the only members of struct ib_rmpp_mad that are relevant
+(that are actually being used) in function ib_umad_write() are mad_hdr
+and rmpp_hdr. So, instead of casting packet->mad.data to
+(struct ib_rmpp_mad *) create a new structure
+
+struct ib_rmpp_mad_hdr {
+        struct ib_mad_hdr       mad_hdr;
+        struct ib_rmpp_hdr      rmpp_hdr;
+} __packed;
+
+and cast packet->mad.data to (struct ib_rmpp_mad_hdr *).
+
+Notice that
+
+        IB_MGMT_RMPP_HDR == sizeof(struct ib_rmpp_mad_hdr) == 36 bytes
+
+Refactor the rest of the code, accordingly.
+
+Fix the following warnings seen under GCC-13 and -Warray-bounds:
+drivers/infiniband/core/user_mad.c:564:50: warning: array subscript ‘struct ib_rmpp_mad[0]’ is partly outside array bounds of ‘unsigned char[140]’ [-Warray-bounds=]
+drivers/infiniband/core/user_mad.c:566:42: warning: array subscript ‘struct ib_rmpp_mad[0]’ is partly outside array bounds of ‘unsigned char[140]’ [-Warray-bounds=]
+drivers/infiniband/core/user_mad.c:618:25: warning: array subscript ‘struct ib_rmpp_mad[0]’ is partly outside array bounds of ‘unsigned char[140]’ [-Warray-bounds=]
+drivers/infiniband/core/user_mad.c:622:44: warning: array subscript ‘struct ib_rmpp_mad[0]’ is partly outside array bounds of ‘unsigned char[140]’ [-Warray-bounds=]
+
+Link: https://github.com/KSPP/linux/issues/273
+Link: https://godbolt.org/z/oYWaGM4Yb [1]
+Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
+Link: https://lore.kernel.org/r/ZBpB91qQcB10m3Fw@work
+Signed-off-by: Leon Romanovsky <leon@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/infiniband/core/user_mad.c | 23 ++++++++++++++---------
+ 1 file changed, 14 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
+index ad3a092b8b5c3..390123f87658b 100644
+--- a/drivers/infiniband/core/user_mad.c
++++ b/drivers/infiniband/core/user_mad.c
+@@ -131,6 +131,11 @@ struct ib_umad_packet {
+       struct ib_user_mad mad;
+ };
++struct ib_rmpp_mad_hdr {
++      struct ib_mad_hdr       mad_hdr;
++      struct ib_rmpp_hdr      rmpp_hdr;
++} __packed;
++
+ #define CREATE_TRACE_POINTS
+ #include <trace/events/ib_umad.h>
+@@ -494,11 +499,11 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
+                            size_t count, loff_t *pos)
+ {
+       struct ib_umad_file *file = filp->private_data;
++      struct ib_rmpp_mad_hdr *rmpp_mad_hdr;
+       struct ib_umad_packet *packet;
+       struct ib_mad_agent *agent;
+       struct rdma_ah_attr ah_attr;
+       struct ib_ah *ah;
+-      struct ib_rmpp_mad *rmpp_mad;
+       __be64 *tid;
+       int ret, data_len, hdr_len, copy_offset, rmpp_active;
+       u8 base_version;
+@@ -506,7 +511,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
+       if (count < hdr_size(file) + IB_MGMT_RMPP_HDR)
+               return -EINVAL;
+-      packet = kzalloc(sizeof *packet + IB_MGMT_RMPP_HDR, GFP_KERNEL);
++      packet = kzalloc(sizeof(*packet) + IB_MGMT_RMPP_HDR, GFP_KERNEL);
+       if (!packet)
+               return -ENOMEM;
+@@ -560,13 +565,13 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
+               goto err_up;
+       }
+-      rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
+-      hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
++      rmpp_mad_hdr = (struct ib_rmpp_mad_hdr *)packet->mad.data;
++      hdr_len = ib_get_mad_data_offset(rmpp_mad_hdr->mad_hdr.mgmt_class);
+-      if (ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
++      if (ib_is_mad_class_rmpp(rmpp_mad_hdr->mad_hdr.mgmt_class)
+           && ib_mad_kernel_rmpp_agent(agent)) {
+               copy_offset = IB_MGMT_RMPP_HDR;
+-              rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
++              rmpp_active = ib_get_rmpp_flags(&rmpp_mad_hdr->rmpp_hdr) &
+                                               IB_MGMT_RMPP_FLAG_ACTIVE;
+       } else {
+               copy_offset = IB_MGMT_MAD_HDR;
+@@ -615,12 +620,12 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
+               tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
+               *tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
+                                  (be64_to_cpup(tid) & 0xffffffff));
+-              rmpp_mad->mad_hdr.tid = *tid;
++              rmpp_mad_hdr->mad_hdr.tid = *tid;
+       }
+       if (!ib_mad_kernel_rmpp_agent(agent)
+-         && ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
+-         && (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
++          && ib_is_mad_class_rmpp(rmpp_mad_hdr->mad_hdr.mgmt_class)
++          && (ib_get_rmpp_flags(&rmpp_mad_hdr->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
+               spin_lock_irq(&file->send_lock);
+               list_add_tail(&packet->list, &file->send_list);
+               spin_unlock_irq(&file->send_lock);
+-- 
+2.39.2
+
diff --git a/queue-5.4/recordmcount-fix-memory-leaks-in-the-uwrite-function.patch b/queue-5.4/recordmcount-fix-memory-leaks-in-the-uwrite-function.patch
new file mode 100644 (file)
index 0000000..b2d3c01
--- /dev/null
@@ -0,0 +1,48 @@
+From 04c9077bf6debff7636664e12754027cc93f939f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 26 Apr 2023 09:05:27 +0800
+Subject: recordmcount: Fix memory leaks in the uwrite function
+
+From: Hao Zeng <zenghao@kylinos.cn>
+
+[ Upstream commit fa359d068574d29e7d2f0fdd0ebe4c6a12b5cfb9 ]
+
+Common realloc mistake: 'file_append' nulled but not freed upon failure
+
+Link: https://lkml.kernel.org/r/20230426010527.703093-1-zenghao@kylinos.cn
+
+Signed-off-by: Hao Zeng <zenghao@kylinos.cn>
+Suggested-by: Steven Rostedt <rostedt@goodmis.org>
+Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ scripts/recordmcount.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
+index cce12e1971d85..ec692af8ce9eb 100644
+--- a/scripts/recordmcount.c
++++ b/scripts/recordmcount.c
+@@ -102,6 +102,7 @@ static ssize_t uwrite(void const *const buf, size_t const count)
+ {
+       size_t cnt = count;
+       off_t idx = 0;
++      void *p = NULL;
+       file_updated = 1;
+@@ -109,7 +110,10 @@ static ssize_t uwrite(void const *const buf, size_t const count)
+               off_t aoffset = (file_ptr + count) - file_end;
+               if (aoffset > file_append_size) {
+-                      file_append = realloc(file_append, aoffset);
++                      p = realloc(file_append, aoffset);
++                      if (!p)
++                              free(file_append);
++                      file_append = p;
+                       file_append_size = aoffset;
+               }
+               if (!file_append) {
+-- 
+2.39.2
+
diff --git a/queue-5.4/regmap-cache-return-error-in-cache-sync-operations-f.patch b/queue-5.4/regmap-cache-return-error-in-cache-sync-operations-f.patch
new file mode 100644 (file)
index 0000000..989a1a8
--- /dev/null
@@ -0,0 +1,49 @@
+From ebcad4e1d62692332e83a0efc9b0b31470ff6fc9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 13 Mar 2023 08:18:11 +0100
+Subject: regmap: cache: Return error in cache sync operations for
+ REGCACHE_NONE
+
+From: Alexander Stein <alexander.stein@ew.tq-group.com>
+
+[ Upstream commit fd883d79e4dcd2417c2b80756f22a2ff03b0f6e0 ]
+
+There is no sense in doing a cache sync on REGCACHE_NONE regmaps.
+Instead of panicking the kernel due to missing cache_ops, return an error
+to client driver.
+
+Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Link: https://lore.kernel.org/r/20230313071812.13577-1-alexander.stein@ew.tq-group.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/base/regmap/regcache.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
+index 7f4b3b62492ca..7fdd702e564ae 100644
+--- a/drivers/base/regmap/regcache.c
++++ b/drivers/base/regmap/regcache.c
+@@ -343,6 +343,9 @@ int regcache_sync(struct regmap *map)
+       const char *name;
+       bool bypass;
++      if (WARN_ON(map->cache_type == REGCACHE_NONE))
++              return -EINVAL;
++
+       BUG_ON(!map->cache_ops);
+       map->lock(map->lock_arg);
+@@ -412,6 +415,9 @@ int regcache_sync_region(struct regmap *map, unsigned int min,
+       const char *name;
+       bool bypass;
++      if (WARN_ON(map->cache_type == REGCACHE_NONE))
++              return -EINVAL;
++
+       BUG_ON(!map->cache_ops);
+       map->lock(map->lock_arg);
+-- 
+2.39.2
+
diff --git a/queue-5.4/samples-bpf-fix-fout-leak-in-hbm-s-run_bpf_prog.patch b/queue-5.4/samples-bpf-fix-fout-leak-in-hbm-s-run_bpf_prog.patch
new file mode 100644 (file)
index 0000000..9f8d7aa
--- /dev/null
@@ -0,0 +1,35 @@
+From 982bde3a9afbd4795e37540965bca30b2b4f3d30 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 11 Apr 2023 16:43:49 +0800
+Subject: samples/bpf: Fix fout leak in hbm's run_bpf_prog
+
+From: Hao Zeng <zenghao@kylinos.cn>
+
+[ Upstream commit 23acb14af1914010dd0aae1bbb7fab28bf518b8e ]
+
+Fix fout being fopen'ed but then not subsequently fclose'd. In the affected
+branch, fout is otherwise going out of scope.
+
+Signed-off-by: Hao Zeng <zenghao@kylinos.cn>
+Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
+Link: https://lore.kernel.org/bpf/20230411084349.1999628-1-zenghao@kylinos.cn
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ samples/bpf/hbm.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/samples/bpf/hbm.c b/samples/bpf/hbm.c
+index e0fbab9bec83e..6d6d4e4ea8437 100644
+--- a/samples/bpf/hbm.c
++++ b/samples/bpf/hbm.c
+@@ -307,6 +307,7 @@ static int run_bpf_prog(char *prog, int cg_id)
+               fout = fopen(fname, "w");
+               fprintf(fout, "id:%d\n", cg_id);
+               fprintf(fout, "ERROR: Could not lookup queue_stats\n");
++              fclose(fout);
+       } else if (stats_flag && qstats.lastPacketTime >
+                  qstats.firstPacketTime) {
+               long long delta_us = (qstats.lastPacketTime -
+-- 
+2.39.2
+
diff --git a/queue-5.4/sched-fix-kcsan-noinstr-violation.patch b/queue-5.4/sched-fix-kcsan-noinstr-violation.patch
new file mode 100644 (file)
index 0000000..dff1fd4
--- /dev/null
@@ -0,0 +1,40 @@
+From fcc3c4038fb0384dadce2f16a529a2cb51cdb09b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 12 Apr 2023 10:24:07 -0700
+Subject: sched: Fix KCSAN noinstr violation
+
+From: Josh Poimboeuf <jpoimboe@kernel.org>
+
+[ Upstream commit e0b081d17a9f4e5c0cbb0e5fbeb1abe3de0f7e4e ]
+
+With KCSAN enabled, end_of_stack() can get out-of-lined.  Force it
+inline.
+
+Fixes the following warnings:
+
+  vmlinux.o: warning: objtool: check_stackleak_irqoff+0x2b: call to end_of_stack() leaves .noinstr.text section
+
+Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Link: https://lore.kernel.org/r/cc1b4d73d3a428a00d206242a68fdf99a934ca7b.1681320026.git.jpoimboe@kernel.org
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/sched/task_stack.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h
+index 1009b6b5ce403..879a5c8f930b6 100644
+--- a/include/linux/sched/task_stack.h
++++ b/include/linux/sched/task_stack.h
+@@ -23,7 +23,7 @@ static __always_inline void *task_stack_page(const struct task_struct *task)
+ #define setup_thread_stack(new,old)   do { } while(0)
+-static inline unsigned long *end_of_stack(const struct task_struct *task)
++static __always_inline unsigned long *end_of_stack(const struct task_struct *task)
+ {
+ #ifdef CONFIG_STACK_GROWSUP
+       return (unsigned long *)((unsigned long)task->stack + THREAD_SIZE) - 1;
+-- 
+2.39.2
+
diff --git a/queue-5.4/scsi-lpfc-prevent-lpfc_debugfs_lockstat_write-buffer.patch b/queue-5.4/scsi-lpfc-prevent-lpfc_debugfs_lockstat_write-buffer.patch
new file mode 100644 (file)
index 0000000..370e3f7
--- /dev/null
@@ -0,0 +1,60 @@
+From 5413ca25da66a6c866a4db422491819fb05a9843 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 1 Mar 2023 15:16:17 -0800
+Subject: scsi: lpfc: Prevent lpfc_debugfs_lockstat_write() buffer overflow
+
+From: Justin Tee <justin.tee@broadcom.com>
+
+[ Upstream commit c6087b82a9146826564a55c5ca0164cac40348f5 ]
+
+A static code analysis tool flagged the possibility of buffer overflow when
+using copy_from_user() for a debugfs entry.
+
+Currently, it is possible that copy_from_user() copies more bytes than what
+would fit in the mybuf char array.  Add a min() restriction check between
+sizeof(mybuf) - 1 and nbytes passed from the userspace buffer to protect
+against buffer overflow.
+
+Link: https://lore.kernel.org/r/20230301231626.9621-2-justintee8345@gmail.com
+Signed-off-by: Justin Tee <justin.tee@broadcom.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/scsi/lpfc/lpfc_debugfs.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
+index 69551132f304c..291fccf02d453 100644
+--- a/drivers/scsi/lpfc/lpfc_debugfs.c
++++ b/drivers/scsi/lpfc/lpfc_debugfs.c
+@@ -2046,6 +2046,7 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
+       char mybuf[64];
+       char *pbuf;
+       int i;
++      size_t bsize;
+       /* Protect copy from user */
+       if (!access_ok(buf, nbytes))
+@@ -2053,7 +2054,9 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
+       memset(mybuf, 0, sizeof(mybuf));
+-      if (copy_from_user(mybuf, buf, nbytes))
++      bsize = min(nbytes, (sizeof(mybuf) - 1));
++
++      if (copy_from_user(mybuf, buf, bsize))
+               return -EFAULT;
+       pbuf = &mybuf[0];
+@@ -2074,7 +2077,7 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
+                       qp->lock_conflict.wq_access = 0;
+               }
+       }
+-      return nbytes;
++      return bsize;
+ }
+ #endif
+-- 
+2.39.2
+
diff --git a/queue-5.4/scsi-message-mptlan-fix-use-after-free-bug-in-mptlan.patch b/queue-5.4/scsi-message-mptlan-fix-use-after-free-bug-in-mptlan.patch
new file mode 100644 (file)
index 0000000..314fe25
--- /dev/null
@@ -0,0 +1,55 @@
+From e937a7bf0275d39face57f8559e5db4459fff811 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 18 Mar 2023 16:16:35 +0800
+Subject: scsi: message: mptlan: Fix use after free bug in mptlan_remove() due
+ to race condition
+
+From: Zheng Wang <zyytlz.wz@163.com>
+
+[ Upstream commit f486893288f3e9b171b836f43853a6426515d800 ]
+
+mptlan_probe() calls mpt_register_lan_device() which initializes the
+&priv->post_buckets_task workqueue. A call to
+mpt_lan_wake_post_buckets_task() will subsequently start the work.
+
+During driver unload in mptlan_remove() the following race may occur:
+
+CPU0                  CPU1
+
+                    |mpt_lan_post_receive_buckets_work()
+mptlan_remove()     |
+  free_netdev()     |
+    kfree(dev);     |
+                    |
+                    | dev->mtu
+                    |   //use
+
+Fix this by finishing the work prior to cleaning up in mptlan_remove().
+
+[mkp: we really should remove mptlan instead of attempting to fix it]
+
+Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
+Link: https://lore.kernel.org/r/20230318081635.796479-1-zyytlz.wz@163.com
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/message/fusion/mptlan.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
+index ebc00d47abf52..624803a887d8f 100644
+--- a/drivers/message/fusion/mptlan.c
++++ b/drivers/message/fusion/mptlan.c
+@@ -1430,7 +1430,9 @@ mptlan_remove(struct pci_dev *pdev)
+ {
+       MPT_ADAPTER             *ioc = pci_get_drvdata(pdev);
+       struct net_device       *dev = ioc->netdev;
++      struct mpt_lan_priv *priv = netdev_priv(dev);
++      cancel_delayed_work_sync(&priv->post_buckets_task);
+       if(dev != NULL) {
+               unregister_netdev(dev);
+               free_netdev(dev);
+-- 
+2.39.2
+
diff --git a/queue-5.4/scsi-target-iscsit-free-cmds-before-session-free.patch b/queue-5.4/scsi-target-iscsit-free-cmds-before-session-free.patch
new file mode 100644 (file)
index 0000000..a7f8804
--- /dev/null
@@ -0,0 +1,64 @@
+From 29a1e75a24a873aa007fcd145aad8146a404337c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 18 Mar 2023 20:56:17 -0500
+Subject: scsi: target: iscsit: Free cmds before session free
+
+From: Dmitry Bogdanov <d.bogdanov@yadro.com>
+
+[ Upstream commit d8990b5a4d065f38f35d69bcd627ec5a7f8330ca ]
+
+Commands from recovery entries are freed after session has been closed.
+That leads to use-after-free at command free or NPE with such call trace:
+
+Time2Retain timer expired for SID: 1, cleaning up iSCSI session.
+BUG: kernel NULL pointer dereference, address: 0000000000000140
+RIP: 0010:sbitmap_queue_clear+0x3a/0xa0
+Call Trace:
+ target_release_cmd_kref+0xd1/0x1f0 [target_core_mod]
+ transport_generic_free_cmd+0xd1/0x180 [target_core_mod]
+ iscsit_free_cmd+0x53/0xd0 [iscsi_target_mod]
+ iscsit_free_connection_recovery_entries+0x29d/0x320 [iscsi_target_mod]
+ iscsit_close_session+0x13a/0x140 [iscsi_target_mod]
+ iscsit_check_post_dataout+0x440/0x440 [iscsi_target_mod]
+ call_timer_fn+0x24/0x140
+
+Move cleanup of recovery enrties to before session freeing.
+
+Reported-by: Forza <forza@tnonline.net>
+Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
+Signed-off-by: Mike Christie <michael.christie@oracle.com>
+Link: https://lore.kernel.org/r/20230319015620.96006-7-michael.christie@oracle.com
+Reviewed-by: Maurizio Lombardi <mlombard@redhat.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/target/iscsi/iscsi_target.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
+index 8b8afa95fbbae..ab2f0ceb1e23b 100644
+--- a/drivers/target/iscsi/iscsi_target.c
++++ b/drivers/target/iscsi/iscsi_target.c
+@@ -4385,6 +4385,9 @@ int iscsit_close_session(struct iscsi_session *sess)
+       iscsit_stop_time2retain_timer(sess);
+       spin_unlock_bh(&se_tpg->session_lock);
++      if (sess->sess_ops->ErrorRecoveryLevel == 2)
++              iscsit_free_connection_recovery_entries(sess);
++
+       /*
+        * transport_deregister_session_configfs() will clear the
+        * struct se_node_acl->nacl_sess pointer now as a iscsi_np process context
+@@ -4413,9 +4416,6 @@ int iscsit_close_session(struct iscsi_session *sess)
+       transport_deregister_session(sess->se_sess);
+-      if (sess->sess_ops->ErrorRecoveryLevel == 2)
+-              iscsit_free_connection_recovery_entries(sess);
+-
+       iscsit_free_all_ooo_cmdsns(sess);
+       spin_lock_bh(&se_tpg->session_lock);
+-- 
+2.39.2
+
diff --git a/queue-5.4/serial-8250-reinit-port-pm-on-port-specific-driver-u.patch b/queue-5.4/serial-8250-reinit-port-pm-on-port-specific-driver-u.patch
new file mode 100644 (file)
index 0000000..591157f
--- /dev/null
@@ -0,0 +1,56 @@
+From 933516af407846a2826176b0ec338e2e13929f3c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 18 Apr 2023 13:14:06 +0300
+Subject: serial: 8250: Reinit port->pm on port specific driver unbind
+
+From: Tony Lindgren <tony@atomide.com>
+
+[ Upstream commit 04e82793f068d2f0ffe62fcea03d007a8cdc16a7 ]
+
+When we unbind a serial port hardware specific 8250 driver, the generic
+serial8250 driver takes over the port. After that we see an oops about 10
+seconds later. This can produce the following at least on some TI SoCs:
+
+Unhandled fault: imprecise external abort (0x1406)
+Internal error: : 1406 [#1] SMP ARM
+
+Turns out that we may still have the serial port hardware specific driver
+port->pm in use, and serial8250_pm() tries to call it after the port
+specific driver is gone:
+
+serial8250_pm [8250_base] from uart_change_pm+0x54/0x8c [serial_base]
+uart_change_pm [serial_base] from uart_hangup+0x154/0x198 [serial_base]
+uart_hangup [serial_base] from __tty_hangup.part.0+0x328/0x37c
+__tty_hangup.part.0 from disassociate_ctty+0x154/0x20c
+disassociate_ctty from do_exit+0x744/0xaac
+do_exit from do_group_exit+0x40/0x8c
+do_group_exit from __wake_up_parent+0x0/0x1c
+
+Let's fix the issue by calling serial8250_set_defaults() in
+serial8250_unregister_port(). This will set the port back to using
+the serial8250 default functions, and sets the port->pm to point to
+serial8250_pm.
+
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Link: https://lore.kernel.org/r/20230418101407.12403-1-tony@atomide.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/8250/8250_core.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
+index 2675771a03a0d..d7afff1e7685f 100644
+--- a/drivers/tty/serial/8250/8250_core.c
++++ b/drivers/tty/serial/8250/8250_core.c
+@@ -1138,6 +1138,7 @@ void serial8250_unregister_port(int line)
+               uart->port.type = PORT_UNKNOWN;
+               uart->port.dev = &serial8250_isa_devs->dev;
+               uart->capabilities = 0;
++              serial8250_init_port(uart);
+               serial8250_apply_quirks(uart);
+               uart_add_one_port(&serial8250_reg, &uart->port);
+       } else {
+-- 
+2.39.2
+
index 6384f2e74787bce49f319d58f186b6e39c800fbb..b780efc0aa7a73e991f7e044f55ecafd7af9e005 100644 (file)
@@ -12,3 +12,45 @@ ipvlan-fix-out-of-bounds-caused-by-unclear-skb-cb.patch
 net-datagram-fix-data-races-in-datagram_poll.patch
 af_unix-fix-a-data-race-of-sk-sk_receive_queue-qlen.patch
 af_unix-fix-data-races-around-sk-sk_shutdown.patch
+fs-hfsplus-remove-warn_on-from-hfsplus_cat_-read-wri.patch
+drm-amd-display-use-dc_log_dc-in-the-trasform-pixel-.patch
+regmap-cache-return-error-in-cache-sync-operations-f.patch
+memstick-r592-fix-uaf-bug-in-r592_remove-due-to-race.patch
+firmware-arm_sdei-fix-sleep-from-invalid-context-bug.patch
+acpi-ec-fix-oops-when-removing-custom-query-handlers.patch
+drm-tegra-avoid-potential-32-bit-integer-overflow.patch
+acpica-avoid-undefined-behavior-applying-zero-offset.patch
+acpica-acpica-check-null-return-of-acpi_allocate_zer.patch
+wifi-brcmfmac-cfg80211-pass-the-pmk-in-binary-instea.patch
+ext2-check-block-size-validity-during-mount.patch
+scsi-lpfc-prevent-lpfc_debugfs_lockstat_write-buffer.patch
+net-pasemi-fix-return-type-of-pasemi_mac_start_tx.patch
+net-catch-invalid-index-in-xps-mapping.patch
+scsi-target-iscsit-free-cmds-before-session-free.patch
+lib-cpu_rmap-avoid-use-after-free-on-rmap-obj-array-.patch
+scsi-message-mptlan-fix-use-after-free-bug-in-mptlan.patch
+gfs2-fix-inode-height-consistency-check.patch
+ext4-set-goal-start-correctly-in-ext4_mb_normalize_r.patch
+ext4-fix-best-extent-lstart-adjustment-logic-in-ext4.patch
+f2fs-fix-to-drop-all-dirty-pages-during-umount-if-cp.patch
+samples-bpf-fix-fout-leak-in-hbm-s-run_bpf_prog.patch
+wifi-iwlwifi-pcie-fix-possible-null-pointer-derefere.patch
+wifi-iwlwifi-pcie-fix-integer-overflow-in-iwl_write_.patch
+wifi-iwlwifi-dvm-fix-memcpy-detected-field-spanning-.patch
+bluetooth-l2cap-fix-bad-unlock-balance-in-l2cap_disc.patch
+staging-rtl8192e-replace-macro-rtl_pci_device-with-p.patch
+hid-logitech-hidpp-don-t-use-the-usb-serial-for-usb-.patch
+hid-logitech-hidpp-reconcile-usb-and-unifying-serial.patch
+spi-spi-imx-fix-mx51_ecspi_-macros-when-cs-3.patch
+hid-wacom-generic-set-battery-quirk-only-when-we-see.patch
+usb-typec-tcpm-fix-multiple-times-discover-svids-err.patch
+serial-8250-reinit-port-pm-on-port-specific-driver-u.patch
+mcb-pci-reallocate-memory-region-to-avoid-memory-ove.patch
+sched-fix-kcsan-noinstr-violation.patch
+recordmcount-fix-memory-leaks-in-the-uwrite-function.patch
+rdma-core-fix-multiple-warray-bounds-warnings.patch
+clk-tegra20-fix-gcc-7-constant-overflow-warning.patch
+iommu-arm-smmu-v3-acknowledge-pri-event-queue-overfl.patch
+input-xpad-add-constants-for-gip-interface-numbers.patch
+phy-st-miphy28lp-use-_poll_timeout-functions-for-wai.patch
+mfd-dln2-fix-memory-leak-in-dln2_probe.patch
diff --git a/queue-5.4/spi-spi-imx-fix-mx51_ecspi_-macros-when-cs-3.patch b/queue-5.4/spi-spi-imx-fix-mx51_ecspi_-macros-when-cs-3.patch
new file mode 100644 (file)
index 0000000..675136e
--- /dev/null
@@ -0,0 +1,80 @@
+From 771bfcc5d4b421931b6045d3f829be492e5f09c7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 18 Mar 2023 18:21:32 -0400
+Subject: spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Kevin Groeneveld <kgroeneveld@lenbrook.com>
+
+[ Upstream commit 87c614175bbf28d3fd076dc2d166bac759e41427 ]
+
+When using gpio based chip select the cs value can go outside the range
+0 – 3. The various MX51_ECSPI_* macros did not take this into consideration
+resulting in possible corruption of the configuration.
+
+For example for any cs value over 3 the SCLKPHA bits would not be set and
+other values in the register possibly corrupted.
+
+One way to fix this is to just mask the cs bits to 2 bits. This still
+allows all 4 native chip selects to work as well as gpio chip selects
+(which can use any of the 4 chip select configurations).
+
+Signed-off-by: Kevin Groeneveld <kgroeneveld@lenbrook.com>
+Link: https://lore.kernel.org/r/20230318222132.3373-1-kgroeneveld@lenbrook.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/spi/spi-imx.c | 24 ++++++++++++++++++------
+ 1 file changed, 18 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
+index 9d593675257e0..67f31183c1180 100644
+--- a/drivers/spi/spi-imx.c
++++ b/drivers/spi/spi-imx.c
+@@ -239,6 +239,18 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
+       return true;
+ }
++/*
++ * Note the number of natively supported chip selects for MX51 is 4. Some
++ * devices may have less actual SS pins but the register map supports 4. When
++ * using gpio chip selects the cs values passed into the macros below can go
++ * outside the range 0 - 3. We therefore need to limit the cs value to avoid
++ * corrupting bits outside the allocated locations.
++ *
++ * The simplest way to do this is to just mask the cs bits to 2 bits. This
++ * still allows all 4 native chip selects to work as well as gpio chip selects
++ * (which can use any of the 4 chip select configurations).
++ */
++
+ #define MX51_ECSPI_CTRL               0x08
+ #define MX51_ECSPI_CTRL_ENABLE                (1 <<  0)
+ #define MX51_ECSPI_CTRL_XCH           (1 <<  2)
+@@ -247,16 +259,16 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
+ #define MX51_ECSPI_CTRL_DRCTL(drctl)  ((drctl) << 16)
+ #define MX51_ECSPI_CTRL_POSTDIV_OFFSET        8
+ #define MX51_ECSPI_CTRL_PREDIV_OFFSET 12
+-#define MX51_ECSPI_CTRL_CS(cs)                ((cs) << 18)
++#define MX51_ECSPI_CTRL_CS(cs)                ((cs & 3) << 18)
+ #define MX51_ECSPI_CTRL_BL_OFFSET     20
+ #define MX51_ECSPI_CTRL_BL_MASK               (0xfff << 20)
+ #define MX51_ECSPI_CONFIG     0x0c
+-#define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs) +  0))
+-#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs) +  4))
+-#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs) +  8))
+-#define MX51_ECSPI_CONFIG_SSBPOL(cs)  (1 << ((cs) + 12))
+-#define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs) + 20))
++#define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs & 3) +  0))
++#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs & 3) +  4))
++#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs & 3) +  8))
++#define MX51_ECSPI_CONFIG_SSBPOL(cs)  (1 << ((cs & 3) + 12))
++#define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs & 3) + 20))
+ #define MX51_ECSPI_INT                0x10
+ #define MX51_ECSPI_INT_TEEN           (1 <<  0)
+-- 
+2.39.2
+
diff --git a/queue-5.4/staging-rtl8192e-replace-macro-rtl_pci_device-with-p.patch b/queue-5.4/staging-rtl8192e-replace-macro-rtl_pci_device-with-p.patch
new file mode 100644 (file)
index 0000000..7c493fe
--- /dev/null
@@ -0,0 +1,57 @@
+From 99eed3a1852ff4886e282cb2c6b30869b75505f8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 23 Feb 2023 07:47:21 +0100
+Subject: staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE
+
+From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
+
+[ Upstream commit fda2093860df4812d69052a8cf4997e53853a340 ]
+
+Replace macro RTL_PCI_DEVICE with PCI_DEVICE to get rid of rtl819xp_ops
+which is empty.
+
+Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
+Link: https://lore.kernel.org/r/8b45ee783fa91196b7c9d6fc840a189496afd2f4.1677133271.git.philipp.g.hortmann@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +++---
+ drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 5 -----
+ 2 files changed, 3 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+index be377e75703bf..ca3cea27489b2 100644
+--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
++++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+@@ -50,9 +50,9 @@ static const struct rtl819x_ops rtl819xp_ops = {
+ };
+ static struct pci_device_id rtl8192_pci_id_tbl[] = {
+-      {RTL_PCI_DEVICE(0x10ec, 0x8192, rtl819xp_ops)},
+-      {RTL_PCI_DEVICE(0x07aa, 0x0044, rtl819xp_ops)},
+-      {RTL_PCI_DEVICE(0x07aa, 0x0047, rtl819xp_ops)},
++      {PCI_DEVICE(0x10ec, 0x8192)},
++      {PCI_DEVICE(0x07aa, 0x0044)},
++      {PCI_DEVICE(0x07aa, 0x0047)},
+       {}
+ };
+diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+index 736f1a824cd2e..7bbd884aa5f13 100644
+--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
++++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+@@ -55,11 +55,6 @@
+ #define IS_HARDWARE_TYPE_8192SE(_priv)                \
+       (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE)
+-#define RTL_PCI_DEVICE(vend, dev, cfg) \
+-      .vendor = (vend), .device = (dev), \
+-      .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
+-      .driver_data = (kernel_ulong_t)&(cfg)
+-
+ #define TOTAL_CAM_ENTRY               32
+ #define CAM_CONTENT_COUNT     8
+-- 
+2.39.2
+
diff --git a/queue-5.4/usb-typec-tcpm-fix-multiple-times-discover-svids-err.patch b/queue-5.4/usb-typec-tcpm-fix-multiple-times-discover-svids-err.patch
new file mode 100644 (file)
index 0000000..6f7dbe5
--- /dev/null
@@ -0,0 +1,59 @@
+From bf3931be40fa8eba8dd9cd4ae1964601f44213cc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 16 Mar 2023 16:11:49 +0800
+Subject: usb: typec: tcpm: fix multiple times discover svids error
+
+From: Frank Wang <frank.wang@rock-chips.com>
+
+[ Upstream commit dac3b192107b978198e89ec0f77375738352e0c8 ]
+
+PD3.0 Spec 6.4.4.3.2 say that only Responder supports 12 or more SVIDs,
+the Discover SVIDs Command Shall be executed multiple times until a
+Discover SVIDs VDO is returned ending either with a SVID value of
+0x0000 in the last part of the last VDO or with a VDO containing two
+SVIDs with values of 0x0000.
+
+In the current implementation, if the last VDO does not find that the
+Discover SVIDs Command would be executed multiple times even if the
+Responder SVIDs are less than 12, and we found some odd dockers just
+meet this case. So fix it.
+
+Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
+Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
+Link: https://lore.kernel.org/r/20230316081149.24519-1-frank.wang@rock-chips.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/typec/tcpm/tcpm.c | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
+index fb18264b702e6..b259a4a28f81a 100644
+--- a/drivers/usb/typec/tcpm/tcpm.c
++++ b/drivers/usb/typec/tcpm/tcpm.c
+@@ -1018,7 +1018,21 @@ static bool svdm_consume_svids(struct tcpm_port *port, const __le32 *payload,
+               pmdata->svids[pmdata->nsvids++] = svid;
+               tcpm_log(port, "SVID %d: 0x%x", pmdata->nsvids, svid);
+       }
+-      return true;
++
++      /*
++       * PD3.0 Spec 6.4.4.3.2: The SVIDs are returned 2 per VDO (see Table
++       * 6-43), and can be returned maximum 6 VDOs per response (see Figure
++       * 6-19). If the Respondersupports 12 or more SVID then the Discover
++       * SVIDs Command Shall be executed multiple times until a Discover
++       * SVIDs VDO is returned ending either with a SVID value of 0x0000 in
++       * the last part of the last VDO or with a VDO containing two SVIDs
++       * with values of 0x0000.
++       *
++       * However, some odd dockers support SVIDs less than 12 but without
++       * 0x0000 in the last VDO, so we need to break the Discover SVIDs
++       * request and return false here.
++       */
++      return cnt == 7;
+ abort:
+       tcpm_log(port, "SVID_DISCOVERY_MAX(%d) too low!", SVID_DISCOVERY_MAX);
+       return false;
+-- 
+2.39.2
+
diff --git a/queue-5.4/wifi-brcmfmac-cfg80211-pass-the-pmk-in-binary-instea.patch b/queue-5.4/wifi-brcmfmac-cfg80211-pass-the-pmk-in-binary-instea.patch
new file mode 100644 (file)
index 0000000..625f2dc
--- /dev/null
@@ -0,0 +1,57 @@
+From dfd16d1f69418152b5da7773fa52df2c251d8082 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 14 Feb 2023 18:24:19 +0900
+Subject: wifi: brcmfmac: cfg80211: Pass the PMK in binary instead of hex
+
+From: Hector Martin <marcan@marcan.st>
+
+[ Upstream commit 89b89e52153fda2733562776c7c9d9d3ebf8dd6d ]
+
+Apparently the hex passphrase mechanism does not work on newer
+chips/firmware (e.g. BCM4387). It seems there was a simple way of
+passing it in binary all along, so use that and avoid the hexification.
+
+OpenBSD has been doing it like this from the beginning, so this should
+work on all chips.
+
+Also clear the structure before setting the PMK. This was leaking
+uninitialized stack contents to the device.
+
+Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
+Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Hector Martin <marcan@marcan.st>
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://lore.kernel.org/r/20230214092423.15175-6-marcan@marcan.st
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+index 5bfff309f5474..b7ceea0b3204d 100644
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -1269,13 +1269,14 @@ static int brcmf_set_pmk(struct brcmf_if *ifp, const u8 *pmk_data, u16 pmk_len)
+ {
+       struct brcmf_pub *drvr = ifp->drvr;
+       struct brcmf_wsec_pmk_le pmk;
+-      int i, err;
++      int err;
++
++      memset(&pmk, 0, sizeof(pmk));
+-      /* convert to firmware key format */
+-      pmk.key_len = cpu_to_le16(pmk_len << 1);
+-      pmk.flags = cpu_to_le16(BRCMF_WSEC_PASSPHRASE);
+-      for (i = 0; i < pmk_len; i++)
+-              snprintf(&pmk.key[2 * i], 3, "%02x", pmk_data[i]);
++      /* pass pmk directly */
++      pmk.key_len = cpu_to_le16(pmk_len);
++      pmk.flags = cpu_to_le16(0);
++      memcpy(pmk.key, pmk_data, pmk_len);
+       /* store psk in firmware */
+       err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_WSEC_PMK,
+-- 
+2.39.2
+
diff --git a/queue-5.4/wifi-iwlwifi-dvm-fix-memcpy-detected-field-spanning-.patch b/queue-5.4/wifi-iwlwifi-dvm-fix-memcpy-detected-field-spanning-.patch
new file mode 100644 (file)
index 0000000..951ffce
--- /dev/null
@@ -0,0 +1,72 @@
+From 2eda0f2443d752956db3449448a19c353354d689 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 18 Apr 2023 15:25:46 +0200
+Subject: wifi: iwlwifi: dvm: Fix memcpy: detected field-spanning write
+ backtrace
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit ef16799640865f937719f0771c93be5dca18adc6 ]
+
+A received TKIP key may be up to 32 bytes because it may contain
+MIC rx/tx keys too. These are not used by iwl and copying these
+over overflows the iwl_keyinfo.key field.
+
+Add a check to not copy more data to iwl_keyinfo.key then will fit.
+
+This fixes backtraces like this one:
+
+ memcpy: detected field-spanning write (size 32) of single field "sta_cmd.key.key" at drivers/net/wireless/intel/iwlwifi/dvm/sta.c:1103 (size 16)
+ WARNING: CPU: 1 PID: 946 at drivers/net/wireless/intel/iwlwifi/dvm/sta.c:1103 iwlagn_send_sta_key+0x375/0x390 [iwldvm]
+ <snip>
+ Hardware name: Dell Inc. Latitude E6430/0H3MT5, BIOS A21 05/08/2017
+ RIP: 0010:iwlagn_send_sta_key+0x375/0x390 [iwldvm]
+ <snip>
+ Call Trace:
+  <TASK>
+  iwl_set_dynamic_key+0x1f0/0x220 [iwldvm]
+  iwlagn_mac_set_key+0x1e4/0x280 [iwldvm]
+  drv_set_key+0xa4/0x1b0 [mac80211]
+  ieee80211_key_enable_hw_accel+0xa8/0x2d0 [mac80211]
+  ieee80211_key_replace+0x22d/0x8e0 [mac80211]
+ <snip>
+
+Link: https://www.alionet.org/index.php?topic=1469.0
+Link: https://lore.kernel.org/linux-wireless/20230218191056.never.374-kees@kernel.org/
+Link: https://lore.kernel.org/linux-wireless/68760035-7f75-1b23-e355-bfb758a87d83@redhat.com/
+Cc: Kees Cook <keescook@chromium.org>
+Suggested-by: Johannes Berg <johannes@sipsolutions.net>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Reviewed-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/intel/iwlwifi/dvm/sta.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
+index 51158edce15b0..f30fdbedd7172 100644
+--- a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
++++ b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
+@@ -1086,6 +1086,7 @@ static int iwlagn_send_sta_key(struct iwl_priv *priv,
+ {
+       __le16 key_flags;
+       struct iwl_addsta_cmd sta_cmd;
++      size_t to_copy;
+       int i;
+       spin_lock_bh(&priv->sta_lock);
+@@ -1105,7 +1106,9 @@ static int iwlagn_send_sta_key(struct iwl_priv *priv,
+               sta_cmd.key.tkip_rx_tsc_byte2 = tkip_iv32;
+               for (i = 0; i < 5; i++)
+                       sta_cmd.key.tkip_rx_ttak[i] = cpu_to_le16(tkip_p1k[i]);
+-              memcpy(sta_cmd.key.key, keyconf->key, keyconf->keylen);
++              /* keyconf may contain MIC rx/tx keys which iwl does not use */
++              to_copy = min_t(size_t, sizeof(sta_cmd.key.key), keyconf->keylen);
++              memcpy(sta_cmd.key.key, keyconf->key, to_copy);
+               break;
+       case WLAN_CIPHER_SUITE_WEP104:
+               key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
+-- 
+2.39.2
+
diff --git a/queue-5.4/wifi-iwlwifi-pcie-fix-integer-overflow-in-iwl_write_.patch b/queue-5.4/wifi-iwlwifi-pcie-fix-integer-overflow-in-iwl_write_.patch
new file mode 100644 (file)
index 0000000..6e90003
--- /dev/null
@@ -0,0 +1,56 @@
+From 7b603da81ec9390caac9db9e69fa53e3a1d6910d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 14 Apr 2023 13:11:59 +0300
+Subject: wifi: iwlwifi: pcie: Fix integer overflow in iwl_write_to_user_buf
+
+From: Hyunwoo Kim <imv4bel@gmail.com>
+
+[ Upstream commit 58d1b717879bfeabe09b35e41ad667c79933eb2e ]
+
+An integer overflow occurs in the iwl_write_to_user_buf() function,
+which is called by the iwl_dbgfs_monitor_data_read() function.
+
+static bool iwl_write_to_user_buf(char __user *user_buf, ssize_t count,
+                                 void *buf, ssize_t *size,
+                                 ssize_t *bytes_copied)
+{
+       int buf_size_left = count - *bytes_copied;
+
+       buf_size_left = buf_size_left - (buf_size_left % sizeof(u32));
+       if (*size > buf_size_left)
+               *size = buf_size_left;
+
+If the user passes a SIZE_MAX value to the "ssize_t count" parameter,
+the ssize_t count parameter is assigned to "int buf_size_left".
+Then compare "*size" with "buf_size_left" . Here, "buf_size_left" is a
+negative number, so "*size" is assigned "buf_size_left" and goes into
+the third argument of the copy_to_user function, causing a heap overflow.
+
+This is not a security vulnerability because iwl_dbgfs_monitor_data_read()
+is a debugfs operation with 0400 privileges.
+
+Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
+Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
+Link: https://lore.kernel.org/r/20230414130637.2d80ace81532.Iecfba549e0e0be21bbb0324675392e42e75bd5ad@changeid
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+index 3a93a7b8ba0af..e7b90cf1f28cf 100644
+--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
++++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+@@ -2832,7 +2832,7 @@ static bool iwl_write_to_user_buf(char __user *user_buf, ssize_t count,
+                                 void *buf, ssize_t *size,
+                                 ssize_t *bytes_copied)
+ {
+-      int buf_size_left = count - *bytes_copied;
++      ssize_t buf_size_left = count - *bytes_copied;
+       buf_size_left = buf_size_left - (buf_size_left % sizeof(u32));
+       if (*size > buf_size_left)
+-- 
+2.39.2
+
diff --git a/queue-5.4/wifi-iwlwifi-pcie-fix-possible-null-pointer-derefere.patch b/queue-5.4/wifi-iwlwifi-pcie-fix-possible-null-pointer-derefere.patch
new file mode 100644 (file)
index 0000000..bd74a86
--- /dev/null
@@ -0,0 +1,56 @@
+From 03c9841a8fa2d919766d18b4ee1d96ded027f10c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 Apr 2023 21:40:32 +0300
+Subject: wifi: iwlwifi: pcie: fix possible NULL pointer dereference
+
+From: Daniel Gabay <daniel.gabay@intel.com>
+
+[ Upstream commit b655b9a9f8467684cfa8906713d33b71ea8c8f54 ]
+
+It is possible that iwl_pci_probe() will fail and free the trans,
+then afterwards iwl_pci_remove() will be called and crash by trying
+to access trans which is already freed, fix it.
+
+iwlwifi 0000:01:00.0: Detected crf-id 0xa5a5a5a2, cnv-id 0xa5a5a5a2
+                     wfpm id 0xa5a5a5a2
+iwlwifi 0000:01:00.0: Can't find a correct rfid for crf id 0x5a2
+...
+BUG: kernel NULL pointer dereference, address: 0000000000000028
+...
+RIP: 0010:iwl_pci_remove+0x12/0x30 [iwlwifi]
+pci_device_remove+0x3e/0xb0
+device_release_driver_internal+0x103/0x1f0
+driver_detach+0x4c/0x90
+bus_remove_driver+0x5c/0xd0
+driver_unregister+0x31/0x50
+pci_unregister_driver+0x40/0x90
+iwl_pci_unregister_driver+0x15/0x20 [iwlwifi]
+__exit_compat+0x9/0x98 [iwlwifi]
+__x64_sys_delete_module+0x147/0x260
+
+Signed-off-by: Daniel Gabay <daniel.gabay@intel.com>
+Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
+Link: https://lore.kernel.org/r/20230413213309.082f6e21341b.I0db21d7fa9a828d571ca886713bd0b5d0b6e1e5c@changeid
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+index f34297fd453c0..5153314e85554 100644
+--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
++++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+@@ -1173,6 +1173,9 @@ static void iwl_pci_remove(struct pci_dev *pdev)
+ {
+       struct iwl_trans *trans = pci_get_drvdata(pdev);
++      if (!trans)
++              return;
++
+       iwl_drv_stop(trans->drv);
+       iwl_trans_pcie_free(trans);
+-- 
+2.39.2
+