Compare commits

...
20 Commits
Author SHA1 Message Date
Minsoo Choo a2b34aaa8d powerpc: Avoid deadlock when CPUs exchange threads
The PowerPC context switch waited for the incoming thread to leave
blocked_lock before releasing the outgoing thread.  If two CPUs selected
each other's running threads concurrently, both CPUs waited for the
other to perform the release and neither could progress.  This appeared
as intermittent boot hangs under QEMU MTTCG when taskqueue threads were
bound to opposite CPUs.

8df2e54214 ("powerpc: put the isync inside the TD_LOCK()...")
attempted to fix the same hang by moving isync into the polling loop.
That did not address the circular wait: isync cannot cause either CPU to
execute the release store after the loop.  It only added context
synchronization to failed iterations and changed timing. Move isync back
to the successful exit, which preserves acquire ordering for subsequent
context loads.

Match the ordering used by other architectures: publish the outgoing
thread's new lock before waiting for the incoming thread.  Apply the
correction to both 32-bit and 64-bit switch paths.

The 2015 change moved the release after the stack switch because the old
implementation continued through pmap_activate() and optional state
restoration on the outgoing thread's stack after making that thread
runnable.  The switch path has since changed: after the release it only
polls wired td_lock state using registers, then immediately loads the
incoming PCB_SP before updating per-CPU state or making any calls.
cpu_switch() also runs with external and decrementer interrupts disabled
by spinlock_enter().  Thus this does not restore the post-release call
window that the 2015 change corrected.

Reviewed by:	jhb, jhibbits
Approved by:	jhb (mentor)
Fixes: 53607fe3cc ("Fix an extremely subtle concurrency bug...")
Fixes: 7a49d964d3 ("Merge r278429 from ppc64:")
Fixes: 8df2e54214 ("powerpc: put the isync inside the TD_LOCK()...")
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D59742

(cherry picked from commit 0571d8a0cc)
2026-10-26 21:18:14 -04:00
Osvaldo Janeri Filho d5d386df28 bhyve: fix integer overflow in qXfer packet parser
doff + dlen overflows unsigned int when both values are close to UINT_MAX,
causing the wrong branch to execute and passing an unbounded length to
append_binary_data().  Rewrite the comparison to avoid the addition.

Reviewed by:	markj
Fixes:		f81cdf24ba ("bhyve: Add support for XML register definitions")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60847

(cherry picked from commit 5ce0ab7355)
2026-10-26 14:35:02 +00:00
Mark Johnston a5f61370a3 inotify: Open target the directory when adding a watch
When an application uses inotify to watch a directory,
vn_inotify_add_watch() reads the directory entries and does a name
lookup so as to induce the filesystem to create namecache entries.
Some filesystems expect the directory to be opened before VOP_READDIR
can be called, so do that.

PR:		299239
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60782

(cherry picked from commit de80428118)
2026-10-26 14:35:02 +00:00
Mark Johnston 72ec5a2b25 kmsan: Add a required forward type declaration
MFC after:	1 week

(cherry picked from commit ad37abf653)
2026-10-26 14:35:02 +00:00
Mark Johnston 68f8842652 amd64/vmm: Don't advertise support for performance counters
vmm doesn't implement them, and after commit 2272fac218
("hwpmc: Add support for AMD-only IRPERF in hwpmc PERF class"), FreeBSD
guests fail to boot since they access the unimplemented IRPERF MSR.

MFC after:	1 week

(cherry picked from commit c83e075d72)
2026-10-26 14:35:02 +00:00
Mark Johnston 0bad0023b4 netinet: Deprecate OSIOCAIFADDR and OSIOCAIFADDR_IN6
Requested by:	glebius
Reviewed by:	pouria, glebius
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60247

(cherry picked from commit 4bb6015764)
2026-10-26 14:35:02 +00:00
Mark Johnston 010e61ab37 netinet6: Fix the OSIOCAIFADDR_IN6 handler
We cannot simply treat a pointer to struct oin6_aliasreq as a pointer to
struct in6_aliasreq: the latter is larger.  In particular, the store to
ifra->ifra_vhid is out of bounds.

