for SADB_UPDATE op SADB_X_EXT_NEW_ADDRESS_SRC/DST extensions, by
checking the sa_len matching the address family requirements before
doing the copy.
Also convert KEY_SETSECASIDX() and KEY_SETSECSPIDX() to functions and
apply the sa_len clamping there.
See https://github.com/0xdeadbeefnetwork/pfkey-sadb-overflow
PR: 297264
Tested by: Wafa Hamzah <[email protected]> (previous version)
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58646
This should provide much higher resistence against struct thread layout
changes for out-of-tree modules depending on linuxkpi.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58733
When the terminal cdev is closed due to revoke, ttydev_close() destroys
t_inpoll and t_outpoll selinfos. Since corresponding knotes reference
files pointing to the same tty cdev, it fdrop()s them. But then the
VOP_CLOSE() call would recurse into the ttydev_close() for the same tty.
More, because the devfs vnode is already doomed, each close call gets
the FREVOKE flag set.
As result, the kernel is recursing as deep into the ttydev_close() as
there are opened files referencing the same tty, which have the knotes
installed. Basically, the recursion level is controlled by userspace.
Prevent it by marking the tty that is handled by ttydev_close(), with
the TF_INDEVCLOSE flag. Do nothing in ttydev_close() when the flag is
already set, avoiding recursion.
Fixes: acd5638e26 ("tty: delete knotes when TTY is revoked")
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58706
For some complex nullfs mount configurations, it is possible to get the
covered vnode lock for the mount shared with some inside-mount vnode
lock. Then at unmount time, vflush() would recurse on the covered vnode
lock when reclaiming the vnode.
Work around it, by temprorarily allowing recursion on the covered vnode
lock. Disable recursion after the unmount if it was not enabled before.
PR: 297174
Reviewed by: jah
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58567
Also add vnode locking wrappers for lockcanrecurse(9) and
lockdisablerecurse(9).
Reviewed by: jah
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58567
Do the advisory aborts of the in-flight requests before flushing the
vnodes. It should mostly eliminate the waits due to requests busying
the mp.
Reported and reviewed by: rew
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58637
For pdwait(2) and pddupfd(2), the returned error is kept EINVAL.
PR: 297293
Reviewed by: lwhsu, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58666
Since autofs_lookup() calls into autofs_trigger_vn() to perform
automounting, and autofs_trigger_vn() unlocks the vnode, it is possible
for the unmount to start meantime. Then autofs_trigger() accesses freed
memory.
At this point, busy can be only done unblocking, and the transient
failure must abort the trigger operation. This would cause spurious
automounter errors, but at least should prevent accesses to the freed
memory.
PR: 294361
Reviewed by: markj, rew
Tested by: rew
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58626
Add the p_zombieref bitmask into struct proc, which enumerates all
legitimate waiters on the process exit status. Among them are parent
for PZOMBIEREF_PARENT, and the holder of the process descriptor for
PZOMBIEREF_PROCDESC, if the process was created by pdfork().
Require all zombie refs to be cleared to reap zombie. This prevents
stealing the exit status from the parent by pdwait()ing on a procdesc
obtained by pdopenpid(), or by waitpid() by debugger from the real
parent.
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58264
Instead of accessing the struct proc and gathering data from it,
memoize the data needed for pdwait() on exited process in struct
procdesc, at the time of process termination.
This allows unlimited number of calls to pdwait(2) on procdesc for
terminated process.
Change the locking requirements for pd_flags to proctree_lock. This does
not modify the pre-patch locking regime, but the change requires it.
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58407
Reported and reviewed by: markj
Fixes: 8cef3c9b76 ("proc_realparent(): assert that an orphaned child has real parent != parent")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58566
Also do not mask bits in the mxcsr_mask. It is ignored by FRSTOR/XRSTOR.
Reported by: markj
Reviewed by: jhb, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58548
There are probably more places which could benefit from allowing to
interrupt vfs_busy() calls at syscalls top level.
Requested by: Peter Eriksson <[email protected]>
Reviewed by: jah, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58477
to avoid using uninitialized value in the KASSERT() statement on the first
iteration.
Also, do the assert under the proctree_lock, which is not critical but
satisfies the invariants.
Noted and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58505
Also use bool for the 'cancel' argument for cond_wait_common().
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58463
State that FIFOs can be created, document the requirement that
dev must be zero then. Mention whiteouts.
PR: 297082
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D58478
Also be more protective in getsid().
Reported by: arrowd
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differrential revision: https://reviews.freebsd.org/D58393
FRED support as defined starting from the SDM rev. 90, requires a new
'events' entry point to receive user and kernel mode exceptions and
interrupts notifications from the hardware. A minimal asm trampoline is
enough, rest can be implemented in C due to the clean FRED organization
of the event reporting.
The syscall entry is handled by a microptimized assembly path, directly
calling into the amd64_syscall() handler, instead of the generic events
entry point.
Tested by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55829
on attach of the knote. It is same as for NOTE_EXIT when attaching to
the exiting process.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58327
This is needed for VM_PHYS_TO_PAGE() to work, which is needed for
pmap_map_io_transient() to work, which is needed for uiomove_fromphys()
to work.
PR: 296348
Reported and tested by: Anton Saietskii <[email protected]>
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58274
Since init become dynamically linked, reroot appeared to be broken
because init copies itself into a transient tmpfs mount to continue
controlling execution right after the reboot(REROOT) syscall. Because
the binary is dynamically linked, it cannot be properly executed.
Provide a minimal static binary 'reroot_seed' embedded into the init as
byte stream, which performs what the 'init -r' did, namely, the second
phase reroot.
For the static build of init as part of the /rescue crunch, keep the
inline reroot code.
Reported and tested by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58164
Convert several callers to use fget_procdesc().
Eliminate procdesc_find() and directly use fget_procdesc() in
sys_pdkill(). Previous code structure required to fdrop() procdesc
while the process is locked.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58117
We need to wake up the pdwait(2) waiters when procdesc event is
reported.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58172
The note type wakes up when there is something for pdwait(2) to report
on the process descriptor.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58123
Currently no filesystems support it.
Reviewed by: mckusick
Discussed with: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D57658
We should exit the net epoch instead of acquiring one more entry.
Reported by: Wafa Hamzah <[email protected]>
Reviewed by: jhb
Sponsored by: Nvidia networking
Fixes: 4726b80d93 ("OFED: Various changes from Linux 4.20")
Differential revision: https://reviews.freebsd.org/D58127
sendfile(): for trailers uio, set uio_rw to UIO_WRITE instead of checking it
kern_filewrite(): remove unused argument offset
kern_writev(): the check should compare cnt against zero, not uio_resid
Reported by: markj
Fixes: dfad790c8c ("sendfile: stop abusing kern_writev()")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
This catches up with 692b0ef150 which added CAPENABLED to
clock_nanosleep(). Curiously recent additions of the pdopenpid(2) and
pddupfd(2) were done before the cited commit, and that regen did not
included the change.
Sponsored by: The FreeBSD Foundation
Provide convenient wrapper kern_filewrite() around fo_write().
Switch to use it in vn_sendfile(). This allows to avoid duplicate
fget() when we already have the reference to the file, which creates a
correctness race with the userspace. Also td_retval[0] clearing hack
can be removed.
Reviewed by: glebius, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58035
This is backward ABI-compatible, because the only place in kernel that
uses the structure, namely the mlx5_ib_cq.c:mlx5_ib_create_cq()
function, copies in as much structure members as provided by userspace.
Tested by: Wafa Hamzah <[email protected]>
Sponsored by: Nvidia networking
MFC after: 1 month
Also do not start a new list for each flag item.
Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D57124
Introduce pd_fpcount that counts the number of file references to the
procdesc. Remove the PDF_CLOSED flag, now it is expressed as
pd_fpcount == 0.
Only send SIGKILL and clear pointers when we are closing the last file
referencing procdesc.
This should be nop until the next commit.
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D57124
Check that the P_WEXIT flag is set.
Requested by: markj
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D57124