From db603e79c91c9e38dba55ebde7ddb38d46aaaa2a Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Fri, 29 Mar 2024 07:55:34 -0400 Subject: [PATCH] Fixes for 5.10 Signed-off-by: Sasha Levin --- ...nsole_may_schedule-in-console_tryloc.patch | 46 +++++++++++++++++++ queue-5.10/series | 1 + 2 files changed, 47 insertions(+) create mode 100644 queue-5.10/printk-update-console_may_schedule-in-console_tryloc.patch diff --git a/queue-5.10/printk-update-console_may_schedule-in-console_tryloc.patch b/queue-5.10/printk-update-console_may_schedule-in-console_tryloc.patch new file mode 100644 index 00000000000..5da3b3c5c55 --- /dev/null +++ b/queue-5.10/printk-update-console_may_schedule-in-console_tryloc.patch @@ -0,0 +1,46 @@ +From da56cc4726de9c226f7348a4722854d5e9d874b7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 26 Feb 2024 13:07:24 +0106 +Subject: printk: Update @console_may_schedule in console_trylock_spinning() + +From: John Ogness + +[ Upstream commit 8076972468584d4a21dab9aa50e388b3ea9ad8c7 ] + +console_trylock_spinning() may takeover the console lock from a +schedulable context. Update @console_may_schedule to make sure it +reflects a trylock acquire. + +Reported-by: Mukesh Ojha +Closes: https://lore.kernel.org/lkml/20240222090538.23017-1-quic_mojha@quicinc.com +Fixes: dbdda842fe96 ("printk: Add console owner and waiter logic to load balance console writes") +Signed-off-by: John Ogness +Reviewed-by: Mukesh Ojha +Reviewed-by: Petr Mladek +Link: https://lore.kernel.org/r/875xybmo2z.fsf@jogness.linutronix.de +Signed-off-by: Petr Mladek +Signed-off-by: Sasha Levin +--- + kernel/printk/printk.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c +index 255654ea12447..a8af93cbc2936 100644 +--- a/kernel/printk/printk.c ++++ b/kernel/printk/printk.c +@@ -1866,6 +1866,12 @@ static int console_trylock_spinning(void) + */ + mutex_acquire(&console_lock_dep_map, 0, 1, _THIS_IP_); + ++ /* ++ * Update @console_may_schedule for trylock because the previous ++ * owner may have been schedulable. ++ */ ++ console_may_schedule = 0; ++ + return 1; + } + +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index 46ef85a2067..1d91d5ecdd0 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -133,3 +133,4 @@ vt-fix-unicode-buffer-corruption-when-deleting-characters.patch fs-aio-check-iocb_aio_rw-before-the-struct-aio_kiocb-conversion.patch tee-optee-fix-kernel-panic-caused-by-incorrect-error-handling.patch xen-events-close-evtchn-after-mapping-cleanup.patch +printk-update-console_may_schedule-in-console_tryloc.patch -- 2.39.5