Since OSIOCAIFADDR_IN6 does not need to copy data back out, it can
simply use a struct in6_ifaliasreq on the stack.

Reported by:	Andrew <[email protected]>
Reviewed by:	pouria
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60184

(cherry picked from commit c109a68145)
2026-10-26 14:12:15 +00:00
Andrew Griffiths 8738545c54 tcp: Preserve borrowed ICMPv6 error mbufs
The TCP-over-UDP ICMP callback receives ip6c_m as a borrowed chain owned
by icmp6_notify_error.  It used m_pulldown() to obtain a contiguous UDP
header even though that API frees the complete chain when the requested
range is unavailable.  The callback could then return without
propagating the lost ownership, leaving raw ICMP delivery to read and
free a stale head.

Validate that the complete UDP header was quoted, copy it through the
chain with m_copydata(), and temporarily advance the parser offset
instead of consuming bytes from the caller-owned packet.

A remote sender can reach the old path when TCP UDP tunneling is enabled
by quoting the configured local UDP source port in an ICMPv6 error and
including only four through seven UDP-header bytes.

Signed-off-by: Andrew Griffiths <[email protected]>

Reviewed by:	pouria, tuexen, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60143

(cherry picked from commit 80af0a32e4)
2026-10-26 14:12:15 +00:00
Mark Johnston c495bc1909 jail: Fix a race in prison_deref()
If we're killing a jail which has some user refs pending, then we would
first drop our ref and then kill all processes in the prison.  However,
it's possible for the prison to be freed before we finish that
operation, generally if the processes exit on their own before
prison_proc_iterate() returns.

Thus, defer the release of the prison refcount until after we've killed
all procs.

Reviewed by:	jamie
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D59984

(cherry picked from commit 79af745f4c)
2026-10-26 14:12:15 +00:00
Mark Johnston 305a2e4747 ssp: Make the panic string more accurate
"stack overflow detected" sounds like the thread faulted because it
ran out of stack space.

Reported by:	Andrew <[email protected]>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0f4b7d28cc)
2026-10-26 14:12:15 +00:00
Mark Johnston 240680dfd4 icmp: Limit routing table updates to the FIB of the redirect
When we receive an ICMP redirect, rib_add_redirect() is used to apply
the redirect to all FIBs.  This has been the case since support for
multiple FIBs was added.  However, it seems rather dubious: the new
gateway might not be routable from all FIBs, and the validation done for
v4 redirects in icmp_verify_redirect_gateway() is only applied to the
FIB from which the redirect originated.

Modify the handler to apply the redirect only in the originating FIB.

Reported by:	Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li,
		and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
Reviewed by:	pouria, zlei, glebius, melifaro
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D59567

(cherry picked from commit 01a95394ab)
2026-10-26 14:12:15 +00:00
Mark Johnston 17b457d659 igmp: Refresh the ip header pointer after m_pullup()
There is a chance that the m_pullup() call immediately above invalidated
the "ip" pointer, so refresh it as we do with the IGMP header.
Otherwise the test in igmp_input_v3_query() for whether the packet is an
IGMPv3 general query might use a pointer to a freed mbuf.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit dc47a6940d)
2026-10-26 14:12:15 +00:00
Mark Johnston c27569419c igmp: Deindent some code
No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 123342f3d2)
2026-10-26 14:12:15 +00:00
Shi Pujin 217dba2044 riscv: Fix the bus_space_read_stream_8 macro
Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60111

(cherry picked from commit 3893050bc1)
2026-10-26 14:12:15 +00:00
Mark Johnston 508c057281 net: Fix handling of sockaddrs in the SIOC{ADD,DEL}MULTI handlers
The SIOCADDMULTI and SIOCDELMULTI handlers add or delete a link-layer
multicast address from an interface's multicast filter list.  The
link-layer address is passed using the ifr_addr field of the request
structure.

struct ifreq's ifr_addr field is a struct sockaddr, which is a fair bit
smaller than struct sockaddr_dl (though big enough to hold an ethernet
address).  Existing callers set the sockaddr length to
sizeof(struct sockaddr_dl), which is too large, and causes OOB accesses
when if_findmulti() is used to compare the address with others, or when
if_addmulti() makes a copy.

