mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
kern: zero out stack buffer after copying out random bits
The kern.arandom sysctl handler uses an intermediate buffer on the stack to hold random data that it subsequently copies out to the sysctl request. Err on the side of caution and zero out the stack buffer after we're done with it to avoid a potential entropy leak later on. Reviewed by: cem, emaste, markj (cherry picked from commit 5862c891bb7c588aa00538d85eb26ffe77d3f709)
This commit is contained in:
parent
f29a2ea5b4
commit
1eb62930e7
1 changed files with 5 additions and 1 deletions
|
|
@ -182,10 +182,14 @@ sysctl_kern_arnd(SYSCTL_HANDLER_ARGS)
|
|||
{
|
||||
char buf[256];
|
||||
size_t len;
|
||||
int error;
|
||||
|
||||
len = MIN(req->oldlen, sizeof(buf));
|
||||
read_random(buf, len);
|
||||
return (SYSCTL_OUT(req, buf, len));
|
||||
|
||||
error = SYSCTL_OUT(req, buf, len);
|
||||
explicit_bzero(buf, len);
|
||||
return (error);
|
||||
}
|
||||
|
||||
SYSCTL_PROC(_kern, KERN_ARND, arandom,
|
||||
|
|
|
|||
Loading…
Reference in a new issue