netinet: Fix getcred sysctl handlers to do nothing if no input is given

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.

Reviewed by:	zlei, rrs, glebius
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49348
This commit is contained in:
Mark Johnston 2025-03-20 01:33:44 +00:00
parent d7efac1be1
commit 3ff865c6a7
5 changed files with 12 additions and 1 deletions

View file

@ -361,8 +361,9 @@ sctp_getcred(SYSCTL_HANDLER_ARGS)
/* FIX, for non-bsd is this right? */
vrf_id = SCTP_DEFAULT_VRFID;
if (req->newptr == NULL)
return (EINVAL);
error = priv_check(req->td, PRIV_NETINET_GETCRED);
if (error)
return (error);

View file

@ -2698,6 +2698,8 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error;
if (req->newptr == NULL)
return (EINVAL);
error = priv_check(req->td, PRIV_NETINET_GETCRED);
if (error)
return (error);
@ -2740,6 +2742,8 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
int mapped = 0;
#endif
if (req->newptr == NULL)
return (EINVAL);
error = priv_check(req->td, PRIV_NETINET_GETCRED);
if (error)
return (error);

View file

@ -844,6 +844,8 @@ udp_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error;
if (req->newptr == NULL)
return (EINVAL);
error = priv_check(req->td, PRIV_NETINET_GETCRED);
if (error)
return (error);

View file

@ -375,6 +375,8 @@ sctp6_getcred(SYSCTL_HANDLER_ARGS)
vrf_id = SCTP_DEFAULT_VRFID;
if (req->newptr == NULL)
return (EINVAL);
error = priv_check(req->td, PRIV_NETINET_GETCRED);
if (error)
return (error);

View file

@ -617,6 +617,8 @@ udp6_getcred(SYSCTL_HANDLER_ARGS)
struct inpcb *inp;
int error;
if (req->newptr == NULL)
return (EINVAL);
error = priv_check(req->td, PRIV_NETINET_GETCRED);
if (error)
return (error);