Fix this without breaking compatibility: copy the user-supplied address
into a sockaddr_dl on the stack, and use the latter for the respective
operation.

Also validate the sockaddr_dl internal length fields, suggested by zlei.

Reported by:	Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li,
		and Ke Xu from Tsinghua University using GLM-5.2 from Z.ai
Reviewed by:	zlei, ae, glebius
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D59919

(cherry picked from commit 10729d0ce1)
2026-10-26 14:12:15 +00:00
Mark Johnston 79a474619f imgact_aout: Remove a prototype for a non-existent function
aout_coredump() was removed in commit 1eecfae3e5.

No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4523cbbfef)
2026-10-26 14:12:15 +00:00
Mark Johnston 7fc0292c9f jail: Simplify refcount manipulation routines
- refcount_acquire() returns the old value, use that to assert that the
  old value was non-zero.
- refcount_release() already asserts that the refcount value is
  non-zero, so don't bother asserting that again in the jail code.
- Use __diagused instead of having separate implementations for
  INVARIANTS and !INVARIANTS.

No functional change intended.

Reviewed by:	jamie
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D59983

(cherry picked from commit de6ee1fde8)
2026-10-26 14:12:15 +00:00
Mark Johnston 5b3cfac97a sysvshm: Fix locking in shm_prison_set()
We were not acquiring the global sysvshm lock when handling cleanup of
sysvshm segments.  Acquire the lock in shm_prison_cleanup() instead, to
be consistent with the sysv semaphore code.

Reviewed by:	jamie
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D60030

(cherry picked from commit 546d150619)
2026-10-26 14:12:15 +00:00
Andrew Griffiths d0e92d89a9 ipfilter: fix inverted range check on the lookup iterator unit
ipf_lookup_iterate() validates iter.ili_unit with

  if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX)

or alternatively,

  if (iter.ili_unit < -1 && iter.ili_unit > 7)

ipf_lookup_add(), ipf_lookup_delete(), ipf_lookup_stats()
ipf_lookup_flush() validate with a ||

Submitted by calif.io for the OpenAI Patch The Planet program

Signed-off-by: Andrew Griffiths <[email protected]>

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D59726

(cherry picked from commit cb035c19c3)
2026-10-26 14:12:15 +00:00
Mark Johnston 63c7715b55 kasan: Fix the annotation for shadow map checks in atomic_load_*
atomic_load_* is a read, not a write.  Otherwise KASAN will report a
use-after-free via atomic_load_* as a write rather than a read.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0aa055edc1)
2026-10-26 14:12:14 +00:00
20 changed files with 138 additions and 124 deletions

No files matched your search

