summaryrefslogtreecommitdiff
path: root/sys/kern
AgeCommit message (Collapse)Author
2019-08-26When a thread tries to exclusively lock a vnode, the same thread mustanton
ensure that any other thread currently trying to acquire the underlying vnode lock has observed that the same vnode is about to be exclusively locked. Such threads must then sleep until the exclusive lock has been released and then try to acquire the lock again. Otherwise, exclusive access to the vnode cannot be guaranteed. Thanks to naddy@ and visa@ for testing; ok visa@ Reported-by: syzbot+374d0e7e2400004957f7@syzkaller.appspotmail.com
2019-08-25Add SIOCDIFADDR_IN6 to the wroute pledge to allow removal of IPv6 addressespamela
Needed for future slaacd(8) improvements OK florian@ deraadt@
2019-08-21sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)cheloha
The DST and TIMEZONE options(4) are incompatible with KARL, so we need some other way to compensate for an RTC running with a known offset. Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has always been minutes West, but this is inconsistent with how everyone else talks about timezones, hence the flip. TIMEZONE has the advantage of being compiled into the binary. Our new sysctl(2) has no such luck, so it needs to be set as early as possible in boot, from sysctl.conf(5), so we can correct the kernel clock from the RTC's local time to UTC before daemons like ntpd(8) and cron(8) start. To encourage this, kern.utc_offset is made immutable after the securelevel(7) is raised to 1. Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@. Additional testing by yasuoka@. ok deraadt@, yasuoka@
2019-08-15NMEA 4.1 has one more field in the RMC message; ok kettenis@Otto Moerbeek
2019-08-15Serialize access to the vnode pointers associated with acct(2) systemanton
accounting. Prevents a race where the acct thread and the acct(2) syscall both tries to close a vnode. ok visa@ Reported-by: syzbot+bf2ac4d4fa9ee92903b8@syzkaller.appspotmail.com
2019-08-13regenanton
2019-08-13Revert unlock of lseek(2) since vn_lock() could end up calling tsleep()anton
which is not allowed without holding the kernel lock. Otherwise, wakeups could be lost. Reported-by: syzbot+57588681ca9e3e9ba926@syzkaller.appspotmail.com
2019-08-12regenanton
2019-08-12Unlock lseek(2) since the file offset is MP-safe by now. Callinganton
VOP_GETATTR() must still be serialized using the kernel lock since the underlying file system implementation is not MP-safe. no objection from deraadt@ and ok mpi@ visa@
2019-08-07The pathname in unveil(2) allocated 1024 bytes on the stack duringAlexander Bluhm
the system call. Better use namei pool like sys___realpath() does. OK semarie@ deraadt@
2019-08-07avoid large MAXPATHLEN object on the stack in coredump(), by allocatingTheo de Raadt
it from the pool. ok bluhm visa
2019-08-06Fix white spaces.Alexander Bluhm
2019-08-05Kernel realpath(3) and unveil(2) did not work correctly if the rootAlexander Bluhm
directory was written as "//". If there is no non-slash character in the path name, use the spacial case for root. found by gmake regression tests; OK naddy@ benno@
2019-08-05Kernel realpath(3) had the same vnode leakage bug like unveil(2).Alexander Bluhm
If parent and lookup vnode are equal, namei(9) locks them once but reference counts twice. from Moritz Buhl
2019-08-05Remove the unused function parameter rootvnode from unveil_add_vnode().Alexander Bluhm
2019-08-05Allow concurrent reads of the f_offset field of struct file byanton
serializing both read/write operations using the existing file mutex. The vnode lock still grants exclusive write access to the offset; the mutex is only used to make the actual write atomic and prevent any concurrent reader from observing intermediate values. ok mpi@ visa@
2019-08-04Calling unveil(2) with the current directory leaked a vnode. EvenAlexander Bluhm
if the parent and the lookup vnode are equal, namei(9) reference counts both. So release the parent vnode uncoditionally. OK visa@
2019-08-03R.I.P. itimerround(); ok mpi@cheloha
2019-08-02Move prototypes of unveil(2) functions which are used in separate CAlexander Bluhm
files into the common namei.h header. OK deraadt@
2019-08-02per-process itimers: itimerval -> itimerspeccheloha
Loongson runs at 128hz. 128 doesn't divide evenly into a million, but it does divide evenly into a billion. So if we do the per-process itimer bookkeeping with itimerspec structs we can have error-free virtual itimers on loongson just as we do on most other platforms. This change doesn't fix the virtual itimer error alpha, as 1024 does not divide evenly into a billion. But this doesn't make the situation any worse, either. ok deraadt@
2019-08-01In ufs_lookup() *vpp is always refcounted, also in the ISDOTDOTAlexander Bluhm
case even if *vpp == vdp. So in unveil_find_cover() it is wrong to skip dereferencing if parent == vp. This fixes an umount(8) device busy error when unveil(2) and chroot(2) are used together on a file system. reported by Matthias Pitzl; OK deraadt@
2019-07-29correct mispellings of EACCES; from Kris KatterjohnTheo de Raadt
2019-07-29When setting immutable flags on directories with chflags(1), callingAlexander Bluhm
unveil(2) on a nonexisting file failed. Ignore files that cannot be created due to permissions. OK deraadt@
2019-07-27Move unveil prototypes from vfs_lookup.c to namei.h for functionsAlexander Bluhm
implemented in kern_unveil.c. OK deraadt@
2019-07-25itimerdecr(): simplify logic with timer*(9) macros; ok millert@cheloha
2019-07-25Use process accounting to find programs which try to access filesAlexander Bluhm
that are hidden by unveil(2). OK deraadt@
2019-07-25vinvalbuf(9): tlseep -> tsleep_nsec(9); ok millert@cheloha
2019-07-23Grab the vnode lock earlier in vn_read() since it could end up sleeping,anton
allowing the file offset to change. This is part of the ongoing effort to protect the file offset using the vnode lock. ok mpi@ visa@
2019-07-23Fix realpath(3) errno code for an empty input path string.Stefan Sperling
It should return ENOENT in this case, but was returning EINVAL. ok bluhm@ deraadt@
2019-07-22Correct minor style nit in sys_getdents() for consistency, missing parens aroundanton
return expression.
2019-07-22Grab the vnode lock earlier in sys_getdents() since it could end upanton
sleeping, allowing the file offset to change. This is part of the ongoing effort to protect the file offset using the vnode lock. ok mpi@ visa@
2019-07-22implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocolRobert Nagy
can also be retrieved with getsockopt(3) it looks like these will also be in the next issue of posix: http://austingroupbugs.net/view.php?id=840#c2263 ok claudio@, sthen@
2019-07-21Grab the vnode lock in vn_seek(). Consensus has emerged around using theanton
existing vnode lock to protect writes to the f_offset field of struct file. As opposed of introducing a new lock which turned out to be harder than anticipated. ok mpi@ visa@
2019-07-20Get rid of `ddb_is_active' instead use `db_active'.Martin Pieuchot
From Christian Ludwig <christian_ludwig at genua dot de> ok visa@
2019-07-19After the kernel has reached the sysclt kern.maxclusters limit,Alexander Bluhm
operations get stuck while holding the net lock. Increasing the limit did not help as there was no wakeup of the waiting pools. So introduce pool_wakeup() and run through the mbuf pool request list when the limit changes. OK dlg@ visa@
2019-07-19vwaitforio(9): tsleep(9) -> tsleep_nsec(9); ok visa@cheloha
2019-07-19getblk(9): tsleep(9) -> tsleep_nsec(9); ok visa@cheloha
2019-07-19ttysleep(): drop unused timeout parametercheloha
All callers sleep indefinitely. With help from visa@. ok visa@, ratchov@, kn@
2019-07-19ddb(4): clean up callout commandcheloha
- display timeouts in the thread work queue, if any - identify timeouts in the thread/softint work queue as such - if not in work queue, print <bucket>/<level>; easier to right-align - print arg pointer by hand to ensure consistent length for all pointers on both 32 and 64-bit platforms - generally make sure columns are correctly aligned and spaced ok mpi@ visa@
2019-07-18Fix unveiling nonexistent files on read-only filesystemskn
Account for VOP_LOOKUP(9) returning EROFS, otherwise unveil(2) would pass the error along and fail. Initial report and diff from semarie OK bluhm millert
2019-07-16Fix uipc white spaces.Alexander Bluhm
2019-07-16According to POSIX msgsnd(2) has to fail with EINVAL if passing aAlexander Bluhm
message with mtype < 1. from Moritz Buhl; OK kn@
2019-07-16Prevent integer overflow in kernel and userland when checking mbufAlexander Bluhm
limits. Convert kernel variables and calculations for mbuf memory into long to allow larger values on 64 bit machines. Put a range check into the kernel sysctl. For the interface itself int is still sufficient. In netstat -m cast all multiplications to unsigned long to hold the product of two unsigned int. input and OK visa@
2019-07-16move the whole `struct pipe' allocation and initialization inside pipe_create()Sebastien Marie
rename pipclose() to pipe_destroy(), and return early instead of having the whole code in if-body. ok claudio@ anton@ visa@ mpi@
2019-07-16Make rrw_init/rrw_init_flags take a const name argument matchingJonathan Gray
rw_init/rw_init_flags and rwlock(9). ok visa@ anton@ mpi@
2019-07-15Stop calling resched_proc() after changing the nice(3) value of a process.Martin Pieuchot
Changing the scheduling priority of a process happens rarely, so it isn't strictly necessary to update the current priority of every threads instantly. Moreover resched_proc() isn't well suited to perform this action: it doesn't consider the state of each thread nor move them to another runqueue. ok visa@
2019-07-15revert unintended change that snuck in last commitBob Beck
2019-07-15Make realpath posixly correct by changing the kernel implementationBob Beck
to not succeed on final path components that do not exist. The original implmentation succeeded in these cases. ok bluhm@
2019-07-15Convert struct unpcb malloc(9) to pool_get(9).Alexander Bluhm
OK mpi@ visa@
2019-07-15revisit pipe initialization and buffer managementSebastien Marie
- in dopipe(), get an already zeroed struct (PR_ZERO) instead of manually initialize each member (in pipe_create) - rename pipespace() and pipe_free_kmem() to pipe_buffer_realloc() and pipe_buffer_free(): it is more evident that the functions works on the same thing - in pipe_buffer_free(), return early and move the if-body as function body No functional change intented. ok anton@ visa@ mpi@