HomeFreeBSD

dummymbuf: Avoid copyout of uninitialized memory from the sysctl handler

Description

dummymbuf: Avoid copyout of uninitialized memory from the sysctl handler

If *rulesp was initially unset, we'll allocate a new buffer and pass it
to sysctl_handle_string(), which copies the existing string out and then
copies in the new string. We need to make sure the buffer containing
the existing rules is initialized, otherwise we leak kernel memory to
userspace.

Fix some nearby style nits while here.

Reported by: KMSAN
Reviewed by: igoro, kp
Fixes: 8aaffd78c0f5 ("Add dummymbuf module for testing purposes")
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D46493

Details