summaryrefslogtreecommitdiffstats
path: root/sys/dev/diskmap.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Resolve some minor nits in diskmapioctl():anton2019-08-061-7/+9
| | | | | | | | | * Favor ENOTTY for unknown ioctl commands * Return the actual error from copyinstr and copyoutstr, removes the need to initialize the local error variable * Do not use parens around return expressions consistently ok visa@
* Favor vn_close() in the error path of diskmapioctl() since side-effectsanton2019-08-051-4/+2
| | | | | | | | | | | caused by calling vn_open() with write permissions must be reverted. Otherwise, the vfs subsystem could panic while releasing the last vnode reference if the writecount is still positive. ok visa@ Reported-by: syzbot+4724df09d9ab0fdca28a@syzkaller.appspotmail.com Reported-by: syzbot+a430606fd528645559db@syzkaller.appspotmail.com
* Make fnew() return a new file with only one reference. This makesvisa2018-08-201-2/+1
| | | | | | the API more logical. OK kettenis@ mpi@
* Decouple unveil from the pledge flags, by adding dedicated unveil flagsbeck2018-08-051-1/+2
| | | | | | | | to the namei args. This fixes a bug where chmod would be allowed when with only READ. This also allows some further cleanup of some awkward things like PLEDGE_STAT that will follow Lots of assistence from semarie@ - thanks! ok semarie@
* Do not try to unlock the fdplock() in an error path if it isn't held.mpi2018-07-041-3/+3
| | | | Found the hardway by mlarkin@, ok bluhm@
* Instead of overwriting `f_data' replace the 'struct file' with a new one.mpi2018-07-031-36/+45
| | | | | | | | | With this change `f_data' is effectively immutable. While here prevent a lock ordering issue by not unterleaving the vnode's lock and the fdplock(). Tested by bluhm@, ok kettenis@, visa@, jsing@
* Mark `f_ops' as immutable.mpi2018-05-091-5/+7
| | | | | | | | | | The only place where it was modified after initialization is a corner case where the vnode of an open file is substitued by another one. Sine the type of the file doesn't change, there's no need to overwrite `f_ops'. While here proctect file counters with `f_mtx'. ok bluhm@, visa@
* Remove proc from the parameters of vn_lock(). The parameter isvisa2018-05-021-2/+2
| | | | | | unnecessary because curproc always does the locking. OK mpi@
* Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysvisa2018-04-281-2/+2
| | | | | | | curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
* Stop assuming <sys/file.h> will pull in fcntl.h when _KERNEL is defined.guenther2018-01-021-1/+2
| | | | ok millert@ sthen@
* If you use sys/param.h, you don't need sys/types.hderaadt2017-09-081-2/+1
|
* Fix some gibbering horrors due to uninitialized struct nameidata'sbeck2016-04-291-5/+3
| | | | | | | | | | | | | | | 1) turn NDINITAT into a function and make the macros point to it with the later goal of getting rid of them. 2) Sweep the kernel for places where people make a struct nameidata manually on the stack and fill in what they hope are the required fields and count on prayer and clean living to always get them right. Instead use NDINIT everywhere. NFS was especially bad for this and there have likely been things lurking there for a while. 3) Add a couple of strategic KASSERT's to catch future offenders. ok krw@ sthen@ deraadt@
* Remove the unused flags argument from VOP_UNLOCK().natano2016-03-191-2/+2
| | | | | | torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
* Add pledge "disklabel", which allows sysctl kern.rawpartition, aderaadt2015-11-201-1/+3
| | | | | | | | | few disklabel ioctls, and the DIOCMAP ioctl against /dev/diskmap used to translate duid numbers into partitions. This will allow pledging of at least 12 disk/filesystem aware programs; due to the negative impact that diff will wait a bit so everyone has a chance to update their kernels. ok semarie
* size for free(); ok krwderaadt2015-08-301-3/+3
|
* Pass a thread pointer instead of its file descriptor table to getvnode(9).mpi2015-05-071-4/+4
| | | | Input and ok millert@
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* primary change: move uvm_vnode out of vnode, keeping only a pointer.tedu2014-12-161-1/+2
| | | | | | objective: vnode.h doesn't include uvm_extern.h anymore. followup changes: include uvm_extern.h or lock.h where necessary. ok and help from deraadt
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-3/+3
| | | | after discussions with beck deraadt kettenis.
* Add struct proc * argument to FRELE() and FILE_SET_MATURE() inguenther2012-04-221-3/+3
| | | | | | anticipation of further changes to closef(). No binary change. ok krw@ miod@ deraadt@
* Add new syscall entries to support the openat(2) family of functionsmatthew2011-07-071-1/+2
| | | | | | | | | | | | | | | | added in POSIX Issue 7: openat(), mknodat(), mkfifoat(), linkat(), symlinkat(), unlinkat(), faccessat(), fstatat(), readlinkat(), fchmodat(), fchownat(), utimensat(), renameat(), and mkdirat(). This diff mostly just refactors the existing sys_foo() logic into a common dofooat() function that can then be called by both sys_foo() and sys_fooat(). Some of the new system calls support new flags to control their behavior, and proper support for these will be added in subsequent diffs. Incorporating suggestions from thib@, guenther@, and tedu@. ok tedu@, thib@, deraadt@, guenther@
* Use getvnode() instead of implementing our own file descriptor handlingjsing2011-07-021-11/+7
| | | | | | | | | code. This gets us some additional validation and correct reference counting. Issue spotted by matthew@ ok thib@
* Do not use NULL in integer comparisons. No functional change.miod2011-04-071-2/+2
| | | | ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@
* Only init the nameidata parts that are strictly needed insteadthib2011-01-121-4/+4
| | | | | | | | | | | | of using NDINIT as vn_open overwrites and sets things up directly it self. the NDINIT usage here was actually wrong and would cause leaks if vn_open would totally honor the nameidata it gets passed, also there is one less place that triggers on my nameidata flag greps... ok jsing@
* plug a memleak, free the devname when we succeed withthib2010-06-141-3/+3
| | | | | | the ioctl. also remove an uneeded if (devname) check. ok jsing@
* Introduce a diskmap pseudo device which allows userland to open a diskjsing2010-06-081-0/+152
specified via its disklabel UID. The mapping from the disklabel UID to the real disk and the opening of the resulting device is performed atomically using a single ioctl. ok krw@ deraadt@