These routines were all assuming that the sysctl handler has some new
value, but this is not the case. SYSCTL_IN() returns 0 in this
scenario, so they were all operating on an uninitialized address. This
is mostly harmless, but trips KMSAN checks, so let's fix them.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 62939 Build 59823: arc lint + arc unit
Event Timeline
IMHO, EINVAL would be better than 0. These are quite non-standard sysctls, that use new value as argument. If actually someone uses them incorrectly, better error than return OK.
Those sysctl handlers copy in a pair of sockaddr_in[6] ( pointed by req->newptr) and copy out the xucred, so what's the point of a NULL req->newptr ? Maybe an error EINVAL is better than 0 ?
Ahh @glebius responses faster than me.
It's probably ok to return EINVAL. I was a bit worried that doing so would result in errors from sysctl -a (which is how I found these bugs in the first place), but I think it's ok. Will update.
No worries. All these sysctl knobs are marked with flag CTLTYPE_OPAQUE, and as per sysctl(8),
-a List all the currently available values except for those which are opaque or excluded from listing via the CTLFLAG_SKIP flag. This option is ignored if one or more variable names are specified on the command line.
They should be excluded from sysctl -a.
Sure, sysctl -ao then. :)
From reading sysctl.c, I believe no error will be printed in this case, but I still need to check.