casaroli commented on code in PR #21902:
URL: https://github.com/apache/nuttx/pull/21902#discussion_r4592469759


##########
libs/libc/stdlib/lib_arc4random.c:
##########


Review Comment:
   In the kernel, getrandom() opens the device with nx_open(): it puts the 
descriptor into the file table of the calling task (fs/vfs/fs_open.c:532) and 
resolves the path in the root of the caller (fs/inode/fs_inodesearch.c:421), 
and getrandom() sets the errno of the caller on an error. So bind() of a task 
with a full file table succeeds with errno EMFILE left behind, and in a 
chroot() jail without /dev the open fails. Both times arc4random_buf() falls 
back to the clock() hash: the UDP/TCP port base and the TCP ISN key then come 
from the clock, which any task can compute. file_open() uses no descriptor and 
no errno of the caller. It also resolves the path in the root of the caller, so 
in a jail without /dev only the entropy pool of the second commit replaces the 
clock() hash.
   



##########
libs/libc/stdlib/lib_arc4random.c:
##########


Review Comment:
   In the kernel, getrandom() opens the device with nx_open(): it puts the 
descriptor into the file table of the calling task (fs/vfs/fs_open.c:532) and 
resolves the path in the root of the caller (fs/inode/fs_inodesearch.c:421), 
and getrandom() sets the errno of the caller on an error. So bind() of a task 
with a full file table succeeds with errno EMFILE left behind, and in a 
chroot() jail without /dev the open fails. Both times arc4random_buf() falls 
back to the clock() hash: the UDP/TCP port base and the TCP ISN key then come 
from the clock, which any task can compute. file_open() uses no descriptor and 
no errno of the caller. It also resolves the path in the root of the caller, so 
in a jail without /dev only the entropy pool (up_rngbuf()) replaces the clock() 
hash.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to