mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 15:45:21 +00:00
inpcb: Restore some NULL checks of credential pointers
At least one out-of-tree port (net-mgmt/ng_ipacct) depends on being able
to call in_pcblookup_local() with cred == NULL, so the MFC of commit
ac1750dd14
("inpcb: Remove NULL checks of credential references")
broke compatibility.
Restore a subset of the NULL checks to avoid breaking the module in the
13.3 release. This is a direct commit to stable/13.
PR: 276868
This commit is contained in:
parent
a64caf2cb2
commit
fe8df7ed1a
@ -2003,7 +2003,8 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
|
||||
/*
|
||||
* Found?
|
||||
*/
|
||||
if (prison_equal_ip4(cred->cr_prison,
|
||||
if (cred == NULL ||
|
||||
prison_equal_ip4(cred->cr_prison,
|
||||
inp->inp_cred->cr_prison))
|
||||
return (inp);
|
||||
}
|
||||
@ -2035,7 +2036,8 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr,
|
||||
*/
|
||||
CK_LIST_FOREACH(inp, &phd->phd_pcblist, inp_portlist) {
|
||||
wildcard = 0;
|
||||
if (!prison_equal_ip4(inp->inp_cred->cr_prison,
|
||||
if (cred != NULL &&
|
||||
!prison_equal_ip4(inp->inp_cred->cr_prison,
|
||||
cred->cr_prison))
|
||||
continue;
|
||||
#ifdef INET6
|
||||
|
@ -764,7 +764,8 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr,
|
||||
IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) &&
|
||||
inp->inp_lport == lport) {
|
||||
/* Found. */
|
||||
if (prison_equal_ip6(cred->cr_prison,
|
||||
if (cred == NULL ||
|
||||
prison_equal_ip6(cred->cr_prison,
|
||||
inp->inp_cred->cr_prison))
|
||||
return (inp);
|
||||
}
|
||||
@ -796,7 +797,8 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr,
|
||||
*/
|
||||
CK_LIST_FOREACH(inp, &phd->phd_pcblist, inp_portlist) {
|
||||
wildcard = 0;
|
||||
if (!prison_equal_ip6(cred->cr_prison,
|
||||
if (cred != NULL &&
|
||||
!prison_equal_ip6(cred->cr_prison,
|
||||
inp->inp_cred->cr_prison))
|
||||
continue;
|
||||
/* XXX inp locking */
|
||||
|
Loading…
Reference in New Issue
Block a user