LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-05-2023, 05:26 AM   #1
Projectile
Member
 
Registered: Jun 2023
Posts: 72
Blog Entries: 1

Rep: Reputation: 13
"uninitialized urandom read" warnings in kernel 5.15.117


The below warnings appear during each boot, ever since the kernel was upgraded from 5.15.19 to 5.15.117:

Code:
[ --- ] random: udevd: uninitialized urandom read (16 bytes read)
[ --- ] random: udevd: uninitialized urandom read (16 bytes read)
[ --- ] random: udevd: uninitialized urandom read (16 bytes read)
[ --- ] random: cryptsetup: uninitialized urandom read (4 bytes read)
[ --- ] random: cryptsetup: uninitialized urandom read (4 bytes read)
Are these warnings something to worry about security-wise?
 
Old 07-05-2023, 12:51 PM   #2
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 990

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
The above messages means that you are using a predictable crypto because of "boot time entropy starvation". There is some information on how to avoid that at https://wiki.debian.org/BoottimeEntropyStarvation

regards Henrik
 
Old 07-05-2023, 01:51 PM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,915

Rep: Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033
Quote:
Originally Posted by henca View Post
The above messages means that you are using a predictable crypto because of "boot time entropy starvation". There is some information on how to avoid that at https://wiki.debian.org/BoottimeEntropyStarvation

regards Henrik
The volume key is generated at creation time, not open time. I'm not entirely sure what cryptsetup uses those 8 bytes of randomness for, but unless his adversary is a State level TLA Agency it's probably not a big deal that urandom isn't fully initialised.

That said, on my laptop my crng pool is initialised within the first 1/10th of a second of boot, well before udev is started by the initrd, so I'm surprised he's hitting this issue.

I used to see these messages prior to the jitter routines being added in kernel 5.4, but I haven't seen them show up since.
 
Old 07-11-2023, 02:43 AM   #4
Projectile
Member
 
Registered: Jun 2023
Posts: 72

Original Poster
Blog Entries: 1

Rep: Reputation: 13
Apparently my CPU doesn't have rdrand? Checking for it yields:

Code:
$ grep CONFIG_RANDOM_TRUST_CPU /boot/config-generic-5.15.117.x64 && grep rdrand /proc/cpuinfo && echo "your system looks fine"
CONFIG_RANDOM_TRUST_CPU=y
$
Any ideas how to fix the "boot time entropy starvation"? I need a solution that works on Slackware 15, please.

EDIT: also, I double-checked and these warnings do appear in kernel 5.15.19 as well so the first post is misleading, sorry.

Last edited by Projectile; 07-11-2023 at 02:50 AM. Reason: old kernel clarification
 
Old 07-11-2023, 04:05 AM   #5
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,852

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
You could try to 'cp /sbin/haveged /boot/initrd-tree/sbin' and add line 'haveged --once' to the script /boot/initrd-tree/init at line 98 after proc, sysfs, devtmpfs have been mounted. Then run a plain 'mkinitrd' without options to build /boot/initrd.gz with otherwise previous initrd content and use it. Do not use the '-c' flag with mkinitrd command because it clears initrd-tree and removes your changes. (If cleared, mkinitrd extracts a new initrd-tree from /usr/share/mkinitrd/initrd-tree.tar.gz where your changes are not yet.)

I have not tested it. So, I would make a copy of the old initrd.gz to a different name and use it as a backup choice in the boot menu of my boot loader.

EDIT: Now I have tested it on my machine which does not have problems with urandom. It booted normally as before.

Last edited by Petri Kaukasoina; 07-11-2023 at 04:41 AM.
 
Old 07-11-2023, 08:34 AM   #6
Projectile
Member
 
Registered: Jun 2023
Posts: 72

Original Poster
Blog Entries: 1

Rep: Reputation: 13
Petri Kaukasoina, I have followed your instructions but unfortunately the warning messages are unaffected:
  1. Deleted /boot/initrd.gz
  2. Copied haveged into /boot/initrd-tree/sbin/
  3. Edited /boot/initrd-tree/init to call `haveged --once` at line 99
  4. Ran `# mkinitrd`
  5. Checked that the new initrd.gz contains haveged and the edited init script (yes)
  6. Ran `# lilo` (/etc/lilo.conf boots /boot/vmlinuz-generic and uses /boot/initrd.gz)

Later I have also tried calling `/sbin/haveged --once`, which made no difference.
`# dmesg -H` shows no mention of "haveged".

