summaryrefslogtreecommitdiff
path: root/sys/kern/vfs_syscalls.c
AgeCommit message (Collapse)Author
2024-11-05remove VATTR_NULL() define, directly call vattr_null()Jonathan Gray
There used to be a predefined null vattr for !DIAGNOSTIC but that was removed in vnode.h rev 1.84 in 2007. ok semarie@ miod@
2024-10-31Unlock fs_sysctl(). It is the only `suid_clear' variable - atomicallyVitaliy Makkoveev
accessed integer. ok bluhm
2024-09-01Regarding previous commit, X_OK on unveil-permitted directories doesTheo de Raadt
not map nicely to UNVEIL_EXEC. But we don't know before calling namei() if the path is a directory. Oh well, stick to UNVEIL_READ for that case, it is going to be good enough for the typical case. Worked out with jeremy after chrome/firefox Downloads directory issue.
2024-08-31jeremy observed that access() on unveiled space was returning errorsTheo de Raadt
for valid requests. This is because the nd.ni_unveil to namei() was always UNVEIL_READ, regardless of the request amode. Building a correct ni_unveil passes a new regression test, producing expected results. ok beck jeremy
2024-07-10Sweep up another softdep crumb.Kenneth R Westerback
Remove #if notyet/#endif chunk that references the never-defined STATFS_SOFTUPD. ok jsg@
2024-05-18Add pathconfat(2): pathconf(2) but with at-fd and flags arguments,Philip Guenther
the latter supporting the ability to get timestamp resolution of symlinks. ok deraadt@ millert@
2024-03-25Move the "no (hard) linking directories" and "no cross-mount links"Philip Guenther
checks from all the filesystems that support hardlinks at all into the VFS layer. Simplify, EPERM description in link(2). ok miod@ mpi@
2024-02-03Remove Softdep.Bob Beck
Softdep has been a no-op for some time now, this removes it to get it out of the way. Flensing mostly done in Talinn, with some help from krw@ ok deraadt@
2023-07-05Make softdep mounts a no-opBob Beck
Softdep is a significant impediment to progressing in the vfs layer so we plan to get it out of the way. It is too clever for us to continue maintaining as it is. ok kettenis@ kn@ tobhe@ and most of the g2k23 room except bluhm@
2023-02-11non-padded 64-bit system calls arrived 2021/12/23, over a year ago.Theo de Raadt
time to delete the backwards compat padded functions in the kernel.
2022-08-14remove unneeded includes in sys/kernJonathan Gray
ok mpi@ miod@
2022-08-01some ports bootstraps, and go internals, need a bit more time to adaptTheo de Raadt
to the padded syscalls going away.
2022-07-20the _pad_ system calls from 2021/12/23 can go awayTheo de Raadt
ok guenther
2022-05-23Respect RLIMIT_FSIZE when extending a file via truncat(2)/ftruncate(2).Todd C. Miller
This refactors the commin parts of sys_truncate() and sys_ftruncate() into dotruncate(). If the new size of the file is larger than the RLIMIT_FSIZE limit _and_ the file is being extended, not truncated, return EFBIG. Adapted from a diff by Piotr Durlej. With help from and OK by deraadt@ guenther@.
2022-02-17Writes to the ps_flags field of struct process should be atomic.Rob Pierce
Ok deraadt@ guenther@
2022-02-15Reintroduce ps state flag 'c' indicating chrooted process (via PS_BITS).Rob Pierce
Ok deraat@
2021-12-23Roll the syscalls that have an off_t argument to remove the explicit padding.Philip Guenther
Switch libc and ld.so to the generic stubs for these calls. WARNING: reboot to updated kernel before installing libc or ld.so! Time for a story... When gcc (back in 1.x days) first implemented long long, it didn't (always) pass 64bit arguments in 'aligned' registers/stack slots, with the result that argument offsets didn't match structure offsets. This affected the nine system calls that pass off_t arguments: ftruncate lseek mmap mquery pread preadv pwrite pwritev truncate To avoid having to do custom ASM wrappers for those, BSD put an explicit pad argument in so that the off_t argument would always start on a even slot and thus be naturally aligned. Thus those odd wrappers in lib/libc/sys/ that use __syscall() and pass an extra '0' argument. The ABIs for different CPUs eventually settled how things should be passed on each and gcc 2.x followed them. The only arch now where it helps is landisk, which needs to skip the last argument register if it would be the first half of a 64bit argument. So: add new syscalls without the pad argument and on landisk do that skipping directly in the syscall handler in the kernel. Keep compat support for the existing syscalls long enough for the transition. ok deraadt@
2021-10-02remove dead variable from sys___realpath()Sebastien Marie
it is a leftover from LOCKPARENT removal in NDINIT() (in rev 1.337) ok mpi@
2021-07-16Remove the unveil current directory pointer from struct process. InsteadClaudio Jeker
pass in the vnode to unveil_start_relative() like it is done for *at() syscalls. This fixes an issue with fchdir() that actually did not correctly reset this pointer when changing the working directory. OK beck@
2021-07-08Remove the code to store intermediary vnodes in the unveil list.Claudio Jeker
These traversed vnodes are a leftover from early times where realpath(3) was still all done in userland. OK semarie@
2021-07-03__realpath: removes LOCKLEAF from NDINIT.Sebastien Marie
The code doesn't doesn't need it: the returned vnode is released immediately. The string path is built from the namei() call using REALPATH, during directories traversal. Without LOCKLEAF, calling vrele() only is enough if namei() found a file, instead of calling VOP_UNLOCK() + vrele(). ok claudio@ mpi@
2021-02-11In the various open functions reduce the fdplock() to only span over theClaudio Jeker
function which need the lock (falloc, fdinsert, fdremove). In most cases it is not correct to hold the lock while calling VFS functions or e.g. closef since those aquire or release long lived VFS locks. OK visa@ mvs@
2020-10-02expose timeval/timespec from system calls into ktrace, before determiningTheo de Raadt
if they are out of range, making it easier to isolate reason for EINVAL ok cheloha
2020-08-23Remove unused debug_syncprt, improve debug sysctl handlingkn
"syncprt" is unused since kern/vfs_syscalls.c r1.147 from 2008. Adding new debug sysctls is a bit opaque and looking at kern/kern_sysctl.c the only visible difference between used and stub ctldebug structs in the debugvars[] array is their extern keyword, indicating that it is defined elsewhere. sys/sysctl.h declares all debugN members as extern upfront, but these declarations are not needed. Remove the unused debug sysctl, rename the only remaining one to something meaningful and remove forward declarations from /sys/sysctl.h; this way, adding new debug sysctls is a matter of adding extern and coming up with a name, which is nicer to read on its own and better to grep for. OK mpi
2020-08-22Move sysctl(2) CTL_DEBUG from DEBUG to new DEBUG_SYSCTLkn
Adding "debug.my-knob" sysctls is really helpful to select different code paths and/or log on demand during runtime without recompile, but as this code is under DEBUG, lots of other noise comes with it which is often undesired, at least when looking at specific subsystems only. Adding globals to the kernel and breaking into DDB to change them helps, but that does not work over SSH, hence the need for debug sysctls. Introduces DEBUG_SYSCTL to make use of the "debug" MIB without the rest of DEBUG; it's DEBUG_SYSCTL and not SYSCTL_DEBUG because it's not a general option for all of sysctl(2). OK gnezdo
2020-06-24kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha
time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
2020-03-19Move unveil data structures away from the proc.h header into theanton
implementation file. Pushing the assignment of ps_uvpcwd down to unveil_add() is required but it doesn't introduce any functional change. ok mpi@ semarie@
2020-03-13In order to unlock flock(2), make writes to the f_iflags field of structanton
file atomic. This also gets rid of the last kernel lock protected field in the scope of struct file. ok mpi@ visa@
2020-01-30Acquire fdplock when updating fd_cmask. This moves the codeVisa Hankala
toward MP-safety. OK mpi@, anton@
2020-01-26add a new __tmpfd system call that creates a new unnamed file in /tmp.Ted Unangst
intended for shm/fd passing, but for programs that may otherwise like filesystem access. ok beck deraadt kettenis
2020-01-18Clear mount operation argument flags from mnt_flag after mount.Visa Hankala
OK bluhm@
2020-01-10Convert the vnode list at the mount point into a tailq. DuringAlexander Bluhm
unmount this list is traversed and the dirty vnodes are flushed to disk. Forced unmount expects that the list is empty after flushing, otherwise the kernel panics with "dangling vnode". As the write to disk can sleep, new vnodes may be inserted. If softdep is enabled, resolving the dependencies creates new dirty vnodes and inserts them to the list. To fix the panic, let insmntque() insert new vnodes at the tail of the list. Then vflush() will still catch them while traversing the list in forward direction. OK tedu@ millert@ visa@
2019-11-29Eliminate the sketchy use of ps_mainproc here by making unveil_add_vnode()Philip Guenther
take a struct proc* instead of a struct process*, and vice versa making unveil_lookup() take a process* instead of a proc*. ok beck@
2019-11-26Don't use LOCKPARENT on namei calls for realpath(). We don'tBob Beck
require this anymore since we now behave like posix. Fixes a problem where a symlink to / would return ENOTDIR because the parent could not be locked - noticed by Raimo Niskanen <raimo@erlang.org> ok guenther@ deraadt@
2019-10-06Fix vn_open to require an op of 0, and 0 or KERNELPATH only as flags.Bob Beck
sweep tree to correct NDIINT op and flags ahead of time. document the requirement. This allows KERNELPATH to be used to bypass unveil for crash dumps with nosuidcoredump=2 or 3 ok visa@ deraadt@ florian@
2019-08-31Make readlink require UNVEIL_READ instead of UNVEIL_INSPECT onlyBob Beck
since realpath() is now a system call ok deraadt@
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-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-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-02Move prototypes of unveil(2) functions which are used in separate CAlexander Bluhm
files into the common namei.h header. OK deraadt@
2019-07-25vinvalbuf(9): tlseep -> tsleep_nsec(9); ok millert@cheloha
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-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-12Revert anton@ changes about read/write unlockingsolene
https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2 ok anton@