The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=574941c931acd7fcd4b4193e7c84a4a0b71b172b
commit 574941c931acd7fcd4b4193e7c84a4a0b71b172b Author: Gleb Smirnoff <[email protected]> AuthorDate: 2026-12-04 18:02:24 +0000 Commit: Gleb Smirnoff <[email protected]> CommitDate: 2026-12-04 18:02:24 +0000 inpcb: in in_pcbladdr() make an exclusion for kernel BOOTP client Allow use of unspecified source address in in_pcbladdr() for the kernel BOOTP client. It needs to send BOOTP/DHCP request with INADDR_ANY source. We considered other options, but they all look too complex and intrusive. This tiny hack hidden by #ifdef BOOTP, that is not included in the GENERIC kernel, would be good enough to keep support for the legacy BOOTP boot. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D62412 Fixes: 713264f6b8bc5f927dd52cf8ffcccfa397034fec PR: 278043 --- sys/netinet/in_pcb.c | 15 ++++++++++++--- sys/nfs/bootp_subr.c | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index df1cd54b5855..75e3ca18609b 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -36,6 +36,7 @@ * SUCH DAMAGE. */ +#include "opt_bootp.h" #include "opt_ddb.h" #include "opt_ipsec.h" #include "opt_inet.h" @@ -1279,9 +1280,13 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr_in *sin, struct ucred *cred) } /* - * Do proper source address selection on an unbound socket in case - * of connect. Take jails into account as well. + * Do proper source address selection on an unbound socket in case of + * connect(2). Take jails into account as well. + * Do not permit sending from 0.0.0.0, with an exclusion for the kernel BOOTP. */ +#ifdef BOOTP +extern struct socket *bootp_so; +#endif int in_pcbladdr(const struct inpcb *inp, struct in_addr *faddr, struct in_addr *laddr, struct ucred *cred) @@ -1505,7 +1510,11 @@ in_pcbladdr(const struct inpcb *inp, struct in_addr *faddr, } done: - if (error == 0 && laddr->s_addr == INADDR_ANY) + if (error == 0 && +#ifdef BOOTP + inp->inp_socket != bootp_so && +#endif + laddr->s_addr == INADDR_ANY) return (EHOSTUNREACH); return (error); } diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index af49379c4f05..6b05a4ec0797 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -235,7 +235,7 @@ struct bootpc_globalcontext { #endif static char bootp_cookie[128]; -static struct socket *bootp_so; +struct socket *bootp_so; SYSCTL_STRING(_kern, OID_AUTO, bootp_cookie, CTLFLAG_RD, bootp_cookie, 0, "Cookie (T134) supplied by bootp server"); @@ -1687,6 +1687,7 @@ retry: bootpc_adjust_interface(ifctx, gctx, td); soclose(bootp_so); + bootp_so = NULL; STAILQ_FOREACH(ifctx, &gctx->interfaces, next) if (ifctx->gotrootpath != 0)
