summaryrefslogtreecommitdiff
path: root/sys/kern
AgeCommit message (Collapse)Author
2023-01-16Currently we disable kbind(2) for static program from libc.a'sPhilip Guenther
preinit hook. Delete that and instead have the kernel disable kbind at exec-time if the program doesn't have an ELF interpreter. For now, permit userland calls to disable it when already disabled so existing static programs continue to work. prompted by deraadt@ questioning about the call in libc.a ok deraadt@ miod@
2023-01-14sysctl(2): KERN_CPUSTATS: zero struct cpustats before copyoutScott Soule Cheloha
2023-01-13Since the signal trampoline is now execute-only we no longer write itMark Kettenis
into core dumps. As a result backtraces through signal handlers no longer work in gdb and other debuggers. Fix this by keeping a read-only mapping of the signal trampoline in the kernel and writing it into the core dump at the virtual address where it is mapped in the process. ok deraadt@, tb@
2023-01-12Use solock() instead solock_shared() within sys_getsockopt(). OtherwiseVitaliy Makkoveev
we acquiring kernel lock with mutex(9) held. This partially reverts rev 1.205 of sys/kern/uipc_syscalls.c. Shared solock() is still fine for getsockname(2) and getpeername(2). Reported-by: syzbot+00a4824cb1b6a214c7d6@syzkaller.appspotmail.com ok kn@ claudio@
2023-01-09setthrname() should return EINVAL, not ENAMETOOLONG, when thePhilip Guenther
input is too long. ok mpi@
2023-01-07regenPhilip Guenther
2023-01-07Add {get,set}thrname(2) for putting thread names in the kernel andPhilip Guenther
exposed in a new field returned by sysctl(KERN_PROC). Update pthread_{get,set}_name_np(3) to use the syscalls. Show them, when set, in ps -H and top -H output. libc and libpthread minor bumps ok mpi@, mvs@, deraadt@
2023-01-06Replace last user of copystr() with strlcpy(). NFCIMiod Vallat
2023-01-05after a few trap.c were fixed to fault with the right access, theTheo de Raadt
signal trampoline can now be PROT_EXEC (without PROT_READ) everywhere ok kettenis
2023-01-02Add tfind_user(), for getting a proc* given a user-space TID andPhilip Guenther
the process* that it should be part of. Use that in clock_get{time,res}(), thrkill(), and ptrace(). ok jca@ miod@ mpi@ mvs@
2023-01-01copyright++;Jonathan Gray
2022-12-31timeout: rename "timeout_at_ts" to "timeout_abs_ts"Scott Soule Cheloha
I think "abs" ("absolute timeout") is a better mnemonic than "at" ("at the given time"). The interface is undocumented and there are only two callers, so renaming it is not a big deal. probably ok kn@
2022-12-31sysctl_clockintr: clear "sum" with memset before copyout(9)Scott Soule Cheloha
2022-12-29Add ktrace struct tracepoints for siginfo_t to the kernel side ofPhilip Guenther
waitid(2) and __thrsigdivert(2) and teach kdump(1) to handle them. Also report more from the siginfo_t inside PSIG tracepoints. ok mpi@
2022-12-27Fix array bounds mismatch with clang 15Patrick Wildt
New warning -Warray-parameter is a bit overzealous. ok millert@ tb@
2022-12-26Replace two (void)copystr(..., NULL) with equivalent (void)strlcpy() calls.Miod Vallat
ok millert@
2022-12-23wrap a line betterTheo de Raadt
2022-12-21The location of the aux info vector is now cached in ps_auxinfo of structClaudio Jeker
process. Use this information to access the vector. OK mpi@ mbuhl@ deraadt@
2022-12-21fix a mangled commentTheo de Raadt
2022-12-19Add WTRAPPED opiton for waitid(2) to control whether CMD_TRAPPEDPhilip Guenther
state changes are reported. That's the 6th bit, so switch to hex constants. Adjust #if tests for consistency ok kettenis@
2022-12-17regen after minherit(2) unlockKlemens Nanni
2022-12-17Unlock minherit(2)Klemens Nanni
struct uvm_map's .addr is protected by the map's lock and .{min,max}_offset are immutable. uvm_map_inherit() locks the VM map upon entry, sets the desired inheritance mode for the given address range (validated outside the lock) and unlocks the map itself. fork(2), i.e. uvm_mapent_forkcopy(), first locks both old and new maps and then copies entries over as per the inheritance type. futex(2), another user of struct vm_map_entry's .inheritance member, also locks the map accordingly. OK mpi
2022-12-13timecounting: add getbinruntime(), getnsecruntime()Scott Soule Cheloha
The networking people want a fast, monotonic clock that only advances while the system is not suspended. The runtime clock satisfies most of these requirements, so introduce getnsecruntime() to provide a fast means for reading it. Based on patches from jca@ and claudio@. ok yasuoka@
2022-12-12Revert sb_state changes to unbreak tree.Theo Buehler
2022-12-11This time, socket's buffer lock requires solock() to be held. As a part ofVitaliy Makkoveev
socket buffers standalone locking work, move socket state bits which represent its buffers state to per buffer state. Introduce `sb_state' and turn SS_CANTSENDMORE to SBS_CANTSENDMORE. This bit will be processed on `so_snd' buffer only. Move SS_CANTRCVMORE and SS_RCVATMARK bits with separate diff to make review easier and exclude possible so_rcv/so_snd mistypes. Also, don't adjust the remaining SS_* bits right now. ok millert@
2022-12-07Document 'uidinfo' structure locks.Vitaliy Makkoveev
Inputs and ok bluhm@
2022-12-07If the called of ypconnect(2) is root, the socket should acquire aTheo de Raadt
reserved port to received secure-maps from the ypserver. issue found by niklas, using a simpler diff i proposed ok miod
2022-12-05zap a pile of dangling tabsTheo de Raadt
2022-12-05Avoid event counter re-insert in evcount_percpu()Visa Hankala
This fixes evcount_list corruption that happened when evcount_percpu() was called after evcount_init_percpu(). OK jca@ cheloha@ jmatthew@
2022-11-30Use shared socket/net lock for IP socketsKlemens Nanni
so{,un}lock_shared() take the shared net lock for PF_INET and PF_INET6 while sticking to the exclusive rwlock elsewhere. getsockopt(2), getsockname(2) and getpeername(2) (all UNLOCK) do not write, so the exclusive net lock is overkill here. OK mvs
2022-11-30regenVitaliy Makkoveev
2022-11-30Unlock getsockopt(2) and setsockopt(2). Unlock them both because atVitaliy Makkoveev
protocol layer they follow the same (*pr_ctloutput)() handlers. At sockets layer we touch only per-socket data, which is solock() protected. At protocol layer, udp(4), unix(4) and key management sockets have no (*pr_ctloutput)() handlers. route_ctloutput() touches only per socket data, which is solock() protected. inet{,6} globals are protected by netlock, which is solock() backend for corresponding sockets. ok bluhm@
2022-11-28Simplify return path of (*pr_ctloutput)() return value in sogetopt().Vitaliy Makkoveev
ok guenther@ kn@
2022-11-26Merge uipc_bind() with unp_bind(). Unlike other unp_*() functions,Vitaliy Makkoveev
unp_bind() has the only uipc_bind() caller. In the uipc_usrreq() times, it made sense to have dedicated unp_bind() for prevent tne code mess within giant switch(), but now it doesn't. ok bluhm@
2022-11-23cache ps_auxinfo inside the kernel, to avoid codedump() reading theMoritz Buhl
copy on userland stack which points at an illicit region. ok kettenis, deraadt
2022-11-19Push kernel lock into pru_control() aka. in6_control() / in_control()Klemens Nanni
so->so_state is already read without kernel lock inside soo_ioctl() which calls pru_control() aka in6_control() and in_control(). OK mvs
2022-11-17stack growth from setrlimit was never updated to set UVM_ET_STACK onTheo de Raadt
the entries, so the check-sp-at-system-call check failed. Quite strange it took this long to find this. ok kettenis
2022-11-15style(9) fix. No functional change.Vitaliy Makkoveev
2022-11-14Fix tag type and buffer limit in DT_TEXTREL lookup.Visa Hankala
OK deraadt@ kettenis@
2022-11-13Split out handlers for SOCK_DGRAM unix(4) sockets from SOCK_STREAM andVitaliy Makkoveev
SOCK_SEQPACKET. Introduce `uipc_dgram_usrreqs' to store pointers for dgram specific handlers. The dgram pru_shutdown and pru_send handlers were splitted to uipc_dgram_shutdown() and uipc_dgram_send(). The pru_accept, pru_rcvd and pru_abort handlers are not required for dgram sockets. The unp_disconnect() remains shared between all unix(4) sockets because it called from common paths too. Proposed by and ok guenther@
2022-11-11Revert last until we can guarantee gh_guid can't escape to theKenneth R Westerback
d_uid written to disk.
2022-11-11timeout(9): remove timeout_set_kclock(), TIMEOUT_INITIALIZER_KCLOCK()Scott Soule Cheloha
We have too many timeout(9) initialization functions and macros. Let's slim it down and combine some interfaces. - Remove timeout_set_kclock(), TIMEOUT_INITIALIZER_KCLOCK(). - Expand timeout_set_flags(), TIMEOUT_INITIALIZER_FLAGS() to accept an additional "kclock" parameter. - Reimplement timeout_set(), timeout_set_proc() with timeout_set_flags(). - Reimplement TIMEOUT_INITIALIZER() with TIMEOUT_INITIALIZER_FLAGS(). - Update the sole timeout_set_flags() user to pass a kclock parameter. - Update the sole timeout_set_kclock() user to call timeout_set_flags(). - Update the sole TIMEOUT_INITIALIZER_FLAGS() user to provide a kclock parameter. The timeout(9) code is now a bit out of sync with the manpage. This will be corrected in a subsequent commit. ok kn@
2022-11-11Use the first 8 bytes of GPT gh_guid as the default d_uid. gh_guid isKenneth R Westerback
initialized with arc4random().
2022-11-10Add mbr_get_fstype() and use it to translate MBR dp_typ fieldsKenneth R Westerback
into FS_* values. Similar to what gpt_get_fstype() does. Code is clearer and better positioned for planned enhancements to spoofing. No intentional functional change.
2022-11-10Put CPUs in the lowest P-state just before the final suspend step. TheMark Kettenis
firmware probably does this for us on ACPI systems with proper S3 support, but this doesn't happen on systems where we park CPUs in a low-power idle state ourselves. ok deraadt@
2022-11-10Add support for per-cpu event counters, to be used for clock and IPIJonathan Matthew
counters where the event being counted occurs across all CPUs in the system. Counter instances can be made per-cpu by calling evcount_percpu() after the counter is attached, and this can occur before or after all system CPUs are attached. Per-cpu counter instances should be incremented using evcount_inc(). ok kettenis@ jca@ cheloha@
2022-11-10fix build after 1.298Jonathan Gray
2022-11-09Remove kernel lock here since msleep() with PCATCH no longer requires it.Claudio Jeker
OK mpi@
2022-11-09Some limited setsockopt/getsockopt are allowed in pledge "stdio".Theo de Raadt
Also allow IPPROTO_TCP:TCP_NODELAY It is very small kernel code, and will allow some software to drop "inet" requested by djm
2022-11-09Simplify the overly complex VXLOCK handling in spec_close.Claudio Jeker
The code only needs to know if the vnode is exclusive locked and this can be done on entry of the function. OK mpi@