lkml.org 
[lkml]   [2021]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RESEND] [PATCH] Revert "efi/random: Treat EFI_RNG_PROTOCOL output as bootloader randomness"
Date


> On 13 Oct 2021, at 12:51, Ivan T. Ivanov <iivanov@suse.de> wrote:
>
> Hi,
>
>> On 13 Oct 2021, at 10:50, Ard Biesheuvel <ardb@kernel.org> wrote:
>>
>> On Wed, 13 Oct 2021 at 09:30, Ivan T. Ivanov <iivanov@suse.de> wrote:
>>>
>>> Hi,
>>>
>>> Quoting Dominik Brodowski (2021-10-12 11:40:34)
>>>> Am Tue, Oct 12, 2021 at 11:27:08AM +0300 schrieb Ivan T. Ivanov:
>>>>> This reverts commit 18b915ac6b0ac5ba7ded03156860f60a9f16df2b.
>>>>>
>>>>> When CONFIG_RANDOM_TRUST_BOOTLOADER is enabled add_bootloader_randomness()
>>>>> calls add_hwgenerator_randomness() which might sleep,
>>>>
>>>> Wouldn't it be better to fix add_bootloader_randomness(), considering
>>>> that
>>>> calls to that function are likely to happen quite early during kernel
>>>> initialization? Especially as it seems to have worked beforehand?
>>>
>>> I have tried. I made wait_event_interruptible() optional, but then
>>> crng_reseed() segfault badly. And I don't think crng_reseed() is
>>> something that I could fix easily. Suggestions are welcomed ;-)
>>>
>>
>> How about
>>
>> diff --git a/drivers/char/random.c b/drivers/char/random.c
>> index 605969ed0f96..1828dc691ebf 100644
>> --- a/drivers/char/random.c
>> +++ b/drivers/char/random.c
>> @@ -2297,9 +2297,8 @@ EXPORT_SYMBOL_GPL(add_hwgenerator_randomness);
>> */
>> void add_bootloader_randomness(const void *buf, unsigned int size)
>> {
>> + add_device_randomness(buf, size);
>> if (IS_ENABLED(CONFIG_RANDOM_TRUST_BOOTLOADER))
>> - add_hwgenerator_randomness(buf, size, size * 8);
>> - else
>> - add_device_randomness(buf, size);
>> + credit_entropy(&input_pool, size * 8);
>> }
>> EXPORT_SYMBOL_GPL(add_bootloader_randomness);
>
> This doesn’t boot. I just changed following and kernel panics.
>
> - credit_entropy
> + credit_entropy_bits
>
> Please see attached file.
>

Ah, sorry. I missed file attachment. Now it should be fine.

[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x481fd010]
[ 0.000000] Linux version 5.3.18-0.gd323798-default (geeko@buildhost) (gcc version 7.5.0 (SUSE Linux)) #1 SMP Wed Oct 13 09:23:12 UTC 2021 (d323798)
[ 0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
[ 0.000000] printk: bootconsole [pl11] enabled
[ 0.000000] efi: EFI v2.70 by EDK II
[ 0.000000] efi: SMBIOS 3.0=0xbbed0000 MEMATTR=0xb9cde018 ACPI 2.0=0xb8420018 MOKvar=0xba64c000 RNG=0xbbfdbd98 MEMRESERVE=0xb834d218
[ 0.000000] efi: seeding entropy pool
[ 0.000000] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000100
[ 0.000000] Mem abort info:
[ 0.000000] ESR = 0x96000004
[ 0.000000] Exception class = DABT (current EL), IL = 32 bits
[ 0.000000] SET = 0, FnV = 0
[ 0.000000] EA = 0, S1PTW = 0
[ 0.000000] Data abort info:
[ 0.000000] ISV = 0, ISS = 0x00000004
[ 0.000000] CM = 0, WnR = 0
[ 0.000000] [0000000000000100] user address but active_mm is swapper
[ 0.000000] Internal error: Oops: 96000004 [#1] SMP
[ 0.000000] Modules linked in:
[ 0.000000] Supported: No, Unreleased kernel
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.3.18-0.gd323798-default #1 SLE15-SP3 (unreleased)
[ 0.000000] pstate: 60000085 (nZCv daIf -PAN -UAO)
[ 0.000000] pc : __queue_work+0x30/0x568
[ 0.000000] lr : __queue_work+0x2c/0x568
[ 0.000000] sp : ffffa9f829d43c40
[ 0.000000] x29: ffffa9f829d43c40 x28: 0000000000004000
[ 0.000000] x27: 0000000000000000 x26: ffffa9f82a86d8a0
[ 0.000000] x25: ffffa9f82a86d000 x24: 0000000000000300
[ 0.000000] x23: ffffa9f829f4d000 x22: 0000000000000300
[ 0.000000] x21: 0000000000000300 x20: ffffa9f829ecbdd0
[ 0.000000] x19: ffffa9f829ecbdd0 x18: 00000000fffffff8
[ 0.000000] x17: 0000000000000000 x16: 0000000fffffffe1
[ 0.000000] x15: 0000000000000007 x14: 0000000000000001
[ 0.000000] x13: 0000000000000019 x12: 0000000000000033
[ 0.000000] x11: 000000000000004c x10: 0000000000000068
[ 0.000000] x9 : ffffa9f8292f3f48 x8 : 000000004e2e5202
[ 0.000000] x7 : 0000000000000005 x6 : ffffa9f829d43d68
[ 0.000000] x5 : 000000000000007f x4 : 0000000000000001
[ 0.000000] x3 : 0000000000000000 x2 : ffffa9f829ecbdd0
[ 0.000000] x1 : 0000000000000000 x0 : ffffa9f8286de150
[ 0.000000] Call trace:
[ 0.000000] __queue_work+0x30/0x568
[ 0.000000] queue_work_on+0x98/0xa0
[ 0.000000] crng_reseed+0x1a8/0x328
[ 0.000000] credit_entropy_bits+0x34c/0x368
[ 0.000000] add_bootloader_randomness+0x3c/0x48
[ 0.000000] efi_config_parse_tables+0x120/0x250
[ 0.000000] efi_init+0x138/0x1e0
[ 0.000000] setup_arch+0x394/0x778
[ 0.000000] start_kernel+0x90/0x568
[ 0.000000] Code: aa0203f4 aa1e03e0 97fe35be 2a1603f8 (b9410360)
[ 0.000000] random: get_random_bytes called from print_oops_end_marker+0x54/0x70 with crng_init=0
[ 0.000000] ---[ end trace 75d6efa456d89665 ]---
[ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
[ 0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---

Ivan

\
 
 \ /
  Last update: 2021-10-13 11:55    [W:0.106 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site