Maybe, the call to haveged is being ignored?
 
Old 07-11-2023, 01:58 PM   #7
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,852

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Please try this as the haveged command in /boot/initrd-tree/init, line 98:
Code:
haveged -n 512 -f /dev/urandom
instead of 'haveged --once'. (And run mkinitrd and lilo.)
 
Old 07-11-2023, 02:17 PM   #8
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,852

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
I just tested that here. I also added line 'sleep 10' after that haveged line, so I could read the output. During boot it printed 'Writing 512 output to /dev/urandom'.
 
1 members found this post helpful.
Old 07-12-2023, 04:24 AM   #9
Projectile
Member
 
Registered: Jun 2023
Posts: 72

Original Poster
Blog Entries: 1

Rep: Reputation: 13
No difference: same warnings like in the first post.
In addition I have also tried (fruitlessly):

Code:
haveged --once
haveged --number=4096 --file=/dev/random
haveged --number=4096 --file=/dev/urandom
sleep 10
Thank you for trying to help.
 
Old 07-12-2023, 05:25 AM   #10
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,852

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Maybe not a good idea, but you could try a longer sleep. And during the sleep you could hit the shift and alt keys a lot and move the mouse a lot. Maybe the interrupts generate enough entropy. (Maybe the os does not trust the quality of entropy fed to /dev/*random.)

Last edited by Petri Kaukasoina; 07-12-2023 at 05:34 AM.
 
1 members found this post helpful.
Old 07-12-2023, 05:45 AM   #11
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,915

Rep: Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033
If you want to force the initrd to wait until the rng has initialised then you can compile this simple program and add it to the start of your initrd:
Code:
#include <stdio.h>
#include <sys/random.h>

int main()
{
    unsigned char r;
    puts("Waiting for random number generator to initialise...");
    return getentropy(&r, sizeof r);
}
The getentropy() call will not return until the kernel rng has initialised. Depending on how well your system gathers entropy this could introduce a short delay, or in the worst case, where no entropy sources are available at all, block the boot indefinitely. On x86 the kernel gathers entropy from CPU timing jitter and interrupts, other archs may not be so lucky.

If you give this a go, make sure you have an alternate initrd to boot from just in case it doesn't return.
 
2 members found this post helpful.
Old 07-12-2023, 05:48 AM   #12
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,915

Rep: Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033
Quote:
Originally Posted by Petri Kaukasoina View Post
Maybe the os does not trust the quality of entropy fed to /dev/*random
More recent kernels no longer increase the entropy count when you write to /dev/random, though the data itself is still merged into the pools.

Last edited by GazL; 07-12-2023 at 05:50 AM.
 
Old 07-12-2023, 07:10 AM   #13
Projectile
Member
 
Registered: Jun 2023
Posts: 72

Original Poster
Blog Entries: 1

Rep: Reputation: 13
GazL, thank you! This fixed all the warnings.

I am marking this thread as "Solved" however I do find it curious that your solution introduced no delay in the boot process and yet `sleep 10` didn't help at all.
 
1 members found this post helpful.
Old 07-12-2023, 09:22 AM   #14
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,915

Rep: Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033
Yes, that is a little odd, but then again 'sleep' doesn't really get the kernel to do much, no matter how long it waits. I guess the getentropy() call managed to get the kernel to do just enough work to generate enough entropy to get the job done: kind of like a self-fulfilling prophecy.

Anyway, glad it worked for you.

BTW, dmesg | grep 'crng init done' will show you the exact timings.
 
Old 07-12-2023, 09:36 AM   #15
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,915

Rep: Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033Reputation: 5033
P.S. this whole thing makes me wonder if carrying over the /etc/random-seed data from one boot to the next is really of any value any more. The kernel periodically reseeds the chacha20 CSPRNG generators now anyway and /dev/random no longer has an 'entropy pool' as such that it draws from.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel panics on 5.15.117 wigums Slackware 3 06-30-2023 07:25 PM
LXer: Debian: 2790-1: nss: uninitialized memory read LXer Syndicated Linux News 0 11-05-2013 02:42 AM
G++ Warning: "'i' may be used uninitialized in this function" Kenny_Strawn Programming 5 04-07-2010 12:55 AM
please help me with this perl code getting error "use of uninitialized value" haxpak Programming 10 03-01-2009 10:55 PM
VFS: Cannot open root device "cobd1" or unknown-block(117,1) lorenzobalan Linux - General 4 12-12-2007 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration