From 7661724b37b47b554445513978807ca8172d0863 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 17 Feb 2022 22:28:46 -0500 Subject: [PATCH] Fixes for 5.16 Signed-off-by: Sasha Levin --- ...x-unmet-dependency-on-gpiolib-for-sn.patch | 51 +++ ...-incomplete-fix-to-avoid-uaf-and-npd.patch | 90 +++++ ..._lock-before-calling-cifs_put_tcp_se.patch | 52 +++ ...ort-to-check-whether-the-system-is-s.patch | 66 ++++ ...-s3-or-s0ix-if-system-is-configured-.patch | 57 +++ ...-users-about-potential-s0ix-problems.patch | 105 ++++++ ...-amdgpu-fix-logic-inversion-in-check.patch | 39 +++ ...kleak-use-noinstr-in-favor-of-notrac.patch | 68 ++++ ...test-fix-vdso_test_abi-return-status.patch | 292 ++++++++++++++++ ...kselftest-signal-all-child-processes.patch | 54 +++ ...it-tool-import-missing-importlib.abc.patch | 45 +++ ...te-christian-brauner-s-email-address.patch | 35 ++ ...e802154-at86rf230-stop-leaking-skb-s.patch | 74 ++++ ...not-refer-to-skb-after-passing-it-on.patch | 40 +++ ...ble-use-after-free-in-controller-res.patch | 63 ++++ ...ssible-use-after-free-in-transport-e.patch | 39 +++ ...sible-use-after-free-in-transport-er.patch | 40 +++ ...fix-unmet-dependency-on-regmap-for-g.patch | 49 +++ ...amd-pmc-correct-usage-of-smu-version.patch | 65 ++++ ...t-fix-possible-circular-locking-depe.patch | 254 ++++++++++++++ ...chscreen_dmi-add-info-for-the-rwc-na.patch | 66 ++++ ..._quota_sync-return-errors-from-sync_.patch | 47 +++ ...wake-up-dev-random-writers-after-zap.patch | 42 +++ ...ync-async_synchronize_full-on-module.patch | 153 ++++++++ ...cate-device-s-budget-map-on-queue-de.patch | 120 +++++++ ...use-after-free-for-aborted-ssp-stp-s.patch | 67 ++++ ...use-after-free-for-aborted-tmf-sas_t.patch | 52 +++ ...x-double-completion-for-sata-devices.patch | 147 ++++++++ ...ter-reduce-zone-stress-test-running-.patch | 71 ++++ ...2-add-missing-dependency-in-makefile.patch | 46 +++ ...2-print-also-errno-in-failure-messag.patch | 44 +++ ...2-skip-testcases-that-fail-with-eopn.patch | 53 +++ ...crease-test-timeout-so-that-all-test.patch | 49 +++ ...incore.check_file_mmap-when-fs-lacks.patch | 69 ++++ ...dapt-the-situation-that-dev-zram0-is.patch | 329 ++++++++++++++++++ ...kip-max_comp_streams-interface-on-ne.patch | 75 ++++ ....sh-fix-compression-ratio-calculatio.patch | 84 +++++ queue-5.16/series | 40 +++ ...super-abort-when-sync_filesystem-ret.patch | 76 ++++ ...ilesystem-return-errors-from-sync_fs.patch | 65 ++++ ...treamline-and-fix-pv-cpu-enumeration.patch | 106 ++++++ 41 files changed, 3379 insertions(+) create mode 100644 queue-5.16/asoc-mediatek-fix-unmet-dependency-on-gpiolib-for-sn.patch create mode 100644 queue-5.16/ax25-improve-the-incomplete-fix-to-avoid-uaf-and-npd.patch create mode 100644 queue-5.16/cifs-unlock-chan_lock-before-calling-cifs_put_tcp_se.patch create mode 100644 queue-5.16/drm-amd-add-support-to-check-whether-the-system-is-s.patch create mode 100644 queue-5.16/drm-amd-only-run-s3-or-s0ix-if-system-is-configured-.patch create mode 100644 queue-5.16/drm-amd-warn-users-about-potential-s0ix-problems.patch create mode 100644 queue-5.16/drm-amdgpu-fix-logic-inversion-in-check.patch create mode 100644 queue-5.16/gcc-plugins-stackleak-use-noinstr-in-favor-of-notrac.patch create mode 100644 queue-5.16/kselftest-fix-vdso_test_abi-return-status.patch create mode 100644 queue-5.16/kselftest-signal-all-child-processes.patch create mode 100644 queue-5.16/kunit-tool-import-missing-importlib.abc.patch create mode 100644 queue-5.16/mailmap-update-christian-brauner-s-email-address.patch create mode 100644 queue-5.16/net-ieee802154-at86rf230-stop-leaking-skb-s.patch create mode 100644 queue-5.16/net-sparx5-do-not-refer-to-skb-after-passing-it-on.patch create mode 100644 queue-5.16/nvme-fix-a-possible-use-after-free-in-controller-res.patch create mode 100644 queue-5.16/nvme-rdma-fix-possible-use-after-free-in-transport-e.patch create mode 100644 queue-5.16/nvme-tcp-fix-possible-use-after-free-in-transport-er.patch create mode 100644 queue-5.16/pinctrl-bcm63xx-fix-unmet-dependency-on-regmap-for-g.patch create mode 100644 queue-5.16/platform-x86-amd-pmc-correct-usage-of-smu-version.patch create mode 100644 queue-5.16/platform-x86-isst-fix-possible-circular-locking-depe.patch create mode 100644 queue-5.16/platform-x86-touchscreen_dmi-add-info-for-the-rwc-na.patch create mode 100644 queue-5.16/quota-make-dquot_quota_sync-return-errors-from-sync_.patch create mode 100644 queue-5.16/random-wake-up-dev-random-writers-after-zap.patch create mode 100644 queue-5.16/revert-module-async-async_synchronize_full-on-module.patch create mode 100644 queue-5.16/scsi-core-reallocate-device-s-budget-map-on-queue-de.patch create mode 100644 queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-ssp-stp-s.patch create mode 100644 queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-tmf-sas_t.patch create mode 100644 queue-5.16/scsi-pm80xx-fix-double-completion-for-sata-devices.patch create mode 100644 queue-5.16/selftests-netfilter-reduce-zone-stress-test-running-.patch create mode 100644 queue-5.16/selftests-openat2-add-missing-dependency-in-makefile.patch create mode 100644 queue-5.16/selftests-openat2-print-also-errno-in-failure-messag.patch create mode 100644 queue-5.16/selftests-openat2-skip-testcases-that-fail-with-eopn.patch create mode 100644 queue-5.16/selftests-rtc-increase-test-timeout-so-that-all-test.patch create mode 100644 queue-5.16/selftests-skip-mincore.check_file_mmap-when-fs-lacks.patch create mode 100644 queue-5.16/selftests-zram-adapt-the-situation-that-dev-zram0-is.patch create mode 100644 queue-5.16/selftests-zram-skip-max_comp_streams-interface-on-ne.patch create mode 100644 queue-5.16/selftests-zram01.sh-fix-compression-ratio-calculatio.patch create mode 100644 queue-5.16/vfs-make-freeze_super-abort-when-sync_filesystem-ret.patch create mode 100644 queue-5.16/vfs-make-sync_filesystem-return-errors-from-sync_fs.patch create mode 100644 queue-5.16/x86-xen-streamline-and-fix-pv-cpu-enumeration.patch diff --git a/queue-5.16/asoc-mediatek-fix-unmet-dependency-on-gpiolib-for-sn.patch b/queue-5.16/asoc-mediatek-fix-unmet-dependency-on-gpiolib-for-sn.patch new file mode 100644 index 00000000000..74df661b20a --- /dev/null +++ b/queue-5.16/asoc-mediatek-fix-unmet-dependency-on-gpiolib-for-sn.patch @@ -0,0 +1,51 @@ +From 5d27577bf7275fe25070abdf46dfb85a4a219c77 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 17 Jan 2022 00:03:24 -0500 +Subject: ASoC: mediatek: fix unmet dependency on GPIOLIB for SND_SOC_DMIC + +From: Julian Braha + +[ Upstream commit 579b2c8f72d974f27d85bbd53846f34675ee3b01 ] + +When SND_SOC_MT8195_MT6359_RT1011_RT5682 is selected, +and GPIOLIB is not selected, +Kbuild gives the following warning: + +WARNING: unmet direct dependencies detected for SND_SOC_DMIC + Depends on [n]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && GPIOLIB [=n] + Selected by [y]: + - SND_SOC_MT8195_MT6359_RT1011_RT5682 [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && I2C [=y] && SND_SOC_MT8195 [=y] && MTK_PMIC_WRAP [=y] + +This is because SND_SOC_MT8195_MT6359_RT1011_RT5682 +selects SND_SOC_DMIC without selecting or depending on +GPIOLIB, depsite SND_SOC_DMIC depending on GPIOLIB. + +This unmet dependency bug was detected by Kismet, +a static analysis tool for Kconfig. Please advise +if this is not the appropriate solution. + +Signed-off-by: Julian Braha +Reviewed-by: Tzung-Bi Shih +Link: https://lore.kernel.org/r/20220117050324.68371-1-julianbraha@gmail.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/mediatek/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig +index 3b1ddea26a9ef..76f191ec7bf84 100644 +--- a/sound/soc/mediatek/Kconfig ++++ b/sound/soc/mediatek/Kconfig +@@ -215,7 +215,7 @@ config SND_SOC_MT8195_MT6359_RT1019_RT5682 + + config SND_SOC_MT8195_MT6359_RT1011_RT5682 + tristate "ASoC Audio driver for MT8195 with MT6359 RT1011 RT5682 codec" +- depends on I2C ++ depends on I2C && GPIOLIB + depends on SND_SOC_MT8195 && MTK_PMIC_WRAP + select SND_SOC_MT6359 + select SND_SOC_RT1011 +-- +2.34.1 + diff --git a/queue-5.16/ax25-improve-the-incomplete-fix-to-avoid-uaf-and-npd.patch b/queue-5.16/ax25-improve-the-incomplete-fix-to-avoid-uaf-and-npd.patch new file mode 100644 index 00000000000..941746684f6 --- /dev/null +++ b/queue-5.16/ax25-improve-the-incomplete-fix-to-avoid-uaf-and-npd.patch @@ -0,0 +1,90 @@ +From 722774ac705342923fb8fe215314ad2177bd289f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 28 Jan 2022 12:47:15 +0800 +Subject: ax25: improve the incomplete fix to avoid UAF and NPD bugs + +From: Duoming Zhou + +[ Upstream commit 4e0f718daf97d47cf7dec122da1be970f145c809 ] + +The previous commit 1ade48d0c27d ("ax25: NPD bug when detaching +AX25 device") introduce lock_sock() into ax25_kill_by_device to +prevent NPD bug. But the concurrency NPD or UAF bug will occur, +when lock_sock() or release_sock() dereferences the ax25_cb->sock. + +The NULL pointer dereference bug can be shown as below: + +ax25_kill_by_device() | ax25_release() + | ax25_destroy_socket() + | ax25_cb_del() + ... | ... + | ax25->sk=NULL; + lock_sock(s->sk); //(1) | + s->ax25_dev = NULL; | ... + release_sock(s->sk); //(2) | + ... | + +The root cause is that the sock is set to null before dereference +site (1) or (2). Therefore, this patch extracts the ax25_cb->sock +in advance, and uses ax25_list_lock to protect it, which can synchronize +with ax25_cb_del() and ensure the value of sock is not null before +dereference sites. + +The concurrency UAF bug can be shown as below: + +ax25_kill_by_device() | ax25_release() + | ax25_destroy_socket() + ... | ... + | sock_put(sk); //FREE + lock_sock(s->sk); //(1) | + s->ax25_dev = NULL; | ... + release_sock(s->sk); //(2) | + ... | + +The root cause is that the sock is released before dereference +site (1) or (2). Therefore, this patch uses sock_hold() to increase +the refcount of sock and uses ax25_list_lock to protect it, which +can synchronize with ax25_cb_del() in ax25_destroy_socket() and +ensure the sock wil not be released before dereference sites. + +Signed-off-by: Duoming Zhou +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/ax25/af_ax25.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c +index 02f43f3e2c564..44a8730c26acc 100644 +--- a/net/ax25/af_ax25.c ++++ b/net/ax25/af_ax25.c +@@ -77,6 +77,7 @@ static void ax25_kill_by_device(struct net_device *dev) + { + ax25_dev *ax25_dev; + ax25_cb *s; ++ struct sock *sk; + + if ((ax25_dev = ax25_dev_ax25dev(dev)) == NULL) + return; +@@ -85,13 +86,15 @@ static void ax25_kill_by_device(struct net_device *dev) + again: + ax25_for_each(s, &ax25_list) { + if (s->ax25_dev == ax25_dev) { ++ sk = s->sk; ++ sock_hold(sk); + spin_unlock_bh(&ax25_list_lock); +- lock_sock(s->sk); ++ lock_sock(sk); + s->ax25_dev = NULL; +- release_sock(s->sk); ++ release_sock(sk); + ax25_disconnect(s, ENETUNREACH); + spin_lock_bh(&ax25_list_lock); +- ++ sock_put(sk); + /* The entry could have been deleted from the + * list meanwhile and thus the next pointer is + * no longer valid. Play it safe and restart +-- +2.34.1 + diff --git a/queue-5.16/cifs-unlock-chan_lock-before-calling-cifs_put_tcp_se.patch b/queue-5.16/cifs-unlock-chan_lock-before-calling-cifs_put_tcp_se.patch new file mode 100644 index 00000000000..3842bdda886 --- /dev/null +++ b/queue-5.16/cifs-unlock-chan_lock-before-calling-cifs_put_tcp_se.patch @@ -0,0 +1,52 @@ +From 64b09ba8409b4f559cf94c0f4008ea50dac37a67 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 29 Jan 2022 09:32:33 +0000 +Subject: cifs: unlock chan_lock before calling cifs_put_tcp_session + +From: Shyam Prasad N + +[ Upstream commit 489f710a738e24d887823a010b8b206b4124e26f ] + +While removing an smb session, we need to free up the +tcp session for each channel for that session. We were +doing this with chan_lock held. This results in a +cyclic dependency with cifs_tcp_ses_lock. + +For now, unlock the chan_lock temporarily before calling +cifs_put_tcp_session. This should not cause any problem +for now, since we do not remove channels anywhere else. +And this code segment will not be called by two threads. + +When we do implement the code for removing channels, we +will need to execute proper ref counting here. + +Signed-off-by: Shyam Prasad N +Signed-off-by: Steve French +Signed-off-by: Sasha Levin +--- + fs/cifs/connect.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c +index cefd0e9623ba9..fb69524a992bb 100644 +--- a/fs/cifs/connect.c ++++ b/fs/cifs/connect.c +@@ -1796,13 +1796,9 @@ void cifs_put_smb_ses(struct cifs_ses *ses) + int i; + + for (i = 1; i < chan_count; i++) { +- /* +- * note: for now, we're okay accessing ses->chans +- * without chan_lock. But when chans can go away, we'll +- * need to introduce ref counting to make sure that chan +- * is not freed from under us. +- */ ++ spin_unlock(&ses->chan_lock); + cifs_put_tcp_session(ses->chans[i].server, 0); ++ spin_lock(&ses->chan_lock); + ses->chans[i].server = NULL; + } + } +-- +2.34.1 + diff --git a/queue-5.16/drm-amd-add-support-to-check-whether-the-system-is-s.patch b/queue-5.16/drm-amd-add-support-to-check-whether-the-system-is-s.patch new file mode 100644 index 00000000000..d69acb15399 --- /dev/null +++ b/queue-5.16/drm-amd-add-support-to-check-whether-the-system-is-s.patch @@ -0,0 +1,66 @@ +From 2b48c89fd236e8360218863f86f8829499a200de Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 25 Jan 2022 21:35:09 -0600 +Subject: drm/amd: add support to check whether the system is set to s3 + +From: Mario Limonciello + +[ Upstream commit f52a2b8badbd24faf73a13c9c07fdb9d07352944 ] + +This will be used to help make decisions on what to do in +misconfigured systems. + +v2: squash in semicolon fix from Stephen Rothwell + +Signed-off-by: Mario Limonciello +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ + drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 13 +++++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h +index 0a5a5370a2004..f59121ec26485 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h +@@ -1419,9 +1419,11 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, + #endif + + #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) ++bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev); + bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); + #else + static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } ++static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; } + #endif + + int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +index b19d407518024..0e12315fa0cb8 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +@@ -1032,6 +1032,19 @@ void amdgpu_acpi_detect(void) + } + + #if IS_ENABLED(CONFIG_SUSPEND) ++/** ++ * amdgpu_acpi_is_s3_active ++ * ++ * @adev: amdgpu_device_pointer ++ * ++ * returns true if supported, false if not. ++ */ ++bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) ++{ ++ return !(adev->flags & AMD_IS_APU) || ++ (pm_suspend_target_state == PM_SUSPEND_MEM); ++} ++ + /** + * amdgpu_acpi_is_s0ix_active + * +-- +2.34.1 + diff --git a/queue-5.16/drm-amd-only-run-s3-or-s0ix-if-system-is-configured-.patch b/queue-5.16/drm-amd-only-run-s3-or-s0ix-if-system-is-configured-.patch new file mode 100644 index 00000000000..2c46345cfe1 --- /dev/null +++ b/queue-5.16/drm-amd-only-run-s3-or-s0ix-if-system-is-configured-.patch @@ -0,0 +1,57 @@ +From 7aeb9f8d1e8ce135d00225d483c2cc50aaef1888 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 25 Jan 2022 21:37:57 -0600 +Subject: drm/amd: Only run s3 or s0ix if system is configured properly + +From: Mario Limonciello + +[ Upstream commit 04ef860469fda6a646dc841190d05b31fae68e8c ] + +This will cause misconfigured systems to not run the GPU suspend +routines. + +* In APUs that are properly configured system will go into s2idle. +* In APUs that are intended to be S3 but user selects + s2idle the GPU will stay fully powered for the suspend. +* In APUs that are intended to be s2idle and system misconfigured + the GPU will stay fully powered for the suspend. +* In systems that are intended to be s2idle, but AMD dGPU is also + present, the dGPU will go through S3 + +Signed-off-by: Mario Limonciello +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +index c811161ce9f09..ab3851c26f71c 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +@@ -2236,6 +2236,7 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work) + static int amdgpu_pmops_prepare(struct device *dev) + { + struct drm_device *drm_dev = dev_get_drvdata(dev); ++ struct amdgpu_device *adev = drm_to_adev(drm_dev); + + /* Return a positive number here so + * DPM_FLAG_SMART_SUSPEND works properly +@@ -2243,6 +2244,13 @@ static int amdgpu_pmops_prepare(struct device *dev) + if (amdgpu_device_supports_boco(drm_dev)) + return pm_runtime_suspended(dev); + ++ /* if we will not support s3 or s2i for the device ++ * then skip suspend ++ */ ++ if (!amdgpu_acpi_is_s0ix_active(adev) && ++ !amdgpu_acpi_is_s3_active(adev)) ++ return 1; ++ + return 0; + } + +-- +2.34.1 + diff --git a/queue-5.16/drm-amd-warn-users-about-potential-s0ix-problems.patch b/queue-5.16/drm-amd-warn-users-about-potential-s0ix-problems.patch new file mode 100644 index 00000000000..f69b8f0228e --- /dev/null +++ b/queue-5.16/drm-amd-warn-users-about-potential-s0ix-problems.patch @@ -0,0 +1,105 @@ +From 0253ee59acb01d976663efcd20521b599890b8f2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 11 Jan 2022 14:00:26 -0600 +Subject: drm/amd: Warn users about potential s0ix problems + +From: Mario Limonciello + +[ Upstream commit a6ed2035878e5ad2e43ed175d8812ac9399d6c40 ] + +On some OEM setups users can configure the BIOS for S3 or S2idle. +When configured to S3 users can still choose 's2idle' in the kernel by +using `/sys/power/mem_sleep`. Before commit 6dc8265f9803 ("drm/amdgpu: +always reset the asic in suspend (v2)"), the GPU would crash. Now when +configured this way, the system should resume but will use more power. + +As such, adjust the `amdpu_acpi_is_s0ix function` to warn users about +potential power consumption issues during their first attempt at +suspending. + +Reported-by: Bjoren Dasse +Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1824 +Reviewed-by: Alex Deucher +Signed-off-by: Mario Limonciello +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu.h | 8 ++++++-- + drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 24 +++++++++++++++++++----- + 2 files changed, 25 insertions(+), 7 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h +index 7d67aec6f4a2b..0a5a5370a2004 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h +@@ -1406,12 +1406,10 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta + int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev); + + void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps); +-bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); + void amdgpu_acpi_detect(void); + #else + static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; } + static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { } +-static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } + static inline void amdgpu_acpi_detect(void) { } + static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; } + static inline int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev, +@@ -1420,6 +1418,12 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, + enum amdgpu_ss ss_state) { return 0; } + #endif + ++#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) ++bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); ++#else ++static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } ++#endif ++ + int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, + uint64_t addr, struct amdgpu_bo **bo, + struct amdgpu_bo_va_mapping **mapping); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +index 4811b0faafd9a..b19d407518024 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +@@ -1031,6 +1031,7 @@ void amdgpu_acpi_detect(void) + } + } + ++#if IS_ENABLED(CONFIG_SUSPEND) + /** + * amdgpu_acpi_is_s0ix_active + * +@@ -1040,11 +1041,24 @@ void amdgpu_acpi_detect(void) + */ + bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) + { +-#if IS_ENABLED(CONFIG_AMD_PMC) && IS_ENABLED(CONFIG_SUSPEND) +- if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) { +- if (adev->flags & AMD_IS_APU) +- return pm_suspend_target_state == PM_SUSPEND_TO_IDLE; ++ if (!(adev->flags & AMD_IS_APU) || ++ (pm_suspend_target_state != PM_SUSPEND_TO_IDLE)) ++ return false; ++ ++ if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) { ++ dev_warn_once(adev->dev, ++ "Power consumption will be higher as BIOS has not been configured for suspend-to-idle.\n" ++ "To use suspend-to-idle change the sleep mode in BIOS setup.\n"); ++ return false; + } +-#endif ++ ++#if !IS_ENABLED(CONFIG_AMD_PMC) ++ dev_warn_once(adev->dev, ++ "Power consumption will be higher as the kernel has not been compiled with CONFIG_AMD_PMC.\n"); + return false; ++#else ++ return true; ++#endif /* CONFIG_AMD_PMC */ + } ++ ++#endif /* CONFIG_SUSPEND */ +-- +2.34.1 + diff --git a/queue-5.16/drm-amdgpu-fix-logic-inversion-in-check.patch b/queue-5.16/drm-amdgpu-fix-logic-inversion-in-check.patch new file mode 100644 index 00000000000..bf9eb0084ca --- /dev/null +++ b/queue-5.16/drm-amdgpu-fix-logic-inversion-in-check.patch @@ -0,0 +1,39 @@ +From 1c731d93355b3a6d53322b56015ad6863237a398 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 28 Jan 2022 13:21:10 +0100 +Subject: drm/amdgpu: fix logic inversion in check +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Christian König + +[ Upstream commit e8ae38720e1a685fd98cfa5ae118c9d07b45ca79 ] + +We probably never trigger this, but the logic inside the check is +inverted. + +Signed-off-by: Christian König +Reviewed-by: Felix Kuehling +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +index c875f1cdd2af7..ffc3ce0004e99 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +@@ -1913,7 +1913,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, + unsigned i; + int r; + +- if (direct_submit && !ring->sched.ready) { ++ if (!direct_submit && !ring->sched.ready) { + DRM_ERROR("Trying to move memory with ring turned off.\n"); + return -EINVAL; + } +-- +2.34.1 + diff --git a/queue-5.16/gcc-plugins-stackleak-use-noinstr-in-favor-of-notrac.patch b/queue-5.16/gcc-plugins-stackleak-use-noinstr-in-favor-of-notrac.patch new file mode 100644 index 00000000000..3f725c58fa3 --- /dev/null +++ b/queue-5.16/gcc-plugins-stackleak-use-noinstr-in-favor-of-notrac.patch @@ -0,0 +1,68 @@ +From 1da4191272f838b5402a138115249f58b48746c0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 3 Feb 2022 12:17:54 -0800 +Subject: gcc-plugins/stackleak: Use noinstr in favor of notrace + +From: Kees Cook + +[ Upstream commit dcb85f85fa6f142aae1fe86f399d4503d49f2b60 ] + +While the stackleak plugin was already using notrace, objtool is now a +bit more picky. Update the notrace uses to noinstr. Silences the +following objtool warnings when building with: + +CONFIG_DEBUG_ENTRY=y +CONFIG_STACK_VALIDATION=y +CONFIG_VMLINUX_VALIDATION=y +CONFIG_GCC_PLUGIN_STACKLEAK=y + + vmlinux.o: warning: objtool: do_syscall_64()+0x9: call to stackleak_track_stack() leaves .noinstr.text section + vmlinux.o: warning: objtool: do_int80_syscall_32()+0x9: call to stackleak_track_stack() leaves .noinstr.text section + vmlinux.o: warning: objtool: exc_general_protection()+0x22: call to stackleak_track_stack() leaves .noinstr.text section + vmlinux.o: warning: objtool: fixup_bad_iret()+0x20: call to stackleak_track_stack() leaves .noinstr.text section + vmlinux.o: warning: objtool: do_machine_check()+0x27: call to stackleak_track_stack() leaves .noinstr.text section + vmlinux.o: warning: objtool: .text+0x5346e: call to stackleak_erase() leaves .noinstr.text section + vmlinux.o: warning: objtool: .entry.text+0x143: call to stackleak_erase() leaves .noinstr.text section + vmlinux.o: warning: objtool: .entry.text+0x10eb: call to stackleak_erase() leaves .noinstr.text section + vmlinux.o: warning: objtool: .entry.text+0x17f9: call to stackleak_erase() leaves .noinstr.text section + +Note that the plugin's addition of calls to stackleak_track_stack() from +noinstr functions is expected to be safe, as it isn't runtime +instrumentation and is self-contained. + +Cc: Alexander Popov +Suggested-by: Peter Zijlstra +Signed-off-by: Kees Cook +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + kernel/stackleak.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/kernel/stackleak.c b/kernel/stackleak.c +index ce161a8e8d975..dd07239ddff9f 100644 +--- a/kernel/stackleak.c ++++ b/kernel/stackleak.c +@@ -48,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write, + #define skip_erasing() false + #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ + +-asmlinkage void notrace stackleak_erase(void) ++asmlinkage void noinstr stackleak_erase(void) + { + /* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */ + unsigned long kstack_ptr = current->lowest_stack; +@@ -102,9 +102,8 @@ asmlinkage void notrace stackleak_erase(void) + /* Reset the 'lowest_stack' value for the next syscall */ + current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64; + } +-NOKPROBE_SYMBOL(stackleak_erase); + +-void __used __no_caller_saved_registers notrace stackleak_track_stack(void) ++void __used __no_caller_saved_registers noinstr stackleak_track_stack(void) + { + unsigned long sp = current_stack_pointer; + +-- +2.34.1 + diff --git a/queue-5.16/kselftest-fix-vdso_test_abi-return-status.patch b/queue-5.16/kselftest-fix-vdso_test_abi-return-status.patch new file mode 100644 index 00000000000..611a53c7246 --- /dev/null +++ b/queue-5.16/kselftest-fix-vdso_test_abi-return-status.patch @@ -0,0 +1,292 @@ +From ef8396ccfe0065c6b3cfbe97f9a4fa7dad5faf29 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 31 Jan 2022 11:34:05 +0000 +Subject: kselftest: Fix vdso_test_abi return status + +From: Vincenzo Frascino + +[ Upstream commit ec049891b2dc16591813eacaddc476b3d27c8c14 ] + +vdso_test_abi contains a batch of tests that verify the validity of the +vDSO ABI. + +When a vDSO symbol is not found the relevant test is skipped reporting +KSFT_SKIP. All the tests return values are then added in a single +variable which is checked to verify failures. This approach can have +side effects which result in reporting the wrong kselftest exit status. + +Fix vdso_test_abi verifying the return code of each test separately. + +Cc: Shuah Khan +Cc: Andy Lutomirski +Cc: Thomas Gleixner +Reported-by: Cristian Marussi +Signed-off-by: Vincenzo Frascino +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/vDSO/vdso_test_abi.c | 135 +++++++++---------- + 1 file changed, 62 insertions(+), 73 deletions(-) + +diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c +index 3d603f1394af4..883ca85424bc5 100644 +--- a/tools/testing/selftests/vDSO/vdso_test_abi.c ++++ b/tools/testing/selftests/vDSO/vdso_test_abi.c +@@ -33,110 +33,114 @@ typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts); + typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts); + typedef time_t (*vdso_time_t)(time_t *t); + +-static int vdso_test_gettimeofday(void) ++#define VDSO_TEST_PASS_MSG() "\n%s(): PASS\n", __func__ ++#define VDSO_TEST_FAIL_MSG(x) "\n%s(): %s FAIL\n", __func__, x ++#define VDSO_TEST_SKIP_MSG(x) "\n%s(): SKIP: Could not find %s\n", __func__, x ++ ++static void vdso_test_gettimeofday(void) + { + /* Find gettimeofday. */ + vdso_gettimeofday_t vdso_gettimeofday = + (vdso_gettimeofday_t)vdso_sym(version, name[0]); + + if (!vdso_gettimeofday) { +- printf("Could not find %s\n", name[0]); +- return KSFT_SKIP; ++ ksft_test_result_skip(VDSO_TEST_SKIP_MSG(name[0])); ++ return; + } + + struct timeval tv; + long ret = vdso_gettimeofday(&tv, 0); + + if (ret == 0) { +- printf("The time is %lld.%06lld\n", +- (long long)tv.tv_sec, (long long)tv.tv_usec); ++ ksft_print_msg("The time is %lld.%06lld\n", ++ (long long)tv.tv_sec, (long long)tv.tv_usec); ++ ksft_test_result_pass(VDSO_TEST_PASS_MSG()); + } else { +- printf("%s failed\n", name[0]); +- return KSFT_FAIL; ++ ksft_test_result_fail(VDSO_TEST_FAIL_MSG(name[0])); + } +- +- return KSFT_PASS; + } + +-static int vdso_test_clock_gettime(clockid_t clk_id) ++static void vdso_test_clock_gettime(clockid_t clk_id) + { + /* Find clock_gettime. */ + vdso_clock_gettime_t vdso_clock_gettime = + (vdso_clock_gettime_t)vdso_sym(version, name[1]); + + if (!vdso_clock_gettime) { +- printf("Could not find %s\n", name[1]); +- return KSFT_SKIP; ++ ksft_test_result_skip(VDSO_TEST_SKIP_MSG(name[1])); ++ return; + } + + struct timespec ts; + long ret = vdso_clock_gettime(clk_id, &ts); + + if (ret == 0) { +- printf("The time is %lld.%06lld\n", +- (long long)ts.tv_sec, (long long)ts.tv_nsec); ++ ksft_print_msg("The time is %lld.%06lld\n", ++ (long long)ts.tv_sec, (long long)ts.tv_nsec); ++ ksft_test_result_pass(VDSO_TEST_PASS_MSG()); + } else { +- printf("%s failed\n", name[1]); +- return KSFT_FAIL; ++ ksft_test_result_fail(VDSO_TEST_FAIL_MSG(name[1])); + } +- +- return KSFT_PASS; + } + +-static int vdso_test_time(void) ++static void vdso_test_time(void) + { + /* Find time. */ + vdso_time_t vdso_time = + (vdso_time_t)vdso_sym(version, name[2]); + + if (!vdso_time) { +- printf("Could not find %s\n", name[2]); +- return KSFT_SKIP; ++ ksft_test_result_skip(VDSO_TEST_SKIP_MSG(name[2])); ++ return; + } + + long ret = vdso_time(NULL); + + if (ret > 0) { +- printf("The time in hours since January 1, 1970 is %lld\n", ++ ksft_print_msg("The time in hours since January 1, 1970 is %lld\n", + (long long)(ret / 3600)); ++ ksft_test_result_pass(VDSO_TEST_PASS_MSG()); + } else { +- printf("%s failed\n", name[2]); +- return KSFT_FAIL; ++ ksft_test_result_fail(VDSO_TEST_FAIL_MSG(name[2])); + } +- +- return KSFT_PASS; + } + +-static int vdso_test_clock_getres(clockid_t clk_id) ++static void vdso_test_clock_getres(clockid_t clk_id) + { ++ int clock_getres_fail = 0; ++ + /* Find clock_getres. */ + vdso_clock_getres_t vdso_clock_getres = + (vdso_clock_getres_t)vdso_sym(version, name[3]); + + if (!vdso_clock_getres) { +- printf("Could not find %s\n", name[3]); +- return KSFT_SKIP; ++ ksft_test_result_skip(VDSO_TEST_SKIP_MSG(name[3])); ++ return; + } + + struct timespec ts, sys_ts; + long ret = vdso_clock_getres(clk_id, &ts); + + if (ret == 0) { +- printf("The resolution is %lld %lld\n", +- (long long)ts.tv_sec, (long long)ts.tv_nsec); ++ ksft_print_msg("The vdso resolution is %lld %lld\n", ++ (long long)ts.tv_sec, (long long)ts.tv_nsec); + } else { +- printf("%s failed\n", name[3]); +- return KSFT_FAIL; ++ clock_getres_fail++; + } + + ret = syscall(SYS_clock_getres, clk_id, &sys_ts); + +- if ((sys_ts.tv_sec != ts.tv_sec) || (sys_ts.tv_nsec != ts.tv_nsec)) { +- printf("%s failed\n", name[3]); +- return KSFT_FAIL; +- } ++ ksft_print_msg("The syscall resolution is %lld %lld\n", ++ (long long)sys_ts.tv_sec, (long long)sys_ts.tv_nsec); + +- return KSFT_PASS; ++ if ((sys_ts.tv_sec != ts.tv_sec) || (sys_ts.tv_nsec != ts.tv_nsec)) ++ clock_getres_fail++; ++ ++ if (clock_getres_fail > 0) { ++ ksft_test_result_fail(VDSO_TEST_FAIL_MSG(name[3])); ++ } else { ++ ksft_test_result_pass(VDSO_TEST_PASS_MSG()); ++ } + } + + const char *vdso_clock_name[12] = { +@@ -158,36 +162,23 @@ const char *vdso_clock_name[12] = { + * This function calls vdso_test_clock_gettime and vdso_test_clock_getres + * with different values for clock_id. + */ +-static inline int vdso_test_clock(clockid_t clock_id) ++static inline void vdso_test_clock(clockid_t clock_id) + { +- int ret0, ret1; +- +- ret0 = vdso_test_clock_gettime(clock_id); +- /* A skipped test is considered passed */ +- if (ret0 == KSFT_SKIP) +- ret0 = KSFT_PASS; +- +- ret1 = vdso_test_clock_getres(clock_id); +- /* A skipped test is considered passed */ +- if (ret1 == KSFT_SKIP) +- ret1 = KSFT_PASS; ++ ksft_print_msg("\nclock_id: %s\n", vdso_clock_name[clock_id]); + +- ret0 += ret1; ++ vdso_test_clock_gettime(clock_id); + +- printf("clock_id: %s", vdso_clock_name[clock_id]); +- +- if (ret0 > 0) +- printf(" [FAIL]\n"); +- else +- printf(" [PASS]\n"); +- +- return ret0; ++ vdso_test_clock_getres(clock_id); + } + ++#define VDSO_TEST_PLAN 16 ++ + int main(int argc, char **argv) + { + unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); +- int ret; ++ ++ ksft_print_header(); ++ ksft_set_plan(VDSO_TEST_PLAN); + + if (!sysinfo_ehdr) { + printf("AT_SYSINFO_EHDR is not present!\n"); +@@ -201,44 +192,42 @@ int main(int argc, char **argv) + + vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); + +- ret = vdso_test_gettimeofday(); ++ vdso_test_gettimeofday(); + + #if _POSIX_TIMERS > 0 + + #ifdef CLOCK_REALTIME +- ret += vdso_test_clock(CLOCK_REALTIME); ++ vdso_test_clock(CLOCK_REALTIME); + #endif + + #ifdef CLOCK_BOOTTIME +- ret += vdso_test_clock(CLOCK_BOOTTIME); ++ vdso_test_clock(CLOCK_BOOTTIME); + #endif + + #ifdef CLOCK_TAI +- ret += vdso_test_clock(CLOCK_TAI); ++ vdso_test_clock(CLOCK_TAI); + #endif + + #ifdef CLOCK_REALTIME_COARSE +- ret += vdso_test_clock(CLOCK_REALTIME_COARSE); ++ vdso_test_clock(CLOCK_REALTIME_COARSE); + #endif + + #ifdef CLOCK_MONOTONIC +- ret += vdso_test_clock(CLOCK_MONOTONIC); ++ vdso_test_clock(CLOCK_MONOTONIC); + #endif + + #ifdef CLOCK_MONOTONIC_RAW +- ret += vdso_test_clock(CLOCK_MONOTONIC_RAW); ++ vdso_test_clock(CLOCK_MONOTONIC_RAW); + #endif + + #ifdef CLOCK_MONOTONIC_COARSE +- ret += vdso_test_clock(CLOCK_MONOTONIC_COARSE); ++ vdso_test_clock(CLOCK_MONOTONIC_COARSE); + #endif + + #endif + +- ret += vdso_test_time(); +- +- if (ret > 0) +- return KSFT_FAIL; ++ vdso_test_time(); + +- return KSFT_PASS; ++ ksft_print_cnts(); ++ return ksft_get_fail_cnt() == 0 ? KSFT_PASS : KSFT_FAIL; + } +-- +2.34.1 + diff --git a/queue-5.16/kselftest-signal-all-child-processes.patch b/queue-5.16/kselftest-signal-all-child-processes.patch new file mode 100644 index 00000000000..637f20ebcb7 --- /dev/null +++ b/queue-5.16/kselftest-signal-all-child-processes.patch @@ -0,0 +1,54 @@ +From 8e7fc917cced744b99b1f3d317779bf20c4977c1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 17 Dec 2021 17:29:55 +0800 +Subject: kselftest: signal all child processes + +From: Li Zhijian + +[ Upstream commit 92d25637a3a45904292c93f1863c6bbda4e3e38f ] + +We have some many cases that will create child process as well, such as +pidfd_wait. Previously, we will signal/kill the parent process when it +is time out, but this signal will not be sent to its child process. In +such case, if child process doesn't terminate itself, ksefltest framework +will hang forever. + +Here we group all its child processes so that kill() can signal all of +them in timeout. + +Fixed change log: Shuah Khan + +Suggested-by: yang xu +Signed-off-by: Li Zhijian +Acked-by: Christian Brauner +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/kselftest_harness.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h +index 79a182cfa43ad..78e59620d28de 100644 +--- a/tools/testing/selftests/kselftest_harness.h ++++ b/tools/testing/selftests/kselftest_harness.h +@@ -875,7 +875,8 @@ static void __timeout_handler(int sig, siginfo_t *info, void *ucontext) + } + + t->timed_out = true; +- kill(t->pid, SIGKILL); ++ // signal process group ++ kill(-(t->pid), SIGKILL); + } + + void __wait_for_test(struct __test_metadata *t) +@@ -985,6 +986,7 @@ void __run_test(struct __fixture_metadata *f, + ksft_print_msg("ERROR SPAWNING TEST CHILD\n"); + t->passed = 0; + } else if (t->pid == 0) { ++ setpgrp(); + t->fn(t, variant); + if (t->skip) + _exit(255); +-- +2.34.1 + diff --git a/queue-5.16/kunit-tool-import-missing-importlib.abc.patch b/queue-5.16/kunit-tool-import-missing-importlib.abc.patch new file mode 100644 index 00000000000..23952fb01f6 --- /dev/null +++ b/queue-5.16/kunit-tool-import-missing-importlib.abc.patch @@ -0,0 +1,45 @@ +From 16f010dea07c72056c24296004f7d0e3ffdf302a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 13 Jan 2022 00:36:57 +0100 +Subject: kunit: tool: Import missing importlib.abc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michał Winiarski + +[ Upstream commit 235528072f28b3b0a1446279b7eaddda36dbf743 ] + +Python 3.10.0 contains: +9e09849d20 ("bpo-41006: importlib.util no longer imports typing (GH-20938)") + +It causes importlib.util to no longer import importlib.abs, which leads +to the following error when trying to use kunit with qemu: +AttributeError: module 'importlib' has no attribute 'abc'. Did you mean: '_abc'? + +Add the missing import. + +Signed-off-by: Michał Winiarski +Reviewed-by: Daniel Latypov +Reviewed-by: Brendan Higgins +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/kunit/kunit_kernel.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py +index 66095568bf327..fae843bf2f0eb 100644 +--- a/tools/testing/kunit/kunit_kernel.py ++++ b/tools/testing/kunit/kunit_kernel.py +@@ -6,6 +6,7 @@ + # Author: Felix Guo + # Author: Brendan Higgins + ++import importlib.abc + import importlib.util + import logging + import subprocess +-- +2.34.1 + diff --git a/queue-5.16/mailmap-update-christian-brauner-s-email-address.patch b/queue-5.16/mailmap-update-christian-brauner-s-email-address.patch new file mode 100644 index 00000000000..831d7135315 --- /dev/null +++ b/queue-5.16/mailmap-update-christian-brauner-s-email-address.patch @@ -0,0 +1,35 @@ +From 7ac1f89e9bfb7007f02bf20445c2532381baefe0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 31 Jan 2022 15:48:54 +0100 +Subject: mailmap: update Christian Brauner's email address + +From: Christian Brauner + +[ Upstream commit 1a2beb3d5a0b4051067ecf49ea799bee340e0e7c ] + +At least one of the addresses will stop functioning after February. + +Signed-off-by: Christian Brauner +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + .mailmap | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/.mailmap b/.mailmap +index b344067e0acb6..3979fb166e0fd 100644 +--- a/.mailmap ++++ b/.mailmap +@@ -74,6 +74,9 @@ Chris Chiu + Christian Borntraeger + Christian Borntraeger + Christian Borntraeger ++Christian Brauner ++Christian Brauner ++Christian Brauner + Christophe Ricard + Christoph Hellwig + Colin Ian King +-- +2.34.1 + diff --git a/queue-5.16/net-ieee802154-at86rf230-stop-leaking-skb-s.patch b/queue-5.16/net-ieee802154-at86rf230-stop-leaking-skb-s.patch new file mode 100644 index 00000000000..e212e45accd --- /dev/null +++ b/queue-5.16/net-ieee802154-at86rf230-stop-leaking-skb-s.patch @@ -0,0 +1,74 @@ +From b7dbb4b06aa5651d6d874aadf8ed794a9eb092b5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 25 Jan 2022 13:14:23 +0100 +Subject: net: ieee802154: at86rf230: Stop leaking skb's + +From: Miquel Raynal + +[ Upstream commit e5ce576d45bf72fd0e3dc37eff897bfcc488f6a9 ] + +Upon error the ieee802154_xmit_complete() helper is not called. Only +ieee802154_wake_queue() is called manually. In the Tx case we then leak +the skb structure. + +Free the skb structure upon error before returning when appropriate. + +As the 'is_tx = 0' cannot be moved in the complete handler because of a +possible race between the delay in switching to STATE_RX_AACK_ON and a +new interrupt, we introduce an intermediate 'was_tx' boolean just for +this purpose. + +There is no Fixes tag applying here, many changes have been made on this +area and the issue kind of always existed. + +Suggested-by: Alexander Aring +Signed-off-by: Miquel Raynal +Acked-by: Alexander Aring +Link: https://lore.kernel.org/r/20220125121426.848337-4-miquel.raynal@bootlin.com +Signed-off-by: Stefan Schmidt +Signed-off-by: Sasha Levin +--- + drivers/net/ieee802154/at86rf230.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c +index 7d67f41387f55..4f5ef8a9a9a87 100644 +--- a/drivers/net/ieee802154/at86rf230.c ++++ b/drivers/net/ieee802154/at86rf230.c +@@ -100,6 +100,7 @@ struct at86rf230_local { + unsigned long cal_timeout; + bool is_tx; + bool is_tx_from_off; ++ bool was_tx; + u8 tx_retry; + struct sk_buff *tx_skb; + struct at86rf230_state_change tx; +@@ -343,7 +344,11 @@ at86rf230_async_error_recover_complete(void *context) + if (ctx->free) + kfree(ctx); + +- ieee802154_wake_queue(lp->hw); ++ if (lp->was_tx) { ++ lp->was_tx = 0; ++ dev_kfree_skb_any(lp->tx_skb); ++ ieee802154_wake_queue(lp->hw); ++ } + } + + static void +@@ -352,7 +357,11 @@ at86rf230_async_error_recover(void *context) + struct at86rf230_state_change *ctx = context; + struct at86rf230_local *lp = ctx->lp; + +- lp->is_tx = 0; ++ if (lp->is_tx) { ++ lp->was_tx = 1; ++ lp->is_tx = 0; ++ } ++ + at86rf230_async_state_change(lp, ctx, STATE_RX_AACK_ON, + at86rf230_async_error_recover_complete); + } +-- +2.34.1 + diff --git a/queue-5.16/net-sparx5-do-not-refer-to-skb-after-passing-it-on.patch b/queue-5.16/net-sparx5-do-not-refer-to-skb-after-passing-it-on.patch new file mode 100644 index 00000000000..2377a9980a3 --- /dev/null +++ b/queue-5.16/net-sparx5-do-not-refer-to-skb-after-passing-it-on.patch @@ -0,0 +1,40 @@ +From 962d1e250fd8812ba420010b50c15c30600ffa3a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Feb 2022 09:30:39 +0100 +Subject: net: sparx5: do not refer to skb after passing it on + +From: Steen Hegelund + +[ Upstream commit 81eb8b0b18789e647e65579303529fd52d861cc2 ] + +Do not try to use any SKB fields after the packet has been passed up in the +receive stack. + +Reported-by: kernel test robot +Reported-by: Dan Carpenter +Signed-off-by: Steen Hegelund +Link: https://lore.kernel.org/r/20220202083039.3774851-1-steen.hegelund@microchip.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +index dc7e5ea6ec158..148d431fcde42 100644 +--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c ++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +@@ -145,9 +145,9 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap) + skb_put(skb, byte_cnt - ETH_FCS_LEN); + eth_skb_pad(skb); + skb->protocol = eth_type_trans(skb, netdev); +- netif_rx(skb); + netdev->stats.rx_bytes += skb->len; + netdev->stats.rx_packets++; ++ netif_rx(skb); + } + + static int sparx5_inject(struct sparx5 *sparx5, +-- +2.34.1 + diff --git a/queue-5.16/nvme-fix-a-possible-use-after-free-in-controller-res.patch b/queue-5.16/nvme-fix-a-possible-use-after-free-in-controller-res.patch new file mode 100644 index 00000000000..259822ef145 --- /dev/null +++ b/queue-5.16/nvme-fix-a-possible-use-after-free-in-controller-res.patch @@ -0,0 +1,63 @@ +From 2b2dc1cb0933f5fc32bbbf71a9e9c68943e8eb92 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Feb 2022 14:54:19 +0200 +Subject: nvme: fix a possible use-after-free in controller reset during load + +From: Sagi Grimberg + +[ Upstream commit 0fa0f99fc84e41057cbdd2efbfe91c6b2f47dd9d ] + +Unlike .queue_rq, in .submit_async_event drivers may not check the ctrl +readiness for AER submission. This may lead to a use-after-free +condition that was observed with nvme-tcp. + +The race condition may happen in the following scenario: +1. driver executes its reset_ctrl_work +2. -> nvme_stop_ctrl - flushes ctrl async_event_work +3. ctrl sends AEN which is received by the host, which in turn + schedules AEN handling +4. teardown admin queue (which releases the queue socket) +5. AEN processed, submits another AER, calling the driver to submit +6. driver attempts to send the cmd +==> use-after-free + +In order to fix that, add ctrl state check to validate the ctrl +is actually able to accept the AER submission. + +This addresses the above race in controller resets because the driver +during teardown should: +1. change ctrl state to RESETTING +2. flush async_event_work (as well as other async work elements) + +So after 1,2, any other AER command will find the +ctrl state to be RESETTING and bail out without submitting the AER. + +Signed-off-by: Sagi Grimberg +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/core.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c +index 1af8a4513708a..9a6586c69afe8 100644 +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -4258,7 +4258,14 @@ static void nvme_async_event_work(struct work_struct *work) + container_of(work, struct nvme_ctrl, async_event_work); + + nvme_aen_uevent(ctrl); +- ctrl->ops->submit_async_event(ctrl); ++ ++ /* ++ * The transport drivers must guarantee AER submission here is safe by ++ * flushing ctrl async_event_work after changing the controller state ++ * from LIVE and before freeing the admin queue. ++ */ ++ if (ctrl->state == NVME_CTRL_LIVE) ++ ctrl->ops->submit_async_event(ctrl); + } + + static bool nvme_ctrl_pp_status(struct nvme_ctrl *ctrl) +-- +2.34.1 + diff --git a/queue-5.16/nvme-rdma-fix-possible-use-after-free-in-transport-e.patch b/queue-5.16/nvme-rdma-fix-possible-use-after-free-in-transport-e.patch new file mode 100644 index 00000000000..dfc99bd7176 --- /dev/null +++ b/queue-5.16/nvme-rdma-fix-possible-use-after-free-in-transport-e.patch @@ -0,0 +1,39 @@ +From 60b2762d0aaad0326bbeef1549e366cc91d140d1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Feb 2022 14:54:21 +0200 +Subject: nvme-rdma: fix possible use-after-free in transport error_recovery + work + +From: Sagi Grimberg + +[ Upstream commit b6bb1722f34bbdbabed27acdceaf585d300c5fd2 ] + +While nvme_rdma_submit_async_event_work is checking the ctrl and queue +state before preparing the AER command and scheduling io_work, in order +to fully prevent a race where this check is not reliable the error +recovery work must flush async_event_work before continuing to destroy +the admin queue after setting the ctrl state to RESETTING such that +there is no race .submit_async_event and the error recovery handler +itself changing the ctrl state. + +Signed-off-by: Sagi Grimberg +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/rdma.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c +index 850f84d204d05..9c55e4be8a398 100644 +--- a/drivers/nvme/host/rdma.c ++++ b/drivers/nvme/host/rdma.c +@@ -1200,6 +1200,7 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work) + struct nvme_rdma_ctrl, err_work); + + nvme_stop_keep_alive(&ctrl->ctrl); ++ flush_work(&ctrl->ctrl.async_event_work); + nvme_rdma_teardown_io_queues(ctrl, false); + nvme_start_queues(&ctrl->ctrl); + nvme_rdma_teardown_admin_queue(ctrl, false); +-- +2.34.1 + diff --git a/queue-5.16/nvme-tcp-fix-possible-use-after-free-in-transport-er.patch b/queue-5.16/nvme-tcp-fix-possible-use-after-free-in-transport-er.patch new file mode 100644 index 00000000000..8dee9aa9c05 --- /dev/null +++ b/queue-5.16/nvme-tcp-fix-possible-use-after-free-in-transport-er.patch @@ -0,0 +1,40 @@ +From bb9602b386aa08c3e7ed57b4ac0f37f890efdb04 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Feb 2022 14:54:20 +0200 +Subject: nvme-tcp: fix possible use-after-free in transport error_recovery + work + +From: Sagi Grimberg + +[ Upstream commit ff9fc7ebf5c06de1ef72a69f9b1ab40af8b07f9e ] + +While nvme_tcp_submit_async_event_work is checking the ctrl and queue +state before preparing the AER command and scheduling io_work, in order +to fully prevent a race where this check is not reliable the error +recovery work must flush async_event_work before continuing to destroy +the admin queue after setting the ctrl state to RESETTING such that +there is no race .submit_async_event and the error recovery handler +itself changing the ctrl state. + +Tested-by: Chris Leech +Signed-off-by: Sagi Grimberg +Signed-off-by: Sasha Levin +--- + drivers/nvme/host/tcp.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c +index 22046415a0942..891a36d02e7c7 100644 +--- a/drivers/nvme/host/tcp.c ++++ b/drivers/nvme/host/tcp.c +@@ -2104,6 +2104,7 @@ static void nvme_tcp_error_recovery_work(struct work_struct *work) + struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; + + nvme_stop_keep_alive(ctrl); ++ flush_work(&ctrl->async_event_work); + nvme_tcp_teardown_io_queues(ctrl, false); + /* unquiesce to fail fast pending requests */ + nvme_start_queues(ctrl); +-- +2.34.1 + diff --git a/queue-5.16/pinctrl-bcm63xx-fix-unmet-dependency-on-regmap-for-g.patch b/queue-5.16/pinctrl-bcm63xx-fix-unmet-dependency-on-regmap-for-g.patch new file mode 100644 index 00000000000..2867da1a6f5 --- /dev/null +++ b/queue-5.16/pinctrl-bcm63xx-fix-unmet-dependency-on-regmap-for-g.patch @@ -0,0 +1,49 @@ +From 17f80a60588d514d8e00f2ad333b367da1942f4f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 17 Jan 2022 01:25:57 -0500 +Subject: pinctrl: bcm63xx: fix unmet dependency on REGMAP for GPIO_REGMAP + +From: Julian Braha + +[ Upstream commit 3a5286955bf5febc3d151bcb2c5e272e383b64aa ] + +When PINCTRL_BCM63XX is selected, +and REGMAP is not selected, +Kbuild gives the following warning: + +WARNING: unmet direct dependencies detected for GPIO_REGMAP + Depends on [n]: GPIOLIB [=y] && REGMAP [=n] + Selected by [y]: + - PINCTRL_BCM63XX [=y] && PINCTRL [=y] + +This is because PINCTRL_BCM63XX +selects GPIO_REGMAP without selecting or depending on +REGMAP, despite GPIO_REGMAP depending on REGMAP. + +This unmet dependency bug was detected by Kismet, +a static analysis tool for Kconfig. Please advise +if this is not the appropriate solution. + +Signed-off-by: Julian Braha +Link: https://lore.kernel.org/r/20220117062557.89568-1-julianbraha@gmail.com +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/bcm/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig +index 8fc1feedd8617..5116b014e2a4f 100644 +--- a/drivers/pinctrl/bcm/Kconfig ++++ b/drivers/pinctrl/bcm/Kconfig +@@ -35,6 +35,7 @@ config PINCTRL_BCM63XX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB ++ select REGMAP + select GPIO_REGMAP + + config PINCTRL_BCM6318 +-- +2.34.1 + diff --git a/queue-5.16/platform-x86-amd-pmc-correct-usage-of-smu-version.patch b/queue-5.16/platform-x86-amd-pmc-correct-usage-of-smu-version.patch new file mode 100644 index 00000000000..e4608dc3056 --- /dev/null +++ b/queue-5.16/platform-x86-amd-pmc-correct-usage-of-smu-version.patch @@ -0,0 +1,65 @@ +From 12f01c551e4ae8b7b592c6b233188cd665634352 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 20 Jan 2022 11:44:39 -0600 +Subject: platform/x86: amd-pmc: Correct usage of SMU version + +From: Mario Limonciello + +[ Upstream commit b8fb0d9b47660ddb8a8256412784aad7cee9f21a ] + +Yellow carp has been outputting versions like `1093.24.0`, but this +is supposed to be 69.24.0. That is the MSB is being interpreted +incorrectly. + +The MSB is not part of the major version, but has generally been +treated that way thus far. It's actually the program, and used to +distinguish between two programs from a similar family but different +codebase. + +Link: https://patchwork.freedesktop.org/patch/469993/ +Signed-off-by: Mario Limonciello +Link: https://lore.kernel.org/r/20220120174439.12770-1-mario.limonciello@amd.com +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/amd-pmc.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c +index 230593ae5d6de..8c74733530e3d 100644 +--- a/drivers/platform/x86/amd-pmc.c ++++ b/drivers/platform/x86/amd-pmc.c +@@ -117,9 +117,10 @@ struct amd_pmc_dev { + u32 cpu_id; + u32 active_ips; + /* SMU version information */ +- u16 major; +- u16 minor; +- u16 rev; ++ u8 smu_program; ++ u8 major; ++ u8 minor; ++ u8 rev; + struct device *dev; + struct mutex lock; /* generic mutex lock */ + #if IS_ENABLED(CONFIG_DEBUG_FS) +@@ -166,11 +167,13 @@ static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev) + if (rc) + return rc; + +- dev->major = (val >> 16) & GENMASK(15, 0); ++ dev->smu_program = (val >> 24) & GENMASK(7, 0); ++ dev->major = (val >> 16) & GENMASK(7, 0); + dev->minor = (val >> 8) & GENMASK(7, 0); + dev->rev = (val >> 0) & GENMASK(7, 0); + +- dev_dbg(dev->dev, "SMU version is %u.%u.%u\n", dev->major, dev->minor, dev->rev); ++ dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n", ++ dev->smu_program, dev->major, dev->minor, dev->rev); + + return 0; + } +-- +2.34.1 + diff --git a/queue-5.16/platform-x86-isst-fix-possible-circular-locking-depe.patch b/queue-5.16/platform-x86-isst-fix-possible-circular-locking-depe.patch new file mode 100644 index 00000000000..aa75253031c --- /dev/null +++ b/queue-5.16/platform-x86-isst-fix-possible-circular-locking-depe.patch @@ -0,0 +1,254 @@ +From e1bf4d7436f6cab25aae29133ded28e2bb717abb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 11 Jan 2022 18:25:21 -0800 +Subject: platform/x86: ISST: Fix possible circular locking dependency detected + +From: Srinivas Pandruvada + +[ Upstream commit 17da2d5f93692086dd096a975225ffd5622d0bf8 ] + +As reported: + +[ 256.104522] ====================================================== +[ 256.113783] WARNING: possible circular locking dependency detected +[ 256.120093] 5.16.0-rc6-yocto-standard+ #99 Not tainted +[ 256.125362] ------------------------------------------------------ +[ 256.131673] intel-speed-sel/844 is trying to acquire lock: +[ 256.137290] ffffffffc036f0d0 (punit_misc_dev_lock){+.+.}-{3:3}, at: isst_if_open+0x18/0x90 [isst_if_common] +[ 256.147171] +[ 256.147171] but task is already holding lock: +[ 256.153135] ffffffff8ee7cb50 (misc_mtx){+.+.}-{3:3}, at: misc_open+0x2a/0x170 +[ 256.160407] +[ 256.160407] which lock already depends on the new lock. +[ 256.160407] +[ 256.168712] +[ 256.168712] the existing dependency chain (in reverse order) is: +[ 256.176327] +[ 256.176327] -> #1 (misc_mtx){+.+.}-{3:3}: +[ 256.181946] lock_acquire+0x1e6/0x330 +[ 256.186265] __mutex_lock+0x9b/0x9b0 +[ 256.190497] mutex_lock_nested+0x1b/0x20 +[ 256.195075] misc_register+0x32/0x1a0 +[ 256.199390] isst_if_cdev_register+0x65/0x180 [isst_if_common] +[ 256.205878] isst_if_probe+0x144/0x16e [isst_if_mmio] +... +[ 256.241976] +[ 256.241976] -> #0 (punit_misc_dev_lock){+.+.}-{3:3}: +[ 256.248552] validate_chain+0xbc6/0x1750 +[ 256.253131] __lock_acquire+0x88c/0xc10 +[ 256.257618] lock_acquire+0x1e6/0x330 +[ 256.261933] __mutex_lock+0x9b/0x9b0 +[ 256.266165] mutex_lock_nested+0x1b/0x20 +[ 256.270739] isst_if_open+0x18/0x90 [isst_if_common] +[ 256.276356] misc_open+0x100/0x170 +[ 256.280409] chrdev_open+0xa5/0x1e0 +... + +The call sequence suggested that misc_device /dev file can be opened +before misc device is yet to be registered, which is done only once. + +Here punit_misc_dev_lock was used as common lock, to protect the +registration by multiple ISST HW drivers, one time setup, prevent +duplicate registry of misc device and prevent load/unload when device +is open. + +We can split into locks: +- One which just prevent duplicate call to misc_register() and one +time setup. Also never call again if the misc_register() failed or +required one time setup is failed. This lock is not shared with +any misc device callbacks. + +- The other lock protects registry, load and unload of HW drivers. + +Sequence in isst_if_cdev_register() +- Register callbacks under punit_misc_dev_open_lock +- Call isst_misc_reg() which registers misc_device on the first +registry which is under punit_misc_dev_reg_lock, which is not +shared with callbacks. + +Sequence in isst_if_cdev_unregister +Just opposite of isst_if_cdev_register + +Reported-and-tested-by: Liwei Song +Signed-off-by: Srinivas Pandruvada +Link: https://lore.kernel.org/r/20220112022521.54669-1-srinivas.pandruvada@linux.intel.com +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + .../intel/speed_select_if/isst_if_common.c | 97 ++++++++++++------- + 1 file changed, 63 insertions(+), 34 deletions(-) + +diff --git a/drivers/platform/x86/intel/speed_select_if/isst_if_common.c b/drivers/platform/x86/intel/speed_select_if/isst_if_common.c +index c9a85eb2e8600..e8424e70d81d2 100644 +--- a/drivers/platform/x86/intel/speed_select_if/isst_if_common.c ++++ b/drivers/platform/x86/intel/speed_select_if/isst_if_common.c +@@ -596,7 +596,10 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, + return ret; + } + +-static DEFINE_MUTEX(punit_misc_dev_lock); ++/* Lock to prevent module registration when already opened by user space */ ++static DEFINE_MUTEX(punit_misc_dev_open_lock); ++/* Lock to allow one share misc device for all ISST interace */ ++static DEFINE_MUTEX(punit_misc_dev_reg_lock); + static int misc_usage_count; + static int misc_device_ret; + static int misc_device_open; +@@ -606,7 +609,7 @@ static int isst_if_open(struct inode *inode, struct file *file) + int i, ret = 0; + + /* Fail open, if a module is going away */ +- mutex_lock(&punit_misc_dev_lock); ++ mutex_lock(&punit_misc_dev_open_lock); + for (i = 0; i < ISST_IF_DEV_MAX; ++i) { + struct isst_if_cmd_cb *cb = &punit_callbacks[i]; + +@@ -628,7 +631,7 @@ static int isst_if_open(struct inode *inode, struct file *file) + } else { + misc_device_open++; + } +- mutex_unlock(&punit_misc_dev_lock); ++ mutex_unlock(&punit_misc_dev_open_lock); + + return ret; + } +@@ -637,7 +640,7 @@ static int isst_if_relase(struct inode *inode, struct file *f) + { + int i; + +- mutex_lock(&punit_misc_dev_lock); ++ mutex_lock(&punit_misc_dev_open_lock); + misc_device_open--; + for (i = 0; i < ISST_IF_DEV_MAX; ++i) { + struct isst_if_cmd_cb *cb = &punit_callbacks[i]; +@@ -645,7 +648,7 @@ static int isst_if_relase(struct inode *inode, struct file *f) + if (cb->registered) + module_put(cb->owner); + } +- mutex_unlock(&punit_misc_dev_lock); ++ mutex_unlock(&punit_misc_dev_open_lock); + + return 0; + } +@@ -662,6 +665,43 @@ static struct miscdevice isst_if_char_driver = { + .fops = &isst_if_char_driver_ops, + }; + ++static int isst_misc_reg(void) ++{ ++ mutex_lock(&punit_misc_dev_reg_lock); ++ if (misc_device_ret) ++ goto unlock_exit; ++ ++ if (!misc_usage_count) { ++ misc_device_ret = isst_if_cpu_info_init(); ++ if (misc_device_ret) ++ goto unlock_exit; ++ ++ misc_device_ret = misc_register(&isst_if_char_driver); ++ if (misc_device_ret) { ++ isst_if_cpu_info_exit(); ++ goto unlock_exit; ++ } ++ } ++ misc_usage_count++; ++ ++unlock_exit: ++ mutex_unlock(&punit_misc_dev_reg_lock); ++ ++ return misc_device_ret; ++} ++ ++static void isst_misc_unreg(void) ++{ ++ mutex_lock(&punit_misc_dev_reg_lock); ++ if (misc_usage_count) ++ misc_usage_count--; ++ if (!misc_usage_count && !misc_device_ret) { ++ misc_deregister(&isst_if_char_driver); ++ isst_if_cpu_info_exit(); ++ } ++ mutex_unlock(&punit_misc_dev_reg_lock); ++} ++ + /** + * isst_if_cdev_register() - Register callback for IOCTL + * @device_type: The device type this callback handling. +@@ -679,38 +719,31 @@ static struct miscdevice isst_if_char_driver = { + */ + int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb) + { +- if (misc_device_ret) +- return misc_device_ret; ++ int ret; + + if (device_type >= ISST_IF_DEV_MAX) + return -EINVAL; + +- mutex_lock(&punit_misc_dev_lock); ++ mutex_lock(&punit_misc_dev_open_lock); ++ /* Device is already open, we don't want to add new callbacks */ + if (misc_device_open) { +- mutex_unlock(&punit_misc_dev_lock); ++ mutex_unlock(&punit_misc_dev_open_lock); + return -EAGAIN; + } +- if (!misc_usage_count) { +- int ret; +- +- misc_device_ret = misc_register(&isst_if_char_driver); +- if (misc_device_ret) +- goto unlock_exit; +- +- ret = isst_if_cpu_info_init(); +- if (ret) { +- misc_deregister(&isst_if_char_driver); +- misc_device_ret = ret; +- goto unlock_exit; +- } +- } + memcpy(&punit_callbacks[device_type], cb, sizeof(*cb)); + punit_callbacks[device_type].registered = 1; +- misc_usage_count++; +-unlock_exit: +- mutex_unlock(&punit_misc_dev_lock); ++ mutex_unlock(&punit_misc_dev_open_lock); + +- return misc_device_ret; ++ ret = isst_misc_reg(); ++ if (ret) { ++ /* ++ * No need of mutex as the misc device register failed ++ * as no one can open device yet. Hence no contention. ++ */ ++ punit_callbacks[device_type].registered = 0; ++ return ret; ++ } ++ return 0; + } + EXPORT_SYMBOL_GPL(isst_if_cdev_register); + +@@ -725,16 +758,12 @@ EXPORT_SYMBOL_GPL(isst_if_cdev_register); + */ + void isst_if_cdev_unregister(int device_type) + { +- mutex_lock(&punit_misc_dev_lock); +- misc_usage_count--; ++ isst_misc_unreg(); ++ mutex_lock(&punit_misc_dev_open_lock); + punit_callbacks[device_type].registered = 0; + if (device_type == ISST_IF_DEV_MBOX) + isst_delete_hash(); +- if (!misc_usage_count && !misc_device_ret) { +- misc_deregister(&isst_if_char_driver); +- isst_if_cpu_info_exit(); +- } +- mutex_unlock(&punit_misc_dev_lock); ++ mutex_unlock(&punit_misc_dev_open_lock); + } + EXPORT_SYMBOL_GPL(isst_if_cdev_unregister); + +-- +2.34.1 + diff --git a/queue-5.16/platform-x86-touchscreen_dmi-add-info-for-the-rwc-na.patch b/queue-5.16/platform-x86-touchscreen_dmi-add-info-for-the-rwc-na.patch new file mode 100644 index 00000000000..62ee99d8017 --- /dev/null +++ b/queue-5.16/platform-x86-touchscreen_dmi-add-info-for-the-rwc-na.patch @@ -0,0 +1,66 @@ +From 451c80b7a54dfc766041563a4a44550994e5a611 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 12 Jan 2022 00:40:21 +0900 +Subject: platform/x86: touchscreen_dmi: Add info for the RWC NANOTE P8 AY07J + 2-in-1 + +From: Yuka Kawajiri + +[ Upstream commit 512eb73cfd1208898cf10cb06094e0ee0bb53b58 ] + +Add touchscreen info for RWC NANOTE P8 (AY07J) 2-in-1. + +Signed-off-by: Yuka Kawajiri +Link: https://lore.kernel.org/r/20220111154019.4599-1-yukx00@gmail.com +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/touchscreen_dmi.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c +index 17dd54d4b783c..e318b40949679 100644 +--- a/drivers/platform/x86/touchscreen_dmi.c ++++ b/drivers/platform/x86/touchscreen_dmi.c +@@ -773,6 +773,21 @@ static const struct ts_dmi_data predia_basic_data = { + .properties = predia_basic_props, + }; + ++static const struct property_entry rwc_nanote_p8_props[] = { ++ PROPERTY_ENTRY_U32("touchscreen-min-y", 46), ++ PROPERTY_ENTRY_U32("touchscreen-size-x", 1728), ++ PROPERTY_ENTRY_U32("touchscreen-size-y", 1140), ++ PROPERTY_ENTRY_BOOL("touchscreen-inverted-y"), ++ PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-rwc-nanote-p8.fw"), ++ PROPERTY_ENTRY_U32("silead,max-fingers", 10), ++ { } ++}; ++ ++static const struct ts_dmi_data rwc_nanote_p8_data = { ++ .acpi_name = "MSSL1680:00", ++ .properties = rwc_nanote_p8_props, ++}; ++ + static const struct property_entry schneider_sct101ctm_props[] = { + PROPERTY_ENTRY_U32("touchscreen-size-x", 1715), + PROPERTY_ENTRY_U32("touchscreen-size-y", 1140), +@@ -1406,6 +1421,15 @@ const struct dmi_system_id touchscreen_dmi_table[] = { + DMI_EXACT_MATCH(DMI_BOARD_NAME, "0E57"), + }, + }, ++ { ++ /* RWC NANOTE P8 */ ++ .driver_data = (void *)&rwc_nanote_p8_data, ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "Default string"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "AY07J"), ++ DMI_MATCH(DMI_PRODUCT_SKU, "0001") ++ }, ++ }, + { + /* Schneider SCT101CTM */ + .driver_data = (void *)&schneider_sct101ctm_data, +-- +2.34.1 + diff --git a/queue-5.16/quota-make-dquot_quota_sync-return-errors-from-sync_.patch b/queue-5.16/quota-make-dquot_quota_sync-return-errors-from-sync_.patch new file mode 100644 index 00000000000..ee82a6c139f --- /dev/null +++ b/queue-5.16/quota-make-dquot_quota_sync-return-errors-from-sync_.patch @@ -0,0 +1,47 @@ +From 5080ad4169a80385f1d2e31663b338b3bb59babb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 30 Jan 2022 08:53:16 -0800 +Subject: quota: make dquot_quota_sync return errors from ->sync_fs + +From: Darrick J. Wong + +[ Upstream commit dd5532a4994bfda0386eb2286ec00758cee08444 ] + +Strangely, dquot_quota_sync ignores the return code from the ->sync_fs +call, which means that quotacalls like Q_SYNC never see the error. This +doesn't seem right, so fix that. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Jan Kara +Reviewed-by: Christoph Hellwig +Acked-by: Christian Brauner +Signed-off-by: Sasha Levin +--- + fs/quota/dquot.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c +index 22d904bde6ab9..a74aef99bd3d6 100644 +--- a/fs/quota/dquot.c ++++ b/fs/quota/dquot.c +@@ -690,9 +690,14 @@ int dquot_quota_sync(struct super_block *sb, int type) + /* This is not very clever (and fast) but currently I don't know about + * any other simple way of getting quota data to disk and we must get + * them there for userspace to be visible... */ +- if (sb->s_op->sync_fs) +- sb->s_op->sync_fs(sb, 1); +- sync_blockdev(sb->s_bdev); ++ if (sb->s_op->sync_fs) { ++ ret = sb->s_op->sync_fs(sb, 1); ++ if (ret) ++ return ret; ++ } ++ ret = sync_blockdev(sb->s_bdev); ++ if (ret) ++ return ret; + + /* + * Now when everything is written we can discard the pagecache so +-- +2.34.1 + diff --git a/queue-5.16/random-wake-up-dev-random-writers-after-zap.patch b/queue-5.16/random-wake-up-dev-random-writers-after-zap.patch new file mode 100644 index 00000000000..9b94aff8c94 --- /dev/null +++ b/queue-5.16/random-wake-up-dev-random-writers-after-zap.patch @@ -0,0 +1,42 @@ +From 8117aa36f6b7e3e28f6b285915cd2536cfc95a65 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 28 Jan 2022 23:44:03 +0100 +Subject: random: wake up /dev/random writers after zap + +From: Jason A. Donenfeld + +[ Upstream commit 042e293e16e3aa9794ce60c29f5b7b0c8170f933 ] + +When account() is called, and the amount of entropy dips below +random_write_wakeup_bits, we wake up the random writers, so that they +can write some more in. However, the RNDZAPENTCNT/RNDCLEARPOOL ioctl +sets the entropy count to zero -- a potential reduction just like +account() -- but does not unblock writers. This commit adds the missing +logic to that ioctl to unblock waiting writers. + +Reviewed-by: Dominik Brodowski +Signed-off-by: Jason A. Donenfeld +Signed-off-by: Sasha Levin +--- + drivers/char/random.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/char/random.c b/drivers/char/random.c +index a27ae3999ff32..ebe86de9d0acc 100644 +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -1963,7 +1963,10 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) + */ + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; +- input_pool.entropy_count = 0; ++ if (xchg(&input_pool.entropy_count, 0) && random_write_wakeup_bits) { ++ wake_up_interruptible(&random_write_wait); ++ kill_fasync(&fasync, SIGIO, POLL_OUT); ++ } + return 0; + case RNDRESEEDCRNG: + if (!capable(CAP_SYS_ADMIN)) +-- +2.34.1 + diff --git a/queue-5.16/revert-module-async-async_synchronize_full-on-module.patch b/queue-5.16/revert-module-async-async_synchronize_full-on-module.patch new file mode 100644 index 00000000000..4047f79bf3d --- /dev/null +++ b/queue-5.16/revert-module-async-async_synchronize_full-on-module.patch @@ -0,0 +1,153 @@ +From 6130034213bc19289111295eda2beb193d28e254 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 15:39:53 -0800 +Subject: Revert "module, async: async_synchronize_full() on module init iff + async is used" + +From: Igor Pylypiv + +[ Upstream commit 67d6212afda218d564890d1674bab28e8612170f ] + +This reverts commit 774a1221e862b343388347bac9b318767336b20b. + +We need to finish all async code before the module init sequence is +done. In the reverted commit the PF_USED_ASYNC flag was added to mark a +thread that called async_schedule(). Then the PF_USED_ASYNC flag was +used to determine whether or not async_synchronize_full() needs to be +invoked. This works when modprobe thread is calling async_schedule(), +but it does not work if module dispatches init code to a worker thread +which then calls async_schedule(). + +For example, PCI driver probing is invoked from a worker thread based on +a node where device is attached: + + if (cpu < nr_cpu_ids) + error = work_on_cpu(cpu, local_pci_probe, &ddi); + else + error = local_pci_probe(&ddi); + +We end up in a situation where a worker thread gets the PF_USED_ASYNC +flag set instead of the modprobe thread. As a result, +async_synchronize_full() is not invoked and modprobe completes without +waiting for the async code to finish. + +The issue was discovered while loading the pm80xx driver: +(scsi_mod.scan=async) + +modprobe pm80xx worker +... + do_init_module() + ... + pci_call_probe() + work_on_cpu(local_pci_probe) + local_pci_probe() + pm8001_pci_probe() + scsi_scan_host() + async_schedule() + worker->flags |= PF_USED_ASYNC; + ... + < return from worker > + ... + if (current->flags & PF_USED_ASYNC) <--- false + async_synchronize_full(); + +Commit 21c3c5d28007 ("block: don't request module during elevator init") +fixed the deadlock issue which the reverted commit 774a1221e862 +("module, async: async_synchronize_full() on module init iff async is +used") tried to fix. + +Since commit 0fdff3ec6d87 ("async, kmod: warn on synchronous +request_module() from async workers") synchronous module loading from +async is not allowed. + +Given that the original deadlock issue is fixed and it is no longer +allowed to call synchronous request_module() from async we can remove +PF_USED_ASYNC flag to make module init consistently invoke +async_synchronize_full() unless async module probe is requested. + +Signed-off-by: Igor Pylypiv +Reviewed-by: Changyuan Lyu +Reviewed-by: Luis Chamberlain +Acked-by: Tejun Heo +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + include/linux/sched.h | 1 - + kernel/async.c | 3 --- + kernel/module.c | 25 +++++-------------------- + 3 files changed, 5 insertions(+), 24 deletions(-) + +diff --git a/include/linux/sched.h b/include/linux/sched.h +index 78c351e35fec6..ee5ed88219631 100644 +--- a/include/linux/sched.h ++++ b/include/linux/sched.h +@@ -1672,7 +1672,6 @@ extern struct pid *cad_pid; + #define PF_MEMALLOC 0x00000800 /* Allocating memory */ + #define PF_NPROC_EXCEEDED 0x00001000 /* set_user() noticed that RLIMIT_NPROC was exceeded */ + #define PF_USED_MATH 0x00002000 /* If unset the fpu must be initialized before use */ +-#define PF_USED_ASYNC 0x00004000 /* Used async_schedule*(), used by module init */ + #define PF_NOFREEZE 0x00008000 /* This thread should not be frozen */ + #define PF_FROZEN 0x00010000 /* Frozen for system suspend */ + #define PF_KSWAPD 0x00020000 /* I am kswapd */ +diff --git a/kernel/async.c b/kernel/async.c +index b8d7a663497f9..b2c4ba5686ee4 100644 +--- a/kernel/async.c ++++ b/kernel/async.c +@@ -205,9 +205,6 @@ async_cookie_t async_schedule_node_domain(async_func_t func, void *data, + atomic_inc(&entry_count); + spin_unlock_irqrestore(&async_lock, flags); + +- /* mark that this task has queued an async job, used by module init */ +- current->flags |= PF_USED_ASYNC; +- + /* schedule for execution */ + queue_work_node(node, system_unbound_wq, &entry->work); + +diff --git a/kernel/module.c b/kernel/module.c +index 84a9141a5e159..f25e7653aa150 100644 +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -3722,12 +3722,6 @@ static noinline int do_init_module(struct module *mod) + } + freeinit->module_init = mod->init_layout.base; + +- /* +- * We want to find out whether @mod uses async during init. Clear +- * PF_USED_ASYNC. async_schedule*() will set it. +- */ +- current->flags &= ~PF_USED_ASYNC; +- + do_mod_ctors(mod); + /* Start the module */ + if (mod->init != NULL) +@@ -3753,22 +3747,13 @@ static noinline int do_init_module(struct module *mod) + + /* + * We need to finish all async code before the module init sequence +- * is done. This has potential to deadlock. For example, a newly +- * detected block device can trigger request_module() of the +- * default iosched from async probing task. Once userland helper +- * reaches here, async_synchronize_full() will wait on the async +- * task waiting on request_module() and deadlock. +- * +- * This deadlock is avoided by perfomring async_synchronize_full() +- * iff module init queued any async jobs. This isn't a full +- * solution as it will deadlock the same if module loading from +- * async jobs nests more than once; however, due to the various +- * constraints, this hack seems to be the best option for now. +- * Please refer to the following thread for details. ++ * is done. This has potential to deadlock if synchronous module ++ * loading is requested from async (which is not allowed!). + * +- * http://thread.gmane.org/gmane.linux.kernel/1420814 ++ * See commit 0fdff3ec6d87 ("async, kmod: warn on synchronous ++ * request_module() from async workers") for more details. + */ +- if (!mod->async_probe_requested && (current->flags & PF_USED_ASYNC)) ++ if (!mod->async_probe_requested) + async_synchronize_full(); + + ftrace_free_mem(mod, mod->init_layout.base, mod->init_layout.base + +-- +2.34.1 + diff --git a/queue-5.16/scsi-core-reallocate-device-s-budget-map-on-queue-de.patch b/queue-5.16/scsi-core-reallocate-device-s-budget-map-on-queue-de.patch new file mode 100644 index 00000000000..95678461c37 --- /dev/null +++ b/queue-5.16/scsi-core-reallocate-device-s-budget-map-on-queue-de.patch @@ -0,0 +1,120 @@ +From dbc9af8f76a9f5c38291103e1fc2c06e2725d885 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 23:37:33 +0800 +Subject: scsi: core: Reallocate device's budget map on queue depth change + +From: Ming Lei + +[ Upstream commit edb854a3680bacc9ef9b91ec0c5ff6105886f6f3 ] + +We currently use ->cmd_per_lun as initial queue depth for setting up the +budget_map. Martin Wilck reported that it is common for the queue_depth to +be subsequently updated in slave_configure() based on detected hardware +characteristics. + +As a result, for some drivers, the static host template settings for +cmd_per_lun and can_queue won't actually get used in practice. And if the +default values are used to allocate the budget_map, memory may be consumed +unnecessarily. + +Fix the issue by reallocating the budget_map after ->slave_configure() +returns. At that time the device queue_depth should accurately reflect what +the hardware needs. + +Link: https://lore.kernel.org/r/20220127153733.409132-1-ming.lei@redhat.com +Cc: Bart Van Assche +Reported-by: Martin Wilck +Suggested-by: Martin Wilck +Tested-by: Martin Wilck +Reviewed-by: Martin Wilck +Reviewed-by: Bart Van Assche +Signed-off-by: Ming Lei +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_scan.c | 55 ++++++++++++++++++++++++++++++++++++---- + 1 file changed, 50 insertions(+), 5 deletions(-) + +diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c +index 23e1c0acdeaee..d0ce723299bf7 100644 +--- a/drivers/scsi/scsi_scan.c ++++ b/drivers/scsi/scsi_scan.c +@@ -214,6 +214,48 @@ static void scsi_unlock_floptical(struct scsi_device *sdev, + SCSI_TIMEOUT, 3, NULL); + } + ++static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev, ++ unsigned int depth) ++{ ++ int new_shift = sbitmap_calculate_shift(depth); ++ bool need_alloc = !sdev->budget_map.map; ++ bool need_free = false; ++ int ret; ++ struct sbitmap sb_backup; ++ ++ /* ++ * realloc if new shift is calculated, which is caused by setting ++ * up one new default queue depth after calling ->slave_configure ++ */ ++ if (!need_alloc && new_shift != sdev->budget_map.shift) ++ need_alloc = need_free = true; ++ ++ if (!need_alloc) ++ return 0; ++ ++ /* ++ * Request queue has to be frozen for reallocating budget map, ++ * and here disk isn't added yet, so freezing is pretty fast ++ */ ++ if (need_free) { ++ blk_mq_freeze_queue(sdev->request_queue); ++ sb_backup = sdev->budget_map; ++ } ++ ret = sbitmap_init_node(&sdev->budget_map, ++ scsi_device_max_queue_depth(sdev), ++ new_shift, GFP_KERNEL, ++ sdev->request_queue->node, false, true); ++ if (need_free) { ++ if (ret) ++ sdev->budget_map = sb_backup; ++ else ++ sbitmap_free(&sb_backup); ++ ret = 0; ++ blk_mq_unfreeze_queue(sdev->request_queue); ++ } ++ return ret; ++} ++ + /** + * scsi_alloc_sdev - allocate and setup a scsi_Device + * @starget: which target to allocate a &scsi_device for +@@ -306,11 +348,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, + * default device queue depth to figure out sbitmap shift + * since we use this queue depth most of times. + */ +- if (sbitmap_init_node(&sdev->budget_map, +- scsi_device_max_queue_depth(sdev), +- sbitmap_calculate_shift(depth), +- GFP_KERNEL, sdev->request_queue->node, +- false, true)) { ++ if (scsi_realloc_sdev_budget_map(sdev, depth)) { + put_device(&starget->dev); + kfree(sdev); + goto out; +@@ -1017,6 +1055,13 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, + } + return SCSI_SCAN_NO_RESPONSE; + } ++ ++ /* ++ * The queue_depth is often changed in ->slave_configure. ++ * Set up budget map again since memory consumption of ++ * the map depends on actual queue depth. ++ */ ++ scsi_realloc_sdev_budget_map(sdev, sdev->queue_depth); + } + + if (sdev->scsi_level >= SCSI_3) +-- +2.34.1 + diff --git a/queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-ssp-stp-s.patch b/queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-ssp-stp-s.patch new file mode 100644 index 00000000000..9bb86bfaf1f --- /dev/null +++ b/queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-ssp-stp-s.patch @@ -0,0 +1,67 @@ +From 74c24eb44f912ef70ad0e0345be5fc51ed6668be Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 21:12:52 +0800 +Subject: scsi: pm8001: Fix use-after-free for aborted SSP/STP sas_task + +From: John Garry + +[ Upstream commit df7abcaa1246e2537ab4016077b5443bb3c09378 ] + +Currently a use-after-free may occur if a sas_task is aborted by the upper +layer before we handle the I/O completion in mpi_ssp_completion() or +mpi_sata_completion(). + +In this case, the following are the two steps in handling those I/O +completions: + + - Call complete() to inform the upper layer handler of completion of + the I/O. + + - Release driver resources associated with the sas_task in + pm8001_ccb_task_free() call. + +When complete() is called, the upper layer may free the sas_task. As such, +we should not touch the associated sas_task afterwards, but we do so in the +pm8001_ccb_task_free() call. + +Fix by swapping the complete() and pm8001_ccb_task_free() calls ordering. + +Link: https://lore.kernel.org/r/1643289172-165636-4-git-send-email-john.garry@huawei.com +Reviewed-by: Damien Le Moal +Acked-by: Jack Wang +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/pm8001/pm80xx_hwi.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c +index 885bc9e71ff64..ca4820d99dc70 100644 +--- a/drivers/scsi/pm8001/pm80xx_hwi.c ++++ b/drivers/scsi/pm8001/pm80xx_hwi.c +@@ -2184,9 +2184,9 @@ mpi_ssp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) + pm8001_dbg(pm8001_ha, FAIL, + "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", + t, status, ts->resp, ts->stat); ++ pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + if (t->slow_task) + complete(&t->slow_task->completion); +- pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + } else { + spin_unlock_irqrestore(&t->task_state_lock, flags); + pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); +@@ -2801,9 +2801,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, + pm8001_dbg(pm8001_ha, FAIL, + "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", + t, status, ts->resp, ts->stat); ++ pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + if (t->slow_task) + complete(&t->slow_task->completion); +- pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); + } else { + spin_unlock_irqrestore(&t->task_state_lock, flags); + spin_unlock_irqrestore(&circularQ->oq_lock, +-- +2.34.1 + diff --git a/queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-tmf-sas_t.patch b/queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-tmf-sas_t.patch new file mode 100644 index 00000000000..4eb3f86e953 --- /dev/null +++ b/queue-5.16/scsi-pm8001-fix-use-after-free-for-aborted-tmf-sas_t.patch @@ -0,0 +1,52 @@ +From 4f39c5580bada10292c6092927a7934336404693 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 21:12:51 +0800 +Subject: scsi: pm8001: Fix use-after-free for aborted TMF sas_task + +From: John Garry + +[ Upstream commit 61f162aa4381845acbdc7f2be4dfb694d027c018 ] + +Currently a use-after-free may occur if a TMF sas_task is aborted before we +handle the IO completion in mpi_ssp_completion(). The abort occurs due to +timeout. + +When the timeout occurs, the SAS_TASK_STATE_ABORTED flag is set and the +sas_task is freed in pm8001_exec_internal_tmf_task(). + +However, if the I/O completion occurs later, the I/O completion still +thinks that the sas_task is available. Fix this by clearing the ccb->task +if the TMF times out - the I/O completion handler does nothing if this +pointer is cleared. + +Link: https://lore.kernel.org/r/1643289172-165636-3-git-send-email-john.garry@huawei.com +Reviewed-by: Damien Le Moal +Acked-by: Jack Wang +Signed-off-by: John Garry +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/pm8001/pm8001_sas.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c +index 83e73009db5cd..c0b45b8a513d7 100644 +--- a/drivers/scsi/pm8001/pm8001_sas.c ++++ b/drivers/scsi/pm8001/pm8001_sas.c +@@ -753,8 +753,13 @@ static int pm8001_exec_internal_tmf_task(struct domain_device *dev, + res = -TMF_RESP_FUNC_FAILED; + /* Even TMF timed out, return direct. */ + if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { ++ struct pm8001_ccb_info *ccb = task->lldd_task; ++ + pm8001_dbg(pm8001_ha, FAIL, "TMF task[%x]timeout.\n", + tmf->tmf); ++ ++ if (ccb) ++ ccb->task = NULL; + goto ex_err; + } + +-- +2.34.1 + diff --git a/queue-5.16/scsi-pm80xx-fix-double-completion-for-sata-devices.patch b/queue-5.16/scsi-pm80xx-fix-double-completion-for-sata-devices.patch new file mode 100644 index 00000000000..cbb3d0342b4 --- /dev/null +++ b/queue-5.16/scsi-pm80xx-fix-double-completion-for-sata-devices.patch @@ -0,0 +1,147 @@ +From 1436ef9edaf16cc77b060d2555252686c24eef33 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 24 Jan 2022 13:52:55 +0530 +Subject: scsi: pm80xx: Fix double completion for SATA devices + +From: Ajish Koshy + +[ Upstream commit c26b85ea16365079be8d206b20556a60a0c69ad4 ] + +Current code handles completions for SATA devices in mpi_sata_completion() +and mpi_sata_event(). + +However, at the time when any SATA event happens, for almost all the event +types, the command is still in the target. It is therefore incorrect to +complete the task in sata_event(). + +There are some events for which we get sata_completions, some need recovery +procedure and others abort. All the tasks must be completed via +sata_completion() path. + +Removed the task done related code from sata_events(). For tasks where we +don't get completions, let top layer call abort() to abort the command post +timeout. + +Link: https://lore.kernel.org/r/20220124082255.86223-1-Ajish.Koshy@microchip.com +Acked-by: Jack Wang +Co-developed-by: Viswas G +Signed-off-by: Viswas G +Signed-off-by: Ajish Koshy +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/pm8001/pm8001_hwi.c | 18 ------------------ + drivers/scsi/pm8001/pm80xx_hwi.c | 26 -------------------------- + 2 files changed, 44 deletions(-) + +diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c +index 4390c8b9170cd..066290dd57565 100644 +--- a/drivers/scsi/pm8001/pm8001_hwi.c ++++ b/drivers/scsi/pm8001/pm8001_hwi.c +@@ -2695,7 +2695,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb) + u32 tag = le32_to_cpu(psataPayload->tag); + u32 port_id = le32_to_cpu(psataPayload->port_id); + u32 dev_id = le32_to_cpu(psataPayload->device_id); +- unsigned long flags; + + ccb = &pm8001_ha->ccb_info[tag]; + +@@ -2735,8 +2734,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb) + ts->resp = SAS_TASK_COMPLETE; + ts->stat = SAS_DATA_OVERRUN; + ts->residual = 0; +- if (pm8001_dev) +- atomic_dec(&pm8001_dev->running_req); + break; + case IO_XFER_ERROR_BREAK: + pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); +@@ -2778,7 +2775,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb) + IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); + ts->resp = SAS_TASK_COMPLETE; + ts->stat = SAS_QUEUE_FULL; +- pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); + return; + } + break; +@@ -2864,20 +2860,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb) + ts->stat = SAS_OPEN_TO; + break; + } +- spin_lock_irqsave(&t->task_state_lock, flags); +- t->task_state_flags &= ~SAS_TASK_STATE_PENDING; +- t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; +- t->task_state_flags |= SAS_TASK_STATE_DONE; +- if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { +- spin_unlock_irqrestore(&t->task_state_lock, flags); +- pm8001_dbg(pm8001_ha, FAIL, +- "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", +- t, event, ts->resp, ts->stat); +- pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); +- } else { +- spin_unlock_irqrestore(&t->task_state_lock, flags); +- pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); +- } + } + + /*See the comments for mpi_ssp_completion */ +diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c +index 4c5b945bf3187..885bc9e71ff64 100644 +--- a/drivers/scsi/pm8001/pm80xx_hwi.c ++++ b/drivers/scsi/pm8001/pm80xx_hwi.c +@@ -2828,7 +2828,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, + u32 tag = le32_to_cpu(psataPayload->tag); + u32 port_id = le32_to_cpu(psataPayload->port_id); + u32 dev_id = le32_to_cpu(psataPayload->device_id); +- unsigned long flags; + + ccb = &pm8001_ha->ccb_info[tag]; + +@@ -2866,8 +2865,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, + ts->resp = SAS_TASK_COMPLETE; + ts->stat = SAS_DATA_OVERRUN; + ts->residual = 0; +- if (pm8001_dev) +- atomic_dec(&pm8001_dev->running_req); + break; + case IO_XFER_ERROR_BREAK: + pm8001_dbg(pm8001_ha, IO, "IO_XFER_ERROR_BREAK\n"); +@@ -2916,11 +2913,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, + IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); + ts->resp = SAS_TASK_COMPLETE; + ts->stat = SAS_QUEUE_FULL; +- spin_unlock_irqrestore(&circularQ->oq_lock, +- circularQ->lock_flags); +- pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); +- spin_lock_irqsave(&circularQ->oq_lock, +- circularQ->lock_flags); + return; + } + break; +@@ -3020,24 +3012,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, + ts->stat = SAS_OPEN_TO; + break; + } +- spin_lock_irqsave(&t->task_state_lock, flags); +- t->task_state_flags &= ~SAS_TASK_STATE_PENDING; +- t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; +- t->task_state_flags |= SAS_TASK_STATE_DONE; +- if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { +- spin_unlock_irqrestore(&t->task_state_lock, flags); +- pm8001_dbg(pm8001_ha, FAIL, +- "task 0x%p done with io_status 0x%x resp 0x%x stat 0x%x but aborted by upper layer!\n", +- t, event, ts->resp, ts->stat); +- pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); +- } else { +- spin_unlock_irqrestore(&t->task_state_lock, flags); +- spin_unlock_irqrestore(&circularQ->oq_lock, +- circularQ->lock_flags); +- pm8001_ccb_task_free_done(pm8001_ha, t, ccb, tag); +- spin_lock_irqsave(&circularQ->oq_lock, +- circularQ->lock_flags); +- } + } + + /*See the comments for mpi_ssp_completion */ +-- +2.34.1 + diff --git a/queue-5.16/selftests-netfilter-reduce-zone-stress-test-running-.patch b/queue-5.16/selftests-netfilter-reduce-zone-stress-test-running-.patch new file mode 100644 index 00000000000..54b2db5f6df --- /dev/null +++ b/queue-5.16/selftests-netfilter-reduce-zone-stress-test-running-.patch @@ -0,0 +1,71 @@ +From ac311564bfed36d952c96a6dace7a0e8849d6636 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 23 Jan 2022 15:45:54 +0100 +Subject: selftests: netfilter: reduce zone stress test running time + +From: Florian Westphal + +[ Upstream commit c858620d2ae3489409af593f005a48a8a324da3d ] + +This selftests needs almost 3 minutes to complete, reduce the +insertes zones to 1000. Test now completes in about 20 seconds. + +Signed-off-by: Florian Westphal +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/netfilter/nft_zones_many.sh | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/tools/testing/selftests/netfilter/nft_zones_many.sh b/tools/testing/selftests/netfilter/nft_zones_many.sh +index 04633119b29a0..5a8db0b48928f 100755 +--- a/tools/testing/selftests/netfilter/nft_zones_many.sh ++++ b/tools/testing/selftests/netfilter/nft_zones_many.sh +@@ -9,7 +9,7 @@ ns="ns-$sfx" + # Kselftest framework requirement - SKIP code is 4. + ksft_skip=4 + +-zones=20000 ++zones=2000 + have_ct_tool=0 + ret=0 + +@@ -75,10 +75,10 @@ EOF + + while [ $i -lt $max_zones ]; do + local start=$(date +%s%3N) +- i=$((i + 10000)) ++ i=$((i + 1000)) + j=$((j + 1)) + # nft rule in output places each packet in a different zone. +- dd if=/dev/zero of=/dev/stdout bs=8k count=10000 2>/dev/null | ip netns exec "$ns" socat STDIN UDP:127.0.0.1:12345,sourceport=12345 ++ dd if=/dev/zero of=/dev/stdout bs=8k count=1000 2>/dev/null | ip netns exec "$ns" socat STDIN UDP:127.0.0.1:12345,sourceport=12345 + if [ $? -ne 0 ] ;then + ret=1 + break +@@ -86,7 +86,7 @@ EOF + + stop=$(date +%s%3N) + local duration=$((stop-start)) +- echo "PASS: added 10000 entries in $duration ms (now $i total, loop $j)" ++ echo "PASS: added 1000 entries in $duration ms (now $i total, loop $j)" + done + + if [ $have_ct_tool -eq 1 ]; then +@@ -128,11 +128,11 @@ test_conntrack_tool() { + break + fi + +- if [ $((i%10000)) -eq 0 ];then ++ if [ $((i%1000)) -eq 0 ];then + stop=$(date +%s%3N) + + local duration=$((stop-start)) +- echo "PASS: added 10000 entries in $duration ms (now $i total)" ++ echo "PASS: added 1000 entries in $duration ms (now $i total)" + start=$stop + fi + done +-- +2.34.1 + diff --git a/queue-5.16/selftests-openat2-add-missing-dependency-in-makefile.patch b/queue-5.16/selftests-openat2-add-missing-dependency-in-makefile.patch new file mode 100644 index 00000000000..57a3a69f50e --- /dev/null +++ b/queue-5.16/selftests-openat2-add-missing-dependency-in-makefile.patch @@ -0,0 +1,46 @@ +From 28c6c04d891b054c35af2f176ff75cfed60e5fb1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jan 2022 10:27:22 +0000 +Subject: selftests: openat2: Add missing dependency in Makefile + +From: Cristian Marussi + +[ Upstream commit ea3396725aa143dd42fe388cb67e44c90d2fb719 ] + +Add a dependency on header helpers.h to the main target; while at that add +to helpers.h also a missing include for bool types. + +Cc: Aleksa Sarai +Signed-off-by: Cristian Marussi +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/openat2/Makefile | 2 +- + tools/testing/selftests/openat2/helpers.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/openat2/Makefile b/tools/testing/selftests/openat2/Makefile +index 4b93b1417b862..843ba56d8e49e 100644 +--- a/tools/testing/selftests/openat2/Makefile ++++ b/tools/testing/selftests/openat2/Makefile +@@ -5,4 +5,4 @@ TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test + + include ../lib.mk + +-$(TEST_GEN_PROGS): helpers.c ++$(TEST_GEN_PROGS): helpers.c helpers.h +diff --git a/tools/testing/selftests/openat2/helpers.h b/tools/testing/selftests/openat2/helpers.h +index ad5d0ba5b6ce9..7056340b9339e 100644 +--- a/tools/testing/selftests/openat2/helpers.h ++++ b/tools/testing/selftests/openat2/helpers.h +@@ -9,6 +9,7 @@ + + #define _GNU_SOURCE + #include ++#include + #include + #include + #include "../kselftest.h" +-- +2.34.1 + diff --git a/queue-5.16/selftests-openat2-print-also-errno-in-failure-messag.patch b/queue-5.16/selftests-openat2-print-also-errno-in-failure-messag.patch new file mode 100644 index 00000000000..96fc26fba13 --- /dev/null +++ b/queue-5.16/selftests-openat2-print-also-errno-in-failure-messag.patch @@ -0,0 +1,44 @@ +From 9c885445b97c89b324df626f695556257f222fd4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jan 2022 10:27:21 +0000 +Subject: selftests: openat2: Print also errno in failure messages + +From: Cristian Marussi + +[ Upstream commit e051cdf655fa016692008a446a060eff06222bb5 ] + +In E_func() macro, on error, print also errno in order to aid debugging. + +Cc: Aleksa Sarai +Signed-off-by: Cristian Marussi +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/openat2/helpers.h | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/tools/testing/selftests/openat2/helpers.h b/tools/testing/selftests/openat2/helpers.h +index a6ea27344db2d..ad5d0ba5b6ce9 100644 +--- a/tools/testing/selftests/openat2/helpers.h ++++ b/tools/testing/selftests/openat2/helpers.h +@@ -62,11 +62,12 @@ bool needs_openat2(const struct open_how *how); + (similar to chroot(2)). */ + #endif /* RESOLVE_IN_ROOT */ + +-#define E_func(func, ...) \ +- do { \ +- if (func(__VA_ARGS__) < 0) \ +- ksft_exit_fail_msg("%s:%d %s failed\n", \ +- __FILE__, __LINE__, #func);\ ++#define E_func(func, ...) \ ++ do { \ ++ errno = 0; \ ++ if (func(__VA_ARGS__) < 0) \ ++ ksft_exit_fail_msg("%s:%d %s failed - errno:%d\n", \ ++ __FILE__, __LINE__, #func, errno); \ + } while (0) + + #define E_asprintf(...) E_func(asprintf, __VA_ARGS__) +-- +2.34.1 + diff --git a/queue-5.16/selftests-openat2-skip-testcases-that-fail-with-eopn.patch b/queue-5.16/selftests-openat2-skip-testcases-that-fail-with-eopn.patch new file mode 100644 index 00000000000..066e3717496 --- /dev/null +++ b/queue-5.16/selftests-openat2-skip-testcases-that-fail-with-eopn.patch @@ -0,0 +1,53 @@ +From 464d2cbcb6b95c4d63ecee627cff096433465cbd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jan 2022 10:27:23 +0000 +Subject: selftests: openat2: Skip testcases that fail with EOPNOTSUPP + +From: Cristian Marussi + +[ Upstream commit ac9e0a250bb155078601a5b999aab05f2a04d1ab ] + +Skip testcases that fail since the requested valid flags combination is not +supported by the underlying filesystem. + +Cc: Aleksa Sarai +Signed-off-by: Cristian Marussi +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/openat2/openat2_test.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c +index 1bddbe934204c..7fb902099de45 100644 +--- a/tools/testing/selftests/openat2/openat2_test.c ++++ b/tools/testing/selftests/openat2/openat2_test.c +@@ -259,6 +259,16 @@ void test_openat2_flags(void) + unlink(path); + + fd = sys_openat2(AT_FDCWD, path, &test->how); ++ if (fd < 0 && fd == -EOPNOTSUPP) { ++ /* ++ * Skip the testcase if it failed because not supported ++ * by FS. (e.g. a valid O_TMPFILE combination on NFS) ++ */ ++ ksft_test_result_skip("openat2 with %s fails with %d (%s)\n", ++ test->name, fd, strerror(-fd)); ++ goto next; ++ } ++ + if (test->err >= 0) + failed = (fd < 0); + else +@@ -303,7 +313,7 @@ void test_openat2_flags(void) + else + resultfn("openat2 with %s fails with %d (%s)\n", + test->name, test->err, strerror(-test->err)); +- ++next: + free(fdpath); + fflush(stdout); + } +-- +2.34.1 + diff --git a/queue-5.16/selftests-rtc-increase-test-timeout-so-that-all-test.patch b/queue-5.16/selftests-rtc-increase-test-timeout-so-that-all-test.patch new file mode 100644 index 00000000000..f1bfb62c327 --- /dev/null +++ b/queue-5.16/selftests-rtc-increase-test-timeout-so-that-all-test.patch @@ -0,0 +1,49 @@ +From 0225acd1cc335f3d6cf1c6bb885e4d17f788f2e6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 12 Jan 2022 14:41:42 -0500 +Subject: selftests: rtc: Increase test timeout so that all tests run +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Nícolas F. R. A. Prado + +[ Upstream commit f034cc1301e7d83d4ec428dd6b8ffb57ca446efb ] + +The timeout setting for the rtc kselftest is currently 90 seconds. This +setting is used by the kselftest runner to stop running a test if it +takes longer than the assigned value. + +However, two of the test cases inside rtc set alarms. These alarms are +set to the next beginning of the minute, so each of these test cases may +take up to, in the worst case, 60 seconds. + +In order to allow for all test cases in rtc to run, even in the worst +case, when using the kselftest runner, the timeout value should be +increased to at least 120. Set it to 180, so there's some additional +slack. + +Correct operation can be tested by running the following command right +after the start of a minute (low second count), and checking that all +test cases run: + + ./run_kselftest.sh -c rtc + +Signed-off-by: Nícolas F. R. A. Prado +Acked-by: Alexandre Belloni +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/rtc/settings | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/rtc/settings b/tools/testing/selftests/rtc/settings +index ba4d85f74cd6b..a953c96aa16e1 100644 +--- a/tools/testing/selftests/rtc/settings ++++ b/tools/testing/selftests/rtc/settings +@@ -1 +1 @@ +-timeout=90 ++timeout=180 +-- +2.34.1 + diff --git a/queue-5.16/selftests-skip-mincore.check_file_mmap-when-fs-lacks.patch b/queue-5.16/selftests-skip-mincore.check_file_mmap-when-fs-lacks.patch new file mode 100644 index 00000000000..1bbf1373792 --- /dev/null +++ b/queue-5.16/selftests-skip-mincore.check_file_mmap-when-fs-lacks.patch @@ -0,0 +1,69 @@ +From 20d065c7cf1909737822397e506002a5dc3de233 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jan 2022 10:27:19 +0000 +Subject: selftests: skip mincore.check_file_mmap when fs lacks needed support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Cristian Marussi + +[ Upstream commit dae1d8ac31896988e7313384c0370176a75e9b45 ] + +Report mincore.check_file_mmap as SKIP instead of FAIL if the underlying +filesystem lacks support of O_TMPFILE or fallocate since such failures +are not really related to mincore functionality. + +Cc: Ricardo Cañuelo +Signed-off-by: Cristian Marussi +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + .../selftests/mincore/mincore_selftest.c | 20 +++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +diff --git a/tools/testing/selftests/mincore/mincore_selftest.c b/tools/testing/selftests/mincore/mincore_selftest.c +index e54106643337b..4c88238fc8f05 100644 +--- a/tools/testing/selftests/mincore/mincore_selftest.c ++++ b/tools/testing/selftests/mincore/mincore_selftest.c +@@ -207,15 +207,21 @@ TEST(check_file_mmap) + + errno = 0; + fd = open(".", O_TMPFILE | O_RDWR, 0600); +- ASSERT_NE(-1, fd) { +- TH_LOG("Can't create temporary file: %s", +- strerror(errno)); ++ if (fd < 0) { ++ ASSERT_EQ(errno, EOPNOTSUPP) { ++ TH_LOG("Can't create temporary file: %s", ++ strerror(errno)); ++ } ++ SKIP(goto out_free, "O_TMPFILE not supported by filesystem."); + } + errno = 0; + retval = fallocate(fd, 0, 0, FILE_SIZE); +- ASSERT_EQ(0, retval) { +- TH_LOG("Error allocating space for the temporary file: %s", +- strerror(errno)); ++ if (retval) { ++ ASSERT_EQ(errno, EOPNOTSUPP) { ++ TH_LOG("Error allocating space for the temporary file: %s", ++ strerror(errno)); ++ } ++ SKIP(goto out_close, "fallocate not supported by filesystem."); + } + + /* +@@ -271,7 +277,9 @@ TEST(check_file_mmap) + } + + munmap(addr, FILE_SIZE); ++out_close: + close(fd); ++out_free: + free(vec); + } + +-- +2.34.1 + diff --git a/queue-5.16/selftests-zram-adapt-the-situation-that-dev-zram0-is.patch b/queue-5.16/selftests-zram-adapt-the-situation-that-dev-zram0-is.patch new file mode 100644 index 00000000000..eb5abe7e8bb --- /dev/null +++ b/queue-5.16/selftests-zram-adapt-the-situation-that-dev-zram0-is.patch @@ -0,0 +1,329 @@ +From 4032de2a7468f22ae1676ea90fa20883c5f2d979 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 17:11:37 +0800 +Subject: selftests/zram: Adapt the situation that /dev/zram0 is being used + +From: Yang Xu + +[ Upstream commit 01dabed20573804750af5c7bf8d1598a6bf7bf6e ] + +If zram-generator package is installed and works, then we can not remove +zram module because zram swap is being used. This case needs a clean zram +environment, change this test by using hot_add/hot_remove interface. So +even zram device is being used, we still can add zram device and remove +them in cleanup. + +The two interface was introduced since kernel commit 6566d1a32bf7("zram: +add dynamic device add/remove functionality") in v4.2-rc1. If kernel +supports these two interface, we use hot_add/hot_remove to slove this +problem, if not, just check whether zram is being used or built in, then +skip it on old kernel. + +Signed-off-by: Yang Xu +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/zram/zram.sh | 15 +--- + tools/testing/selftests/zram/zram01.sh | 3 +- + tools/testing/selftests/zram/zram02.sh | 1 - + tools/testing/selftests/zram/zram_lib.sh | 110 +++++++++++++---------- + 4 files changed, 66 insertions(+), 63 deletions(-) + +diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh +index 232e958ec4547..b0b91d9b0dc21 100755 +--- a/tools/testing/selftests/zram/zram.sh ++++ b/tools/testing/selftests/zram/zram.sh +@@ -2,9 +2,6 @@ + # SPDX-License-Identifier: GPL-2.0 + TCID="zram.sh" + +-# Kselftest framework requirement - SKIP code is 4. +-ksft_skip=4 +- + . ./zram_lib.sh + + run_zram () { +@@ -18,14 +15,4 @@ echo "" + + check_prereqs + +-# check zram module exists +-MODULE_PATH=/lib/modules/`uname -r`/kernel/drivers/block/zram/zram.ko +-if [ -f $MODULE_PATH ]; then +- run_zram +-elif [ -b /dev/zram0 ]; then +- run_zram +-else +- echo "$TCID : No zram.ko module or /dev/zram0 device file not found" +- echo "$TCID : CONFIG_ZRAM is not set" +- exit $ksft_skip +-fi ++run_zram +diff --git a/tools/testing/selftests/zram/zram01.sh b/tools/testing/selftests/zram/zram01.sh +index e9e9eb777e2c7..8f4affe34f3e4 100755 +--- a/tools/testing/selftests/zram/zram01.sh ++++ b/tools/testing/selftests/zram/zram01.sh +@@ -33,7 +33,7 @@ zram_algs="lzo" + + zram_fill_fs() + { +- for i in $(seq 0 $(($dev_num - 1))); do ++ for i in $(seq $dev_start $dev_end); do + echo "fill zram$i..." + local b=0 + while [ true ]; do +@@ -67,7 +67,6 @@ zram_mount + + zram_fill_fs + zram_cleanup +-zram_unload + + if [ $ERR_CODE -ne 0 ]; then + echo "$TCID : [FAIL]" +diff --git a/tools/testing/selftests/zram/zram02.sh b/tools/testing/selftests/zram/zram02.sh +index e83b404807c09..2418b0c4ed136 100755 +--- a/tools/testing/selftests/zram/zram02.sh ++++ b/tools/testing/selftests/zram/zram02.sh +@@ -36,7 +36,6 @@ zram_set_memlimit + zram_makeswap + zram_swapoff + zram_cleanup +-zram_unload + + if [ $ERR_CODE -ne 0 ]; then + echo "$TCID : [FAIL]" +diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh +index f47fc0f27e99e..21ec1966de76c 100755 +--- a/tools/testing/selftests/zram/zram_lib.sh ++++ b/tools/testing/selftests/zram/zram_lib.sh +@@ -5,10 +5,12 @@ + # Author: Alexey Kodanev + # Modified: Naresh Kamboju + +-MODULE=0 + dev_makeswap=-1 + dev_mounted=-1 +- ++dev_start=0 ++dev_end=-1 ++module_load=-1 ++sys_control=-1 + # Kselftest framework requirement - SKIP code is 4. + ksft_skip=4 + kernel_version=`uname -r | cut -d'.' -f1,2` +@@ -46,57 +48,72 @@ zram_cleanup() + { + echo "zram cleanup" + local i= +- for i in $(seq 0 $dev_makeswap); do ++ for i in $(seq $dev_start $dev_makeswap); do + swapoff /dev/zram$i + done + +- for i in $(seq 0 $dev_mounted); do ++ for i in $(seq $dev_start $dev_mounted); do + umount /dev/zram$i + done + +- for i in $(seq 0 $(($dev_num - 1))); do ++ for i in $(seq $dev_start $dev_end); do + echo 1 > /sys/block/zram${i}/reset + rm -rf zram$i + done + +-} ++ if [ $sys_control -eq 1 ]; then ++ for i in $(seq $dev_start $dev_end); do ++ echo $i > /sys/class/zram-control/hot_remove ++ done ++ fi + +-zram_unload() +-{ +- if [ $MODULE -ne 0 ] ; then +- echo "zram rmmod zram" ++ if [ $module_load -eq 1 ]; then + rmmod zram > /dev/null 2>&1 + fi + } + + zram_load() + { +- # check zram module exists +- MODULE_PATH=/lib/modules/`uname -r`/kernel/drivers/block/zram/zram.ko +- if [ -f $MODULE_PATH ]; then +- MODULE=1 +- echo "create '$dev_num' zram device(s)" +- modprobe zram num_devices=$dev_num +- if [ $? -ne 0 ]; then +- echo "failed to insert zram module" +- exit 1 +- fi +- +- dev_num_created=$(ls /dev/zram* | wc -w) ++ echo "create '$dev_num' zram device(s)" ++ ++ # zram module loaded, new kernel ++ if [ -d "/sys/class/zram-control" ]; then ++ echo "zram modules already loaded, kernel supports" \ ++ "zram-control interface" ++ dev_start=$(ls /dev/zram* | wc -w) ++ dev_end=$(($dev_start + $dev_num - 1)) ++ sys_control=1 ++ ++ for i in $(seq $dev_start $dev_end); do ++ cat /sys/class/zram-control/hot_add > /dev/null ++ done ++ ++ echo "all zram devices (/dev/zram$dev_start~$dev_end" \ ++ "successfully created" ++ return 0 ++ fi + +- if [ "$dev_num_created" -ne "$dev_num" ]; then +- echo "unexpected num of devices: $dev_num_created" +- ERR_CODE=-1 ++ # detect old kernel or built-in ++ modprobe zram num_devices=$dev_num ++ if [ ! -d "/sys/class/zram-control" ]; then ++ if grep -q '^zram' /proc/modules; then ++ rmmod zram > /dev/null 2>&1 ++ if [ $? -ne 0 ]; then ++ echo "zram module is being used on old kernel" \ ++ "without zram-control interface" ++ exit $ksft_skip ++ fi + else +- echo "zram load module successful" ++ echo "test needs CONFIG_ZRAM=m on old kernel without" \ ++ "zram-control interface" ++ exit $ksft_skip + fi +- elif [ -b /dev/zram0 ]; then +- echo "/dev/zram0 device file found: OK" +- else +- echo "ERROR: No zram.ko module or no /dev/zram0 device found" +- echo "$TCID : CONFIG_ZRAM is not set" +- exit 1 ++ modprobe zram num_devices=$dev_num + fi ++ ++ module_load=1 ++ dev_end=$(($dev_num - 1)) ++ echo "all zram devices (/dev/zram0~$dev_end) successfully created" + } + + zram_max_streams() +@@ -110,7 +127,7 @@ zram_max_streams() + return 0 + fi + +- local i=0 ++ local i=$dev_start + for max_s in $zram_max_streams; do + local sys_path="/sys/block/zram${i}/max_comp_streams" + echo $max_s > $sys_path || \ +@@ -122,7 +139,7 @@ zram_max_streams() + echo "FAIL can't set max_streams '$max_s', get $max_stream" + + i=$(($i + 1)) +- echo "$sys_path = '$max_streams' ($i/$dev_num)" ++ echo "$sys_path = '$max_streams'" + done + + echo "zram max streams: OK" +@@ -132,15 +149,16 @@ zram_compress_alg() + { + echo "test that we can set compression algorithm" + +- local algs=$(cat /sys/block/zram0/comp_algorithm) ++ local i=$dev_start ++ local algs=$(cat /sys/block/zram${i}/comp_algorithm) + echo "supported algs: $algs" +- local i=0 ++ + for alg in $zram_algs; do + local sys_path="/sys/block/zram${i}/comp_algorithm" + echo "$alg" > $sys_path || \ + echo "FAIL can't set '$alg' to $sys_path" + i=$(($i + 1)) +- echo "$sys_path = '$alg' ($i/$dev_num)" ++ echo "$sys_path = '$alg'" + done + + echo "zram set compression algorithm: OK" +@@ -149,14 +167,14 @@ zram_compress_alg() + zram_set_disksizes() + { + echo "set disk size to zram device(s)" +- local i=0 ++ local i=$dev_start + for ds in $zram_sizes; do + local sys_path="/sys/block/zram${i}/disksize" + echo "$ds" > $sys_path || \ + echo "FAIL can't set '$ds' to $sys_path" + + i=$(($i + 1)) +- echo "$sys_path = '$ds' ($i/$dev_num)" ++ echo "$sys_path = '$ds'" + done + + echo "zram set disksizes: OK" +@@ -166,14 +184,14 @@ zram_set_memlimit() + { + echo "set memory limit to zram device(s)" + +- local i=0 ++ local i=$dev_start + for ds in $zram_mem_limits; do + local sys_path="/sys/block/zram${i}/mem_limit" + echo "$ds" > $sys_path || \ + echo "FAIL can't set '$ds' to $sys_path" + + i=$(($i + 1)) +- echo "$sys_path = '$ds' ($i/$dev_num)" ++ echo "$sys_path = '$ds'" + done + + echo "zram set memory limit: OK" +@@ -182,8 +200,8 @@ zram_set_memlimit() + zram_makeswap() + { + echo "make swap with zram device(s)" +- local i=0 +- for i in $(seq 0 $(($dev_num - 1))); do ++ local i=$dev_start ++ for i in $(seq $dev_start $dev_end); do + mkswap /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log +@@ -206,7 +224,7 @@ zram_makeswap() + zram_swapoff() + { + local i= +- for i in $(seq 0 $dev_makeswap); do ++ for i in $(seq $dev_start $dev_end); do + swapoff /dev/zram$i > err.log 2>&1 + if [ $? -ne 0 ]; then + cat err.log +@@ -220,7 +238,7 @@ zram_swapoff() + + zram_makefs() + { +- local i=0 ++ local i=$dev_start + for fs in $zram_filesystems; do + # if requested fs not supported default it to ext2 + which mkfs.$fs > /dev/null 2>&1 || fs=ext2 +@@ -239,7 +257,7 @@ zram_makefs() + zram_mount() + { + local i=0 +- for i in $(seq 0 $(($dev_num - 1))); do ++ for i in $(seq $dev_start $dev_end); do + echo "mount /dev/zram$i" + mkdir zram$i + mount /dev/zram$i zram$i > /dev/null || \ +-- +2.34.1 + diff --git a/queue-5.16/selftests-zram-skip-max_comp_streams-interface-on-ne.patch b/queue-5.16/selftests-zram-skip-max_comp_streams-interface-on-ne.patch new file mode 100644 index 00000000000..2eae072219e --- /dev/null +++ b/queue-5.16/selftests-zram-skip-max_comp_streams-interface-on-ne.patch @@ -0,0 +1,75 @@ +From b8456d0366a6db73456a524c250a6d79847c3b07 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 17:11:35 +0800 +Subject: selftests/zram: Skip max_comp_streams interface on newer kernel + +From: Yang Xu + +[ Upstream commit fc4eb486a59d70bd35cf1209f0e68c2d8b979193 ] + +Since commit 43209ea2d17a ("zram: remove max_comp_streams internals"), zram +has switched to per-cpu streams. Even kernel still keep this interface for +some reasons, but writing to max_comp_stream doesn't take any effect. So +skip it on newer kernel ie 4.7. + +The code that comparing kernel version is from xfstests testsuite ext4/053. + +Signed-off-by: Yang Xu +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/zram/zram_lib.sh | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh +index 6f872f266fd11..f47fc0f27e99e 100755 +--- a/tools/testing/selftests/zram/zram_lib.sh ++++ b/tools/testing/selftests/zram/zram_lib.sh +@@ -11,6 +11,9 @@ dev_mounted=-1 + + # Kselftest framework requirement - SKIP code is 4. + ksft_skip=4 ++kernel_version=`uname -r | cut -d'.' -f1,2` ++kernel_major=${kernel_version%.*} ++kernel_minor=${kernel_version#*.} + + trap INT + +@@ -25,6 +28,20 @@ check_prereqs() + fi + } + ++kernel_gte() ++{ ++ major=${1%.*} ++ minor=${1#*.} ++ ++ if [ $kernel_major -gt $major ]; then ++ return 0 ++ elif [[ $kernel_major -eq $major && $kernel_minor -ge $minor ]]; then ++ return 0 ++ fi ++ ++ return 1 ++} ++ + zram_cleanup() + { + echo "zram cleanup" +@@ -86,6 +103,13 @@ zram_max_streams() + { + echo "set max_comp_streams to zram device(s)" + ++ kernel_gte 4.7 ++ if [ $? -eq 0 ]; then ++ echo "The device attribute max_comp_streams was"\ ++ "deprecated in 4.7" ++ return 0 ++ fi ++ + local i=0 + for max_s in $zram_max_streams; do + local sys_path="/sys/block/zram${i}/max_comp_streams" +-- +2.34.1 + diff --git a/queue-5.16/selftests-zram01.sh-fix-compression-ratio-calculatio.patch b/queue-5.16/selftests-zram01.sh-fix-compression-ratio-calculatio.patch new file mode 100644 index 00000000000..973fa0c25e7 --- /dev/null +++ b/queue-5.16/selftests-zram01.sh-fix-compression-ratio-calculatio.patch @@ -0,0 +1,84 @@ +From dd8032dbf5c1e499a497efcef1bb8bc7ef5540c1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 27 Jan 2022 17:11:36 +0800 +Subject: selftests/zram01.sh: Fix compression ratio calculation + +From: Yang Xu + +[ Upstream commit d18da7ec3719559d6e74937266d0416e6c7e0b31 ] + +zram01 uses `free -m` to measure zram memory usage. The results are no +sense because they are polluted by all running processes on the system. + +We Should only calculate the free memory delta for the current process. +So use the third field of /sys/block/zram/mm_stat to measure memory +usage instead. The file is available since kernel 4.1. + +orig_data_size(first): uncompressed size of data stored in this disk. +compr_data_size(second): compressed size of data stored in this disk +mem_used_total(third): the amount of memory allocated for this disk + +Also remove useless zram cleanup call in zram_fill_fs and so we don't +need to cleanup zram twice if fails. + +Signed-off-by: Yang Xu +Signed-off-by: Shuah Khan +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/zram/zram01.sh | 30 +++++++------------------- + 1 file changed, 8 insertions(+), 22 deletions(-) + +diff --git a/tools/testing/selftests/zram/zram01.sh b/tools/testing/selftests/zram/zram01.sh +index 114863d9fb876..e9e9eb777e2c7 100755 +--- a/tools/testing/selftests/zram/zram01.sh ++++ b/tools/testing/selftests/zram/zram01.sh +@@ -33,8 +33,6 @@ zram_algs="lzo" + + zram_fill_fs() + { +- local mem_free0=$(free -m | awk 'NR==2 {print $4}') +- + for i in $(seq 0 $(($dev_num - 1))); do + echo "fill zram$i..." + local b=0 +@@ -45,29 +43,17 @@ zram_fill_fs() + b=$(($b + 1)) + done + echo "zram$i can be filled with '$b' KB" +- done + +- local mem_free1=$(free -m | awk 'NR==2 {print $4}') +- local used_mem=$(($mem_free0 - $mem_free1)) ++ local mem_used_total=`awk '{print $3}' "/sys/block/zram$i/mm_stat"` ++ local v=$((100 * 1024 * $b / $mem_used_total)) ++ if [ "$v" -lt 100 ]; then ++ echo "FAIL compression ratio: 0.$v:1" ++ ERR_CODE=-1 ++ return ++ fi + +- local total_size=0 +- for sm in $zram_sizes; do +- local s=$(echo $sm | sed 's/M//') +- total_size=$(($total_size + $s)) ++ echo "zram compression ratio: $(echo "scale=2; $v / 100 " | bc):1: OK" + done +- +- echo "zram used ${used_mem}M, zram disk sizes ${total_size}M" +- +- local v=$((100 * $total_size / $used_mem)) +- +- if [ "$v" -lt 100 ]; then +- echo "FAIL compression ratio: 0.$v:1" +- ERR_CODE=-1 +- zram_cleanup +- return +- fi +- +- echo "zram compression ratio: $(echo "scale=2; $v / 100 " | bc):1: OK" + } + + check_prereqs +-- +2.34.1 + diff --git a/queue-5.16/series b/queue-5.16/series index 6a563faa66c..14abcb06b3a 100644 --- a/queue-5.16/series +++ b/queue-5.16/series @@ -28,3 +28,43 @@ hid-apple-set-the-tilde-quirk-flag-on-the-wellspring-5-and-later.patch btrfs-don-t-hold-cpu-for-too-long-when-defragging-a-file.patch btrfs-send-in-case-of-io-error-log-it.patch btrfs-defrag-don-t-try-to-defrag-extents-which-are-under-writeback.patch +asoc-mediatek-fix-unmet-dependency-on-gpiolib-for-sn.patch +platform-x86-touchscreen_dmi-add-info-for-the-rwc-na.patch +platform-x86-isst-fix-possible-circular-locking-depe.patch +platform-x86-amd-pmc-correct-usage-of-smu-version.patch +kunit-tool-import-missing-importlib.abc.patch +selftests-rtc-increase-test-timeout-so-that-all-test.patch +kselftest-signal-all-child-processes.patch +selftests-netfilter-reduce-zone-stress-test-running-.patch +net-ieee802154-at86rf230-stop-leaking-skb-s.patch +selftests-zram-skip-max_comp_streams-interface-on-ne.patch +selftests-zram01.sh-fix-compression-ratio-calculatio.patch +selftests-zram-adapt-the-situation-that-dev-zram0-is.patch +selftests-openat2-print-also-errno-in-failure-messag.patch +selftests-openat2-add-missing-dependency-in-makefile.patch +selftests-openat2-skip-testcases-that-fail-with-eopn.patch +selftests-skip-mincore.check_file_mmap-when-fs-lacks.patch +ax25-improve-the-incomplete-fix-to-avoid-uaf-and-npd.patch +cifs-unlock-chan_lock-before-calling-cifs_put_tcp_se.patch +pinctrl-bcm63xx-fix-unmet-dependency-on-regmap-for-g.patch +vfs-make-freeze_super-abort-when-sync_filesystem-ret.patch +vfs-make-sync_filesystem-return-errors-from-sync_fs.patch +quota-make-dquot_quota_sync-return-errors-from-sync_.patch +scsi-pm80xx-fix-double-completion-for-sata-devices.patch +kselftest-fix-vdso_test_abi-return-status.patch +scsi-core-reallocate-device-s-budget-map-on-queue-de.patch +scsi-pm8001-fix-use-after-free-for-aborted-tmf-sas_t.patch +scsi-pm8001-fix-use-after-free-for-aborted-ssp-stp-s.patch +drm-amd-warn-users-about-potential-s0ix-problems.patch +mailmap-update-christian-brauner-s-email-address.patch +nvme-fix-a-possible-use-after-free-in-controller-res.patch +nvme-tcp-fix-possible-use-after-free-in-transport-er.patch +nvme-rdma-fix-possible-use-after-free-in-transport-e.patch +net-sparx5-do-not-refer-to-skb-after-passing-it-on.patch +drm-amd-add-support-to-check-whether-the-system-is-s.patch +drm-amd-only-run-s3-or-s0ix-if-system-is-configured-.patch +drm-amdgpu-fix-logic-inversion-in-check.patch +x86-xen-streamline-and-fix-pv-cpu-enumeration.patch +revert-module-async-async_synchronize_full-on-module.patch +gcc-plugins-stackleak-use-noinstr-in-favor-of-notrac.patch +random-wake-up-dev-random-writers-after-zap.patch diff --git a/queue-5.16/vfs-make-freeze_super-abort-when-sync_filesystem-ret.patch b/queue-5.16/vfs-make-freeze_super-abort-when-sync_filesystem-ret.patch new file mode 100644 index 00000000000..2e0b1c06082 --- /dev/null +++ b/queue-5.16/vfs-make-freeze_super-abort-when-sync_filesystem-ret.patch @@ -0,0 +1,76 @@ +From ffdd8991230b9512b83886b69064d7020f1f4360 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 30 Jan 2022 08:53:16 -0800 +Subject: vfs: make freeze_super abort when sync_filesystem returns error + +From: Darrick J. Wong + +[ Upstream commit 2719c7160dcfaae1f73a1c0c210ad3281c19022e ] + +If we fail to synchronize the filesystem while preparing to freeze the +fs, abort the freeze. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Jan Kara +Reviewed-by: Christoph Hellwig +Acked-by: Christian Brauner +Signed-off-by: Sasha Levin +--- + fs/super.c | 19 ++++++++++++------- + 1 file changed, 12 insertions(+), 7 deletions(-) + +diff --git a/fs/super.c b/fs/super.c +index a6405d44d4ca2..d978dd031a036 100644 +--- a/fs/super.c ++++ b/fs/super.c +@@ -1619,11 +1619,9 @@ static void lockdep_sb_freeze_acquire(struct super_block *sb) + percpu_rwsem_acquire(sb->s_writers.rw_sem + level, 0, _THIS_IP_); + } + +-static void sb_freeze_unlock(struct super_block *sb) ++static void sb_freeze_unlock(struct super_block *sb, int level) + { +- int level; +- +- for (level = SB_FREEZE_LEVELS - 1; level >= 0; level--) ++ for (level--; level >= 0; level--) + percpu_up_write(sb->s_writers.rw_sem + level); + } + +@@ -1694,7 +1692,14 @@ int freeze_super(struct super_block *sb) + sb_wait_write(sb, SB_FREEZE_PAGEFAULT); + + /* All writers are done so after syncing there won't be dirty data */ +- sync_filesystem(sb); ++ ret = sync_filesystem(sb); ++ if (ret) { ++ sb->s_writers.frozen = SB_UNFROZEN; ++ sb_freeze_unlock(sb, SB_FREEZE_PAGEFAULT); ++ wake_up(&sb->s_writers.wait_unfrozen); ++ deactivate_locked_super(sb); ++ return ret; ++ } + + /* Now wait for internal filesystem counter */ + sb->s_writers.frozen = SB_FREEZE_FS; +@@ -1706,7 +1711,7 @@ int freeze_super(struct super_block *sb) + printk(KERN_ERR + "VFS:Filesystem freeze failed\n"); + sb->s_writers.frozen = SB_UNFROZEN; +- sb_freeze_unlock(sb); ++ sb_freeze_unlock(sb, SB_FREEZE_FS); + wake_up(&sb->s_writers.wait_unfrozen); + deactivate_locked_super(sb); + return ret; +@@ -1751,7 +1756,7 @@ static int thaw_super_locked(struct super_block *sb) + } + + sb->s_writers.frozen = SB_UNFROZEN; +- sb_freeze_unlock(sb); ++ sb_freeze_unlock(sb, SB_FREEZE_FS); + out: + wake_up(&sb->s_writers.wait_unfrozen); + deactivate_locked_super(sb); +-- +2.34.1 + diff --git a/queue-5.16/vfs-make-sync_filesystem-return-errors-from-sync_fs.patch b/queue-5.16/vfs-make-sync_filesystem-return-errors-from-sync_fs.patch new file mode 100644 index 00000000000..093924f3df4 --- /dev/null +++ b/queue-5.16/vfs-make-sync_filesystem-return-errors-from-sync_fs.patch @@ -0,0 +1,65 @@ +From 0d2077f4ce1682bdf75dac1748d6ae3b965930ac Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 30 Jan 2022 08:53:16 -0800 +Subject: vfs: make sync_filesystem return errors from ->sync_fs + +From: Darrick J. Wong + +[ Upstream commit 5679897eb104cec9e99609c3f045a0c20603da4c ] + +Strangely, sync_filesystem ignores the return code from the ->sync_fs +call, which means that syscalls like syncfs(2) never see the error. +This doesn't seem right, so fix that. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Jan Kara +Reviewed-by: Christoph Hellwig +Acked-by: Christian Brauner +Signed-off-by: Sasha Levin +--- + fs/sync.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/fs/sync.c b/fs/sync.c +index 3ce8e2137f310..c7690016453e4 100644 +--- a/fs/sync.c ++++ b/fs/sync.c +@@ -29,7 +29,7 @@ + */ + int sync_filesystem(struct super_block *sb) + { +- int ret; ++ int ret = 0; + + /* + * We need to be protected against the filesystem going from +@@ -52,15 +52,21 @@ int sync_filesystem(struct super_block *sb) + * at a time. + */ + writeback_inodes_sb(sb, WB_REASON_SYNC); +- if (sb->s_op->sync_fs) +- sb->s_op->sync_fs(sb, 0); ++ if (sb->s_op->sync_fs) { ++ ret = sb->s_op->sync_fs(sb, 0); ++ if (ret) ++ return ret; ++ } + ret = sync_blockdev_nowait(sb->s_bdev); +- if (ret < 0) ++ if (ret) + return ret; + + sync_inodes_sb(sb); +- if (sb->s_op->sync_fs) +- sb->s_op->sync_fs(sb, 1); ++ if (sb->s_op->sync_fs) { ++ ret = sb->s_op->sync_fs(sb, 1); ++ if (ret) ++ return ret; ++ } + return sync_blockdev(sb->s_bdev); + } + EXPORT_SYMBOL(sync_filesystem); +-- +2.34.1 + diff --git a/queue-5.16/x86-xen-streamline-and-fix-pv-cpu-enumeration.patch b/queue-5.16/x86-xen-streamline-and-fix-pv-cpu-enumeration.patch new file mode 100644 index 00000000000..cd3b1731235 --- /dev/null +++ b/queue-5.16/x86-xen-streamline-and-fix-pv-cpu-enumeration.patch @@ -0,0 +1,106 @@ +From f0d1c0b0f1d4efbb1e29434f886464a973251504 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Feb 2022 11:57:16 +0100 +Subject: x86/Xen: streamline (and fix) PV CPU enumeration + +From: Jan Beulich + +[ Upstream commit e25a8d959992f61b64a58fc62fb7951dc6f31d1f ] + +This started out with me noticing that "dom0_max_vcpus=" with +larger than the number of physical CPUs reported through ACPI tables +would not bring up the "excess" vCPU-s. Addressing this is the primary +purpose of the change; CPU maps handling is being tidied only as far as +is necessary for the change here (with the effect of also avoiding the +setting up of too much per-CPU infrastructure, i.e. for CPUs which can +never come online). + +Noticing that xen_fill_possible_map() is called way too early, whereas +xen_filter_cpu_maps() is called too late (after per-CPU areas were +already set up), and further observing that each of the functions serves +only one of Dom0 or DomU, it looked like it was better to simplify this. +Use the .get_smp_config hook instead, uniformly for Dom0 and DomU. +xen_fill_possible_map() can be dropped altogether, while +xen_filter_cpu_maps() is re-purposed but not otherwise changed. + +Signed-off-by: Jan Beulich +Reviewed-by: Boris Ostrovsky +Link: https://lore.kernel.org/r/2dbd5f0a-9859-ca2d-085e-a02f7166c610@suse.com +Signed-off-by: Juergen Gross +Signed-off-by: Sasha Levin +--- + arch/x86/xen/enlighten_pv.c | 4 ---- + arch/x86/xen/smp_pv.c | 26 ++++++-------------------- + 2 files changed, 6 insertions(+), 24 deletions(-) + +diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c +index 5004feb16783d..d47c3d176ae4b 100644 +--- a/arch/x86/xen/enlighten_pv.c ++++ b/arch/x86/xen/enlighten_pv.c +@@ -1341,10 +1341,6 @@ asmlinkage __visible void __init xen_start_kernel(void) + + xen_acpi_sleep_register(); + +- /* Avoid searching for BIOS MP tables */ +- x86_init.mpparse.find_smp_config = x86_init_noop; +- x86_init.mpparse.get_smp_config = x86_init_uint_noop; +- + xen_boot_params_init_edd(); + + #ifdef CONFIG_ACPI +diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c +index 6a8f3b53ab834..4a6019238ee7d 100644 +--- a/arch/x86/xen/smp_pv.c ++++ b/arch/x86/xen/smp_pv.c +@@ -148,28 +148,12 @@ int xen_smp_intr_init_pv(unsigned int cpu) + return rc; + } + +-static void __init xen_fill_possible_map(void) +-{ +- int i, rc; +- +- if (xen_initial_domain()) +- return; +- +- for (i = 0; i < nr_cpu_ids; i++) { +- rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); +- if (rc >= 0) { +- num_processors++; +- set_cpu_possible(i, true); +- } +- } +-} +- +-static void __init xen_filter_cpu_maps(void) ++static void __init _get_smp_config(unsigned int early) + { + int i, rc; + unsigned int subtract = 0; + +- if (!xen_initial_domain()) ++ if (early) + return; + + num_processors = 0; +@@ -210,7 +194,6 @@ static void __init xen_pv_smp_prepare_boot_cpu(void) + * sure the old memory can be recycled. */ + make_lowmem_page_readwrite(xen_initial_gdt); + +- xen_filter_cpu_maps(); + xen_setup_vcpu_info_placement(); + + /* +@@ -476,5 +459,8 @@ static const struct smp_ops xen_smp_ops __initconst = { + void __init xen_smp_init(void) + { + smp_ops = xen_smp_ops; +- xen_fill_possible_map(); ++ ++ /* Avoid searching for BIOS MP tables */ ++ x86_init.mpparse.find_smp_config = x86_init_noop; ++ x86_init.mpparse.get_smp_config = _get_smp_config; + } +-- +2.34.1 + -- 2.47.3