]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Tue, 19 Sep 2023 17:29:06 +0000 (13:29 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 19 Sep 2023 17:29:06 +0000 (13:29 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
47 files changed:
queue-5.4/acpi-video-add-backlight-native-dmi-quirk-for-lenovo.patch [new file with mode: 0644]
queue-5.4/acpica-add-aml_no_operand_resolve-flag-to-timer.patch [new file with mode: 0644]
queue-5.4/alx-fix-oob-read-compiler-warning.patch [new file with mode: 0644]
queue-5.4/autofs-fix-memory-leak-of-waitqueues-in-autofs_catat.patch [new file with mode: 0644]
queue-5.4/btrfs-add-a-helper-to-read-the-superblock-metadata_u.patch [new file with mode: 0644]
queue-5.4/btrfs-compare-the-correct-fsid-metadata_uuid-in-btrf.patch [new file with mode: 0644]
queue-5.4/btrfs-move-btrfs_pinned_by_swapfile-prototype-into-v.patch [new file with mode: 0644]
queue-5.4/btrfs-output-extra-debug-info-if-we-failed-to-find-a.patch [new file with mode: 0644]
queue-5.4/bus-ti-sysc-configure-uart-quirks-for-k3-soc.patch [new file with mode: 0644]
queue-5.4/crypto-lib-mpi-avoid-null-pointer-deref-in-mpi_cmp_u.patch [new file with mode: 0644]
queue-5.4/devlink-remove-reload-failed-checks-in-params-get-se.patch [new file with mode: 0644]
queue-5.4/drm-exynos-fix-a-possible-null-pointer-dereference-d.patch [new file with mode: 0644]
queue-5.4/ext2-fix-datatype-of-block-number-in-ext2_xattr_set2.patch [new file with mode: 0644]
queue-5.4/fs-jfs-prevent-double-free-in-dbunmount-after-failed.patch [new file with mode: 0644]
queue-5.4/hw_breakpoint-fix-single-stepping-when-using-bpf_ove.patch [new file with mode: 0644]
queue-5.4/jfs-fix-invalid-free-of-jfs_ip-ipimap-i_imap-in-diun.patch [new file with mode: 0644]
queue-5.4/kernel-fork-beware-of-__put_task_struct-calling-cont.patch [new file with mode: 0644]
queue-5.4/kobject-add-sanity-check-for-kset-kobj.ktype-in-kset.patch [new file with mode: 0644]
queue-5.4/libbpf-free-btf_vmlinux-when-closing-bpf_object.patch [new file with mode: 0644]
queue-5.4/locks-fix-kasan-use-after-free-in-trace_event_raw_ev.patch [new file with mode: 0644]
queue-5.4/md-raid1-fix-error-iso-c90-forbids-mixed-declaration.patch [new file with mode: 0644]
queue-5.4/md-raid1-fix-potential-oob-in-raid1_remove_disk.patch [new file with mode: 0644]
queue-5.4/media-af9005-fix-null-ptr-deref-in-af9005_i2c_xfer.patch [new file with mode: 0644]
queue-5.4/media-anysee-fix-null-ptr-deref-in-anysee_master_xfe.patch [new file with mode: 0644]
queue-5.4/media-az6007-fix-null-ptr-deref-in-az6007_i2c_xfer.patch [new file with mode: 0644]
queue-5.4/media-dvb-usb-v2-af9035-fix-null-ptr-deref-in-af9035.patch [new file with mode: 0644]
queue-5.4/media-dw2102-fix-null-ptr-deref-in-dw2102_i2c_transf.patch [new file with mode: 0644]
queue-5.4/media-pci-cx23885-replace-bug-with-error-return.patch [new file with mode: 0644]
queue-5.4/media-pci-ipu3-cio2-initialise-timing-struct-to-avoi.patch [new file with mode: 0644]
queue-5.4/media-tuners-qt1010-replace-bug_on-with-a-regular-er.patch [new file with mode: 0644]
queue-5.4/mmc-sdhci-esdhc-imx-improve-esdhc_flag_err010450.patch [new file with mode: 0644]
queue-5.4/perf-build-update-build-rule-for-generated-files.patch [new file with mode: 0644]
queue-5.4/perf-jevents-make-build-dependency-on-test-jsons.patch [new file with mode: 0644]
queue-5.4/perf-jevents-switch-build-to-use-jevents.py.patch [new file with mode: 0644]
queue-5.4/perf-smmuv3-enable-hisilicon-erratum-162001900-quirk.patch [new file with mode: 0644]
queue-5.4/perf-tools-add-an-option-to-build-without-libbfd.patch [new file with mode: 0644]
queue-5.4/powerpc-pseries-fix-possible-memory-leak-in-ibmebus_.patch [new file with mode: 0644]
queue-5.4/scsi-target-iscsi-fix-buffer-overflow-in-lio_target_.patch [new file with mode: 0644]
queue-5.4/selftests-tracing-fix-to-unmount-tracefs-for-recover.patch [new file with mode: 0644]
queue-5.4/serial-cpm_uart-avoid-suspicious-locking.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/tools-features-add-feature-test-to-check-if-libbfd-h.patch [new file with mode: 0644]
queue-5.4/tpm_tis-resend-command-to-recover-from-data-transfer.patch [new file with mode: 0644]
queue-5.4/usb-gadget-fsl_qe_udc-validate-endpoint-index-for-ch.patch [new file with mode: 0644]
queue-5.4/wifi-ath9k-fix-printk-specifier.patch [new file with mode: 0644]
queue-5.4/wifi-mac80211_hwsim-drop-short-frames.patch [new file with mode: 0644]
queue-5.4/wifi-mwifiex-fix-fortify-warning.patch [new file with mode: 0644]

diff --git a/queue-5.4/acpi-video-add-backlight-native-dmi-quirk-for-lenovo.patch b/queue-5.4/acpi-video-add-backlight-native-dmi-quirk-for-lenovo.patch
new file mode 100644 (file)
index 0000000..a2f7637
--- /dev/null
@@ -0,0 +1,47 @@
+From 8dfc2e20ff8218a3dd397dce256a4ee94abceb33 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 18 Apr 2023 08:42:00 +0200
+Subject: ACPI: video: Add backlight=native DMI quirk for Lenovo Ideapad Z470
+
+From: Jiri Slaby (SUSE) <jirislaby@kernel.org>
+
+[ Upstream commit 96b709be183c56293933ef45b8b75f8af268c6de ]
+
+The Lenovo Ideapad Z470 predates Windows 8, so it defaults to using
+acpi_video for backlight control. But this is not functional on this
+model.
+
+Add a DMI quirk to use the native backlight interface which works.
+
+Link: https://bugzilla.suse.com/show_bug.cgi?id=1208724
+Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
+Reviewed-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/video_detect.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
+index ef40cd7f36eba..be9c70806b620 100644
+--- a/drivers/acpi/video_detect.c
++++ b/drivers/acpi/video_detect.c
+@@ -310,6 +310,15 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
+               DMI_MATCH(DMI_BOARD_NAME, "Lenovo IdeaPad S405"),
+               },
+       },
++      {
++       /* https://bugzilla.suse.com/show_bug.cgi?id=1208724 */
++       .callback = video_detect_force_native,
++       /* Lenovo Ideapad Z470 */
++       .matches = {
++              DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++              DMI_MATCH(DMI_PRODUCT_VERSION, "IdeaPad Z470"),
++              },
++      },
+       {
+        /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
+        .callback = video_detect_force_native,
+-- 
+2.40.1
+
diff --git a/queue-5.4/acpica-add-aml_no_operand_resolve-flag-to-timer.patch b/queue-5.4/acpica-add-aml_no_operand_resolve-flag-to-timer.patch
new file mode 100644 (file)
index 0000000..69f67d7
--- /dev/null
@@ -0,0 +1,60 @@
+From da5de697f81bf3f62a39480dfceb711996509f6b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 26 Jun 2023 22:26:06 +0000
+Subject: ACPICA: Add AML_NO_OPERAND_RESOLVE flag to Timer
+
+From: Abhishek Mainkar <abmainkar@nvidia.com>
+
+[ Upstream commit 3a21ffdbc825e0919db9da0e27ee5ff2cc8a863e ]
+
+ACPICA commit 90310989a0790032f5a0140741ff09b545af4bc5
+
+According to the ACPI specification 19.6.134, no argument is required to be passed for ASL Timer instruction. For taking care of no argument, AML_NO_OPERAND_RESOLVE flag is added to ASL Timer instruction opcode.
+
+When ASL timer instruction interpreted by ACPI interpreter, getting error. After adding AML_NO_OPERAND_RESOLVE flag to ASL Timer instruction opcode, issue is not observed.
+
+=============================================================
+UBSAN: array-index-out-of-bounds in acpica/dswexec.c:401:12 index -1 is out of range for type 'union acpi_operand_object *[9]'
+CPU: 37 PID: 1678 Comm: cat Not tainted
+6.0.0-dev-th500-6.0.y-1+bcf8c46459e407-generic-64k
+HW name: NVIDIA BIOS v1.1.1-d7acbfc-dirty 12/19/2022 Call trace:
+ dump_backtrace+0xe0/0x130
+ show_stack+0x20/0x60
+ dump_stack_lvl+0x68/0x84
+ dump_stack+0x18/0x34
+ ubsan_epilogue+0x10/0x50
+ __ubsan_handle_out_of_bounds+0x80/0x90
+ acpi_ds_exec_end_op+0x1bc/0x6d8
+ acpi_ps_parse_loop+0x57c/0x618
+ acpi_ps_parse_aml+0x1e0/0x4b4
+ acpi_ps_execute_method+0x24c/0x2b8
+ acpi_ns_evaluate+0x3a8/0x4bc
+ acpi_evaluate_object+0x15c/0x37c
+ acpi_evaluate_integer+0x54/0x15c
+ show_power+0x8c/0x12c [acpi_power_meter]
+
+Link: https://github.com/acpica/acpica/commit/90310989
+Signed-off-by: Abhishek Mainkar <abmainkar@nvidia.com>
+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/psopcode.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
+index 43775c5ce17c5..2f9b226ec4f63 100644
+--- a/drivers/acpi/acpica/psopcode.c
++++ b/drivers/acpi/acpica/psopcode.c
+@@ -603,7 +603,7 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
+ /* 7E */ ACPI_OP("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY,
+                        AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R,
+-                       AML_FLAGS_EXEC_0A_0T_1R),
++                       AML_FLAGS_EXEC_0A_0T_1R | AML_NO_OPERAND_RESOLVE),
+ /* ACPI 5.0 opcodes */
+-- 
+2.40.1
+
diff --git a/queue-5.4/alx-fix-oob-read-compiler-warning.patch b/queue-5.4/alx-fix-oob-read-compiler-warning.patch
new file mode 100644 (file)
index 0000000..d481844
--- /dev/null
@@ -0,0 +1,54 @@
+From 5656e68954e9b6b4c48b0bf3ecc62e13207650f9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 21 Aug 2023 09:32:18 +0800
+Subject: alx: fix OOB-read compiler warning
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: GONG, Ruiqi <gongruiqi1@huawei.com>
+
+[ Upstream commit 3a198c95c95da10ad844cbeade2fe40bdf14c411 ]
+
+The following message shows up when compiling with W=1:
+
+In function ‘fortify_memcpy_chk’,
+    inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2:
+./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’
+declared with attribute warning: detected read beyond size of field (2nd parameter);
+maybe use struct_group()? [-Werror=attribute-warning]
+  592 |    __read_overflow2_field(q_size_field, size);
+      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In order to get alx stats altogether, alx_get_ethtool_stats() reads
+beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats,
+and refactor the unnecessarily complicated BUILD_BUG_ON btw.
+
+Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
+Reviewed-by: Simon Horman <horms@kernel.org>
+Link: https://lore.kernel.org/r/20230821013218.1614265-1-gongruiqi@huaweicloud.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/atheros/alx/ethtool.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/ethernet/atheros/alx/ethtool.c b/drivers/net/ethernet/atheros/alx/ethtool.c
+index 2f4eabf652e80..51e5aa2c74b34 100644
+--- a/drivers/net/ethernet/atheros/alx/ethtool.c
++++ b/drivers/net/ethernet/atheros/alx/ethtool.c
+@@ -281,9 +281,8 @@ static void alx_get_ethtool_stats(struct net_device *netdev,
+       spin_lock(&alx->stats_lock);
+       alx_update_hw_stats(hw);
+-      BUILD_BUG_ON(sizeof(hw->stats) - offsetof(struct alx_hw_stats, rx_ok) <
+-                   ALX_NUM_STATS * sizeof(u64));
+-      memcpy(data, &hw->stats.rx_ok, ALX_NUM_STATS * sizeof(u64));
++      BUILD_BUG_ON(sizeof(hw->stats) != ALX_NUM_STATS * sizeof(u64));
++      memcpy(data, &hw->stats, sizeof(hw->stats));
+       spin_unlock(&alx->stats_lock);
+ }
+-- 
+2.40.1
+
diff --git a/queue-5.4/autofs-fix-memory-leak-of-waitqueues-in-autofs_catat.patch b/queue-5.4/autofs-fix-memory-leak-of-waitqueues-in-autofs_catat.patch
new file mode 100644 (file)
index 0000000..cf0e3c0
--- /dev/null
@@ -0,0 +1,106 @@
+From ccfc334a68e311dac24c1c93010064c20819f5d9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 4 Aug 2023 13:33:12 +0800
+Subject: autofs: fix memory leak of waitqueues in autofs_catatonic_mode
+
+From: Fedor Pchelkin <pchelkin@ispras.ru>
+
+[ Upstream commit ccbe77f7e45dfb4420f7f531b650c00c6e9c7507 ]
+
+Syzkaller reports a memory leak:
+
+BUG: memory leak
+unreferenced object 0xffff88810b279e00 (size 96):
+  comm "syz-executor399", pid 3631, jiffies 4294964921 (age 23.870s)
+  hex dump (first 32 bytes):
+    00 00 00 00 00 00 00 00 08 9e 27 0b 81 88 ff ff  ..........'.....
+    08 9e 27 0b 81 88 ff ff 00 00 00 00 00 00 00 00  ..'.............
+  backtrace:
+    [<ffffffff814cfc90>] kmalloc_trace+0x20/0x90 mm/slab_common.c:1046
+    [<ffffffff81bb75ca>] kmalloc include/linux/slab.h:576 [inline]
+    [<ffffffff81bb75ca>] autofs_wait+0x3fa/0x9a0 fs/autofs/waitq.c:378
+    [<ffffffff81bb88a7>] autofs_do_expire_multi+0xa7/0x3e0 fs/autofs/expire.c:593
+    [<ffffffff81bb8c33>] autofs_expire_multi+0x53/0x80 fs/autofs/expire.c:619
+    [<ffffffff81bb6972>] autofs_root_ioctl_unlocked+0x322/0x3b0 fs/autofs/root.c:897
+    [<ffffffff81bb6a95>] autofs_root_ioctl+0x25/0x30 fs/autofs/root.c:910
+    [<ffffffff81602a9c>] vfs_ioctl fs/ioctl.c:51 [inline]
+    [<ffffffff81602a9c>] __do_sys_ioctl fs/ioctl.c:870 [inline]
+    [<ffffffff81602a9c>] __se_sys_ioctl fs/ioctl.c:856 [inline]
+    [<ffffffff81602a9c>] __x64_sys_ioctl+0xfc/0x140 fs/ioctl.c:856
+    [<ffffffff84608225>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+    [<ffffffff84608225>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
+    [<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+autofs_wait_queue structs should be freed if their wait_ctr becomes zero.
+Otherwise they will be lost.
+
+In this case an AUTOFS_IOC_EXPIRE_MULTI ioctl is done, then a new
+waitqueue struct is allocated in autofs_wait(), its initial wait_ctr
+equals 2. After that wait_event_killable() is interrupted (it returns
+-ERESTARTSYS), so that 'wq->name.name == NULL' condition may be not
+satisfied. Actually, this condition can be satisfied when
+autofs_wait_release() or autofs_catatonic_mode() is called and, what is
+also important, wait_ctr is decremented in those places. Upon the exit of
+autofs_wait(), wait_ctr is decremented to 1. Then the unmounting process
+begins: kill_sb calls autofs_catatonic_mode(), which should have freed the
+waitqueues, but it only decrements its usage counter to zero which is not
+a correct behaviour.
+
+edit:imk
+This description is of course not correct. The umount performed as a result
+of an expire is a umount of a mount that has been automounted, it's not the
+autofs mount itself. They happen independently, usually after everything
+mounted within the autofs file system has been expired away. If everything
+hasn't been expired away the automount daemon can still exit leaving mounts
+in place. But expires done in both cases will result in a notification that
+calls autofs_wait_release() with a result status. The problem case is the
+summary execution of of the automount daemon. In this case any waiting
+processes won't be woken up until either they are terminated or the mount
+is umounted.
+end edit: imk
+
+So in catatonic mode we should free waitqueues which counter becomes zero.
+
+edit: imk
+Initially I was concerned that the calling of autofs_wait_release() and
+autofs_catatonic_mode() was not mutually exclusive but that can't be the
+case (obviously) because the queue entry (or entries) is removed from the
+list when either of these two functions are called. Consequently the wait
+entry will be freed by only one of these functions or by the woken process
+in autofs_wait() depending on the order of the calls.
+end edit: imk
+
+Reported-by: syzbot+5e53f70e69ff0c0a1c0c@syzkaller.appspotmail.com
+Suggested-by: Takeshi Misawa <jeliantsurux@gmail.com>
+Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
+Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
+Signed-off-by: Ian Kent <raven@themaw.net>
+Cc: Matthew Wilcox <willy@infradead.org>
+Cc: Andrei Vagin <avagin@gmail.com>
+Cc: autofs@vger.kernel.org
+Cc: linux-kernel@vger.kernel.org
+Message-Id: <169112719161.7590.6700123246297365841.stgit@donald.themaw.net>
+Signed-off-by: Christian Brauner <brauner@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/autofs/waitq.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c
+index b04c528b19d34..1230bdf329898 100644
+--- a/fs/autofs/waitq.c
++++ b/fs/autofs/waitq.c
+@@ -32,8 +32,9 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi)
+               wq->status = -ENOENT; /* Magic is gone - report failure */
+               kfree(wq->name.name);
+               wq->name.name = NULL;
+-              wq->wait_ctr--;
+               wake_up_interruptible(&wq->queue);
++              if (!--wq->wait_ctr)
++                      kfree(wq);
+               wq = nwq;
+       }
+       fput(sbi->pipe);        /* Close the pipe */
+-- 
+2.40.1
+
diff --git a/queue-5.4/btrfs-add-a-helper-to-read-the-superblock-metadata_u.patch b/queue-5.4/btrfs-add-a-helper-to-read-the-superblock-metadata_u.patch
new file mode 100644 (file)
index 0000000..f279ecc
--- /dev/null
@@ -0,0 +1,58 @@
+From d0ab1ea6d4131b35e1164afc1b4315627320ed1e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 31 Jul 2023 19:16:32 +0800
+Subject: btrfs: add a helper to read the superblock metadata_uuid
+
+From: Anand Jain <anand.jain@oracle.com>
+
+[ Upstream commit 4844c3664a72d36cc79752cb651c78860b14c240 ]
+
+In some cases, we need to read the FSID from the superblock when the
+metadata_uuid is not set, and otherwise, read the metadata_uuid. So,
+add a helper.
+
+Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
+Signed-off-by: Anand Jain <anand.jain@oracle.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Stable-dep-of: 6bfe3959b0e7 ("btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/volumes.c | 8 ++++++++
+ fs/btrfs/volumes.h | 1 +
+ 2 files changed, 9 insertions(+)
+
+diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
+index 0d4afeacb237b..f9192dcb9208b 100644
+--- a/fs/btrfs/volumes.c
++++ b/fs/btrfs/volumes.c
+@@ -895,6 +895,14 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
+       return -EINVAL;
+ }
++u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb)
++{
++      bool has_metadata_uuid = (btrfs_super_incompat_flags(sb) &
++                                BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
++
++      return has_metadata_uuid ? sb->metadata_uuid : sb->fsid;
++}
++
+ /*
+  * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices
+  * being created with a disk that has already completed its fsid change.
+diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
+index fd8fdaa4b0cdf..762c0a3754982 100644
+--- a/fs/btrfs/volumes.h
++++ b/fs/btrfs/volumes.h
+@@ -582,5 +582,6 @@ const char *btrfs_bg_type_to_raid_name(u64 flags);
+ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
+ bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
++u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb);
+ #endif
+-- 
+2.40.1
+
diff --git a/queue-5.4/btrfs-compare-the-correct-fsid-metadata_uuid-in-btrf.patch b/queue-5.4/btrfs-compare-the-correct-fsid-metadata_uuid-in-btrf.patch
new file mode 100644 (file)
index 0000000..acc5b20
--- /dev/null
@@ -0,0 +1,66 @@
+From ef41435cde096a038e2cc5d66c84abd6567ad21a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 31 Jul 2023 19:16:35 +0800
+Subject: btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super
+
+From: Anand Jain <anand.jain@oracle.com>
+
+[ Upstream commit 6bfe3959b0e7a526f5c64747801a8613f002f05a ]
+
+The function btrfs_validate_super() should verify the metadata_uuid in
+the provided superblock argument. Because, all its callers expect it to
+do that.
+
+Such as in the following stacks:
+
+  write_all_supers()
+   sb = fs_info->super_for_commit;
+   btrfs_validate_write_super(.., sb)
+     btrfs_validate_super(.., sb, ..)
+
+  scrub_one_super()
+       btrfs_validate_super(.., sb, ..)
+
+And
+   check_dev_super()
+       btrfs_validate_super(.., sb, ..)
+
+However, it currently verifies the fs_info::super_copy::metadata_uuid
+instead.  Fix this using the correct metadata_uuid in the superblock
+argument.
+
+CC: stable@vger.kernel.org # 5.4+
+Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
+Signed-off-by: Anand Jain <anand.jain@oracle.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/disk-io.c | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
+index a02fa6c07087c..b4ed11b5f1480 100644
+--- a/fs/btrfs/disk-io.c
++++ b/fs/btrfs/disk-io.c
+@@ -2487,13 +2487,11 @@ static int validate_super(struct btrfs_fs_info *fs_info,
+               ret = -EINVAL;
+       }
+-      if (btrfs_fs_incompat(fs_info, METADATA_UUID) &&
+-          memcmp(fs_info->fs_devices->metadata_uuid,
+-                 fs_info->super_copy->metadata_uuid, BTRFS_FSID_SIZE)) {
++      if (memcmp(fs_info->fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(sb),
++                 BTRFS_FSID_SIZE) != 0) {
+               btrfs_err(fs_info,
+ "superblock metadata_uuid doesn't match metadata uuid of fs_devices: %pU != %pU",
+-                      fs_info->super_copy->metadata_uuid,
+-                      fs_info->fs_devices->metadata_uuid);
++                        btrfs_sb_fsid_ptr(sb), fs_info->fs_devices->metadata_uuid);
+               ret = -EINVAL;
+       }
+-- 
+2.40.1
+
diff --git a/queue-5.4/btrfs-move-btrfs_pinned_by_swapfile-prototype-into-v.patch b/queue-5.4/btrfs-move-btrfs_pinned_by_swapfile-prototype-into-v.patch
new file mode 100644 (file)
index 0000000..b5ae2dc
--- /dev/null
@@ -0,0 +1,50 @@
+From 637a2239a117fd1fd41e44c2be9af903a92c72f9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 14 Sep 2022 19:04:40 -0400
+Subject: btrfs: move btrfs_pinned_by_swapfile prototype into volumes.h
+
+From: Josef Bacik <josef@toxicpanda.com>
+
+[ Upstream commit c2e79e865b87c2920a3cd39de69c35f2bc758a51 ]
+
+This is defined in volumes.c, move the prototype into volumes.h.
+
+Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Reviewed-by: Anand Jain <anand.jain@oracle.com>
+Signed-off-by: Josef Bacik <josef@toxicpanda.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Stable-dep-of: 6bfe3959b0e7 ("btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/ctree.h   | 2 --
+ fs/btrfs/volumes.h | 2 ++
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
+index c2e5fe972f566..b141a7ba4507b 100644
+--- a/fs/btrfs/ctree.h
++++ b/fs/btrfs/ctree.h
+@@ -482,8 +482,6 @@ struct btrfs_swapfile_pin {
+       bool is_block_group;
+ };
+-bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
+-
+ enum {
+       BTRFS_FS_BARRIER,
+       BTRFS_FS_CLOSING_START,
+diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
+index aa6a6d7b2978e..fd8fdaa4b0cdf 100644
+--- a/fs/btrfs/volumes.h
++++ b/fs/btrfs/volumes.h
+@@ -581,4 +581,6 @@ int btrfs_bg_type_to_factor(u64 flags);
+ const char *btrfs_bg_type_to_raid_name(u64 flags);
+ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
++bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
++
+ #endif
+-- 
+2.40.1
+
diff --git a/queue-5.4/btrfs-output-extra-debug-info-if-we-failed-to-find-a.patch b/queue-5.4/btrfs-output-extra-debug-info-if-we-failed-to-find-a.patch
new file mode 100644 (file)
index 0000000..d5ad166
--- /dev/null
@@ -0,0 +1,52 @@
+From e15fa44b6e77a903a01a99eda03f1b58ae4138aa Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 1 Aug 2023 19:02:28 +0800
+Subject: btrfs: output extra debug info if we failed to find an inline backref
+
+From: Qu Wenruo <wqu@suse.com>
+
+[ Upstream commit 7f72f50547b7af4ddf985b07fc56600a4deba281 ]
+
+[BUG]
+Syzbot reported several warning triggered inside
+lookup_inline_extent_backref().
+
+[CAUSE]
+As usual, the reproducer doesn't reliably trigger locally here, but at
+least we know the WARN_ON() is triggered when an inline backref can not
+be found, and it can only be triggered when @insert is true. (I.e.
+inserting a new inline backref, which means the backref should already
+exist)
+
+[ENHANCEMENT]
+After the WARN_ON(), dump all the parameters and the extent tree
+leaf to help debug.
+
+Link: https://syzkaller.appspot.com/bug?extid=d6f9ff86c1d804ba2bc6
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/btrfs/extent-tree.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index e47f53e780890..a9191a0d2f4c9 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -895,6 +895,11 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
+               err = -ENOENT;
+               goto out;
+       } else if (WARN_ON(ret)) {
++              btrfs_print_leaf(path->nodes[0]);
++              btrfs_err(fs_info,
++"extent item not found for insert, bytenr %llu num_bytes %llu parent %llu root_objectid %llu owner %llu offset %llu",
++                        bytenr, num_bytes, parent, root_objectid, owner,
++                        offset);
+               err = -EIO;
+               goto out;
+       }
+-- 
+2.40.1
+
diff --git a/queue-5.4/bus-ti-sysc-configure-uart-quirks-for-k3-soc.patch b/queue-5.4/bus-ti-sysc-configure-uart-quirks-for-k3-soc.patch
new file mode 100644 (file)
index 0000000..7db2b74
--- /dev/null
@@ -0,0 +1,39 @@
+From 60291f063b4b87877373a9f614330ece1f473843 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 4 Aug 2023 13:38:01 +0300
+Subject: bus: ti-sysc: Configure uart quirks for k3 SoC
+
+From: Tony Lindgren <tony@atomide.com>
+
+[ Upstream commit 03a711d3cb83692733f865312f49e665c49de6de ]
+
+Enable the uart quirks similar to the earlier SoCs. Let's assume we are
+likely going to need a k3 specific quirk mask separate from the earlier
+SoCs, so let's not start changing the revision register mask at this point.
+
+Note that SYSC_QUIRK_LEGACY_IDLE will be needed until we can remove the
+need for pm_runtime_irq_safe() from 8250_omap driver.
+
+Reviewed-by: Nishanth Menon <nm@ti.com>
+Signed-off-by: Tony Lindgren <tony@atomide.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/bus/ti-sysc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
+index e1a9838c96655..b542c2b2aef49 100644
+--- a/drivers/bus/ti-sysc.c
++++ b/drivers/bus/ti-sysc.c
+@@ -1379,6 +1379,8 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
+                  SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
+       SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff,
+                  SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
++      SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47424e03, 0xffffffff,
++                 SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
+       /* Quirks that need to be set based on the module address */
+       SYSC_QUIRK("mcpdm", 0x40132000, 0, 0x10, -ENODEV, 0x50000800, 0xffffffff,
+-- 
+2.40.1
+
diff --git a/queue-5.4/crypto-lib-mpi-avoid-null-pointer-deref-in-mpi_cmp_u.patch b/queue-5.4/crypto-lib-mpi-avoid-null-pointer-deref-in-mpi_cmp_u.patch
new file mode 100644 (file)
index 0000000..2018c16
--- /dev/null
@@ -0,0 +1,45 @@
+From b3753fbdfe5a034ca0465d5d9715ce7d4f651b18 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 4 Aug 2023 09:32:18 +0000
+Subject: crypto: lib/mpi - avoid null pointer deref in mpi_cmp_ui()
+
+From: Mark O'Donovan <shiftee@posteo.net>
+
+[ Upstream commit 9e47a758b70167c9301d2b44d2569f86c7796f2d ]
+
+During NVMeTCP Authentication a controller can trigger a kernel
+oops by specifying the 8192 bit Diffie Hellman group and passing
+a correctly sized, but zeroed Diffie Hellamn value.
+mpi_cmp_ui() was detecting this if the second parameter was 0,
+but 1 is passed from dh_is_pubkey_valid(). This causes the null
+pointer u->d to be dereferenced towards the end of mpi_cmp_ui()
+
+Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ lib/mpi/mpi-cmp.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/lib/mpi/mpi-cmp.c b/lib/mpi/mpi-cmp.c
+index d25e9e96c310f..ceaebe181cd70 100644
+--- a/lib/mpi/mpi-cmp.c
++++ b/lib/mpi/mpi-cmp.c
+@@ -25,8 +25,12 @@ int mpi_cmp_ui(MPI u, unsigned long v)
+       mpi_limb_t limb = v;
+       mpi_normalize(u);
+-      if (!u->nlimbs && !limb)
+-              return 0;
++      if (u->nlimbs == 0) {
++              if (v == 0)
++                      return 0;
++              else
++                      return -1;
++      }
+       if (u->sign)
+               return -1;
+       if (u->nlimbs > 1)
+-- 
+2.40.1
+
diff --git a/queue-5.4/devlink-remove-reload-failed-checks-in-params-get-se.patch b/queue-5.4/devlink-remove-reload-failed-checks-in-params-get-se.patch
new file mode 100644 (file)
index 0000000..c1c5032
--- /dev/null
@@ -0,0 +1,68 @@
+From 270b8758da3b80034b8108aa07a353cc0647cff5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 13 Jul 2023 11:44:19 +0200
+Subject: devlink: remove reload failed checks in params get/set callbacks
+
+From: Jiri Pirko <jiri@nvidia.com>
+
+[ Upstream commit 633d76ad01ad0321a1ace3e5cc4fed06753d7ac4 ]
+
+The checks in question were introduced by:
+commit 6b4db2e528f6 ("devlink: Fix use-after-free after a failed reload").
+That fixed an issue of reload with mlxsw driver.
+
+Back then, that was a valid fix, because there was a limitation
+in place that prevented drivers from registering/unregistering params
+when devlink instance was registered.
+
+It was possible to do the fix differently by changing drivers to
+register/unregister params in appropriate places making sure the ops
+operate only on memory which is allocated and initialized. But that,
+as a dependency, would require to remove the limitation mentioned above.
+
+Eventually, this limitation was lifted by:
+commit 1d18bb1a4ddd ("devlink: allow registering parameters after the instance")
+
+Also, the alternative fix (which also fixed another issue) was done by:
+commit 74cbc3c03c82 ("mlxsw: spectrum_acl_tcam: Move devlink param to TCAM code").
+
+Therefore, the checks are no longer relevant. Each driver should make
+sure to have the params registered only when the memory the ops
+are working with is allocated and initialized.
+
+So remove the checks.
+
+Signed-off-by: Jiri Pirko <jiri@nvidia.com>
+Reviewed-by: Ido Schimmel <idosch@nvidia.com>
+Reviewed-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/devlink.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/net/core/devlink.c b/net/core/devlink.c
+index b4dabe5d89f72..5bd6330ab4275 100644
+--- a/net/core/devlink.c
++++ b/net/core/devlink.c
+@@ -2953,7 +2953,7 @@ static int devlink_param_get(struct devlink *devlink,
+                            const struct devlink_param *param,
+                            struct devlink_param_gset_ctx *ctx)
+ {
+-      if (!param->get || devlink->reload_failed)
++      if (!param->get)
+               return -EOPNOTSUPP;
+       return param->get(devlink, param->id, ctx);
+ }
+@@ -2962,7 +2962,7 @@ static int devlink_param_set(struct devlink *devlink,
+                            const struct devlink_param *param,
+                            struct devlink_param_gset_ctx *ctx)
+ {
+-      if (!param->set || devlink->reload_failed)
++      if (!param->set)
+               return -EOPNOTSUPP;
+       return param->set(devlink, param->id, ctx);
+ }
+-- 
+2.40.1
+
diff --git a/queue-5.4/drm-exynos-fix-a-possible-null-pointer-dereference-d.patch b/queue-5.4/drm-exynos-fix-a-possible-null-pointer-dereference-d.patch
new file mode 100644 (file)
index 0000000..06d96ca
--- /dev/null
@@ -0,0 +1,61 @@
+From 723978f00ac6f498ec77b3481789d0a602ac70ae Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 30 Jun 2023 10:19:06 +0800
+Subject: drm/exynos: fix a possible null-pointer dereference due to data race
+ in exynos_drm_crtc_atomic_disable()
+
+From: Tuo Li <islituo@gmail.com>
+
+[ Upstream commit 2e63972a2de14482d0eae1a03a73e379f1c3f44c ]
+
+The variable crtc->state->event is often protected by the lock
+crtc->dev->event_lock when is accessed. However, it is accessed as a
+condition of an if statement in exynos_drm_crtc_atomic_disable() without
+holding the lock:
+
+  if (crtc->state->event && !crtc->state->active)
+
+However, if crtc->state->event is changed to NULL by another thread right
+after the conditions of the if statement is checked to be true, a
+null-pointer dereference can occur in drm_crtc_send_vblank_event():
+
+  e->pipe = pipe;
+
+To fix this possible null-pointer dereference caused by data race, the
+spin lock coverage is extended to protect the if statement as well as the
+function call to drm_crtc_send_vblank_event().
+
+Reported-by: BassCheck <bass@buaa.edu.cn>
+Link: https://sites.google.com/view/basscheck/home
+Signed-off-by: Tuo Li <islituo@gmail.com>
+Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Added relevant link.
+Signed-off-by: Inki Dae <inki.dae@samsung.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/exynos/exynos_drm_crtc.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+index 77ce78986408b..c10eea6db9a80 100644
+--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
++++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+@@ -39,13 +39,12 @@ static void exynos_drm_crtc_atomic_disable(struct drm_crtc *crtc,
+       if (exynos_crtc->ops->disable)
+               exynos_crtc->ops->disable(exynos_crtc);
++      spin_lock_irq(&crtc->dev->event_lock);
+       if (crtc->state->event && !crtc->state->active) {
+-              spin_lock_irq(&crtc->dev->event_lock);
+               drm_crtc_send_vblank_event(crtc, crtc->state->event);
+-              spin_unlock_irq(&crtc->dev->event_lock);
+-
+               crtc->state->event = NULL;
+       }
++      spin_unlock_irq(&crtc->dev->event_lock);
+ }
+ static int exynos_crtc_atomic_check(struct drm_crtc *crtc,
+-- 
+2.40.1
+
diff --git a/queue-5.4/ext2-fix-datatype-of-block-number-in-ext2_xattr_set2.patch b/queue-5.4/ext2-fix-datatype-of-block-number-in-ext2_xattr_set2.patch
new file mode 100644 (file)
index 0000000..8c2925a
--- /dev/null
@@ -0,0 +1,55 @@
+From 02d2615d0711638192900ba5d7142b5c41708fc0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Aug 2023 12:03:40 +0200
+Subject: ext2: fix datatype of block number in ext2_xattr_set2()
+
+From: Georg Ottinger <g.ottinger@gmx.at>
+
+[ Upstream commit e88076348425b7d0491c8c98d8732a7df8de7aa3 ]
+
+I run a small server that uses external hard drives for backups. The
+backup software I use uses ext2 filesystems with 4KiB block size and
+the server is running SELinux and therefore relies on xattr. I recently
+upgraded the hard drives from 4TB to 12TB models. I noticed that after
+transferring some TBs I got a filesystem error "Freeing blocks not in
+datazone - block = 18446744071529317386, count = 1" and the backup
+process stopped. Trying to fix the fs with e2fsck resulted in a
+completely corrupted fs. The error probably came from ext2_free_blocks(),
+and because of the large number 18e19 this problem immediately looked
+like some kind of integer overflow. Whereas the 4TB fs was about 1e9
+blocks, the new 12TB is about 3e9 blocks. So, searching the ext2 code,
+I came across the line in fs/ext2/xattr.c:745 where ext2_new_block()
+is called and the resulting block number is stored in the variable block
+as an int datatype. If a block with a block number greater than
+INT32_MAX is returned, this variable overflows and the call to
+sb_getblk() at line fs/ext2/xattr.c:750 fails, then the call to
+ext2_free_blocks() produces the error.
+
+Signed-off-by: Georg Ottinger <g.ottinger@gmx.at>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Message-Id: <20230815100340.22121-1-g.ottinger@gmx.at>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/ext2/xattr.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
+index 62acbe27d8bf4..ca7ff31a1f194 100644
+--- a/fs/ext2/xattr.c
++++ b/fs/ext2/xattr.c
+@@ -690,10 +690,10 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
+                       /* We need to allocate a new block */
+                       ext2_fsblk_t goal = ext2_group_first_block_no(sb,
+                                               EXT2_I(inode)->i_block_group);
+-                      int block = ext2_new_block(inode, goal, &error);
++                      ext2_fsblk_t block = ext2_new_block(inode, goal, &error);
+                       if (error)
+                               goto cleanup;
+-                      ea_idebug(inode, "creating block %d", block);
++                      ea_idebug(inode, "creating block %lu", block);
+                       new_bh = sb_getblk(sb, block);
+                       if (unlikely(!new_bh)) {
+-- 
+2.40.1
+
diff --git a/queue-5.4/fs-jfs-prevent-double-free-in-dbunmount-after-failed.patch b/queue-5.4/fs-jfs-prevent-double-free-in-dbunmount-after-failed.patch
new file mode 100644 (file)
index 0000000..7290a7c
--- /dev/null
@@ -0,0 +1,121 @@
+From 0f57448aa1ca97cf76a35ba81ee33d6a798f698d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 1 Jul 2023 17:05:42 +0300
+Subject: fs/jfs: prevent double-free in dbUnmount() after failed jfs_remount()
+
+From: Andrew Kanner <andrew.kanner@gmail.com>
+
+[ Upstream commit cade5397e5461295f3cb87880534b6a07cafa427 ]
+
+Syzkaller reported the following issue:
+==================================================================
+BUG: KASAN: double-free in slab_free mm/slub.c:3787 [inline]
+BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3800
+Free of addr ffff888086408000 by task syz-executor.4/12750
+[...]
+Call Trace:
+ <TASK>
+[...]
+ kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:482
+ ____kasan_slab_free+0xfb/0x120
+ kasan_slab_free include/linux/kasan.h:177 [inline]
+ slab_free_hook mm/slub.c:1781 [inline]
+ slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807
+ slab_free mm/slub.c:3787 [inline]
+ __kmem_cache_free+0x71/0x110 mm/slub.c:3800
+ dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264
+ jfs_umount+0x248/0x3b0 fs/jfs/jfs_umount.c:87
+ jfs_put_super+0x86/0x190 fs/jfs/super.c:194
+ generic_shutdown_super+0x130/0x310 fs/super.c:492
+ kill_block_super+0x79/0xd0 fs/super.c:1386
+ deactivate_locked_super+0xa7/0xf0 fs/super.c:332
+ cleanup_mnt+0x494/0x520 fs/namespace.c:1291
+ task_work_run+0x243/0x300 kernel/task_work.c:179
+ resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
+ exit_to_user_mode_loop+0x124/0x150 kernel/entry/common.c:171
+ exit_to_user_mode_prepare+0xb2/0x140 kernel/entry/common.c:203
+ __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
+ syscall_exit_to_user_mode+0x26/0x60 kernel/entry/common.c:296
+ do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[...]
+ </TASK>
+
+Allocated by task 13352:
+ kasan_save_stack mm/kasan/common.c:45 [inline]
+ kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
+ ____kasan_kmalloc mm/kasan/common.c:371 [inline]
+ __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:380
+ kmalloc include/linux/slab.h:580 [inline]
+ dbMount+0x54/0x980 fs/jfs/jfs_dmap.c:164
+ jfs_mount+0x1dd/0x830 fs/jfs/jfs_mount.c:121
+ jfs_fill_super+0x590/0xc50 fs/jfs/super.c:556
+ mount_bdev+0x26c/0x3a0 fs/super.c:1359
+ legacy_get_tree+0xea/0x180 fs/fs_context.c:610
+ vfs_get_tree+0x88/0x270 fs/super.c:1489
+ do_new_mount+0x289/0xad0 fs/namespace.c:3145
+ do_mount fs/namespace.c:3488 [inline]
+ __do_sys_mount fs/namespace.c:3697 [inline]
+ __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+Freed by task 13352:
+ kasan_save_stack mm/kasan/common.c:45 [inline]
+ kasan_set_track+0x3d/0x60 mm/kasan/common.c:52
+ kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:518
+ ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
+ kasan_slab_free include/linux/kasan.h:177 [inline]
+ slab_free_hook mm/slub.c:1781 [inline]
+ slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1807
+ slab_free mm/slub.c:3787 [inline]
+ __kmem_cache_free+0x71/0x110 mm/slub.c:3800
+ dbUnmount+0xf4/0x110 fs/jfs/jfs_dmap.c:264
+ jfs_mount_rw+0x545/0x740 fs/jfs/jfs_mount.c:247
+ jfs_remount+0x3db/0x710 fs/jfs/super.c:454
+ reconfigure_super+0x3bc/0x7b0 fs/super.c:935
+ vfs_fsconfig_locked fs/fsopen.c:254 [inline]
+ __do_sys_fsconfig fs/fsopen.c:439 [inline]
+ __se_sys_fsconfig+0xad5/0x1060 fs/fsopen.c:314
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[...]
+
+JFS_SBI(ipbmap->i_sb)->bmap wasn't set to NULL after kfree() in
+dbUnmount().
+
+Syzkaller uses faultinject to reproduce this KASAN double-free
+warning. The issue is triggered if either diMount() or dbMount() fail
+in jfs_remount(), since diUnmount() or dbUnmount() already happened in
+such a case - they will do double-free on next execution: jfs_umount
+or jfs_remount.
+
+Tested on both upstream and jfs-next by syzkaller.
+
+Reported-and-tested-by: syzbot+6a93efb725385bc4b2e9@syzkaller.appspotmail.com
+Closes: https://lore.kernel.org/all/000000000000471f2d05f1ce8bad@google.com/T/
+Link: https://syzkaller.appspot.com/bug?extid=6a93efb725385bc4b2e9
+Signed-off-by: Andrew Kanner <andrew.kanner@gmail.com>
+Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/jfs/jfs_dmap.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
+index 8e8d53241386f..a785c747a8cbb 100644
+--- a/fs/jfs/jfs_dmap.c
++++ b/fs/jfs/jfs_dmap.c
+@@ -269,6 +269,7 @@ int dbUnmount(struct inode *ipbmap, int mounterror)
+       /* free the memory for the in-memory bmap. */
+       kfree(bmp);
++      JFS_SBI(ipbmap->i_sb)->bmap = NULL;
+       return (0);
+ }
+-- 
+2.40.1
+
diff --git a/queue-5.4/hw_breakpoint-fix-single-stepping-when-using-bpf_ove.patch b/queue-5.4/hw_breakpoint-fix-single-stepping-when-using-bpf_ove.patch
new file mode 100644 (file)
index 0000000..260b104
--- /dev/null
@@ -0,0 +1,150 @@
+From 2f4cef417a880f1f7fe290b592b6413555e70655 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 5 Jun 2023 12:19:23 -0700
+Subject: hw_breakpoint: fix single-stepping when using bpf_overflow_handler
+
+From: Tomislav Novak <tnovak@meta.com>
+
+[ Upstream commit d11a69873d9a7435fe6a48531e165ab80a8b1221 ]
+
+Arm platforms use is_default_overflow_handler() to determine if the
+hw_breakpoint code should single-step over the breakpoint trigger or
+let the custom handler deal with it.
+
+Since bpf_overflow_handler() currently isn't recognized as a default
+handler, attaching a BPF program to a PERF_TYPE_BREAKPOINT event causes
+it to keep firing (the instruction triggering the data abort exception
+is never skipped). For example:
+
+  # bpftrace -e 'watchpoint:0x10000:4:w { print("hit") }' -c ./test
+  Attaching 1 probe...
+  hit
+  hit
+  [...]
+  ^C
+
+(./test performs a single 4-byte store to 0x10000)
+
+This patch replaces the check with uses_default_overflow_handler(),
+which accounts for the bpf_overflow_handler() case by also testing
+if one of the perf_event_output functions gets invoked indirectly,
+via orig_default_handler.
+
+Signed-off-by: Tomislav Novak <tnovak@meta.com>
+Tested-by: Samuel Gosselin <sgosselin@google.com> # arm64
+Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
+Acked-by: Alexei Starovoitov <ast@kernel.org>
+Link: https://lore.kernel.org/linux-arm-kernel/20220923203644.2731604-1-tnovak@fb.com/
+Link: https://lore.kernel.org/r/20230605191923.1219974-1-tnovak@meta.com
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/arm/kernel/hw_breakpoint.c   |  8 ++++----
+ arch/arm64/kernel/hw_breakpoint.c |  4 ++--
+ include/linux/perf_event.h        | 22 +++++++++++++++++++---
+ 3 files changed, 25 insertions(+), 9 deletions(-)
+
+diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
+index b06d9ea07c846..a69dd64a84017 100644
+--- a/arch/arm/kernel/hw_breakpoint.c
++++ b/arch/arm/kernel/hw_breakpoint.c
+@@ -623,7 +623,7 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
+       hw->address &= ~alignment_mask;
+       hw->ctrl.len <<= offset;
+-      if (is_default_overflow_handler(bp)) {
++      if (uses_default_overflow_handler(bp)) {
+               /*
+                * Mismatch breakpoints are required for single-stepping
+                * breakpoints.
+@@ -795,7 +795,7 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr,
+                * Otherwise, insert a temporary mismatch breakpoint so that
+                * we can single-step over the watchpoint trigger.
+                */
+-              if (!is_default_overflow_handler(wp))
++              if (!uses_default_overflow_handler(wp))
+                       continue;
+ step:
+               enable_single_step(wp, instruction_pointer(regs));
+@@ -808,7 +808,7 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr,
+               info->trigger = addr;
+               pr_debug("watchpoint fired: address = 0x%x\n", info->trigger);
+               perf_bp_event(wp, regs);
+-              if (is_default_overflow_handler(wp))
++              if (uses_default_overflow_handler(wp))
+                       enable_single_step(wp, instruction_pointer(regs));
+       }
+@@ -883,7 +883,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
+                       info->trigger = addr;
+                       pr_debug("breakpoint fired: address = 0x%x\n", addr);
+                       perf_bp_event(bp, regs);
+-                      if (is_default_overflow_handler(bp))
++                      if (uses_default_overflow_handler(bp))
+                               enable_single_step(bp, addr);
+                       goto unlock;
+               }
+diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
+index b4a1607958246..534578eba556e 100644
+--- a/arch/arm64/kernel/hw_breakpoint.c
++++ b/arch/arm64/kernel/hw_breakpoint.c
+@@ -654,7 +654,7 @@ static int breakpoint_handler(unsigned long unused, unsigned int esr,
+               perf_bp_event(bp, regs);
+               /* Do we need to handle the stepping? */
+-              if (is_default_overflow_handler(bp))
++              if (uses_default_overflow_handler(bp))
+                       step = 1;
+ unlock:
+               rcu_read_unlock();
+@@ -733,7 +733,7 @@ static u64 get_distance_from_watchpoint(unsigned long addr, u64 val,
+ static int watchpoint_report(struct perf_event *wp, unsigned long addr,
+                            struct pt_regs *regs)
+ {
+-      int step = is_default_overflow_handler(wp);
++      int step = uses_default_overflow_handler(wp);
+       struct arch_hw_breakpoint *info = counter_arch_bp(wp);
+       info->trigger = addr;
+diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
+index b7ac395513c0f..c99e2f851d312 100644
+--- a/include/linux/perf_event.h
++++ b/include/linux/perf_event.h
+@@ -1018,15 +1018,31 @@ extern int perf_event_output(struct perf_event *event,
+                            struct pt_regs *regs);
+ static inline bool
+-is_default_overflow_handler(struct perf_event *event)
++__is_default_overflow_handler(perf_overflow_handler_t overflow_handler)
+ {
+-      if (likely(event->overflow_handler == perf_event_output_forward))
++      if (likely(overflow_handler == perf_event_output_forward))
+               return true;
+-      if (unlikely(event->overflow_handler == perf_event_output_backward))
++      if (unlikely(overflow_handler == perf_event_output_backward))
+               return true;
+       return false;
+ }
++#define is_default_overflow_handler(event) \
++      __is_default_overflow_handler((event)->overflow_handler)
++
++#ifdef CONFIG_BPF_SYSCALL
++static inline bool uses_default_overflow_handler(struct perf_event *event)
++{
++      if (likely(is_default_overflow_handler(event)))
++              return true;
++
++      return __is_default_overflow_handler(event->orig_overflow_handler);
++}
++#else
++#define uses_default_overflow_handler(event) \
++      is_default_overflow_handler(event)
++#endif
++
+ extern void
+ perf_event_header__init_id(struct perf_event_header *header,
+                          struct perf_sample_data *data,
+-- 
+2.40.1
+
diff --git a/queue-5.4/jfs-fix-invalid-free-of-jfs_ip-ipimap-i_imap-in-diun.patch b/queue-5.4/jfs-fix-invalid-free-of-jfs_ip-ipimap-i_imap-in-diun.patch
new file mode 100644 (file)
index 0000000..279617c
--- /dev/null
@@ -0,0 +1,77 @@
+From 88295e5aad2876f0cfea3354809d608a4fa735ad Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 1 Dec 2022 20:46:28 +0800
+Subject: jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount
+
+From: Liu Shixin via Jfs-discussion <jfs-discussion@lists.sourceforge.net>
+
+[ Upstream commit 6e2bda2c192d0244b5a78b787ef20aa10cb319b7 ]
+
+syzbot found an invalid-free in diUnmount:
+
+BUG: KASAN: double-free in slab_free mm/slub.c:3661 [inline]
+BUG: KASAN: double-free in __kmem_cache_free+0x71/0x110 mm/slub.c:3674
+Free of addr ffff88806f410000 by task syz-executor131/3632
+
+ CPU: 0 PID: 3632 Comm: syz-executor131 Not tainted 6.1.0-rc7-syzkaller-00012-gca57f02295f1 #0
+ Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
+ Call Trace:
+  <TASK>
+  __dump_stack lib/dump_stack.c:88 [inline]
+  dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
+  print_address_description+0x74/0x340 mm/kasan/report.c:284
+  print_report+0x107/0x1f0 mm/kasan/report.c:395
+  kasan_report_invalid_free+0xac/0xd0 mm/kasan/report.c:460
+  ____kasan_slab_free+0xfb/0x120
+  kasan_slab_free include/linux/kasan.h:177 [inline]
+  slab_free_hook mm/slub.c:1724 [inline]
+  slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750
+  slab_free mm/slub.c:3661 [inline]
+  __kmem_cache_free+0x71/0x110 mm/slub.c:3674
+  diUnmount+0xef/0x100 fs/jfs/jfs_imap.c:195
+  jfs_umount+0x108/0x370 fs/jfs/jfs_umount.c:63
+  jfs_put_super+0x86/0x190 fs/jfs/super.c:194
+  generic_shutdown_super+0x130/0x310 fs/super.c:492
+  kill_block_super+0x79/0xd0 fs/super.c:1428
+  deactivate_locked_super+0xa7/0xf0 fs/super.c:332
+  cleanup_mnt+0x494/0x520 fs/namespace.c:1186
+  task_work_run+0x243/0x300 kernel/task_work.c:179
+  exit_task_work include/linux/task_work.h:38 [inline]
+  do_exit+0x664/0x2070 kernel/exit.c:820
+  do_group_exit+0x1fd/0x2b0 kernel/exit.c:950
+  __do_sys_exit_group kernel/exit.c:961 [inline]
+  __se_sys_exit_group kernel/exit.c:959 [inline]
+  __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:959
+  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+  do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
+  entry_SYSCALL_64_after_hwframe+0x63/0xcd
+[...]
+
+JFS_IP(ipimap)->i_imap is not setting to NULL after free in diUnmount.
+If jfs_remount() free JFS_IP(ipimap)->i_imap but then failed at diMount().
+JFS_IP(ipimap)->i_imap will be freed once again.
+Fix this problem by setting JFS_IP(ipimap)->i_imap to NULL after free.
+
+Reported-by: syzbot+90a11e6b1e810785c6ff@syzkaller.appspotmail.com
+Signed-off-by: Liu Shixin <liushixin2@huawei.com>
+Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/jfs/jfs_imap.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
+index 937ca07b58b1d..67c67604b8c85 100644
+--- a/fs/jfs/jfs_imap.c
++++ b/fs/jfs/jfs_imap.c
+@@ -195,6 +195,7 @@ int diUnmount(struct inode *ipimap, int mounterror)
+        * free in-memory control structure
+        */
+       kfree(imap);
++      JFS_IP(ipimap)->i_imap = NULL;
+       return (0);
+ }
+-- 
+2.40.1
+
diff --git a/queue-5.4/kernel-fork-beware-of-__put_task_struct-calling-cont.patch b/queue-5.4/kernel-fork-beware-of-__put_task_struct-calling-cont.patch
new file mode 100644 (file)
index 0000000..b0ba3ca
--- /dev/null
@@ -0,0 +1,128 @@
+From 4786c5c4222f322ddda8c6c73f54377b85cfc0ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 14 Jun 2023 09:23:21 -0300
+Subject: kernel/fork: beware of __put_task_struct() calling context
+
+From: Wander Lairson Costa <wander@redhat.com>
+
+[ Upstream commit d243b34459cea30cfe5f3a9b2feb44e7daff9938 ]
+
+Under PREEMPT_RT, __put_task_struct() indirectly acquires sleeping
+locks. Therefore, it can't be called from an non-preemptible context.
+
+One practical example is splat inside inactive_task_timer(), which is
+called in a interrupt context:
+
+  CPU: 1 PID: 2848 Comm: life Kdump: loaded Tainted: G W ---------
+   Hardware name: HP ProLiant DL388p Gen8, BIOS P70 07/15/2012
+   Call Trace:
+   dump_stack_lvl+0x57/0x7d
+   mark_lock_irq.cold+0x33/0xba
+   mark_lock+0x1e7/0x400
+   mark_usage+0x11d/0x140
+   __lock_acquire+0x30d/0x930
+   lock_acquire.part.0+0x9c/0x210
+   rt_spin_lock+0x27/0xe0
+   refill_obj_stock+0x3d/0x3a0
+   kmem_cache_free+0x357/0x560
+   inactive_task_timer+0x1ad/0x340
+   __run_hrtimer+0x8a/0x1a0
+   __hrtimer_run_queues+0x91/0x130
+   hrtimer_interrupt+0x10f/0x220
+   __sysvec_apic_timer_interrupt+0x7b/0xd0
+   sysvec_apic_timer_interrupt+0x4f/0xd0
+   asm_sysvec_apic_timer_interrupt+0x12/0x20
+   RIP: 0033:0x7fff196bf6f5
+
+Instead of calling __put_task_struct() directly, we defer it using
+call_rcu(). A more natural approach would use a workqueue, but since
+in PREEMPT_RT, we can't allocate dynamic memory from atomic context,
+the code would become more complex because we would need to put the
+work_struct instance in the task_struct and initialize it when we
+allocate a new task_struct.
+
+The issue is reproducible with stress-ng:
+
+  while true; do
+      stress-ng --sched deadline --sched-period 1000000000 \
+             --sched-runtime 800000000 --sched-deadline \
+             1000000000 --mmapfork 23 -t 20
+  done
+
+Reported-by: Hu Chunyu <chuhu@redhat.com>
+Suggested-by: Oleg Nesterov <oleg@redhat.com>
+Suggested-by: Valentin Schneider <vschneid@redhat.com>
+Suggested-by: Peter Zijlstra <peterz@infradead.org>
+Signed-off-by: Wander Lairson Costa <wander@redhat.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Link: https://lore.kernel.org/r/20230614122323.37957-2-wander@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/sched/task.h | 28 +++++++++++++++++++++++++++-
+ kernel/fork.c              |  8 ++++++++
+ 2 files changed, 35 insertions(+), 1 deletion(-)
+
+diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
+index 853ab403e77b8..e3c20a4f81f5e 100644
+--- a/include/linux/sched/task.h
++++ b/include/linux/sched/task.h
+@@ -113,10 +113,36 @@ static inline struct task_struct *get_task_struct(struct task_struct *t)
+ }
+ extern void __put_task_struct(struct task_struct *t);
++extern void __put_task_struct_rcu_cb(struct rcu_head *rhp);
+ static inline void put_task_struct(struct task_struct *t)
+ {
+-      if (refcount_dec_and_test(&t->usage))
++      if (!refcount_dec_and_test(&t->usage))
++              return;
++
++      /*
++       * under PREEMPT_RT, we can't call put_task_struct
++       * in atomic context because it will indirectly
++       * acquire sleeping locks.
++       *
++       * call_rcu() will schedule delayed_put_task_struct_rcu()
++       * to be called in process context.
++       *
++       * __put_task_struct() is called when
++       * refcount_dec_and_test(&t->usage) succeeds.
++       *
++       * This means that it can't "conflict" with
++       * put_task_struct_rcu_user() which abuses ->rcu the same
++       * way; rcu_users has a reference so task->usage can't be
++       * zero after rcu_users 1 -> 0 transition.
++       *
++       * delayed_free_task() also uses ->rcu, but it is only called
++       * when it fails to fork a process. Therefore, there is no
++       * way it can conflict with put_task_struct().
++       */
++      if (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible())
++              call_rcu(&t->rcu, __put_task_struct_rcu_cb);
++      else
+               __put_task_struct(t);
+ }
+diff --git a/kernel/fork.c b/kernel/fork.c
+index 39134effb2bff..1728aa77861cb 100644
+--- a/kernel/fork.c
++++ b/kernel/fork.c
+@@ -749,6 +749,14 @@ void __put_task_struct(struct task_struct *tsk)
+ }
+ EXPORT_SYMBOL_GPL(__put_task_struct);
++void __put_task_struct_rcu_cb(struct rcu_head *rhp)
++{
++      struct task_struct *task = container_of(rhp, struct task_struct, rcu);
++
++      __put_task_struct(task);
++}
++EXPORT_SYMBOL_GPL(__put_task_struct_rcu_cb);
++
+ void __init __weak arch_task_cache_init(void) { }
+ /*
+-- 
+2.40.1
+
diff --git a/queue-5.4/kobject-add-sanity-check-for-kset-kobj.ktype-in-kset.patch b/queue-5.4/kobject-add-sanity-check-for-kset-kobj.ktype-in-kset.patch
new file mode 100644 (file)
index 0000000..adb8bd2
--- /dev/null
@@ -0,0 +1,60 @@
+From 829873d265e346f4f5cd70679a4b3a8a5e6e3ac0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 5 Aug 2023 16:41:13 +0800
+Subject: kobject: Add sanity check for kset->kobj.ktype in kset_register()
+
+From: Zhen Lei <thunder.leizhen@huawei.com>
+
+[ Upstream commit 4d0fe8c52bb3029d83e323c961221156ab98680b ]
+
+When I register a kset in the following way:
+       static struct kset my_kset;
+       kobject_set_name(&my_kset.kobj, "my_kset");
+        ret = kset_register(&my_kset);
+
+A null pointer dereference exception is occurred:
+[ 4453.568337] Unable to handle kernel NULL pointer dereference at \
+virtual address 0000000000000028
+... ...
+[ 4453.810361] Call trace:
+[ 4453.813062]  kobject_get_ownership+0xc/0x34
+[ 4453.817493]  kobject_add_internal+0x98/0x274
+[ 4453.822005]  kset_register+0x5c/0xb4
+[ 4453.825820]  my_kobj_init+0x44/0x1000 [my_kset]
+... ...
+
+Because I didn't initialize my_kset.kobj.ktype.
+
+According to the description in Documentation/core-api/kobject.rst:
+ - A ktype is the type of object that embeds a kobject.  Every structure
+   that embeds a kobject needs a corresponding ktype.
+
+So add sanity check to make sure kset->kobj.ktype is not NULL.
+
+Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
+Link: https://lore.kernel.org/r/20230805084114.1298-2-thunder.leizhen@huaweicloud.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ lib/kobject.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/kobject.c b/lib/kobject.c
+index 0c6d17503a113..c4025a880d753 100644
+--- a/lib/kobject.c
++++ b/lib/kobject.c
+@@ -877,6 +877,11 @@ int kset_register(struct kset *k)
+       if (!k)
+               return -EINVAL;
++      if (!k->kobj.ktype) {
++              pr_err("must have a ktype to be initialized properly!\n");
++              return -EINVAL;
++      }
++
+       kset_init(k);
+       err = kobject_add_internal(&k->kobj);
+       if (err)
+-- 
+2.40.1
+
diff --git a/queue-5.4/libbpf-free-btf_vmlinux-when-closing-bpf_object.patch b/queue-5.4/libbpf-free-btf_vmlinux-when-closing-bpf_object.patch
new file mode 100644 (file)
index 0000000..b5c1525
--- /dev/null
@@ -0,0 +1,41 @@
+From 3fc7deb49fe22dbae16e7d81da0f187ab97cb8bb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 22 Aug 2023 12:38:40 -0700
+Subject: libbpf: Free btf_vmlinux when closing bpf_object
+
+From: Hao Luo <haoluo@google.com>
+
+[ Upstream commit 29d67fdebc42af6466d1909c60fdd1ef4f3e5240 ]
+
+I hit a memory leak when testing bpf_program__set_attach_target().
+Basically, set_attach_target() may allocate btf_vmlinux, for example,
+when setting attach target for bpf_iter programs. But btf_vmlinux
+is freed only in bpf_object_load(), which means if we only open
+bpf object but not load it, setting attach target may leak
+btf_vmlinux.
+
+So let's free btf_vmlinux in bpf_object__close() anyway.
+
+Signed-off-by: Hao Luo <haoluo@google.com>
+Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20230822193840.1509809-1-haoluo@google.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/lib/bpf/libbpf.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
+index b8849812449c3..343018632d2d1 100644
+--- a/tools/lib/bpf/libbpf.c
++++ b/tools/lib/bpf/libbpf.c
+@@ -4202,6 +4202,7 @@ void bpf_object__close(struct bpf_object *obj)
+       bpf_object__elf_finish(obj);
+       bpf_object__unload(obj);
+       btf__free(obj->btf);
++      btf__free(obj->btf_vmlinux);
+       btf_ext__free(obj->btf_ext);
+       for (i = 0; i < obj->nr_maps; i++) {
+-- 
+2.40.1
+
diff --git a/queue-5.4/locks-fix-kasan-use-after-free-in-trace_event_raw_ev.patch b/queue-5.4/locks-fix-kasan-use-after-free-in-trace_event_raw_ev.patch
new file mode 100644 (file)
index 0000000..312bf2a
--- /dev/null
@@ -0,0 +1,88 @@
+From 8b6d4d1029164296624fecd0914be0ac71de1e67 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 Jul 2023 13:19:04 +0800
+Subject: locks: fix KASAN: use-after-free in
+ trace_event_raw_event_filelock_lock
+
+From: Will Shiu <Will.Shiu@mediatek.com>
+
+[ Upstream commit 74f6f5912693ce454384eaeec48705646a21c74f ]
+
+As following backtrace, the struct file_lock request , in posix_lock_inode
+is free before ftrace function using.
+Replace the ftrace function ahead free flow could fix the use-after-free
+issue.
+
+[name:report&]===============================================
+BUG:KASAN: use-after-free in trace_event_raw_event_filelock_lock+0x80/0x12c
+[name:report&]Read at addr f6ffff8025622620 by task NativeThread/16753
+[name:report_hw_tags&]Pointer tag: [f6], memory tag: [fe]
+[name:report&]
+BT:
+Hardware name: MT6897 (DT)
+Call trace:
+ dump_backtrace+0xf8/0x148
+ show_stack+0x18/0x24
+ dump_stack_lvl+0x60/0x7c
+ print_report+0x2c8/0xa08
+ kasan_report+0xb0/0x120
+ __do_kernel_fault+0xc8/0x248
+ do_bad_area+0x30/0xdc
+ do_tag_check_fault+0x1c/0x30
+ do_mem_abort+0x58/0xbc
+ el1_abort+0x3c/0x5c
+ el1h_64_sync_handler+0x54/0x90
+ el1h_64_sync+0x68/0x6c
+ trace_event_raw_event_filelock_lock+0x80/0x12c
+ posix_lock_inode+0xd0c/0xd60
+ do_lock_file_wait+0xb8/0x190
+ fcntl_setlk+0x2d8/0x440
+...
+[name:report&]
+[name:report&]Allocated by task 16752:
+...
+ slab_post_alloc_hook+0x74/0x340
+ kmem_cache_alloc+0x1b0/0x2f0
+ posix_lock_inode+0xb0/0xd60
+...
+ [name:report&]
+ [name:report&]Freed by task 16752:
+...
+  kmem_cache_free+0x274/0x5b0
+  locks_dispose_list+0x3c/0x148
+  posix_lock_inode+0xc40/0xd60
+  do_lock_file_wait+0xb8/0x190
+  fcntl_setlk+0x2d8/0x440
+  do_fcntl+0x150/0xc18
+...
+
+Signed-off-by: Will Shiu <Will.Shiu@mediatek.com>
+Signed-off-by: Jeff Layton <jlayton@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/locks.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fs/locks.c b/fs/locks.c
+index b8a31c1c4fff3..90f92784aa554 100644
+--- a/fs/locks.c
++++ b/fs/locks.c
+@@ -1338,6 +1338,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
+  out:
+       spin_unlock(&ctx->flc_lock);
+       percpu_up_read(&file_rwsem);
++      trace_posix_lock_inode(inode, request, error);
+       /*
+        * Free any unused locks.
+        */
+@@ -1346,7 +1347,6 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
+       if (new_fl2)
+               locks_free_lock(new_fl2);
+       locks_dispose_list(&dispose);
+-      trace_posix_lock_inode(inode, request, error);
+       return error;
+ }
+-- 
+2.40.1
+
diff --git a/queue-5.4/md-raid1-fix-error-iso-c90-forbids-mixed-declaration.patch b/queue-5.4/md-raid1-fix-error-iso-c90-forbids-mixed-declaration.patch
new file mode 100644 (file)
index 0000000..9ca02bc
--- /dev/null
@@ -0,0 +1,54 @@
+From f6a89bbeff037b0b6c03118a6de231a1b2938673 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 11 Sep 2023 14:25:23 -0700
+Subject: md/raid1: fix error: ISO C90 forbids mixed declarations
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Nigel Croxon <ncroxon@redhat.com>
+
+[ Upstream commit df203da47f4428bc286fc99318936416253a321c ]
+
+There is a compile error when this commit is added:
+md: raid1: fix potential OOB in raid1_remove_disk()
+
+drivers/md/raid1.c: In function 'raid1_remove_disk':
+drivers/md/raid1.c:1844:9: error: ISO C90 forbids mixed declarations
+and code [-Werror=declaration-after-statement]
+1844 |         struct raid1_info *p = conf->mirrors + number;
+     |         ^~~~~~
+
+That's because the new code was inserted before the struct.
+The change is move the struct command above this commit.
+
+Fixes: 8b0472b50bcf ("md: raid1: fix potential OOB in raid1_remove_disk()")
+Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
+Signed-off-by: Song Liu <song@kernel.org>
+Link: https://lore.kernel.org/r/46d929d0-2aab-4cf2-b2bf-338963e8ba5a@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/md/raid1.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
+index f96e079454700..c40237cfdcb0f 100644
+--- a/drivers/md/raid1.c
++++ b/drivers/md/raid1.c
+@@ -1808,12 +1808,11 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
+       struct r1conf *conf = mddev->private;
+       int err = 0;
+       int number = rdev->raid_disk;
++      struct raid1_info *p = conf->mirrors + number;
+       if (unlikely(number >= conf->raid_disks))
+               goto abort;
+-      struct raid1_info *p = conf->mirrors + number;
+-
+       if (rdev != p->rdev)
+               p = conf->mirrors + conf->raid_disks + number;
+-- 
+2.40.1
+
diff --git a/queue-5.4/md-raid1-fix-potential-oob-in-raid1_remove_disk.patch b/queue-5.4/md-raid1-fix-potential-oob-in-raid1_remove_disk.patch
new file mode 100644 (file)
index 0000000..1d72998
--- /dev/null
@@ -0,0 +1,46 @@
+From 552e4fdab07e4e5ad9708d0ffb34c53399e6a390 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 22 Jul 2023 15:53:53 +0800
+Subject: md: raid1: fix potential OOB in raid1_remove_disk()
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit 8b0472b50bcf0f19a5119b00a53b63579c8e1e4d ]
+
+If rddev->raid_disk is greater than mddev->raid_disks, there will be
+an out-of-bounds in raid1_remove_disk(). We have already found
+similar reports as follows:
+
+1) commit d17f744e883b ("md-raid10: fix KASAN warning")
+2) commit 1ebc2cec0b7d ("dm raid: fix KASAN warning in raid5_remove_disk")
+
+Fix this bug by checking whether the "number" variable is
+valid.
+
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Reviewed-by: Yu Kuai <yukuai3@huawei.com>
+Link: https://lore.kernel.org/r/tencent_0D24426FAC6A21B69AC0C03CE4143A508F09@qq.com
+Signed-off-by: Song Liu <song@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/md/raid1.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
+index 1919de4c8c12d..f96e079454700 100644
+--- a/drivers/md/raid1.c
++++ b/drivers/md/raid1.c
+@@ -1808,6 +1808,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
+       struct r1conf *conf = mddev->private;
+       int err = 0;
+       int number = rdev->raid_disk;
++
++      if (unlikely(number >= conf->raid_disks))
++              goto abort;
++
+       struct raid1_info *p = conf->mirrors + number;
+       if (rdev != p->rdev)
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-af9005-fix-null-ptr-deref-in-af9005_i2c_xfer.patch b/queue-5.4/media-af9005-fix-null-ptr-deref-in-af9005_i2c_xfer.patch
new file mode 100644 (file)
index 0000000..be641b9
--- /dev/null
@@ -0,0 +1,52 @@
+From 05a91de67be29b09a05f57ba02f53ec10d4c6157 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 8 Jul 2023 23:24:11 +0800
+Subject: media: af9005: Fix null-ptr-deref in af9005_i2c_xfer
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit f4ee84f27625ce1fdf41e8483fa0561a1b837d10 ]
+
+In af9005_i2c_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach af9005_i2c_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen.
+We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a
+("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb/af9005.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
+index 89b4b5d84cdff..827f9db16aa10 100644
+--- a/drivers/media/usb/dvb-usb/af9005.c
++++ b/drivers/media/usb/dvb-usb/af9005.c
+@@ -422,6 +422,10 @@ static int af9005_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+               if (ret == 0)
+                       ret = 2;
+       } else {
++              if (msg[0].len < 2) {
++                      ret = -EOPNOTSUPP;
++                      goto unlock;
++              }
+               /* write one or more registers */
+               reg = msg[0].buf[0];
+               addr = msg[0].addr;
+@@ -431,6 +435,7 @@ static int af9005_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                       ret = 1;
+       }
++unlock:
+       mutex_unlock(&d->i2c_mutex);
+       return ret;
+ }
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-anysee-fix-null-ptr-deref-in-anysee_master_xfe.patch b/queue-5.4/media-anysee-fix-null-ptr-deref-in-anysee_master_xfe.patch
new file mode 100644 (file)
index 0000000..b9e6383
--- /dev/null
@@ -0,0 +1,43 @@
+From bb72788f896ca00efaecea1ea5852a3769e35600 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 9 Jul 2023 00:02:20 +0800
+Subject: media: anysee: fix null-ptr-deref in anysee_master_xfer
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit c30411266fd67ea3c02a05c157231654d5a3bdc9 ]
+
+In anysee_master_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach anysee_master_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen.
+We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a
+("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+[hverkuil: add spaces around +]
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb-v2/anysee.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
+index fb6d99dea31aa..08fdb9e5e3a22 100644
+--- a/drivers/media/usb/dvb-usb-v2/anysee.c
++++ b/drivers/media/usb/dvb-usb-v2/anysee.c
+@@ -202,7 +202,7 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
+       while (i < num) {
+               if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
+-                      if (msg[i].len > 2 || msg[i+1].len > 60) {
++                      if (msg[i].len != 2 || msg[i + 1].len > 60) {
+                               ret = -EOPNOTSUPP;
+                               break;
+                       }
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-az6007-fix-null-ptr-deref-in-az6007_i2c_xfer.patch b/queue-5.4/media-az6007-fix-null-ptr-deref-in-az6007_i2c_xfer.patch
new file mode 100644 (file)
index 0000000..17dd9d9
--- /dev/null
@@ -0,0 +1,55 @@
+From b5f1b2491b3989203a87b1110390a668340b0b94 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 9 Jul 2023 00:28:17 +0800
+Subject: media: az6007: Fix null-ptr-deref in az6007_i2c_xfer()
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit 1047f9343011f2cedc73c64829686206a7e9fc3f ]
+
+In az6007_i2c_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach az6007_i2c_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen.
+We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a
+("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb-v2/az6007.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
+index 7524c90f5da61..6cbfe75791c21 100644
+--- a/drivers/media/usb/dvb-usb-v2/az6007.c
++++ b/drivers/media/usb/dvb-usb-v2/az6007.c
+@@ -788,6 +788,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
+                       if (az6007_xfer_debug)
+                               printk(KERN_DEBUG "az6007: I2C W addr=0x%x len=%d\n",
+                                      addr, msgs[i].len);
++                      if (msgs[i].len < 1) {
++                              ret = -EIO;
++                              goto err;
++                      }
+                       req = AZ6007_I2C_WR;
+                       index = msgs[i].buf[0];
+                       value = addr | (1 << 8);
+@@ -802,6 +806,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
+                       if (az6007_xfer_debug)
+                               printk(KERN_DEBUG "az6007: I2C R addr=0x%x len=%d\n",
+                                      addr, msgs[i].len);
++                      if (msgs[i].len < 1) {
++                              ret = -EIO;
++                              goto err;
++                      }
+                       req = AZ6007_I2C_RD;
+                       index = msgs[i].buf[0];
+                       value = addr;
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-dvb-usb-v2-af9035-fix-null-ptr-deref-in-af9035.patch b/queue-5.4/media-dvb-usb-v2-af9035-fix-null-ptr-deref-in-af9035.patch
new file mode 100644 (file)
index 0000000..7f8ee2a
--- /dev/null
@@ -0,0 +1,64 @@
+From 39d6580085ee6fc9a5bd164f6e61742ece9d71be Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 6 Jul 2023 00:06:54 +0800
+Subject: media: dvb-usb-v2: af9035: Fix null-ptr-deref in
+ af9035_i2c_master_xfer
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit 7bf744f2de0a848fb1d717f5831b03db96feae89 ]
+
+In af9035_i2c_master_xfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach af9035_i2c_master_xfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen.
+We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 0ed554fd769a
+("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
+
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb-v2/af9035.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
+index 3afd18733614a..3a7e5f2f6e951 100644
+--- a/drivers/media/usb/dvb-usb-v2/af9035.c
++++ b/drivers/media/usb/dvb-usb-v2/af9035.c
+@@ -321,6 +321,8 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
+                       ret = -EOPNOTSUPP;
+               } else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
+                          (msg[0].addr == state->af9033_i2c_addr[1])) {
++                      if (msg[0].len < 3 || msg[1].len < 1)
++                              return -EOPNOTSUPP;
+                       /* demod access via firmware interface */
+                       u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
+                                       msg[0].buf[2];
+@@ -380,6 +382,8 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
+                       ret = -EOPNOTSUPP;
+               } else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
+                          (msg[0].addr == state->af9033_i2c_addr[1])) {
++                      if (msg[0].len < 3)
++                              return -EOPNOTSUPP;
+                       /* demod access via firmware interface */
+                       u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
+                                       msg[0].buf[2];
+@@ -387,10 +391,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
+                       if (msg[0].addr == state->af9033_i2c_addr[1])
+                               reg |= 0x100000;
+-                      ret = (msg[0].len >= 3) ? af9035_wr_regs(d, reg,
+-                                                               &msg[0].buf[3],
+-                                                               msg[0].len - 3)
+-                                              : -EOPNOTSUPP;
++                      ret = af9035_wr_regs(d, reg, &msg[0].buf[3], msg[0].len - 3);
+               } else {
+                       /* I2C write */
+                       u8 buf[MAX_XFER_SIZE];
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-dw2102-fix-null-ptr-deref-in-dw2102_i2c_transf.patch b/queue-5.4/media-dw2102-fix-null-ptr-deref-in-dw2102_i2c_transf.patch
new file mode 100644 (file)
index 0000000..bec65a5
--- /dev/null
@@ -0,0 +1,98 @@
+From 134fa652b78bef5251986ed34c56012608673abc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 8 Jul 2023 18:22:52 +0800
+Subject: media: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer()
+
+From: Zhang Shurong <zhang_shurong@foxmail.com>
+
+[ Upstream commit 5ae544d94abc8ff77b1b9bf8774def3fa5689b5b ]
+
+In dw2102_i2c_transfer, msg is controlled by user. When msg[i].buf
+is null and msg[i].len is zero, former checks on msg[i].buf would be
+passed. Malicious data finally reach dw2102_i2c_transfer. If accessing
+msg[i].buf[0] without sanity check, null ptr deref would happen.
+We add check on msg[i].len to prevent crash.
+
+Similar commit:
+commit 950e252cb469
+("[media] dw2102: limit messages to buffer size")
+
+Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/usb/dvb-usb/dw2102.c | 24 ++++++++++++++++++++++++
+ 1 file changed, 24 insertions(+)
+
+diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
+index f8f589ebab74b..924a6478007a8 100644
+--- a/drivers/media/usb/dvb-usb/dw2102.c
++++ b/drivers/media/usb/dvb-usb/dw2102.c
+@@ -128,6 +128,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+       switch (num) {
+       case 2:
++              if (msg[0].len < 1) {
++                      num = -EOPNOTSUPP;
++                      break;
++              }
+               /* read stv0299 register */
+               value = msg[0].buf[0];/* register */
+               for (i = 0; i < msg[1].len; i++) {
+@@ -139,6 +143,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+       case 1:
+               switch (msg[0].addr) {
+               case 0x68:
++                      if (msg[0].len < 2) {
++                              num = -EOPNOTSUPP;
++                              break;
++                      }
+                       /* write to stv0299 register */
+                       buf6[0] = 0x2a;
+                       buf6[1] = msg[0].buf[0];
+@@ -148,6 +156,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                       break;
+               case 0x60:
+                       if (msg[0].flags == 0) {
++                              if (msg[0].len < 4) {
++                                      num = -EOPNOTSUPP;
++                                      break;
++                              }
+                       /* write to tuner pll */
+                               buf6[0] = 0x2c;
+                               buf6[1] = 5;
+@@ -159,6 +171,10 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                               dw210x_op_rw(d->udev, 0xb2, 0, 0,
+                                               buf6, 7, DW210X_WRITE_MSG);
+                       } else {
++                              if (msg[0].len < 1) {
++                                      num = -EOPNOTSUPP;
++                                      break;
++                              }
+                       /* read from tuner */
+                               dw210x_op_rw(d->udev, 0xb5, 0, 0,
+                                               buf6, 1, DW210X_READ_MSG);
+@@ -166,12 +182,20 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+                       }
+                       break;
+               case (DW2102_RC_QUERY):
++                      if (msg[0].len < 2) {
++                              num = -EOPNOTSUPP;
++                              break;
++                      }
+                       dw210x_op_rw(d->udev, 0xb8, 0, 0,
+                                       buf6, 2, DW210X_READ_MSG);
+                       msg[0].buf[0] = buf6[0];
+                       msg[0].buf[1] = buf6[1];
+                       break;
+               case (DW2102_VOLTAGE_CTRL):
++                      if (msg[0].len < 1) {
++                              num = -EOPNOTSUPP;
++                              break;
++                      }
+                       buf6[0] = 0x30;
+                       buf6[1] = msg[0].buf[0];
+                       dw210x_op_rw(d->udev, 0xb2, 0, 0,
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-pci-cx23885-replace-bug-with-error-return.patch b/queue-5.4/media-pci-cx23885-replace-bug-with-error-return.patch
new file mode 100644 (file)
index 0000000..57ec3f2
--- /dev/null
@@ -0,0 +1,36 @@
+From 0ceab7c023c4ea37e99b156744c1129bce1f530a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 21 Jul 2023 10:23:42 +0200
+Subject: media: pci: cx23885: replace BUG with error return
+
+From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+
+[ Upstream commit 2e1796fd4904fdd6062a8e4589778ea899ea0c8d ]
+
+It was completely unnecessary to use BUG in buffer_prepare().
+Just replace it with an error return. This also fixes a smatch warning:
+
+drivers/media/pci/cx23885/cx23885-video.c:422 buffer_prepare() error: uninitialized symbol 'ret'.
+
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/pci/cx23885/cx23885-video.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
+index 7fc408ee4934f..f56b271db8bea 100644
+--- a/drivers/media/pci/cx23885/cx23885-video.c
++++ b/drivers/media/pci/cx23885/cx23885-video.c
+@@ -409,7 +409,7 @@ static int buffer_prepare(struct vb2_buffer *vb)
+                               dev->height >> 1);
+               break;
+       default:
+-              BUG();
++              return -EINVAL; /* should not happen */
+       }
+       dprintk(2, "[%p/%d] buffer_init - %dx%d %dbpp 0x%08x - dma=0x%08lx\n",
+               buf, buf->vb.vb2_buf.index,
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-pci-ipu3-cio2-initialise-timing-struct-to-avoi.patch b/queue-5.4/media-pci-ipu3-cio2-initialise-timing-struct-to-avoi.patch
new file mode 100644 (file)
index 0000000..cbcfc22
--- /dev/null
@@ -0,0 +1,37 @@
+From dcdcb748001d2e6bfa80d772179ea44daec917e4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 1 Aug 2023 10:14:30 +0300
+Subject: media: pci: ipu3-cio2: Initialise timing struct to avoid a compiler
+ warning
+
+From: Sakari Ailus <sakari.ailus@linux.intel.com>
+
+[ Upstream commit 9d7531be3085a8f013cf173ccc4e72e3cf493538 ]
+
+Initialise timing struct in cio2_hw_init() to zero in order to avoid a
+compiler warning. The warning was a false positive.
+
+Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+index 3457f0f545c48..9c0d117e093b1 100644
+--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
++++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+@@ -359,7 +359,7 @@ static int cio2_hw_init(struct cio2_device *cio2, struct cio2_queue *q)
+       void __iomem *const base = cio2->base;
+       u8 lanes, csi2bus = q->csi2.port;
+       u8 sensor_vc = SENSOR_VIR_CH_DFLT;
+-      struct cio2_csi2_timing timing;
++      struct cio2_csi2_timing timing = { 0 };
+       int i, r;
+       fmt = cio2_find_format(NULL, &q->subdev_fmt.code);
+-- 
+2.40.1
+
diff --git a/queue-5.4/media-tuners-qt1010-replace-bug_on-with-a-regular-er.patch b/queue-5.4/media-tuners-qt1010-replace-bug_on-with-a-regular-er.patch
new file mode 100644 (file)
index 0000000..ddc9512
--- /dev/null
@@ -0,0 +1,46 @@
+From 9e068ec74dfaf21c91727272520ccc9f3a74d7a1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 20 Jul 2023 08:20:51 +0200
+Subject: media: tuners: qt1010: replace BUG_ON with a regular error
+
+From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+
+[ Upstream commit ee630b29ea44d1851bb6c903f400956604834463 ]
+
+BUG_ON is unnecessary here, and in addition it confuses smatch.
+Replacing this with an error return help resolve this smatch
+warning:
+
+drivers/media/tuners/qt1010.c:350 qt1010_init() error: buffer overflow 'i2c_data' 34 <= 34
+
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/tuners/qt1010.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/media/tuners/qt1010.c b/drivers/media/tuners/qt1010.c
+index fa5d2692131f9..f7516cb52436e 100644
+--- a/drivers/media/tuners/qt1010.c
++++ b/drivers/media/tuners/qt1010.c
+@@ -342,11 +342,12 @@ static int qt1010_init(struct dvb_frontend *fe)
+                       else
+                               valptr = &tmpval;
+-                      BUG_ON(i >= ARRAY_SIZE(i2c_data) - 1);
+-
+-                      err = qt1010_init_meas1(priv, i2c_data[i+1].reg,
+-                                              i2c_data[i].reg,
+-                                              i2c_data[i].val, valptr);
++                      if (i >= ARRAY_SIZE(i2c_data) - 1)
++                              err = -EIO;
++                      else
++                              err = qt1010_init_meas1(priv, i2c_data[i + 1].reg,
++                                                      i2c_data[i].reg,
++                                                      i2c_data[i].val, valptr);
+                       i++;
+                       break;
+               }
+-- 
+2.40.1
+
diff --git a/queue-5.4/mmc-sdhci-esdhc-imx-improve-esdhc_flag_err010450.patch b/queue-5.4/mmc-sdhci-esdhc-imx-improve-esdhc_flag_err010450.patch
new file mode 100644 (file)
index 0000000..7d1adc6
--- /dev/null
@@ -0,0 +1,54 @@
+From a7f323d35a3411dca98c439f5df573820b4710af Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 11 Aug 2023 23:48:53 +0200
+Subject: mmc: sdhci-esdhc-imx: improve ESDHC_FLAG_ERR010450
+
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+
+[ Upstream commit 5ae4b0d8875caa44946e579420c7fd5740d58653 ]
+
+Errata ERR010450 only shows up if voltage is 1.8V, but if the device is
+supplied by 3v3 the errata can be ignored. So let's check for if quirk
+SDHCI_QUIRK2_NO_1_8_V is defined or not before limiting the frequency.
+
+Cc: Jim Reinhart <jimr@tekvox.com>
+Cc: James Autry <jautry@tekvox.com>
+Cc: Matthew Maron <matthewm@tekvox.com>
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Acked-by: Haibo Chen <haibo.chen@nxp.com>
+Acked-by: Adrian Hunter <adrian.hunter@intel.com>
+Link: https://lore.kernel.org/r/20230811214853.8623-1-giulio.benetti@benettiengineering.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/sdhci-esdhc-imx.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
+index b3f761eca8299..762288c6d30ce 100644
+--- a/drivers/mmc/host/sdhci-esdhc-imx.c
++++ b/drivers/mmc/host/sdhci-esdhc-imx.c
+@@ -153,8 +153,8 @@
+ #define ESDHC_FLAG_HS400              BIT(9)
+ /*
+  * The IP has errata ERR010450
+- * uSDHC: Due to the I/O timing limit, for SDR mode, SD card clock can't
+- * exceed 150MHz, for DDR mode, SD card clock can't exceed 45MHz.
++ * uSDHC: At 1.8V due to the I/O timing limit, for SDR mode, SD card
++ * clock can't exceed 150MHz, for DDR mode, SD card clock can't exceed 45MHz.
+  */
+ #define ESDHC_FLAG_ERR010450          BIT(10)
+ /* The IP supports HS400ES mode */
+@@ -777,7 +777,8 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
+               | ESDHC_CLOCK_MASK);
+       sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
+-      if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
++      if ((imx_data->socdata->flags & ESDHC_FLAG_ERR010450) &&
++          (!(host->quirks2 & SDHCI_QUIRK2_NO_1_8_V))) {
+               unsigned int max_clock;
+               max_clock = imx_data->is_ddr ? 45000000 : 150000000;
+-- 
+2.40.1
+
diff --git a/queue-5.4/perf-build-update-build-rule-for-generated-files.patch b/queue-5.4/perf-build-update-build-rule-for-generated-files.patch
new file mode 100644 (file)
index 0000000..ced6351
--- /dev/null
@@ -0,0 +1,87 @@
+From ae2b85b8560a82bcf7902fed7ef733b31385515f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 27 Jul 2023 19:24:46 -0700
+Subject: perf build: Update build rule for generated files
+
+From: Namhyung Kim <namhyung@kernel.org>
+
+[ Upstream commit 7822a8913f4c51c7d1aff793b525d60c3384fb5b ]
+
+The bison and flex generate C files from the source (.y and .l)
+files.  When O= option is used, they are saved in a separate directory
+but the default build rule assumes the .C files are in the source
+directory.  So it might read invalid file if there are generated files
+from an old version.  The same is true for the pmu-events files.
+
+For example, the following command would cause a build failure:
+
+  $ git checkout v6.3
+  $ make -C tools/perf  # build in the same directory
+
+  $ git checkout v6.5-rc2
+  $ mkdir build  # create a build directory
+  $ make -C tools/perf O=build  # build in a different directory but it
+                                # refers files in the source directory
+
+Let's update the build rule to specify those cases explicitly to depend
+on the files in the output directory.
+
+Note that it's not a complete fix and it needs the next patch for the
+include path too.
+
+Fixes: 80eeb67fe577aa76 ("perf jevents: Program to convert JSON file")
+Signed-off-by: Namhyung Kim <namhyung@kernel.org>
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Anup Sharma <anupnewsmail@gmail.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/r/20230728022447.1323563-1-namhyung@kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/build/Makefile.build  | 10 ++++++++++
+ tools/perf/pmu-events/Build |  6 ++++++
+ 2 files changed, 16 insertions(+)
+
+diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
+index cd72016c3cfa7..5a727094ae832 100644
+--- a/tools/build/Makefile.build
++++ b/tools/build/Makefile.build
+@@ -116,6 +116,16 @@ $(OUTPUT)%.s: %.c FORCE
+       $(call rule_mkdir)
+       $(call if_changed_dep,cc_s_c)
++# bison and flex files are generated in the OUTPUT directory
++# so it needs a separate rule to depend on them properly
++$(OUTPUT)%-bison.o: $(OUTPUT)%-bison.c FORCE
++      $(call rule_mkdir)
++      $(call if_changed_dep,$(host)cc_o_c)
++
++$(OUTPUT)%-flex.o: $(OUTPUT)%-flex.c FORCE
++      $(call rule_mkdir)
++      $(call if_changed_dep,$(host)cc_o_c)
++
+ # Gather build data:
+ #   obj-y        - list of build objects
+ #   subdir-y     - list of directories to nest
+diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
+index 5ec5ce8c31bab..ea8c41f9c7398 100644
+--- a/tools/perf/pmu-events/Build
++++ b/tools/perf/pmu-events/Build
+@@ -25,3 +25,9 @@ $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS_PY)
+       $(call rule_mkdir)
+       $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(SRCARCH) pmu-events/arch $@
+ endif
++
++# pmu-events.c file is generated in the OUTPUT directory so it needs a
++# separate rule to depend on it properly
++$(OUTPUT)pmu-events/pmu-events.o: $(PMU_EVENTS_C)
++      $(call rule_mkdir)
++      $(call if_changed_dep,cc_o_c)
+-- 
+2.40.1
+
diff --git a/queue-5.4/perf-jevents-make-build-dependency-on-test-jsons.patch b/queue-5.4/perf-jevents-make-build-dependency-on-test-jsons.patch
new file mode 100644 (file)
index 0000000..c8bffd2
--- /dev/null
@@ -0,0 +1,54 @@
+From 3b46dbd509aae2809bf19bc92bf963b0266378ed Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 3 Aug 2021 08:44:09 +0100
+Subject: perf jevents: Make build dependency on test JSONs
+
+From: John Garry <john.garry@huawei.com>
+
+[ Upstream commit 517db3b59537a59f6cc251b1926df93e93bb9c87 ]
+
+Currently all JSONs and the mapfile for an arch are dependencies for
+building pmu-events.c
+
+The test JSONs are missing as a dependency, so add them.
+
+Signed-off-by: John Garry <john.garry@huawei.com>
+Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Jin Yao <yao.jin@linux.intel.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: linuxarm@huawei.com
+Link: http://lore.kernel.org/lkml/90094733-741c-50e5-ac7d-f5640b5f0bdd@huawei.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 7822a8913f4c ("perf build: Update build rule for generated files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/pmu-events/Build | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
+index 215ba30b85343..a055dee6a46af 100644
+--- a/tools/perf/pmu-events/Build
++++ b/tools/perf/pmu-events/Build
+@@ -6,10 +6,13 @@ pmu-events-y += pmu-events.o
+ JDIR          =  pmu-events/arch/$(SRCARCH)
+ JSON          =  $(shell [ -d $(JDIR) ] &&                            \
+                       find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
++JDIR_TEST     =  pmu-events/arch/test
++JSON_TEST     =  $(shell [ -d $(JDIR_TEST) ] &&                       \
++                      find $(JDIR_TEST) -name '*.json')
+ #
+ # Locate/process JSON files in pmu-events/arch/
+ # directory and create tables in pmu-events.c.
+ #
+-$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS)
++$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS)
+       $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V)
+-- 
+2.40.1
+
diff --git a/queue-5.4/perf-jevents-switch-build-to-use-jevents.py.patch b/queue-5.4/perf-jevents-switch-build-to-use-jevents.py.patch
new file mode 100644 (file)
index 0000000..2e21fef
--- /dev/null
@@ -0,0 +1,295 @@
+From 4aefcff9723fa5a6225e6b053d02609e385ea04d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 29 Jun 2022 11:25:04 -0700
+Subject: perf jevents: Switch build to use jevents.py
+
+From: Ian Rogers <rogers.email@gmail.com>
+
+[ Upstream commit 00facc760903be6675870c2749e2cd72140e396e ]
+
+Generate pmu-events.c using jevents.py rather than the binary built from
+jevents.c.
+
+Add a new config variable NO_JEVENTS that is set when there is no
+architecture json or an appropriate python interpreter isn't present.
+
+When NO_JEVENTS is defined the file pmu-events/empty-pmu-events.c is
+copied and used as the pmu-events.c file.
+
+Signed-off-by: Ian Rogers <irogers@google.com>
+Tested-by: John Garry <john.garry@huawei.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ananth Narayan <ananth.narayan@amd.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Andrew Kilroy <andrew.kilroy@arm.com>
+Cc: Caleb Biggers <caleb.biggers@intel.com>
+Cc: Felix Fietkau <nbd@nbd.name>
+Cc: Ian Rogers <rogers.email@gmail.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: James Clark <james.clark@arm.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Kajol Jain <kjain@linux.ibm.com>
+Cc: Kan Liang <kan.liang@linux.intel.com>
+Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
+Cc: Like Xu <likexu@tencent.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Nick Forrington <nick.forrington@arm.com>
+Cc: Paul Clarke <pc@us.ibm.com>
+Cc: Perry Taylor <perry.taylor@intel.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Qi Liu <liuqi115@huawei.com>
+Cc: Ravi Bangoria <ravi.bangoria@amd.com>
+Cc: Sandipan Das <sandipan.das@amd.com>
+Cc: Santosh Shukla <santosh.shukla@amd.com>
+Cc: Stephane Eranian <eranian@google.com>
+Cc: Will Deacon <will@kernel.org>
+Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
+Link: https://lore.kernel.org/r/20220629182505.406269-4-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 7822a8913f4c ("perf build: Update build rule for generated files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/Makefile.config               |  19 +++
+ tools/perf/Makefile.perf                 |   1 +
+ tools/perf/pmu-events/Build              |  13 +-
+ tools/perf/pmu-events/empty-pmu-events.c | 158 +++++++++++++++++++++++
+ 4 files changed, 189 insertions(+), 2 deletions(-)
+ create mode 100644 tools/perf/pmu-events/empty-pmu-events.c
+
+diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
+index e95281586f65e..b76800bbc632a 100644
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -752,6 +752,25 @@ else
+   endif
+ endif
++ifneq ($(NO_JEVENTS),1)
++  ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),)
++    NO_JEVENTS := 1
++  endif
++endif
++ifneq ($(NO_JEVENTS),1)
++  NO_JEVENTS := 0
++  ifndef PYTHON
++    $(warning No python interpreter disabling jevent generation)
++    NO_JEVENTS := 1
++  else
++    # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016.
++    JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 6) else "0")' 2> /dev/null)
++    ifneq ($(JEVENTS_PYTHON_GOOD), 1)
++      $(warning Python interpreter too old (older than 3.6) disabling jevent generation)
++      NO_JEVENTS := 1
++    endif
++  endif
++endif
+ ifndef NO_LIBBFD
+   ifeq ($(feature-libbfd), 1)
+diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
+index 961f5e4fd6566..b0314f31e5a37 100644
+--- a/tools/perf/Makefile.perf
++++ b/tools/perf/Makefile.perf
+@@ -584,6 +584,7 @@ JEVENTS       := $(OUTPUT)pmu-events/jevents
+ JEVENTS_IN    := $(OUTPUT)pmu-events/jevents-in.o
+ PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
++export NO_JEVENTS
+ export JEVENTS
+diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
+index a055dee6a46af..5ec5ce8c31bab 100644
+--- a/tools/perf/pmu-events/Build
++++ b/tools/perf/pmu-events/Build
+@@ -9,10 +9,19 @@ JSON         =  $(shell [ -d $(JDIR) ] &&                            \
+ JDIR_TEST     =  pmu-events/arch/test
+ JSON_TEST     =  $(shell [ -d $(JDIR_TEST) ] &&                       \
+                       find $(JDIR_TEST) -name '*.json')
++JEVENTS_PY    =  pmu-events/jevents.py
+ #
+ # Locate/process JSON files in pmu-events/arch/
+ # directory and create tables in pmu-events.c.
+ #
+-$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS)
+-      $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V)
++
++ifeq ($(NO_JEVENTS),1)
++$(OUTPUT)pmu-events/pmu-events.c: pmu-events/empty-pmu-events.c
++      $(call rule_mkdir)
++      $(Q)$(call echo-cmd,gen)cp $< $@
++else
++$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS_PY)
++      $(call rule_mkdir)
++      $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(SRCARCH) pmu-events/arch $@
++endif
+diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-events/empty-pmu-events.c
+new file mode 100644
+index 0000000000000..77e655c6f1162
+--- /dev/null
++++ b/tools/perf/pmu-events/empty-pmu-events.c
+@@ -0,0 +1,158 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * An empty pmu-events.c file used when there is no architecture json files in
++ * arch or when the jevents.py script cannot be run.
++ *
++ * The test cpu/soc is provided for testing.
++ */
++#include "pmu-events/pmu-events.h"
++
++static const struct pmu_event pme_test_soc_cpu[] = {
++      {
++              .name = "l3_cache_rd",
++              .event = "event=0x40",
++              .desc = "L3 cache access, read",
++              .topic = "cache",
++              .long_desc = "Attributable Level 3 cache access, read",
++      },
++      {
++              .name = "segment_reg_loads.any",
++              .event = "event=0x6,period=200000,umask=0x80",
++              .desc = "Number of segment register loads",
++              .topic = "other",
++      },
++      {
++              .name = "dispatch_blocked.any",
++              .event = "event=0x9,period=200000,umask=0x20",
++              .desc = "Memory cluster signals to block micro-op dispatch for any reason",
++              .topic = "other",
++      },
++      {
++              .name = "eist_trans",
++              .event = "event=0x3a,period=200000,umask=0x0",
++              .desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions",
++              .topic = "other",
++      },
++      {
++              .name = "uncore_hisi_ddrc.flux_wcmd",
++              .event = "event=0x2",
++              .desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
++              .topic = "uncore",
++              .long_desc = "DDRC write commands",
++              .pmu = "hisi_sccl,ddrc",
++      },
++      {
++              .name = "unc_cbo_xsnp_response.miss_eviction",
++              .event = "event=0x22,umask=0x81",
++              .desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core. Unit: uncore_cbox ",
++              .topic = "uncore",
++              .long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core",
++              .pmu = "uncore_cbox",
++      },
++      {
++              .name = "event-hyphen",
++              .event = "event=0xe0,umask=0x00",
++              .desc = "UNC_CBO_HYPHEN. Unit: uncore_cbox ",
++              .topic = "uncore",
++              .long_desc = "UNC_CBO_HYPHEN",
++              .pmu = "uncore_cbox",
++      },
++      {
++              .name = "event-two-hyph",
++              .event = "event=0xc0,umask=0x00",
++              .desc = "UNC_CBO_TWO_HYPH. Unit: uncore_cbox ",
++              .topic = "uncore",
++              .long_desc = "UNC_CBO_TWO_HYPH",
++              .pmu = "uncore_cbox",
++      },
++      {
++              .name = "uncore_hisi_l3c.rd_hit_cpipe",
++              .event = "event=0x7",
++              .desc = "Total read hits. Unit: hisi_sccl,l3c ",
++              .topic = "uncore",
++              .long_desc = "Total read hits",
++              .pmu = "hisi_sccl,l3c",
++      },
++      {
++              .name = "uncore_imc_free_running.cache_miss",
++              .event = "event=0x12",
++              .desc = "Total cache misses. Unit: uncore_imc_free_running ",
++              .topic = "uncore",
++              .long_desc = "Total cache misses",
++              .pmu = "uncore_imc_free_running",
++      },
++      {
++              .name = "uncore_imc.cache_hits",
++              .event = "event=0x34",
++              .desc = "Total cache hits. Unit: uncore_imc ",
++              .topic = "uncore",
++              .long_desc = "Total cache hits",
++              .pmu = "uncore_imc",
++      },
++      {
++              .name = "bp_l1_btb_correct",
++              .event = "event=0x8a",
++              .desc = "L1 BTB Correction",
++              .topic = "branch",
++      },
++      {
++              .name = "bp_l2_btb_correct",
++              .event = "event=0x8b",
++              .desc = "L2 BTB Correction",
++              .topic = "branch",
++      },
++      {
++              .name = 0,
++              .event = 0,
++              .desc = 0,
++      },
++};
++
++const struct pmu_events_map pmu_events_map[] = {
++      {
++              .cpuid = "testcpu",
++              .version = "v1",
++              .type = "core",
++              .table = pme_test_soc_cpu,
++      },
++      {
++              .cpuid = 0,
++              .version = 0,
++              .type = 0,
++              .table = 0,
++      },
++};
++
++static const struct pmu_event pme_test_soc_sys[] = {
++      {
++              .name = "sys_ddr_pmu.write_cycles",
++              .event = "event=0x2b",
++              .desc = "ddr write-cycles event. Unit: uncore_sys_ddr_pmu ",
++              .compat = "v8",
++              .topic = "uncore",
++              .pmu = "uncore_sys_ddr_pmu",
++      },
++      {
++              .name = "sys_ccn_pmu.read_cycles",
++              .event = "config=0x2c",
++              .desc = "ccn read-cycles event. Unit: uncore_sys_ccn_pmu ",
++              .compat = "0x01",
++              .topic = "uncore",
++              .pmu = "uncore_sys_ccn_pmu",
++      },
++      {
++              .name = 0,
++              .event = 0,
++              .desc = 0,
++      },
++};
++
++const struct pmu_sys_events pmu_sys_event_tables[] = {
++      {
++              .table = pme_test_soc_sys,
++              .name = "pme_test_soc_sys",
++      },
++      {
++              .table = 0
++      },
++};
+-- 
+2.40.1
+
diff --git a/queue-5.4/perf-smmuv3-enable-hisilicon-erratum-162001900-quirk.patch b/queue-5.4/perf-smmuv3-enable-hisilicon-erratum-162001900-quirk.patch
new file mode 100644 (file)
index 0000000..c5ca5ed
--- /dev/null
@@ -0,0 +1,160 @@
+From d79172d4eb46e0c7183828ce136fecd23e718ef9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 14 Aug 2023 20:40:12 +0800
+Subject: perf/smmuv3: Enable HiSilicon Erratum 162001900 quirk for HIP08/09
+
+From: Yicong Yang <yangyicong@hisilicon.com>
+
+[ Upstream commit 0242737dc4eb9f6e9a5ea594b3f93efa0b12f28d ]
+
+Some HiSilicon SMMU PMCG suffers the erratum 162001900 that the PMU
+disable control sometimes fail to disable the counters. This will lead
+to error or inaccurate data since before we enable the counters the
+counter's still counting for the event used in last perf session.
+
+This patch tries to fix this by hardening the global disable process.
+Before disable the PMU, writing an invalid event type (0xffff) to
+focibly stop the counters. Correspondingly restore each events on
+pmu::pmu_enable().
+
+Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
+Link: https://lore.kernel.org/r/20230814124012.58013-1-yangyicong@huawei.com
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ Documentation/arm64/silicon-errata.rst |  3 ++
+ drivers/acpi/arm64/iort.c              |  5 ++-
+ drivers/perf/arm_smmuv3_pmu.c          | 46 +++++++++++++++++++++++++-
+ include/linux/acpi_iort.h              |  1 +
+ 4 files changed, 53 insertions(+), 2 deletions(-)
+
+diff --git a/Documentation/arm64/silicon-errata.rst b/Documentation/arm64/silicon-errata.rst
+index 36a8c01191a07..6b70b6aabcffe 100644
+--- a/Documentation/arm64/silicon-errata.rst
++++ b/Documentation/arm64/silicon-errata.rst
+@@ -134,6 +134,9 @@ stable kernels.
+ +----------------+-----------------+-----------------+-----------------------------+
+ | Hisilicon      | Hip08 SMMU PMCG | #162001800      | N/A                         |
+ +----------------+-----------------+-----------------+-----------------------------+
++| Hisilicon      | Hip08 SMMU PMCG | #162001900      | N/A                         |
++|                | Hip09 SMMU PMCG |                 |                             |
+++----------------+-----------------+-----------------+-----------------------------+
+ +----------------+-----------------+-----------------+-----------------------------+
+ | Qualcomm Tech. | Kryo/Falkor v1  | E1003           | QCOM_FALKOR_ERRATUM_1003    |
+ +----------------+-----------------+-----------------+-----------------------------+
+diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
+index 553c89b0bdcbb..09eb170f26d27 100644
+--- a/drivers/acpi/arm64/iort.c
++++ b/drivers/acpi/arm64/iort.c
+@@ -1393,7 +1393,10 @@ static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res,
+ static struct acpi_platform_list pmcg_plat_info[] __initdata = {
+       /* HiSilicon Hip08 Platform */
+       {"HISI  ", "HIP08   ", 0, ACPI_SIG_IORT, greater_than_or_equal,
+-       "Erratum #162001800", IORT_SMMU_V3_PMCG_HISI_HIP08},
++       "Erratum #162001800, Erratum #162001900", IORT_SMMU_V3_PMCG_HISI_HIP08},
++      /* HiSilicon Hip09 Platform */
++      {"HISI  ", "HIP09   ", 0, ACPI_SIG_IORT, greater_than_or_equal,
++       "Erratum #162001900", IORT_SMMU_V3_PMCG_HISI_HIP09},
+       { }
+ };
+diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
+index 0b6af77196418..de85e9191947a 100644
+--- a/drivers/perf/arm_smmuv3_pmu.c
++++ b/drivers/perf/arm_smmuv3_pmu.c
+@@ -95,6 +95,7 @@
+ #define SMMU_PMCG_PA_SHIFT              12
+ #define SMMU_PMCG_EVCNTR_RDONLY         BIT(0)
++#define SMMU_PMCG_HARDEN_DISABLE        BIT(1)
+ static int cpuhp_state_num;
+@@ -138,6 +139,20 @@ static inline void smmu_pmu_enable(struct pmu *pmu)
+       writel(SMMU_PMCG_CR_ENABLE, smmu_pmu->reg_base + SMMU_PMCG_CR);
+ }
++static int smmu_pmu_apply_event_filter(struct smmu_pmu *smmu_pmu,
++                                     struct perf_event *event, int idx);
++
++static inline void smmu_pmu_enable_quirk_hip08_09(struct pmu *pmu)
++{
++      struct smmu_pmu *smmu_pmu = to_smmu_pmu(pmu);
++      unsigned int idx;
++
++      for_each_set_bit(idx, smmu_pmu->used_counters, smmu_pmu->num_counters)
++              smmu_pmu_apply_event_filter(smmu_pmu, smmu_pmu->events[idx], idx);
++
++      smmu_pmu_enable(pmu);
++}
++
+ static inline void smmu_pmu_disable(struct pmu *pmu)
+ {
+       struct smmu_pmu *smmu_pmu = to_smmu_pmu(pmu);
+@@ -146,6 +161,22 @@ static inline void smmu_pmu_disable(struct pmu *pmu)
+       writel(0, smmu_pmu->reg_base + SMMU_PMCG_IRQ_CTRL);
+ }
++static inline void smmu_pmu_disable_quirk_hip08_09(struct pmu *pmu)
++{
++      struct smmu_pmu *smmu_pmu = to_smmu_pmu(pmu);
++      unsigned int idx;
++
++      /*
++       * The global disable of PMU sometimes fail to stop the counting.
++       * Harden this by writing an invalid event type to each used counter
++       * to forcibly stop counting.
++       */
++      for_each_set_bit(idx, smmu_pmu->used_counters, smmu_pmu->num_counters)
++              writel(0xffff, smmu_pmu->reg_base + SMMU_PMCG_EVTYPER(idx));
++
++      smmu_pmu_disable(pmu);
++}
++
+ static inline void smmu_pmu_counter_set_value(struct smmu_pmu *smmu_pmu,
+                                             u32 idx, u64 value)
+ {
+@@ -719,7 +750,10 @@ static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu)
+       switch (model) {
+       case IORT_SMMU_V3_PMCG_HISI_HIP08:
+               /* HiSilicon Erratum 162001800 */
+-              smmu_pmu->options |= SMMU_PMCG_EVCNTR_RDONLY;
++              smmu_pmu->options |= SMMU_PMCG_EVCNTR_RDONLY | SMMU_PMCG_HARDEN_DISABLE;
++              break;
++      case IORT_SMMU_V3_PMCG_HISI_HIP09:
++              smmu_pmu->options |= SMMU_PMCG_HARDEN_DISABLE;
+               break;
+       }
+@@ -808,6 +842,16 @@ static int smmu_pmu_probe(struct platform_device *pdev)
+       smmu_pmu_get_acpi_options(smmu_pmu);
++      /*
++       * For platforms suffer this quirk, the PMU disable sometimes fails to
++       * stop the counters. This will leads to inaccurate or error counting.
++       * Forcibly disable the counters with these quirk handler.
++       */
++      if (smmu_pmu->options & SMMU_PMCG_HARDEN_DISABLE) {
++              smmu_pmu->pmu.pmu_enable = smmu_pmu_enable_quirk_hip08_09;
++              smmu_pmu->pmu.pmu_disable = smmu_pmu_disable_quirk_hip08_09;
++      }
++
+       /* Pick one CPU to be the preferred one to use */
+       smmu_pmu->on_cpu = raw_smp_processor_id();
+       WARN_ON(irq_set_affinity_hint(smmu_pmu->irq,
+diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h
+index 8e7e2ec37f1b2..64f700254ca0f 100644
+--- a/include/linux/acpi_iort.h
++++ b/include/linux/acpi_iort.h
+@@ -21,6 +21,7 @@
+  */
+ #define IORT_SMMU_V3_PMCG_GENERIC        0x00000000 /* Generic SMMUv3 PMCG */
+ #define IORT_SMMU_V3_PMCG_HISI_HIP08     0x00000001 /* HiSilicon HIP08 PMCG */
++#define IORT_SMMU_V3_PMCG_HISI_HIP09     0x00000002 /* HiSilicon HIP09 PMCG */
+ int iort_register_domain_token(int trans_id, phys_addr_t base,
+                              struct fwnode_handle *fw_node);
+-- 
+2.40.1
+
diff --git a/queue-5.4/perf-tools-add-an-option-to-build-without-libbfd.patch b/queue-5.4/perf-tools-add-an-option-to-build-without-libbfd.patch
new file mode 100644 (file)
index 0000000..05b2d3c
--- /dev/null
@@ -0,0 +1,97 @@
+From dc601b50c6c92ec7b5f26d2ea755ed3ed10e7853 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Sep 2021 15:57:56 -0700
+Subject: perf tools: Add an option to build without libbfd
+
+From: Ian Rogers <irogers@google.com>
+
+[ Upstream commit 0d1c50ac488ebdaeeaea8ed5069f8d435fd485ed ]
+
+Some distributions, like debian, don't link perf with libbfd. Add a
+build flag to make this configuration buildable and testable.
+
+This was inspired by:
+
+  https://lore.kernel.org/linux-perf-users/20210910102307.2055484-1-tonyg@leastfixedpoint.com/T/#u
+
+Signed-off-by: Ian Rogers <irogers@google.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: tony garnock-jones <tonyg@leastfixedpoint.com>
+Link: http://lore.kernel.org/lkml/20210910225756.729087-1-irogers@google.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 7822a8913f4c ("perf build: Update build rule for generated files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/perf/Makefile.config | 47 ++++++++++++++++++++------------------
+ 1 file changed, 25 insertions(+), 22 deletions(-)
+
+diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
+index cc11050420496..e95281586f65e 100644
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -752,33 +752,36 @@ else
+   endif
+ endif
+-ifeq ($(feature-libbfd), 1)
+-  EXTLIBS += -lbfd -lopcodes
+-else
+-  # we are on a system that requires -liberty and (maybe) -lz
+-  # to link against -lbfd; test each case individually here
+-
+-  # call all detections now so we get correct
+-  # status in VF output
+-  $(call feature_check,libbfd-liberty)
+-  $(call feature_check,libbfd-liberty-z)
+-  ifeq ($(feature-libbfd-liberty), 1)
+-    EXTLIBS += -lbfd -lopcodes -liberty
+-    FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
++ifndef NO_LIBBFD
++  ifeq ($(feature-libbfd), 1)
++    EXTLIBS += -lbfd -lopcodes
+   else
+-    ifeq ($(feature-libbfd-liberty-z), 1)
+-      EXTLIBS += -lbfd -lopcodes -liberty -lz
+-      FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
++    # we are on a system that requires -liberty and (maybe) -lz
++    # to link against -lbfd; test each case individually here
++
++    # call all detections now so we get correct
++    # status in VF output
++    $(call feature_check,libbfd-liberty)
++    $(call feature_check,libbfd-liberty-z)
++
++    ifeq ($(feature-libbfd-liberty), 1)
++      EXTLIBS += -lbfd -lopcodes -liberty
++      FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
++    else
++      ifeq ($(feature-libbfd-liberty-z), 1)
++        EXTLIBS += -lbfd -lopcodes -liberty -lz
++        FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
++      endif
+     endif
++    $(call feature_check,disassembler-four-args)
+   endif
+-  $(call feature_check,disassembler-four-args)
+-endif
+-ifeq ($(feature-libbfd-buildid), 1)
+-  CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
+-else
+-  msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
++  ifeq ($(feature-libbfd-buildid), 1)
++    CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
++  else
++    msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
++  endif
+ endif
+ ifdef NO_DEMANGLE
+-- 
+2.40.1
+
diff --git a/queue-5.4/powerpc-pseries-fix-possible-memory-leak-in-ibmebus_.patch b/queue-5.4/powerpc-pseries-fix-possible-memory-leak-in-ibmebus_.patch
new file mode 100644 (file)
index 0000000..6c22099
--- /dev/null
@@ -0,0 +1,39 @@
+From 207e26220d2f38327b79d78e7de8816b4698c31e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 10 Nov 2022 09:19:29 +0800
+Subject: powerpc/pseries: fix possible memory leak in ibmebus_bus_init()
+
+From: ruanjinjie <ruanjinjie@huawei.com>
+
+[ Upstream commit afda85b963c12947e298ad85d757e333aa40fd74 ]
+
+If device_register() returns error in ibmebus_bus_init(), name of kobject
+which is allocated in dev_set_name() called in device_add() is leaked.
+
+As comment of device_add() says, it should call put_device() to drop
+the reference count that was set in device_initialize() when it fails,
+so the name can be freed in kobject_cleanup().
+
+Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://msgid.link/20221110011929.3709774-1-ruanjinjie@huawei.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/ibmebus.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
+index b91eb0929ed14..55569e3c9db72 100644
+--- a/arch/powerpc/platforms/pseries/ibmebus.c
++++ b/arch/powerpc/platforms/pseries/ibmebus.c
+@@ -450,6 +450,7 @@ static int __init ibmebus_bus_init(void)
+       if (err) {
+               printk(KERN_WARNING "%s: device_register returned %i\n",
+                      __func__, err);
++              put_device(&ibmebus_bus_device);
+               bus_unregister(&ibmebus_bus_type);
+               return err;
+-- 
+2.40.1
+
diff --git a/queue-5.4/scsi-target-iscsi-fix-buffer-overflow-in-lio_target_.patch b/queue-5.4/scsi-target-iscsi-fix-buffer-overflow-in-lio_target_.patch
new file mode 100644 (file)
index 0000000..a9c667a
--- /dev/null
@@ -0,0 +1,163 @@
+From 8f1de6fd26bd12dfc7eeee68ee8a3bd156341ae0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 22 Jul 2023 18:26:37 +0300
+Subject: scsi: target: iscsi: Fix buffer overflow in
+ lio_target_nacl_info_show()
+
+From: Konstantin Shelekhin <k.shelekhin@yadro.com>
+
+[ Upstream commit 801f287c93ff95582b0a2d2163f12870a2f076d4 ]
+
+The function lio_target_nacl_info_show() uses sprintf() in a loop to print
+details for every iSCSI connection in a session without checking for the
+buffer length. With enough iSCSI connections it's possible to overflow the
+buffer provided by configfs and corrupt the memory.
+
+This patch replaces sprintf() with sysfs_emit_at() that checks for buffer
+boundries.
+
+Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
+Link: https://lore.kernel.org/r/20230722152657.168859-2-k.shelekhin@yadro.com
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/target/iscsi/iscsi_target_configfs.c | 54 ++++++++++----------
+ 1 file changed, 27 insertions(+), 27 deletions(-)
+
+diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
+index 0fa1d57b26fa8..3cd671bbb9a41 100644
+--- a/drivers/target/iscsi/iscsi_target_configfs.c
++++ b/drivers/target/iscsi/iscsi_target_configfs.c
+@@ -508,102 +508,102 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
+       spin_lock_bh(&se_nacl->nacl_sess_lock);
+       se_sess = se_nacl->nacl_sess;
+       if (!se_sess) {
+-              rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
++              rb += sysfs_emit_at(page, rb, "No active iSCSI Session for Initiator"
+                       " Endpoint: %s\n", se_nacl->initiatorname);
+       } else {
+               sess = se_sess->fabric_sess_ptr;
+-              rb += sprintf(page+rb, "InitiatorName: %s\n",
++              rb += sysfs_emit_at(page, rb, "InitiatorName: %s\n",
+                       sess->sess_ops->InitiatorName);
+-              rb += sprintf(page+rb, "InitiatorAlias: %s\n",
++              rb += sysfs_emit_at(page, rb, "InitiatorAlias: %s\n",
+                       sess->sess_ops->InitiatorAlias);
+-              rb += sprintf(page+rb,
++              rb += sysfs_emit_at(page, rb,
+                             "LIO Session ID: %u   ISID: 0x%6ph  TSIH: %hu  ",
+                             sess->sid, sess->isid, sess->tsih);
+-              rb += sprintf(page+rb, "SessionType: %s\n",
++              rb += sysfs_emit_at(page, rb, "SessionType: %s\n",
+                               (sess->sess_ops->SessionType) ?
+                               "Discovery" : "Normal");
+-              rb += sprintf(page+rb, "Session State: ");
++              rb += sysfs_emit_at(page, rb, "Session State: ");
+               switch (sess->session_state) {
+               case TARG_SESS_STATE_FREE:
+-                      rb += sprintf(page+rb, "TARG_SESS_FREE\n");
++                      rb += sysfs_emit_at(page, rb, "TARG_SESS_FREE\n");
+                       break;
+               case TARG_SESS_STATE_ACTIVE:
+-                      rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
++                      rb += sysfs_emit_at(page, rb, "TARG_SESS_STATE_ACTIVE\n");
+                       break;
+               case TARG_SESS_STATE_LOGGED_IN:
+-                      rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
++                      rb += sysfs_emit_at(page, rb, "TARG_SESS_STATE_LOGGED_IN\n");
+                       break;
+               case TARG_SESS_STATE_FAILED:
+-                      rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
++                      rb += sysfs_emit_at(page, rb, "TARG_SESS_STATE_FAILED\n");
+                       break;
+               case TARG_SESS_STATE_IN_CONTINUE:
+-                      rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
++                      rb += sysfs_emit_at(page, rb, "TARG_SESS_STATE_IN_CONTINUE\n");
+                       break;
+               default:
+-                      rb += sprintf(page+rb, "ERROR: Unknown Session"
++                      rb += sysfs_emit_at(page, rb, "ERROR: Unknown Session"
+                                       " State!\n");
+                       break;
+               }
+-              rb += sprintf(page+rb, "---------------------[iSCSI Session"
++              rb += sysfs_emit_at(page, rb, "---------------------[iSCSI Session"
+                               " Values]-----------------------\n");
+-              rb += sprintf(page+rb, "  CmdSN/WR  :  CmdSN/WC  :  ExpCmdSN"
++              rb += sysfs_emit_at(page, rb, "  CmdSN/WR  :  CmdSN/WC  :  ExpCmdSN"
+                               "  :  MaxCmdSN  :     ITT    :     TTT\n");
+               max_cmd_sn = (u32) atomic_read(&sess->max_cmd_sn);
+-              rb += sprintf(page+rb, " 0x%08x   0x%08x   0x%08x   0x%08x"
++              rb += sysfs_emit_at(page, rb, " 0x%08x   0x%08x   0x%08x   0x%08x"
+                               "   0x%08x   0x%08x\n",
+                       sess->cmdsn_window,
+                       (max_cmd_sn - sess->exp_cmd_sn) + 1,
+                       sess->exp_cmd_sn, max_cmd_sn,
+                       sess->init_task_tag, sess->targ_xfer_tag);
+-              rb += sprintf(page+rb, "----------------------[iSCSI"
++              rb += sysfs_emit_at(page, rb, "----------------------[iSCSI"
+                               " Connections]-------------------------\n");
+               spin_lock(&sess->conn_lock);
+               list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
+-                      rb += sprintf(page+rb, "CID: %hu  Connection"
++                      rb += sysfs_emit_at(page, rb, "CID: %hu  Connection"
+                                       " State: ", conn->cid);
+                       switch (conn->conn_state) {
+                       case TARG_CONN_STATE_FREE:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_FREE\n");
+                               break;
+                       case TARG_CONN_STATE_XPT_UP:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_XPT_UP\n");
+                               break;
+                       case TARG_CONN_STATE_IN_LOGIN:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_IN_LOGIN\n");
+                               break;
+                       case TARG_CONN_STATE_LOGGED_IN:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_LOGGED_IN\n");
+                               break;
+                       case TARG_CONN_STATE_IN_LOGOUT:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_IN_LOGOUT\n");
+                               break;
+                       case TARG_CONN_STATE_LOGOUT_REQUESTED:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
+                               break;
+                       case TARG_CONN_STATE_CLEANUP_WAIT:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "TARG_CONN_STATE_CLEANUP_WAIT\n");
+                               break;
+                       default:
+-                              rb += sprintf(page+rb,
++                              rb += sysfs_emit_at(page, rb,
+                                       "ERROR: Unknown Connection State!\n");
+                               break;
+                       }
+-                      rb += sprintf(page+rb, "   Address %pISc %s", &conn->login_sockaddr,
++                      rb += sysfs_emit_at(page, rb, "   Address %pISc %s", &conn->login_sockaddr,
+                               (conn->network_transport == ISCSI_TCP) ?
+                               "TCP" : "SCTP");
+-                      rb += sprintf(page+rb, "  StatSN: 0x%08x\n",
++                      rb += sysfs_emit_at(page, rb, "  StatSN: 0x%08x\n",
+                               conn->stat_sn);
+               }
+               spin_unlock(&sess->conn_lock);
+-- 
+2.40.1
+
diff --git a/queue-5.4/selftests-tracing-fix-to-unmount-tracefs-for-recover.patch b/queue-5.4/selftests-tracing-fix-to-unmount-tracefs-for-recover.patch
new file mode 100644 (file)
index 0000000..9736a61
--- /dev/null
@@ -0,0 +1,65 @@
+From f2450f518a75a2d75cb2111782cd5415b248591a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 12 Sep 2023 10:10:39 +0900
+Subject: selftests: tracing: Fix to unmount tracefs for recovering environment
+
+From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
+
+[ Upstream commit 7e021da80f48582171029714f8a487347f29dddb ]
+
+Fix to unmount the tracefs if the ftracetest mounted it for recovering
+system environment. If the tracefs is already mounted, this does nothing.
+
+Suggested-by: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/all/29fce076-746c-4650-8358-b4e0fa215cf7@sirena.org.uk/
+Fixes: cbd965bde74c ("ftrace/selftests: Return the skip code when tracing directory not configured in kernel")
+Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
+Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
+Reviewed-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/testing/selftests/ftrace/ftracetest | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
+index 19e9236dec5e2..f2e1b2bfcf0b0 100755
+--- a/tools/testing/selftests/ftrace/ftracetest
++++ b/tools/testing/selftests/ftrace/ftracetest
+@@ -30,6 +30,9 @@ err_ret=1
+ # kselftest skip code is 4
+ err_skip=4
++# umount required
++UMOUNT_DIR=""
++
+ # cgroup RT scheduling prevents chrt commands from succeeding, which
+ # induces failures in test wakeup tests.  Disable for the duration of
+ # the tests.
+@@ -44,6 +47,9 @@ setup() {
+ cleanup() {
+   echo $sched_rt_runtime_orig > $sched_rt_runtime
++  if [ -n "${UMOUNT_DIR}" ]; then
++    umount ${UMOUNT_DIR} ||:
++  fi
+ }
+ errexit() { # message
+@@ -155,11 +161,13 @@ if [ -z "$TRACING_DIR" ]; then
+           mount -t tracefs nodev /sys/kernel/tracing ||
+             errexit "Failed to mount /sys/kernel/tracing"
+           TRACING_DIR="/sys/kernel/tracing"
++          UMOUNT_DIR=${TRACING_DIR}
+       # If debugfs exists, then so does /sys/kernel/debug
+       elif [ -d "/sys/kernel/debug" ]; then
+           mount -t debugfs nodev /sys/kernel/debug ||
+             errexit "Failed to mount /sys/kernel/debug"
+           TRACING_DIR="/sys/kernel/debug/tracing"
++          UMOUNT_DIR=${TRACING_DIR}
+       else
+           err_ret=$err_skip
+           errexit "debugfs and tracefs are not configured in this kernel"
+-- 
+2.40.1
+
diff --git a/queue-5.4/serial-cpm_uart-avoid-suspicious-locking.patch b/queue-5.4/serial-cpm_uart-avoid-suspicious-locking.patch
new file mode 100644 (file)
index 0000000..9a5e10d
--- /dev/null
@@ -0,0 +1,80 @@
+From 2fcd1f0c2fb797a86aa17c250045ce3f4d1739dd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 3 Aug 2023 15:56:42 +0200
+Subject: serial: cpm_uart: Avoid suspicious locking
+
+From: Christophe Leroy <christophe.leroy@csgroup.eu>
+
+[ Upstream commit 36ef11d311f405e55ad8e848c19b212ff71ef536 ]
+
+  CHECK   drivers/tty/serial/cpm_uart/cpm_uart_core.c
+drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock
+
+Allthough 'nolock' is not expected to change, sparse find the following
+form suspicious:
+
+       if (unlikely(nolock)) {
+               local_irq_save(flags);
+       } else {
+               spin_lock_irqsave(&pinfo->port.lock, flags);
+       }
+
+       cpm_uart_early_write(pinfo, s, count, true);
+
+       if (unlikely(nolock)) {
+               local_irq_restore(flags);
+       } else {
+               spin_unlock_irqrestore(&pinfo->port.lock, flags);
+       }
+
+Rewrite it a more obvious form:
+
+       if (unlikely(oops_in_progress)) {
+               local_irq_save(flags);
+               cpm_uart_early_write(pinfo, s, count, true);
+               local_irq_restore(flags);
+       } else {
+               spin_lock_irqsave(&pinfo->port.lock, flags);
+               cpm_uart_early_write(pinfo, s, count, true);
+               spin_unlock_irqrestore(&pinfo->port.lock, flags);
+       }
+
+Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
+Link: https://lore.kernel.org/r/f7da5cdc9287960185829cfef681a7d8614efa1f.1691068700.git.christophe.leroy@csgroup.eu
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/cpm_uart/cpm_uart_core.c | 13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+index de6d02f7abe2b..c37036fee231d 100644
+--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
++++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+@@ -1267,19 +1267,14 @@ static void cpm_uart_console_write(struct console *co, const char *s,
+ {
+       struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index];
+       unsigned long flags;
+-      int nolock = oops_in_progress;
+-      if (unlikely(nolock)) {
++      if (unlikely(oops_in_progress)) {
+               local_irq_save(flags);
+-      } else {
+-              spin_lock_irqsave(&pinfo->port.lock, flags);
+-      }
+-
+-      cpm_uart_early_write(pinfo, s, count, true);
+-
+-      if (unlikely(nolock)) {
++              cpm_uart_early_write(pinfo, s, count, true);
+               local_irq_restore(flags);
+       } else {
++              spin_lock_irqsave(&pinfo->port.lock, flags);
++              cpm_uart_early_write(pinfo, s, count, true);
+               spin_unlock_irqrestore(&pinfo->port.lock, flags);
+       }
+ }
+-- 
+2.40.1
+
index 383df5b617bbb2e48a2785bdb2c089ad177ba738..95488e34af98e9313eae4367e4b715136948ce99 100644 (file)
@@ -307,3 +307,49 @@ ixgbe-fix-timestamp-configuration-code.patch
 kcm-fix-error-handling-for-sock_dgram-in-kcm_sendmsg.patch
 drm-amd-display-fix-a-bug-when-searching-for-insert_above_mpcc.patch
 parisc-drop-loops_per_jiffy-from-per_cpu-struct.patch
+autofs-fix-memory-leak-of-waitqueues-in-autofs_catat.patch
+btrfs-output-extra-debug-info-if-we-failed-to-find-a.patch
+locks-fix-kasan-use-after-free-in-trace_event_raw_ev.patch
+acpica-add-aml_no_operand_resolve-flag-to-timer.patch
+kernel-fork-beware-of-__put_task_struct-calling-cont.patch
+acpi-video-add-backlight-native-dmi-quirk-for-lenovo.patch
+perf-smmuv3-enable-hisilicon-erratum-162001900-quirk.patch
+hw_breakpoint-fix-single-stepping-when-using-bpf_ove.patch
+devlink-remove-reload-failed-checks-in-params-get-se.patch
+wifi-ath9k-fix-printk-specifier.patch
+wifi-mwifiex-fix-fortify-warning.patch
+crypto-lib-mpi-avoid-null-pointer-deref-in-mpi_cmp_u.patch
+tpm_tis-resend-command-to-recover-from-data-transfer.patch
+mmc-sdhci-esdhc-imx-improve-esdhc_flag_err010450.patch
+alx-fix-oob-read-compiler-warning.patch
+wifi-mac80211_hwsim-drop-short-frames.patch
+libbpf-free-btf_vmlinux-when-closing-bpf_object.patch
+drm-exynos-fix-a-possible-null-pointer-dereference-d.patch
+bus-ti-sysc-configure-uart-quirks-for-k3-soc.patch
+md-raid1-fix-potential-oob-in-raid1_remove_disk.patch
+ext2-fix-datatype-of-block-number-in-ext2_xattr_set2.patch
+fs-jfs-prevent-double-free-in-dbunmount-after-failed.patch
+jfs-fix-invalid-free-of-jfs_ip-ipimap-i_imap-in-diun.patch
+powerpc-pseries-fix-possible-memory-leak-in-ibmebus_.patch
+media-dvb-usb-v2-af9035-fix-null-ptr-deref-in-af9035.patch
+media-dw2102-fix-null-ptr-deref-in-dw2102_i2c_transf.patch
+media-af9005-fix-null-ptr-deref-in-af9005_i2c_xfer.patch
+media-anysee-fix-null-ptr-deref-in-anysee_master_xfe.patch
+media-az6007-fix-null-ptr-deref-in-az6007_i2c_xfer.patch
+media-tuners-qt1010-replace-bug_on-with-a-regular-er.patch
+media-pci-cx23885-replace-bug-with-error-return.patch
+usb-gadget-fsl_qe_udc-validate-endpoint-index-for-ch.patch
+scsi-target-iscsi-fix-buffer-overflow-in-lio_target_.patch
+serial-cpm_uart-avoid-suspicious-locking.patch
+media-pci-ipu3-cio2-initialise-timing-struct-to-avoi.patch
+kobject-add-sanity-check-for-kset-kobj.ktype-in-kset.patch
+tools-features-add-feature-test-to-check-if-libbfd-h.patch
+perf-jevents-make-build-dependency-on-test-jsons.patch
+perf-tools-add-an-option-to-build-without-libbfd.patch
+perf-jevents-switch-build-to-use-jevents.py.patch
+perf-build-update-build-rule-for-generated-files.patch
+btrfs-move-btrfs_pinned_by_swapfile-prototype-into-v.patch
+btrfs-add-a-helper-to-read-the-superblock-metadata_u.patch
+btrfs-compare-the-correct-fsid-metadata_uuid-in-btrf.patch
+selftests-tracing-fix-to-unmount-tracefs-for-recover.patch
+md-raid1-fix-error-iso-c90-forbids-mixed-declaration.patch
diff --git a/queue-5.4/tools-features-add-feature-test-to-check-if-libbfd-h.patch b/queue-5.4/tools-features-add-feature-test-to-check-if-libbfd-h.patch
new file mode 100644 (file)
index 0000000..710d284
--- /dev/null
@@ -0,0 +1,132 @@
+From a22950e751cde187a5650f9029720e7fa02ea97c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 3 Sep 2020 13:44:39 -0300
+Subject: tools features: Add feature test to check if libbfd has buildid
+ support
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+[ Upstream commit e71e19a9ea70952a53d58a99971820ce6c1794a8 ]
+
+Which is needed by the PE executable support, for instance.
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Ian Rogers <irogers@google.com>
+Cc: Jacek Caban <jacek@codeweavers.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Mark Rutland <mark.rutland@arm.com>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Remi Bernon <rbernon@codeweavers.com>
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Stable-dep-of: 7822a8913f4c ("perf build: Update build rule for generated files")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ tools/build/Makefile.feature              | 2 ++
+ tools/build/feature/Makefile              | 4 ++++
+ tools/build/feature/test-all.c            | 5 +++++
+ tools/build/feature/test-libbfd-buildid.c | 8 ++++++++
+ tools/perf/Makefile.config                | 6 ++++++
+ 5 files changed, 25 insertions(+)
+ create mode 100644 tools/build/feature/test-libbfd-buildid.c
+
+diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
+index 1ea26bb8c5791..6714c886940f8 100644
+--- a/tools/build/Makefile.feature
++++ b/tools/build/Makefile.feature
+@@ -42,6 +42,7 @@ FEATURE_TESTS_BASIC :=                  \
+         gtk2-infobar                    \
+         libaudit                        \
+         libbfd                          \
++        libbfd-buildid                        \
+         libcap                          \
+         libelf                          \
+         libelf-getphdrnum               \
+@@ -110,6 +111,7 @@ FEATURE_DISPLAY ?=              \
+          gtk2                   \
+          libaudit               \
+          libbfd                 \
++         libbfd-buildid               \
+          libcap                 \
+          libelf                 \
+          libnuma                \
+diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
+index 88392219d425e..8104e505efde6 100644
+--- a/tools/build/feature/Makefile
++++ b/tools/build/feature/Makefile
+@@ -15,6 +15,7 @@ FILES=                                          \
+          test-hello.bin                         \
+          test-libaudit.bin                      \
+          test-libbfd.bin                        \
++         test-libbfd-buildid.bin              \
+          test-disassembler-four-args.bin        \
+          test-reallocarray.bin                        \
+          test-libbfd-liberty.bin                \
+@@ -223,6 +224,9 @@ $(OUTPUT)test-libpython.bin:
+ $(OUTPUT)test-libbfd.bin:
+       $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
++$(OUTPUT)test-libbfd-buildid.bin:
++      $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
++
+ $(OUTPUT)test-disassembler-four-args.bin:
+       $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
+diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
+index 6eaeaf2da36ea..039bd2fbe7d9e 100644
+--- a/tools/build/feature/test-all.c
++++ b/tools/build/feature/test-all.c
+@@ -90,6 +90,10 @@
+ # include "test-libbfd.c"
+ #undef main
++#define main main_test_libbfd_buildid
++# include "test-libbfd-buildid.c"
++#undef main
++
+ #define main main_test_backtrace
+ # include "test-backtrace.c"
+ #undef main
+@@ -208,6 +212,7 @@ int main(int argc, char *argv[])
+       main_test_gtk2(argc, argv);
+       main_test_gtk2_infobar(argc, argv);
+       main_test_libbfd();
++      main_test_libbfd_buildid();
+       main_test_backtrace();
+       main_test_libnuma();
+       main_test_numa_num_possible_cpus();
+diff --git a/tools/build/feature/test-libbfd-buildid.c b/tools/build/feature/test-libbfd-buildid.c
+new file mode 100644
+index 0000000000000..157644b04c052
+--- /dev/null
++++ b/tools/build/feature/test-libbfd-buildid.c
+@@ -0,0 +1,8 @@
++// SPDX-License-Identifier: GPL-2.0
++#include <bfd.h>
++
++int main(void)
++{
++      bfd *abfd = bfd_openr("Pedro", 0);
++      return abfd && (!abfd->build_id || abfd->build_id->size > 0x506564726f);
++}
+diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
+index b94d9afad3f79..cc11050420496 100644
+--- a/tools/perf/Makefile.config
++++ b/tools/perf/Makefile.config
+@@ -775,6 +775,12 @@ else
+   $(call feature_check,disassembler-four-args)
+ endif
++ifeq ($(feature-libbfd-buildid), 1)
++  CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
++else
++  msg := $(warning Old version of libbfd/binutils things like PE executable profiling will not be available);
++endif
++
+ ifdef NO_DEMANGLE
+   CFLAGS += -DNO_DEMANGLE
+ else
+-- 
+2.40.1
+
diff --git a/queue-5.4/tpm_tis-resend-command-to-recover-from-data-transfer.patch b/queue-5.4/tpm_tis-resend-command-to-recover-from-data-transfer.patch
new file mode 100644 (file)
index 0000000..eda798b
--- /dev/null
@@ -0,0 +1,50 @@
+From d9090c1c1333bb233be4814fc0956a5803c617b8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 13 Jun 2023 20:02:59 +0200
+Subject: tpm_tis: Resend command to recover from data transfer errors
+
+From: Alexander Steffen <Alexander.Steffen@infineon.com>
+
+[ Upstream commit 280db21e153d8810ce3b93640c63ae922bcb9e8e ]
+
+Similar to the transmission of TPM responses, also the transmission of TPM
+commands may become corrupted. Instead of aborting when detecting such
+issues, try resending the command again.
+
+Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
+Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
+Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/char/tpm/tpm_tis_core.c | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
+index ef47d1d58ac3a..a084f732c1804 100644
+--- a/drivers/char/tpm/tpm_tis_core.c
++++ b/drivers/char/tpm/tpm_tis_core.c
+@@ -421,10 +421,17 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
+       int rc;
+       u32 ordinal;
+       unsigned long dur;
+-
+-      rc = tpm_tis_send_data(chip, buf, len);
+-      if (rc < 0)
+-              return rc;
++      unsigned int try;
++
++      for (try = 0; try < TPM_RETRY; try++) {
++              rc = tpm_tis_send_data(chip, buf, len);
++              if (rc >= 0)
++                      /* Data transfer done successfully */
++                      break;
++              else if (rc != -EIO)
++                      /* Data transfer failed, not recoverable */
++                      return rc;
++      }
+       /* go and do it */
+       rc = tpm_tis_write8(priv, TPM_STS(priv->locality), TPM_STS_GO);
+-- 
+2.40.1
+
diff --git a/queue-5.4/usb-gadget-fsl_qe_udc-validate-endpoint-index-for-ch.patch b/queue-5.4/usb-gadget-fsl_qe_udc-validate-endpoint-index-for-ch.patch
new file mode 100644 (file)
index 0000000..80e3d78
--- /dev/null
@@ -0,0 +1,37 @@
+From 18786884ee700d9277c71db2d51b8705164164bb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 28 Jun 2023 16:15:11 +0800
+Subject: usb: gadget: fsl_qe_udc: validate endpoint index for ch9 udc
+
+From: Ma Ke <make_ruc2021@163.com>
+
+[ Upstream commit ce9daa2efc0872a9a68ea51dc8000df05893ef2e ]
+
+We should verify the bound of the array to assure that host
+may not manipulate the index to point past endpoint array.
+
+Signed-off-by: Ma Ke <make_ruc2021@163.com>
+Acked-by: Li Yang <leoyang.li@nxp.com>
+Link: https://lore.kernel.org/r/20230628081511.186850-1-make_ruc2021@163.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/usb/gadget/udc/fsl_qe_udc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c
+index 2707be6282988..63109c6e55068 100644
+--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
++++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
+@@ -1950,6 +1950,8 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value,
+       } else if ((request_type & USB_RECIP_MASK) == USB_RECIP_ENDPOINT) {
+               /* Get endpoint status */
+               int pipe = index & USB_ENDPOINT_NUMBER_MASK;
++              if (pipe >= USB_MAX_ENDPOINTS)
++                      goto stall;
+               struct qe_ep *target_ep = &udc->eps[pipe];
+               u16 usep;
+-- 
+2.40.1
+
diff --git a/queue-5.4/wifi-ath9k-fix-printk-specifier.patch b/queue-5.4/wifi-ath9k-fix-printk-specifier.patch
new file mode 100644 (file)
index 0000000..962db65
--- /dev/null
@@ -0,0 +1,68 @@
+From 59437c665a92fcdae92e6c9589222a83bbb735f4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 23 Jul 2023 12:04:02 +0800
+Subject: wifi: ath9k: fix printk specifier
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Dongliang Mu <dzm91@hust.edu.cn>
+
+[ Upstream commit 061115fbfb2ce5870c9a004d68dc63138c07c782 ]
+
+Smatch reports:
+
+ath_pci_probe() warn: argument 4 to %lx specifier is cast from pointer
+ath_ahb_probe() warn: argument 4 to %lx specifier is cast from pointer
+
+Fix it by modifying %lx to %p in the printk format string.
+
+Note that with this change, the pointer address will be printed as a
+hashed value by default. This is appropriate because the kernel
+should not leak kernel pointers to user space in an informational
+message. If someone wants to see the real address for debugging
+purposes, this can be achieved with the no_hash_pointers kernel option.
+
+Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
+Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
+Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
+Link: https://lore.kernel.org/r/20230723040403.296723-1-dzm91@hust.edu.cn
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/ath/ath9k/ahb.c | 4 ++--
+ drivers/net/wireless/ath/ath9k/pci.c | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
+index 63019c3de034d..26023e3b4b9df 100644
+--- a/drivers/net/wireless/ath/ath9k/ahb.c
++++ b/drivers/net/wireless/ath/ath9k/ahb.c
+@@ -136,8 +136,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
+       ah = sc->sc_ah;
+       ath9k_hw_name(ah, hw_name, sizeof(hw_name));
+-      wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n",
+-                 hw_name, (unsigned long)mem, irq);
++      wiphy_info(hw->wiphy, "%s mem=0x%p, irq=%d\n",
++                 hw_name, mem, irq);
+       return 0;
+diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
+index 92b2dd396436a..cb3318bd3cad2 100644
+--- a/drivers/net/wireless/ath/ath9k/pci.c
++++ b/drivers/net/wireless/ath/ath9k/pci.c
+@@ -993,8 +993,8 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+       sc->sc_ah->msi_reg = 0;
+       ath9k_hw_name(sc->sc_ah, hw_name, sizeof(hw_name));
+-      wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n",
+-                 hw_name, (unsigned long)sc->mem, pdev->irq);
++      wiphy_info(hw->wiphy, "%s mem=0x%p, irq=%d\n",
++                 hw_name, sc->mem, pdev->irq);
+       return 0;
+-- 
+2.40.1
+
diff --git a/queue-5.4/wifi-mac80211_hwsim-drop-short-frames.patch b/queue-5.4/wifi-mac80211_hwsim-drop-short-frames.patch
new file mode 100644 (file)
index 0000000..14fe18f
--- /dev/null
@@ -0,0 +1,49 @@
+From 950d8771333a2dd52bd674e9a45953f2ac2753d4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 15 Aug 2023 21:28:01 +0200
+Subject: wifi: mac80211_hwsim: drop short frames
+
+From: Johannes Berg <johannes.berg@intel.com>
+
+[ Upstream commit fba360a047d5eeeb9d4b7c3a9b1c8308980ce9a6 ]
+
+While technically some control frames like ACK are shorter and
+end after Address 1, such frames shouldn't be forwarded through
+wmediumd or similar userspace, so require the full 3-address
+header to avoid accessing invalid memory if shorter frames are
+passed in.
+
+Reported-by: syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com
+Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/mac80211_hwsim.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
+index f80b1d57d6c38..a21739b2f44e6 100644
+--- a/drivers/net/wireless/mac80211_hwsim.c
++++ b/drivers/net/wireless/mac80211_hwsim.c
+@@ -3367,14 +3367,15 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
+       frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]);
+       frame_data = (void *)nla_data(info->attrs[HWSIM_ATTR_FRAME]);
++      if (frame_data_len < sizeof(struct ieee80211_hdr_3addr) ||
++          frame_data_len > IEEE80211_MAX_DATA_LEN)
++              goto err;
++
+       /* Allocate new skb here */
+       skb = alloc_skb(frame_data_len, GFP_KERNEL);
+       if (skb == NULL)
+               goto err;
+-      if (frame_data_len > IEEE80211_MAX_DATA_LEN)
+-              goto err;
+-
+       /* Copy the data */
+       skb_put_data(skb, frame_data, frame_data_len);
+-- 
+2.40.1
+
diff --git a/queue-5.4/wifi-mwifiex-fix-fortify-warning.patch b/queue-5.4/wifi-mwifiex-fix-fortify-warning.patch
new file mode 100644 (file)
index 0000000..53e2dd9
--- /dev/null
@@ -0,0 +1,87 @@
+From 1703b5ccdd93b0aca577c235da7d269d18db7597 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 29 Jun 2023 11:51:01 +0300
+Subject: wifi: mwifiex: fix fortify warning
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Dmitry Antipov <dmantipov@yandex.ru>
+
+[ Upstream commit dcce94b80a954a8968ff29fafcfb066d6197fa9a ]
+
+When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y,
+I've noticed the following:
+
+In function ‘fortify_memcpy_chk’,
+    inlined from ‘mwifiex_construct_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:765:3,
+    inlined from ‘mwifiex_send_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:856:6:
+./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’
+declared with attribute warning: detected read beyond size of field (2nd parameter);
+maybe use struct_group()? [-Wattribute-warning]
+  529 |                         __read_overflow2_field(q_size_field, size);
+      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The compiler actually complains on:
+
+memmove(pos + ETH_ALEN, &mgmt->u.action.category,
+       sizeof(mgmt->u.action.u.tdls_discover_resp));
+
+and it happens because the fortification logic interprets this
+as an attempt to overread 1-byte 'u.action.category' member of
+'struct ieee80211_mgmt'. To silence this warning, it's enough
+to pass an address of 'u.action' itself instead of an address
+of its first member.
+
+This also fixes an improper usage of 'sizeof()'. Since 'skb' is
+extended with 'sizeof(mgmt->u.action.u.tdls_discover_resp) + 1'
+bytes (where 1 is actually 'sizeof(mgmt->u.action.category)'),
+I assume that the same number of bytes should be copied.
+
+Suggested-by: Brian Norris <briannorris@chromium.org>
+Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
+Reviewed-by: Brian Norris <briannorris@chromium.org>
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://lore.kernel.org/r/20230629085115.180499-2-dmantipov@yandex.ru
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/marvell/mwifiex/tdls.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/wireless/marvell/mwifiex/tdls.c b/drivers/net/wireless/marvell/mwifiex/tdls.c
+index f8f282ce39bd4..17f8379351923 100644
+--- a/drivers/net/wireless/marvell/mwifiex/tdls.c
++++ b/drivers/net/wireless/marvell/mwifiex/tdls.c
+@@ -734,6 +734,7 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,
+       int ret;
+       u16 capab;
+       struct ieee80211_ht_cap *ht_cap;
++      unsigned int extra;
+       u8 radio, *pos;
+       capab = priv->curr_bss_params.bss_descriptor.cap_info_bitmap;
+@@ -752,7 +753,10 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,
+       switch (action_code) {
+       case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
+-              skb_put(skb, sizeof(mgmt->u.action.u.tdls_discover_resp) + 1);
++              /* See the layout of 'struct ieee80211_mgmt'. */
++              extra = sizeof(mgmt->u.action.u.tdls_discover_resp) +
++                      sizeof(mgmt->u.action.category);
++              skb_put(skb, extra);
+               mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
+               mgmt->u.action.u.tdls_discover_resp.action_code =
+                                             WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
+@@ -761,8 +765,7 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,
+               mgmt->u.action.u.tdls_discover_resp.capability =
+                                                            cpu_to_le16(capab);
+               /* move back for addr4 */
+-              memmove(pos + ETH_ALEN, &mgmt->u.action.category,
+-                      sizeof(mgmt->u.action.u.tdls_discover_resp));
++              memmove(pos + ETH_ALEN, &mgmt->u.action, extra);
+               /* init address 4 */
+               eth_broadcast_addr(pos);
+-- 
+2.40.1
+