From: Sasha Levin Date: Sat, 3 Feb 2024 17:24:50 +0000 (-0500) Subject: Fixes for 5.10 X-Git-Tag: v6.1.77~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=994a0d209127582bbb8ea5467f2021b2305457e0;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/pm-sleep-fix-error-handling-in-dpm_prepare.patch b/queue-5.10/pm-sleep-fix-error-handling-in-dpm_prepare.patch new file mode 100644 index 00000000000..9384bcb7058 --- /dev/null +++ b/queue-5.10/pm-sleep-fix-error-handling-in-dpm_prepare.patch @@ -0,0 +1,47 @@ +From 8ae44ae170b0716a7a02454405f8358cee0231bd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 16 Dec 2021 20:30:18 +0100 +Subject: PM: sleep: Fix error handling in dpm_prepare() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Rafael J. Wysocki + +[ Upstream commit 544e737dea5ad1a457f25dbddf68761ff25e028b ] + +Commit 2aa36604e824 ("PM: sleep: Avoid calling put_device() under +dpm_list_mtx") forgot to update the while () loop termination +condition to also break the loop if error is nonzero, which +causes the loop to become infinite if device_prepare() returns +an error for one device. + +Add the missing !error check. + +Fixes: 2aa36604e824 ("PM: sleep: Avoid calling put_device() under dpm_list_mtx") +Signed-off-by: Rafael J. Wysocki +Reported-by: Thomas Hellström +Reviewed-by: Thomas Hellström +Reviewed-by: Ulf Hansson +Cc: All applicable +Signed-off-by: Sasha Levin +--- + drivers/base/power/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c +index c493e48e420f..fbc57c4fcdd0 100644 +--- a/drivers/base/power/main.c ++++ b/drivers/base/power/main.c +@@ -1897,7 +1897,7 @@ int dpm_prepare(pm_message_t state) + device_block_probing(); + + mutex_lock(&dpm_list_mtx); +- while (!list_empty(&dpm_list)) { ++ while (!list_empty(&dpm_list) && !error) { + struct device *dev = to_device(dpm_list.next); + + get_device(dev); +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index b697c07a4cc..5a785a9c4c5 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -243,3 +243,5 @@ net-sysfs-fix-sys-class-net-iface-path.patch hid-apple-add-support-for-the-2021-magic-keyboard.patch hid-apple-add-2021-magic-keyboard-fn-key-mapping.patch bonding-remove-print-in-bond_verify_device_path.patch +uapi-stddef.h-fix-__declare_flex_array-for-c.patch +pm-sleep-fix-error-handling-in-dpm_prepare.patch diff --git a/queue-5.10/uapi-stddef.h-fix-__declare_flex_array-for-c.patch b/queue-5.10/uapi-stddef.h-fix-__declare_flex_array-for-c.patch new file mode 100644 index 00000000000..2564f755376 --- /dev/null +++ b/queue-5.10/uapi-stddef.h-fix-__declare_flex_array-for-c.patch @@ -0,0 +1,76 @@ +From 4cbf4b17744121807951dd3e36aa7080fd092433 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 Sep 2023 19:22:24 +0300 +Subject: uapi: stddef.h: Fix __DECLARE_FLEX_ARRAY for C++ + +From: Alexey Dobriyan + +[ Upstream commit 32a4ec211d4164e667d9d0b807fadf02053cd2e9 ] + +__DECLARE_FLEX_ARRAY(T, member) macro expands to + + struct { + struct {} __empty_member; + T member[]; + }; + +which is subtly wrong in C++ because sizeof(struct{}) is 1 not 0, +changing UAPI structures layouts. + +This can be fixed by expanding to + + T member[]; + +Now g++ doesn't like "T member[]" either, throwing errors on +the following code: + + struct S { + union { + T1 member1[]; + T2 member2[]; + }; + }; + +or + + struct S { + T member[]; + }; + +Use "T member[0];" which seems to work and does the right thing wrt +structure layout. + +Signed-off-by: Alexey Dobriyan +Fixes: 3080ea5553cc ("stddef: Introduce DECLARE_FLEX_ARRAY() helper") +Link: https://lore.kernel.org/r/97242381-f1ec-4a4a-9472-1a464f575657@p183 +Signed-off-by: Kees Cook +Signed-off-by: Sasha Levin +--- + include/uapi/linux/stddef.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h +index 7837ba4fe728..46c7bab501cb 100644 +--- a/include/uapi/linux/stddef.h ++++ b/include/uapi/linux/stddef.h +@@ -29,6 +29,11 @@ + struct TAG { MEMBERS } ATTRS NAME; \ + } + ++#ifdef __cplusplus ++/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */ ++#define __DECLARE_FLEX_ARRAY(T, member) \ ++ T member[0] ++#else + /** + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * +@@ -45,3 +50,5 @@ + TYPE NAME[]; \ + } + #endif ++ ++#endif +-- +2.43.0 +