+1 -2
View File
@@ -138,8 +138,7 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax, uint64_t *rbx,
* unsupported or unsafe AMD extended features
* (8000_0008 EBX).
*/
regs[1] &= (AMDFEID_CLZERO | AMDFEID_IRPERF |
AMDFEID_XSAVEERPTR);
regs[1] &= AMDFEID_CLZERO | AMDFEID_XSAVEERPTR;
vm_get_topology(vm, &sockets, &cores, &threads,
&maxcpus);
+17 -28
View File
@@ -2936,14 +2936,11 @@ prison_hold_locked(struct prison *pr)
void
prison_hold(struct prison *pr)
{
#ifdef INVARIANTS
int was_valid = refcount_acquire_if_not_zero(&pr->pr_ref);
u_int old __diagused;
KASSERT(was_valid,
("Trying to hold dead prison %p (jid=%d).", pr, pr->pr_id));
#else
refcount_acquire(&pr->pr_ref);
#endif
old = refcount_acquire(&pr->pr_ref);
KASSERT(old > 0,
("cannot hold a non-alive prison (jid=%d)", pr->pr_id));
}
/*
@@ -2982,19 +2979,12 @@ prison_free(struct prison *pr)
static void
prison_free_not_last(struct prison *pr)
{
#ifdef INVARIANTS
int lastref;
bool released __diagused;
KASSERT(refcount_load(&pr->pr_ref) > 0,
("Trying to free dead prison %p (jid=%d).",
pr, pr->pr_id));
lastref = refcount_release(&pr->pr_ref);
KASSERT(!lastref,
released = refcount_release(&pr->pr_ref);
KASSERT(!released,
("prison_free_not_last freed last ref on prison %p (jid=%d).",
pr, pr->pr_id));
#else
refcount_release(&pr->pr_ref);
#endif
}
/*
@@ -3009,14 +2999,11 @@ prison_free_not_last(struct prison *pr)
void
prison_proc_hold(struct prison *pr)
{
#ifdef INVARIANTS
int was_alive = refcount_acquire_if_not_zero(&pr->pr_uref);
u_int old __diagused;
KASSERT(was_alive,
("Cannot add a process to a non-alive prison (jid=%d)", pr->pr_id));
#else
refcount_acquire(&pr->pr_uref);
#endif
old = refcount_acquire(&pr->pr_uref);
KASSERT(old > 0,
("cannot add a process to a non-alive prison (jid=%d)", pr->pr_id));
}
/*
@@ -3033,8 +3020,6 @@ prison_proc_free(struct prison *pr)
* This allows assurance that a locked prison will remain alive
* until it is unlocked.
*/
KASSERT(refcount_load(&pr->pr_uref) > 0,
("Trying to kill a process in a dead prison (jid=%d)", pr->pr_id));
if (!refcount_release_if_not_last(&pr->pr_uref)) {
/*
* Don't remove the last user reference in this context,
@@ -3236,8 +3221,10 @@ prison_deref(struct prison *pr, int flags)
* that need to be killed, either in this prison or its
* descendants.
*/
if (refcount_load(&pr->pr_uref) > 0)
if (refcount_load(&pr->pr_uref) > 0) {
killpr = pr;
flags &= ~PD_DEREF;
}
/* Make sure the parent prison doesn't get killed. */
flags &= ~PD_KILL;
}
@@ -3297,8 +3284,10 @@ prison_deref(struct prison *pr, int flags)
sx_xunlock(&allprison_lock);
/* Kill any processes attached to a killed prison. */
if (killpr != NULL)
if (killpr != NULL) {
prison_proc_iterate(killpr, prison_kill_processes_cb, NULL);
prison_free(killpr);
}
/*
* Finish removing any unreferenced prisons, which couldn't happen
+1 -2
View File
@@ -11,8 +11,7 @@ void __stack_chk_fail(void);
void
__stack_chk_fail(void)
{
panic("stack overflow detected; backtrace may be corrupted");
panic("stack buffer overflow detected; backtrace may be corrupted");
}
static void
+1 -1
View File
@@ -761,7 +761,7 @@ kasan_casueword(volatile u_long *base, u_long oldval, u_long *oldvalp,
#define _ASAN_ATOMIC_FUNC_LOAD(name, type) \
type kasan_atomic_load_##name(const volatile type *ptr) \
{ \
kasan_shadow_check((uintptr_t)ptr, sizeof(type), true, \
kasan_shadow_check((uintptr_t)ptr, sizeof(type), false, \
__RET_ADDR); \
return (atomic_load_##name(ptr)); \
}
+2 -2
View File
@@ -1304,13 +1304,11 @@ shm_prison_remove(void *obj, void *data __unused)
struct prison *pr = obj;
struct prison *rpr;
SYSVSHM_LOCK();
prison_lock(pr);
rpr = osd_jail_get(pr, shm_prison_slot);
prison_unlock(pr);
if (rpr == pr)
shm_prison_cleanup(pr);
SYSVSHM_UNLOCK();
return (0);
}
@@ -1320,6 +1318,7 @@ shm_prison_cleanup(struct prison *pr)
struct shmid_kernel *shmseg;
int i;
SYSVSHM_LOCK();
/* Remove any segments that belong to this jail. */
for (i = 0; i < shmalloced; i++) {
shmseg = &shmsegs[i];
@@ -1328,6 +1327,7 @@ shm_prison_cleanup(struct prison *pr)
shm_remove(shmseg, i);
}
}
SYSVSHM_UNLOCK();
}
SYSCTL_JAIL_PARAM_SYS_NODE(sysvshm, CTLFLAG_RW, "SYSV shared memory");
+9
View File
@@ -781,6 +781,14 @@ vn_inotify_add_watch(struct vnode *vp, struct inotify_softc *sc, uint32_t mask,
size_t buflen, len;
int eof, error;
/*
* Some filesystems, at least fuse, require that the directory
* be opened before reading it.
*/
error = VOP_OPEN(vp, FREAD, td->td_ucred, td, NULL);
if (error != 0)
return (error);
buflen = 128 * sizeof(struct dirent);
buf = malloc(buflen, M_TEMP, M_WAITOK);
@@ -817,6 +825,7 @@ vn_inotify_add_watch(struct vnode *vp, struct inotify_softc *sc, uint32_t mask,
vrele(nd.ni_vp);
}
free(buf, M_TEMP);
VOP_CLOSE(vp, FREAD, td->td_ucred, td);
if (error != 0)
return (error);
}
+25 -4
View File
@@ -2776,6 +2776,9 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
case SIOCADDMULTI:
case SIOCDELMULTI:
{
struct sockaddr_dl sa_dl;
if (cmd == SIOCADDMULTI)
error = priv_check(td, PRIV_NET_ADDMULTI);
else
@@ -2787,9 +2790,25 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
if ((ifp->if_flags & IFF_MULTICAST) == 0)
return (EOPNOTSUPP);
/* Don't let users screw up protocols' entries. */
/*
* The sockaddr embedded in the ifreq is not large enough to
* hold a full sockaddr_dl, but existing callers of these ioctls
* will set sa_len = sizeof(struct sockaddr_dl) anyway. Bounce
* the sockaddr into a sockaddr_dl on the stack to avoid
* potential out-of-bounds accesses.
*/
if (ifr->ifr_addr.sa_family != AF_LINK)
return (EINVAL);
memset(&sa_dl, 0, sizeof(sa_dl));
memcpy(&sa_dl, &ifr->ifr_addr,
MIN(ifr->ifr_addr.sa_len, sizeof(ifr->ifr_addr)));
sa_dl.sdl_family = AF_LINK;
sa_dl.sdl_len = MIN(ifr->ifr_addr.sa_len, sizeof(sa_dl));
if (sa_dl.sdl_nlen + sa_dl.sdl_alen + sa_dl.sdl_slen >
sizeof(ifr->ifr_addr) -
offsetof(struct sockaddr_dl, sdl_data) ||
sa_dl.sdl_nlen > IFNAMSIZ)
return (EINVAL);
if (cmd == SIOCADDMULTI) {
struct epoch_tracker et;
@@ -2803,18 +2822,20 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
* already exists.
*/
NET_EPOCH_ENTER(et);
ifma = if_findmulti(ifp, &ifr->ifr_addr);
ifma = if_findmulti(ifp, (struct sockaddr *)&sa_dl);
NET_EPOCH_EXIT(et);
if (ifma != NULL)
error = EADDRINUSE;
else
error = if_addmulti(ifp, &ifr->ifr_addr, &ifma);
error = if_addmulti(ifp,
(struct sockaddr *)&sa_dl, &ifma);
} else {
error = if_delmulti(ifp, &ifr->ifr_addr);
error = if_delmulti(ifp, (struct sockaddr *)&sa_dl);
}
if (error == 0)
getmicrotime(&ifp->if_lastchange);
break;
}
case SIOCSIFPHYADDR:
case SIOCDIFPHYADDR:
+33 -33
View File
@@ -1567,43 +1567,43 @@ igmp_input(struct mbuf **mp, int *offp, int proto)
break;
case IGMP_VERSION_3: {
struct igmpv3 *igmpv3;
uint16_t igmpv3len;
uint16_t nsrc;
struct igmpv3 *igmpv3;
uint16_t igmpv3len;
uint16_t nsrc;
IGMPSTAT_INC(igps_rcv_v3_queries);
igmpv3 = (struct igmpv3 *)igmp;
/*
* Validate length based on source count.
*/
nsrc = ntohs(igmpv3->igmp_numsrc);
if (nsrc * sizeof(in_addr_t) >
UINT16_MAX - iphlen - IGMP_V3_QUERY_MINLEN) {
IGMPSTAT_INC(igps_rcv_tooshort);
m_freem(m);
return (IPPROTO_DONE);
}
/*
* m_pullup() may modify m, so pullup in
* this scope.
*/
igmpv3len = iphlen + IGMP_V3_QUERY_MINLEN +
sizeof(struct in_addr) * nsrc;
if ((!M_WRITABLE(m) ||
m->m_len < igmpv3len) &&
(m = m_pullup(m, igmpv3len)) == NULL) {
IGMPSTAT_INC(igps_rcv_tooshort);
return (IPPROTO_DONE);
}
igmpv3 = (struct igmpv3 *)(mtod(m, uint8_t *)
+ iphlen);
if (igmp_input_v3_query(ifp, ip, igmpv3) != 0) {
m_freem(m);
return (IPPROTO_DONE);
}
IGMPSTAT_INC(igps_rcv_v3_queries);
igmpv3 = (struct igmpv3 *)igmp;
/*
* Validate length based on source count.
*/
nsrc = ntohs(igmpv3->igmp_numsrc);
if (nsrc * sizeof(in_addr_t) >
UINT16_MAX - iphlen - IGMP_V3_QUERY_MINLEN) {
IGMPSTAT_INC(igps_rcv_tooshort);
m_freem(m);
return (IPPROTO_DONE);
}
/*
* m_pullup() may modify m, so pullup in
* this scope.
*/
igmpv3len = iphlen + IGMP_V3_QUERY_MINLEN +
sizeof(struct in_addr) * nsrc;
if ((!M_WRITABLE(m) ||
m->m_len < igmpv3len) &&
(m = m_pullup(m, igmpv3len)) == NULL) {
IGMPSTAT_INC(igps_rcv_tooshort);
return (IPPROTO_DONE);
}
ip = mtod(m, struct ip *);
igmpv3 = (struct igmpv3 *)(mtod(m, uint8_t *) + iphlen);
if (igmp_input_v3_query(ifp, ip, igmpv3) != 0) {
m_freem(m);
return (IPPROTO_DONE);
}
break;
}
}
break;
case IGMP_v1_HOST_MEMBERSHIP_REPORT:
+2
View File
@@ -365,6 +365,8 @@ in_control_ioctl(u_long cmd, void *data, struct ifnet *ifp,
sx_xunlock(&in_control_sx);
return (error);
case OSIOCAIFADDR: /* 9.x compat */
gone_in(17, "%s (pid %d) uses OSIOCAIFADDR");
/* FALLTHROUGH */
case SIOCAIFADDR:
sx_xlock(&in_control_sx);
error = in_aifaddr_ioctl(cmd, data, ifp, cred);
+4 -7
View File
@@ -466,7 +466,6 @@ icmp_input(struct mbuf **mp, int *offp, int proto)
int hlen = *offp;
int icmplen = ntohs(ip->ip_len) - *offp;
int i, code;
int fibnum;
NET_EPOCH_ASSERT();
@@ -737,12 +736,10 @@ reflect:
break;
}
for ( fibnum = 0; fibnum < rt_numfibs; fibnum++) {
rib_add_redirect(fibnum, (struct sockaddr *)&icmpsrc,
(struct sockaddr *)&icmpdst,
(struct sockaddr *)&icmpgw, m->m_pkthdr.rcvif,
RTF_GATEWAY, V_redirtimeout);
}
rib_add_redirect(M_GETFIB(m), (struct sockaddr *)&icmpsrc,
(struct sockaddr *)&icmpdst,
(struct sockaddr *)&icmpgw, m->m_pkthdr.rcvif,
RTF_GATEWAY, V_redirtimeout);
break;
/*
+9 -13
View File
@@ -3201,25 +3201,21 @@ static void
tcp6_ctlinput_viaudp(udp_tun_icmp_param_t param)
{
struct ip6ctlparam *ip6cp = param.ip6cp;
struct mbuf *m;
struct udphdr *udp;
struct udphdr udp;
uint16_t port;
m = m_pulldown(ip6cp->ip6c_m, ip6cp->ip6c_off, sizeof(struct udphdr), NULL);
if (m == NULL) {
if (ip6cp->ip6c_m->m_pkthdr.len <
ip6cp->ip6c_off + sizeof(struct udphdr))
return;
}
udp = mtod(m, struct udphdr *);
if (ntohs(udp->uh_sport) != V_tcp_udp_tunneling_port) {
m_copydata(ip6cp->ip6c_m, ip6cp->ip6c_off, sizeof(udp),
(caddr_t)&udp);
if (ntohs(udp.uh_sport) != V_tcp_udp_tunneling_port)
return;
}
port = udp->uh_dport;
m_adj(m, sizeof(struct udphdr));
if ((m->m_flags & M_PKTHDR) == 0) {
ip6cp->ip6c_m->m_pkthdr.len -= sizeof(struct udphdr);
}
port = udp.uh_dport;
ip6cp->ip6c_off += sizeof(struct udphdr);
/* Now call in to the normal handling code */
tcp6_ctlinput_with_port(ip6cp, port);
ip6cp->ip6c_off -= sizeof(struct udphdr);
}
#endif /* INET6 */
+3 -5
View File
@@ -2356,7 +2356,6 @@ icmp6_redirect_input(struct mbuf *m, int off)
struct sockaddr_in6 ssrc;
struct sockaddr *gw;
int rt_flags;
u_int fibnum;
bzero(&sdst, sizeof(sdst));
bzero(&ssrc, sizeof(ssrc));
@@ -2375,10 +2374,9 @@ icmp6_redirect_input(struct mbuf *m, int off)
rt_flags |= RTF_GATEWAY;
} else
gw = ifp->if_addr->ifa_addr;
for (fibnum = 0; fibnum < rt_numfibs; fibnum++)
rib_add_redirect(fibnum, (struct sockaddr *)&sdst, gw,
(struct sockaddr *)&ssrc, ifp, rt_flags,
V_icmp6_redirtimeout);
rib_add_redirect(M_GETFIB(m), (struct sockaddr *)&sdst, gw,
(struct sockaddr *)&ssrc, ifp, rt_flags,
V_icmp6_redirtimeout);
}
freeit:
+5 -2
View File
@@ -269,7 +269,7 @@ in6_control_ioctl(u_long cmd, void *data,
{
struct in6_ifreq *ifr = (struct in6_ifreq *)data;
struct in6_ifaddr *ia = NULL;
struct in6_aliasreq *ifra = (struct in6_aliasreq *)data;
struct in6_aliasreq tmpifra, *ifra = (struct in6_aliasreq *)data;
struct sockaddr_in6 *sa6;
int error;
bool control_locked = false;
@@ -278,8 +278,11 @@ in6_control_ioctl(u_long cmd, void *data,
* Compat to make pre-10.x ifconfig(8) operable.
*/
if (cmd == OSIOCAIFADDR_IN6) {
gone_in(17, "%s (pid %d) uses OSIOCAIFADDR_IN6");
cmd = SIOCAIFADDR_IN6;
ifra->ifra_vhid = 0;
ifra = &tmpifra;
memset(ifra, 0, sizeof(*ifra));
memcpy(ifra, data, sizeof(struct oin6_aliasreq));
}
switch (cmd) {
+1 -1
View File
@@ -666,7 +666,7 @@ ipf_lookup_iterate(ipf_main_softc_t *softc, void *data, int uid, void *ctx)
if (err != 0)
return (err);
if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX) {
if (iter.ili_unit < IPL_LOGALL || iter.ili_unit > IPL_LOGMAX) {
IPFERROR(50038);
return (EINVAL);
}
+11 -7
View File
@@ -129,6 +129,15 @@ ENTRY(cpu_switch)
sync /* Make sure all of that finished */
cpu_switchin:
/*
* Release the old thread before waiting for the new one. Two CPUs
* may exchange threads, so waiting first would leave each CPU waiting
* for the other to perform this store.
*/
cmpwi %r14,0
beq- 1f
stw %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */
1:
#if defined(SMP) && defined(SCHED_ULE)
/* Wait for the new thread to become unblocked */
bl 1f
@@ -141,19 +150,14 @@ cpu_switchin:
blocked_loop:
lwz %r7,TD_LOCK(%r2)
cmpw %r6,%r7
isync
beq- blocked_loop
isync /* Acquire thread state. */
#endif
lwz %r17,TD_PCB(%r2) /* Get new current PCB */
lwz %r1,PCB_SP(%r17) /* Load new stack pointer */
/* Release old thread now that we have a stack pointer set up */
cmpwi %r14,0
beq- 1f
stw %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */
1: mfsprg %r7,0 /* Get the pcpu pointer */
mfsprg %r7,0 /* Get the pcpu pointer */
stw %r2,PC_CURTHREAD(%r7) /* Store new current thread */
lwz %r17,TD_PCB(%r2) /* Store new current PCB */
stw %r17,PC_CURPCB(%r7)
+11 -7
View File
@@ -187,6 +187,15 @@ save_tar:
sync /* Make sure all of that finished */
cpu_switchin:
/*
* Release the old thread before waiting for the new one. Two CPUs
* may exchange threads, so waiting first would leave each CPU waiting
* for the other to perform this store.
*/
cmpdi %r14,0
beq- 1f
std %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */
1:
#if defined(SMP) && defined(SCHED_ULE)
/* Wait for the new thread to become unblocked */
addis %r6,%r2,TOC_REF(blocked_lock)@ha
@@ -194,20 +203,15 @@ cpu_switchin:
blocked_loop:
ld %r7,TD_LOCK(%r13)
cmpd %r6,%r7
isync
beq- blocked_loop
isync /* Acquire thread state. */
#endif
ld %r17,TD_PCB(%r13) /* Get new PCB */
ld %r1,PCB_SP(%r17) /* Load the stack pointer */
addi %r1,%r1,-48 /* Remember about cpu_switch stack frame */
/* Release old thread now that we have a stack pointer set up */
cmpdi %r14,0
beq- 1f
std %r16,TD_LOCK(%r14) /* ULE: update old thread's lock */
1: mfsprg %r7,0 /* Get the pcpu pointer */
mfsprg %r7,0 /* Get the pcpu pointer */
std %r13,PC_CURTHREAD(%r7) /* Store new current thread */
ld %r17,TD_PCB(%r13) /* Store new current PCB */
std %r17,PC_CURPCB(%r7)
+1 -1
View File
@@ -314,7 +314,7 @@ struct bus_space {
#define bus_space_read_stream_1(t, h, o) __bs_rs_s(1,(t), (h), (o))
#define bus_space_read_stream_2(t, h, o) __bs_rs_s(2,(t), (h), (o))
#define bus_space_read_stream_4(t, h, o) __bs_rs_s(4,(t), (h), (o))
#define bus_space_read_stream_8(t, h, o) __bs_rs_s(8,8,(t),(h),(o))
#define bus_space_read_stream_8(t, h, o) __bs_rs_s(8,(t), (h), (o))
/*
* Bus read multiple operations.
-8
View File
@@ -146,12 +146,4 @@ struct exec {
#define EX_DYNAMIC 0x20 /* contains run-time link-edit info */
#define EX_DPMASK 0x30 /* mask for the above */
#ifdef _KERNEL
struct thread;
struct vnode;
int aout_coredump(struct thread *td, struct vnode *vp, off_t limit,
int flags);
#endif
#endif /* !_IMGACT_AOUT_H_ */
+1
View File
@@ -50,6 +50,7 @@ union ccb;
struct bio;
struct mbuf;
struct memdesc;
struct thread;
struct uio;
void kmsan_init(void);
+1 -1
View File
@@ -1695,7 +1695,7 @@ gdb_query(const uint8_t *data, size_t len)
start_packet();
if (doff >= xmllen) {
append_char('l');
} else if (doff + dlen >= xmllen) {
} else if (dlen >= xmllen - doff) {
append_char('l');
append_binary_data(xml + doff, xmllen - doff);
} else {