]> xenbits.xensource.com Git - unikraft/unikraft.git/commit
lib/ukrandom: Validate getrandom input & rm assert
authorAndrei Tatar <andrei@unikraft.io>
Tue, 29 Apr 2025 15:57:40 +0000 (17:57 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Tue, 29 Apr 2025 16:49:28 +0000 (16:49 +0000)
commite6ac4dfe62e1e61dd0d6d8d78418f7728f9dfa9c
tree4bbb074304414a69c12bd73a5968281af4b21ad0
parentfaaecca04a509dfc6bd0a0c3f7866f7f0162f1a8
lib/ukrandom: Validate getrandom input & rm assert

This change removes the assert on the buffer argument to the getrandom
syscall and replaces it with defined input validation, based on observed
behavior in Linux:
- if the requested number of bytes is 0, getrandom shortcuts to success
- if buffer is NULL and > 0 bytes requested, return -EFAULT instead of
  crashing

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1637
lib/ukrandom/getrandom.c