diff options
Diffstat (limited to 'debian/patches-rt/0002-lib-vsprintf-Initialize-vsprintf-s-pointer-hash-once.patch')
-rw-r--r-- | debian/patches-rt/0002-lib-vsprintf-Initialize-vsprintf-s-pointer-hash-once.patch | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/debian/patches-rt/0002-lib-vsprintf-Initialize-vsprintf-s-pointer-hash-once.patch b/debian/patches-rt/0002-lib-vsprintf-Initialize-vsprintf-s-pointer-hash-once.patch index 5dafdd3e7..6c5927228 100644 --- a/debian/patches-rt/0002-lib-vsprintf-Initialize-vsprintf-s-pointer-hash-once.patch +++ b/debian/patches-rt/0002-lib-vsprintf-Initialize-vsprintf-s-pointer-hash-once.patch @@ -1,8 +1,8 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> -Date: Fri, 29 Jul 2022 10:53:00 +0200 +Date: Mon, 1 Aug 2022 11:34:33 +0200 Subject: [PATCH 2/2] lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready. -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.19/older/patches-5.19-rc8-rt9.tar.xz +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.0/older/patches-6.0-rt11.tar.xz The printk code invokes vnsprintf in order to compute the complete string before adding it into its buffer. This happens in an IRQ-off @@ -19,43 +19,45 @@ during the vsprintf() invocation which would fix the just mentioned problem. However printk itself can be invoked in a context with disabled interrupts which would lead to the very same problem. -Move the initializaion of ptr_key into a worker and schedule it from +Move the initialization of ptr_key into a worker and schedule it from subsys_initcall(). This happens early but after the workqueue subsystem -is ready. Use get_random_bytes_wait() to retrieve the random value which -will block until random data is available. +is ready. Use get_random_bytes() to retrieve the random value if the RNG +core is ready, otherwise schedule a worker in two seconds and try again. Reported-by: Mike Galbraith <efault@gmx.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> -Link: https://lkml.kernel.org/r/20220729154716.429964-3-bigeasy@linutronix.de +Link: https://lkml.kernel.org/r/YueeIgPGUJgsnsAh@linutronix.de --- - lib/vsprintf.c | 44 +++++++++++++++++++++++++------------------- - 1 file changed, 25 insertions(+), 19 deletions(-) + lib/vsprintf.c | 46 +++++++++++++++++++++++++++------------------- + 1 file changed, 27 insertions(+), 19 deletions(-) --- a/lib/vsprintf.c +++ b/lib/vsprintf.c -@@ -751,31 +751,37 @@ static int __init debug_boot_weak_hash_e +@@ -751,31 +751,39 @@ static int __init debug_boot_weak_hash_e early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable); static bool filled_random_ptr_key; +static siphash_key_t ptr_key __read_mostly; ++static void fill_ptr_key_workfn(struct work_struct *work); ++static DECLARE_DELAYED_WORK(fill_ptr_key_work, fill_ptr_key_workfn); + +static void fill_ptr_key_workfn(struct work_struct *work) +{ -+ int ret; -+ -+ ret = get_random_bytes_wait(&ptr_key, sizeof(ptr_key)); -+ if (WARN_ON(ret < 0)) ++ if (!rng_is_initialized()) { ++ queue_delayed_work(system_unbound_wq, &fill_ptr_key_work, HZ * 2); + return; ++ } ++ ++ get_random_bytes(&ptr_key, sizeof(ptr_key)); ++ + /* Pairs with smp_rmb() before reading ptr_key. */ + smp_wmb(); + WRITE_ONCE(filled_random_ptr_key, true); +} + -+static int vsprintf_init_hashval(void) ++static int __init vsprintf_init_hashval(void) +{ -+ static DECLARE_WORK(fill_ptr_key_work, fill_ptr_key_workfn); -+ -+ queue_work(system_unbound_wq, &fill_ptr_key_work); ++ fill_ptr_key_workfn(NULL); + return 0; +} +subsys_initcall(vsprintf_init_hashval) |