git: b0ccf53f2455 - main - inpcb: Assert against wildcard addrs in in_pcblookup_hash_locked()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Feb 2023 16:50:37 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b0ccf53f2455ad300b8b784c4b1a91a5733e890f commit b0ccf53f2455ad300b8b784c4b1a91a5733e890f Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-02-03 15:57:19 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-02-03 16:48:25 +0000 inpcb: Assert against wildcard addrs in in_pcblookup_hash_locked() No functional change intended. Reviewed by: glebius MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D38361 --- sys/netinet/in_pcb.c | 4 ++++ sys/netinet6/in6_pcb.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 23d30d8b968a..ce8a58883be4 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -2242,6 +2242,10 @@ in_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in_addr faddr, KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, ("%s: invalid lookup flags %d", __func__, lookupflags)); + KASSERT(faddr.s_addr != INADDR_ANY, + ("%s: invalid foreign address", __func__)); + KASSERT(laddr.s_addr != INADDR_ANY, + ("%s: invalid local address", __func__)); INP_HASH_LOCK_ASSERT(pcbinfo); /* diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index c3012ffab68f..0a4ae51cb5ef 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -980,6 +980,10 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, ("%s: invalid lookup flags %d", __func__, lookupflags)); + KASSERT(!IN6_IS_ADDR_UNSPECIFIED(faddr), + ("%s: invalid foreign address", __func__)); + KASSERT(!IN6_IS_ADDR_UNSPECIFIED(laddr), + ("%s: invalid local address", __func__)); INP_HASH_LOCK_ASSERT(pcbinfo);