cs-education / sysbuild

A system programming learning environment in the browser
https://cs-education.github.io/sys/
Other
36 stars 35 forks source link

Initialize /dev/urandom in TTY1 before user control #152

Closed coltonmercurio closed 8 years ago

coltonmercurio commented 8 years ago

Internally, gcc reads bits from /dev/urandom. So on the first compile, a user would see: image This is not ideal, so to silence this (place in boot sequence) we execute "head -c1 /dev/urandom" in TTY1 to initialize urandom.

coltonmercurio commented 8 years ago

This solution is not optimal since the output "random: head urandom read with 51 bits of entropy available" is at times printed on the bottom most line of the terminal.

angrave commented 8 years ago

FYI The kernel message is generated whenever the first read from urandom occurs -

http://lxr.free-electrons.com/source/drivers/char/random.c#L1458 1458 urandom_read(struct file _file, char __user buf, size_t nbytes, loff_t ppos) 1459 { 1460 int ret; 1461 1462 if (unlikely(nonblocking_pool.initialized == 0)) 1463 printkonce(KERN_NOTICE "random: %s urandom read " 1464 "with %d bits of entropy available\n", 1465 current->comm, nonblocking_pool.entropy_total); 1466 1467 nbytes = min_t(size_t, nbytes, INT_MAX >> (ENTROPY_SHIFT + 3)); 1468 ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); 1469 1470 trace_urandom_read(8 \ nbytes, ENTROPY_BITS(&nonblocking_pool), 1471 ENTROPY_BITS(&input_pool)); 1472 return ret; 1473 }

Also I'm not sure writing to /dev/(u)random is sufficient - probably need to go the ioctl route

Suggestion for an upstream future a Jor1K Feature: Provide an interface to be able to add entropy from the outside i.e. the browser

On 4/25/16 7:45 PM, Colton Mercurio wrote:

This solution is not optimal since the output "random: head urandom read with 51 bits of entropy available" is at times printed on the bottom most line of the terminal.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_cs-2Deducation_sysbuild_pull_152-23issuecomment-2D214573965&d=CwMCaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=DvT4PEagC1_uJoK7XYcVznCf9vBnV8AqDdM20MaTLvM&m=NqSKnHSS7YONF789jrQIEWyT-QkSVJT6VVK3MRxLG-Y&s=P1UsUtCqHluaSBY1LZPRrDu5w3Yi0hFQY-bhBCV_OBU&e=