summaryrefslogtreecommitdiff
path: root/sys/kern
AgeCommit message (Collapse)Author
2022-10-07Add mimmutable(2) system call which locks the permissions (PROT_*) ofTheo de Raadt
memory mappings so they cannot be changed by a later mmap(), mprotect(), or munmap(), which will error with EPERM instead. ok kettenis
2022-10-03System calls should not fail due to temporary memory shortage inAlexander Bluhm
malloc(9) or pool_get(9). Pass down a wait flag to pru_attach(). During syscall socket(2) it is ok to wait, this logic was missing for internet pcb. Pfkey and route sockets were already waiting. sonewconn() must not wait when called during TCP 3-way handshake. This logic has been preserved. Unix domain stream socket connect(2) can wait until the other side has created the socket to accept. OK mvs@
2022-10-03Add a second membar producer into counters_zero(). Now it isAlexander Bluhm
symmetric to counters_read(). OK jmatthew@
2022-10-01The syscall table generation awk script was also used by compat layersTheo de Raadt
in the past, but those compat layers are gone. Remove support for the "config file" ok miod millert
2022-09-28Fix memory corruptions with sysv semaphores due to sleeps in copyin,Moritz Buhl
copyout and malloc. During a sleep another thread could delete the semaphore (and possibly allocate another one at the same location with different permissions) which would lead to an invalid access after wake up. Therefore check the semaphore pointer, the sequence, the permissions and some values in seminfo after each sleep. OK bluhm@ Reported-by: syzbot+60ba811fe2e8a6b0f975@syzkaller.appspotmail.com
2022-09-23Don't hardcode disk major device types inside DEBUG block. UseKenneth R Westerback
findblkname() and DISKUNIT(). Allows all block devices, not just sd* and vnd* to generate useful names in DEBUG output. Cluebat by deraadt@
2022-09-20Remove unused and unimplemented unp_drain().Vitaliy Makkoveev
ok bluhm@
2022-09-18timecounting: tc_reset_quality: print notice if active counter changesScott Soule Cheloha
Give the user a hint as to what happened if they boot up and the TSC is not the active counter. "sure" deraadt@
2022-09-17bind() to AF_UNIX will now require unveil "w". "w" may seem a little oddTheo de Raadt
(and it may seem it should be "r" to get access to the file to collect the underlying socket, which is fully r/w in a non-file way). But this matches the POSIX spec that the file be 'writeable'. The regress test and daemons have been updated for this behaviour. Gap discovered by martijn, long discussions with benno
2022-09-16semctl1 and msgctl were introduced for binary compatibility for OpenBSD 3.5.Moritz Buhl
They are no longer needed. OK bluhm@
2022-09-15Remove unneeded interim DPRINTF() verbiage. Make DEBUG compileKenneth R Westerback
again.
2022-09-14AF_UNIX bind() must use UNVEIL_CREATE for namei() because it is creatingTheo de Raadt
a file in the filesystem. Spotted by martijn. A review of AF_UNIX binding programs has been done by benno, and we think it is worth commiting this semantic change now and watching for fallout.
2022-09-13Change pru_rcvd() return type to the type of void. We have no interestVitaliy Makkoveev
on pru_rcvd() return value. Drop "pru_rcvd != NULL" check within pru_rcvd() wrapper. We only call it if the socket's protocol have PR_WANTRCVD flag set. Such sockets are route domain, tcp(4) and unix(4) sockets. ok guenther@ bluhm@
2022-09-11Remove the DKF_LABELVALID flag from struct disk. Instead, trust disk driversMiod Vallat
to always be able to provide a duid, and keep ignoring whole zero duids. This fixes a race in vnd setup where the disk_attach callback could run before any I/O occurs on the vnd, thus not having a label available yet. noticed by otto@ and kn@; ok kn@
2022-09-11Add #define's for GPT partition attribute bits REQUIRED, IGNOREKenneth R Westerback
and BOOTABLE, set BOOTABLE attribute bit instead of using the incorrect GPTDOSACTIVE value, have 'fdisk -v' print out GPT partition attributes if any of the 64 bits are set, don't spoof any partition with REQUIRED bit set. Prompted by kettenis@ stumbling across a machine with 40+ (!!) REQUIRED GPT partitions. Tested & ok kettenis@
2022-09-05Pledge sendmmsg and recvmmsg with stdio similar to their non-loopMoritz Buhl
counter parts. Input deraadt. ok bluhm
2022-09-05Use shared netlock in soreceive(). The UDP and IP divert layerAlexander Bluhm
provide locking of the PCB. If that is possible, use shared instead of exclusive netlock in soreceive(). The PCB mutex provides a per socket lock against multiple soreceive() running in parallel. Release and regrab both locks in sosleep_nsec(). OK mvs@
2022-09-04Use pru_send function to check socket splicing compatibility. OnlyAlexander Bluhm
checking socket type is not sufficient as it could splice together unix and inet sockets resulting in crashes. As splicing is about sending, the same send function looks like a good criteria. Reported-by: syzbot+fc6901d63d858d5dd00a@syzkaller.appspotmail.com Reported-by: syzbot+0e026f1bf8b259c6395e@syzkaller.appspotmail.com OK gnezdo@
2022-09-03Move PRU_PEERADDR request to (*pru_peeraddr)().Vitaliy Makkoveev
Introduce in{,6}_peeraddr() and use them for inet and inet6 sockets, except tcp(4) case. Also remove *_usrreq() handlers. ok bluhm@
2022-09-03regenMoritz Buhl
2022-09-03Make recvmmsg and sendmmsg look more alike. change the flag typeMoritz Buhl
to int like other flag parameters, NetBSD uses unsigned int, FreeBSD and Linux do int. OK bluhm@
2022-09-03Move PRU_SOCKADDR request to (*pru_sockaddr)()Vitaliy Makkoveev
Introduce in{,6}_sockaddr() functions, and use them for all except tcp(4) inet sockets. For tcp(4) sockets use tcp_sockaddr() to keep debug ability. The key management and route domain sockets returns EINVAL error for PRU_SOCKADDR request, so keep this behaviour for a while instead of make pru_sockaddr handler optional and return EOPNOTSUPP. ok bluhm@
2022-09-03whitespaceMike Larkin
2022-09-03Make sure we don't suspend if we have no way to wake up the machine.Mark Kettenis
The idea is that device drivers that can wake up the machine register themselves by calling device_register_wakeup(). To prevent regressions on amd64, we let acpi(4) register itself as a wakeup device if the AML for the machine defines wakeup devices. This may be refined in the future. This diff will prevent people from suspending their arm64 SBCs without having a way to wake them up. For now the only driver that registers itself is axppmic(4), which means that at this moment only SBCs with an allwinner A64 or H5 SoC will actually support suspend/resume. ok mlarkin@, deraadt@
2022-09-03Allow suspend with root on sdmmc(4).Mark Kettenis
ok deraadt@
2022-09-03Fix socket splicing between inet and inet6 sockets broken by PRU_CONTROLVitaliy Makkoveev
request splitting to (*pru_control)(). ok bluhm@
2022-09-03regenMoritz Buhl
2022-09-03add the sendmmsg syscall that allows sending multiple msghdrs atMoritz Buhl
once. libc, man page, and regress parts to come. With input from jca@, bluhm@. OK bluhm@
2022-09-02Constify nam2blk[], chrtoblktbl[] and octeon devmap[].Miod Vallat
ok mpi@ millert@
2022-09-02Don't ignore an OpenBSD GPT partition just because the GPT saysKenneth R Westerback
it extends beyond the edge of the disk the GPT currently inhabits. We only care if enough of it is addressable that a disklabel is accessible. Brings GPT handling of 'OpenBSD partitions extending too far' into line with the MBR handling of the same situation.
2022-09-02regenMoritz Buhl
2022-09-02add the recvmmsg syscall that allows receiving multiple msghdrs atMoritz Buhl
once. libc, man page, and regress parts to come. With input from jca@, guenther@, bluhm@. OK bluhm@
2022-09-02Move PRU_CONTROL request to (*pru_control)().Vitaliy Makkoveev
The 'proc *' arg is not used for PRU_CONTROL request, so remove it from pru_control() wrapper. Split out {tcp,udp}6_usrreqs from {tcp,udp}_usrreqs and use them for inet6 case. ok guenther@ bluhm@
2022-09-02Nuke variable partlba that is set but not used.Kenneth R Westerback
2022-09-02Relax GTP header validity check by allowing 1 sector size usableKenneth R Westerback
LBA area (gh_lba_start == gh_lba_end) and allowing either or both of gh_lba_start and gh_lba_end to exceed the size of the disk the GPT currently inhabits. Reduces false negatives and inappropriate fall through to MBR spoofing and allows repair of otherwise valid GPT.
2022-09-02Get the retguard region's phys address from pmap, instead of using linkerMike Larkin
script symbols. This is needed since we don't have those symbols on all archs where we want hibernate. ok kettenis, and input and help from miod.
2022-09-02openpty() family of functions use /dev/ptm PTMGET to open a master+slave fdTheo de Raadt
pair, and also provides their names. Internally, 3 NDINIT+namei operations access /dev/[tp]ty[p-zP-T][0-9a-zA-Z], of these 2 followed unveil restrictions. I argue if you unveil /dev/ptm, (and not the 372 other nodes), you still want openpty() to provide you with working fd's, and the names, which the caller will probably never open manually, because the fd's are given. So change all NDINIT to use KERNELPATH, bypassing unveil. ok semarie
2022-09-01whitespaceMike Larkin
2022-09-01Move PRU_CONNECT2 request to (*pru_connect2)().Vitaliy Makkoveev
ok bluhm@
2022-09-01Stop setting d_bbsize and d_sbsize. Nobody has paidKenneth R Westerback
any attention for some time. ok otto@ as part of larger diff
2022-08-31Move PRU_SENDOOB request to (*pru_sendoob)().Vitaliy Makkoveev
PRU_SENDOOB request always consumes passed `top' and `control' mbufs. To avoid dummy m_freem(9) handlers for all protocols release passed mbufs in the pru_sendoob() EOPNOTSUPP error path. Also fix `control' mbuf(9) leak in the tcp(4) PRU_SENDOOB error path. ok bluhm@
2022-08-30Fix uninitialized variable after the switch to (*pru_send); found the hardMiod Vallat
way on alpha. ok bluhm@ mvs@
2022-08-29If ld.so loading fails inside execve, uprintf a message to report thisTheo de Raadt
before the SIGABRT kills the process. This clarifies the failure mode (and resolution to take) when a dynamic executable is run while /usr isn't mounted. ok miod kettenis
2022-08-29Move PRU_RCVOOB request to (*pru_rcvoob)().Vitaliy Makkoveev
ok bluhm@
2022-08-28Move PRU_SENSE request to (*pru_sense)().Vitaliy Makkoveev
ok bluhm@
2022-08-28Move PRU_ABORT request to (*pru_abort)().Vitaliy Makkoveev
We abort only the sockets which are linked to `so_q' or `so_q0' queues of listening socket. Such sockets have no corresponding file descriptor and are not accessed from userland, so PRU_ABORT used to destroy them on listening socket destruction. Currently all our sockets support PRU_ABORT request, but actually it required only for tcp(4) and unix(4) sockets, so i should be optional. However, they will be removed with separate diff, and this time PRU_ABORT requests were converted as is. Also, the socket should be destroyed on PRU_ABORT request, but route and key management sockets leave it alive. This was also converted as is, because this wrong code never called. ok bluhm@
2022-08-28Don't check `so_pcb' with PR_WANTRCVD flag. tcp(4) sockets are the onlyVitaliy Makkoveev
sockets which could have NULL `so_pcb' and we handle this case within tcp_rcvd() handler. ok bluhm@
2022-08-27Move PRU_SEND request to (*pru_send)().Vitaliy Makkoveev
The former PRU_SEND error path of gre_usrreq() had `control' mbuf(9) leak. It was fixed in new gre_send(). The former pfkeyv2_send() was renamed to pfkeyv2_dosend(). ok bluhm@
2022-08-26Move PRU_RCVD request to (*pru_rcvd)().Vitaliy Makkoveev
ok bluhm@
2022-08-22Move PRU_SHUTDOWN request to (*pru_shutdown)().Vitaliy Makkoveev
ok bluhm@