aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_syscalls.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert UF_OPENING workaround for CURRENT.Konstantin Belousov2007-05-311-14/+2
| | | | | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith) Notes: svn path=/head/; revision=170152
* Mark the filedescriptor table entries with VOP_OPEN being performed for themKonstantin Belousov2007-05-041-0/+12
| | | | | | | | | | | | | | | as UF_OPENING. Disable closing of that entries. This should fix the crashes caused by devfs_open() (and fifo_open()) dereferencing struct file * by index, while the filedescriptor is closed by parallel thread. Idea by: tegge Reviewed by: tegge (previous version of patch) Tested by: Peter Holm Approved by: re (kensmith) MFC after: 3 weeks Notes: svn path=/head/; revision=169250
* Implement SEEK_DATA and SEEK_HOLE extensions to lseek(2) as found inPawel Jakub Dawidek2007-04-051-0/+7
| | | | | | | | | OpenSolaris. For more information please refer to: http://blogs.sun.com/bonwick/entry/seek_hole_and_seek_data Notes: svn path=/head/; revision=168397
* Replace custom file descriptor array sleep lock constructed using a mutexRobert Watson2007-04-041-25/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and flags with an sxlock. This leads to a significant and measurable performance improvement as a result of access to shared locking for frequent lookup operations, reduced general overhead, and reduced overhead in the event of contention. All of these are imported for threaded applications where simultaneous access to a shared file descriptor array occurs frequently. Kris has reported 2x-4x transaction rate improvements on 8-core MySQL benchmarks; smaller improvements can be expected for many workloads as a result of reduced overhead. - Generally eliminate the distinction between "fast" and regular acquisisition of the filedesc lock; the plan is that they will now all be fast. Change all locking instances to either shared or exclusive locks. - Correct a bug (pointed out by kib) in fdfree() where previously msleep() was called without the mutex held; sx_sleep() is now always called with the sxlock held exclusively. - Universally hold the struct file lock over changes to struct file, rather than the filedesc lock or no lock. Always update the f_ops field last. A further memory barrier is required here in the future (discussed with jhb). - Improve locking and reference management in linux_at(), which fails to properly acquire vnode references before using vnode pointers. Annotate improper use of vn_fullpath(), which will be replaced at a future date. In fcntl(), we conservatively acquire an exclusive lock, even though in some cases a shared lock may be sufficient, which should be revisited. The dropping of the filedesc lock in fdgrowtable() is no longer required as the sxlock can be held over the sleep operation; we should consider removing that (pointed out by attilio). Tested by: kris Discussed with: jhb, kris, attilio, jeff Notes: svn path=/head/; revision=168355
* Don't go to a whole lot of extra work to handle the race where the newJohn Baldwin2007-04-021-25/+2
| | | | | | | | | file descriptor is closed out from under us in kern_open(). This race is already handled and the file will be closed when kern_open() does an fdrop just before returning. Notes: svn path=/head/; revision=168267
* If vn_open() fails during kern_open(), don't fdrop() the new file objectJohn Baldwin2007-03-211-5/+2
| | | | | | | | | | | | | | | | until after the call to fdclose(). This closes an obscure race that could result in the later call to fdclose() actually closing a different file descriptor if another thread close()'s the file descriptor being opened before fdrop() is called, so the fdrop() in kern_open() frees the file object, then the second thread (or a third) creates a new file descriptor which reuses both the same index and the same file pointer thus tricking fdclose() in the first thread into thinking that the original file was still open. MFC after: 1 week Notes: svn path=/head/; revision=167783
* Busy filesystem around call of VFS_QUOTACTL() vfs op.Konstantin Belousov2007-03-141-6/+7
| | | | | | | | | Tested by: Peter Holm Reviewed by: tegge Approved by: re (kensmith) Notes: svn path=/head/; revision=167540
* Further system call comment cleanup:Robert Watson2007-03-051-27/+13
| | | | | | | | | | | | | - Remove also "MP SAFE" after prior "MPSAFE" pass. (suggested by bde) - Remove extra blank lines in some cases. - Add extra blank lines in some cases. - Remove no-op comments consisting solely of the function name, the word "syscall", or the system call name. - Add punctuation. - Re-wrap some comments. Notes: svn path=/head/; revision=167232
* Remove union_dircheckp hook, it is not needed by new unionfs code anymore.Konstantin Belousov2007-02-191-65/+33
| | | | | | | | | | | | As consequence, getdirentries() no longer needs to drop/reacquire directory vnode lock, that would allow it to be reclaimed in between. Reported and tested by: Peter Holm Approved by: rodrigc (unionfs) MFC after: 1 week Notes: svn path=/head/; revision=166824
* Move vnode-to-file-handle translation from vfs_vptofh to vop_vptofh method.Pawel Jakub Dawidek2007-02-151-2/+2
| | | | | | | | | | | | | | | | | | | This way we may support multiple structures in v_data vnode field within one file system without using black magic. Vnode-to-file-handle should be VOP in the first place, but was made VFS operation to keep interface as compatible as possible with SUN's VFS. BTW. Now Solaris also implements vnode-to-file-handle as VOP operation. VFS_VPTOFH() was left for API backward compatibility, but is marked for removal before 8.0-RELEASE. Approved by: mckusick Discussed with: many (on IRC) Tested with: ufs, msdosfs, cd9660, nullfs and zfs Notes: svn path=/head/; revision=166774
* Following a repo-copy of vfs_syscalls.c to vfs_extattr.c, removeRobert Watson2006-12-231-745/+0
| | | | | | | | | | | | | | | non-extattr functions from vfs_extattr.c, and extattr functions from vfs_syscalls.c. Change copyright/license on vfs_extattr.c to my copyright/license on the extended attribute implementation (from extattr.h). Clean up includes a bit. Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=165471
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningRobert Watson2006-11-061-29/+39
| | | | | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net> Notes: svn path=/head/; revision=164033
* The attempt to rename "." with MAC framework compiled in would cause attemptKonstantin Belousov2006-10-261-1/+2
| | | | | | | | | | | | to twice unlock the vnode. Check that ni_vp and ni_dvp are different before doing second unlock. Reviewed by: rwatson Approved by: pjd (mentor) MFC after: 1 week Notes: svn path=/head/; revision=163703
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hRobert Watson2006-10-221-1/+1
| | | | | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA Notes: svn path=/head/; revision=163606
* Add mnt_noasync counter to better handle interleaved calls to nmount(),Tor Egge2006-09-261-4/+6
| | | | | | | | | sync() and sync_fsync() without losing MNT_ASYNC. Add MNTK_ASYNC flag which is set only when MNT_ASYNC is set and mnt_noasync is zero, and check that flag instead of MNT_ASYNC before initiating async io. Notes: svn path=/head/; revision=162649
* Use mount interlock to protect all changes to mnt_flag and mnt_kern_flag.Tor Egge2006-09-261-0/+4
| | | | | | | | This eliminates a race where MNT_UPDATE flag could be lost when nmount() raced against sync(), sync_fsync() or quotactl(). Notes: svn path=/head/; revision=162647
* There is no need to set 'sp' to NULL anymore.Pawel Jakub Dawidek2006-09-201-1/+0
| | | | Notes: svn path=/head/; revision=162459
* Copy stat information from mount structure before it can change identity.Tor Egge2006-09-201-2/+2
| | | | Notes: svn path=/head/; revision=162456
* Declare security and security.bsd sysctl hierarchies in sysctl.h alongRobert Watson2006-09-171-2/+0
| | | | | | | | | | | with other commonly used sysctl name spaces, rather than declaring them all over the place. MFC after: 1 month Sponsored by: nCircle Network Security, Inc. Notes: svn path=/head/; revision=162383
* Fix some bugs in the previous revision (1.419). Don't perform extraJohn Baldwin2006-08-021-9/+4
| | | | | | | | | | | | | | | vfs_rel() on the mountpoint if the MAC checks fail in kern_statfs() and kern_fstatfs(). Similarly, don't perform an extra vfs_rel() if we get a doomed vnode in kern_fstatfs(), and handle the case of mp being NULL (for some doomed vnodes) by conditionalizing the vfs_rel() in kern_fstatfs() on mp != NULL. CID: 1517 Found by: Coverity Prevent (tm) (kern_fstatfs()) Pointy hat to: jhb Notes: svn path=/head/; revision=160924
* Hold the reference on the mountpoint slightly longer in kern_statfs() andJohn Baldwin2006-07-271-2/+2
| | | | | | | | | | | kern_fstatfs() so that it is still held when prison_enforce_statfs() is called (since that function likes to poke and prod at the mountpoint structure). MFC after: 3 days Notes: svn path=/head/; revision=160767
* Call change_dir() instead of duplicating the code in fchdir().John Baldwin2006-07-191-8/+1
| | | | Notes: svn path=/head/; revision=160507
* - Add conditional VFS Giant locking to getdents_common() (linux ABIs),John Baldwin2006-07-111-2/+11
| | | | | | | | | | | ibcs2_getdents(), ibcs2_read(), ogetdirentries(), svr4_sys_getdents(), and svr4_sys_getdents64() similar to that in getdirentries(). - Mark ibcs2_getdents(), ibcs2_read(), linux_getdents(), linux_getdents64(), linux_readdir(), ogetdirentries(), svr4_sys_getdents(), and svr4_sys_getdents64() MPSAFE. Notes: svn path=/head/; revision=160276
* Audit the remaining parameters to the extattr system calls. GenerateWayne Salamon2006-07-061-0/+28
| | | | | | | | | | the audit records for those calls. Obtained from: TrustedBSD Project Approved by: rwatson (mentor) Notes: svn path=/head/; revision=160136
* Audit command, uid arguments for quotactl().Robert Watson2006-06-051-0/+4
| | | | | | | | | | | Audit the mode argument to mkfifo(). Audit the target path passed to symlink(). Submitted by: wsalamon Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=159260
* - Release the references acquired by VOP_GETWRITEMOUNT and vfs_getvfs().Jeff Roberson2006-03-311-13/+12
| | | | | | | | | Discussed with: tegge Tested by: kris Sponsored by: Isilon Systems, Inc. Notes: svn path=/head/; revision=157325
* Change vn_open() to honor the MPSAFE flag in the passed in nameidata objectJohn Baldwin2006-03-281-1/+1
| | | | | | | | | | | and use that instead of testing fdidx against -1 to determine if it should release Giant if Giant was locked due to the requested file residing on a non-MPSAFE VFS. Discussed with: jeff Notes: svn path=/head/; revision=157230
* - Remove explicit calls to lock and unlock Giant and replace them withJeff Roberson2006-03-211-83/+66
| | | | | | | | | | | VFS_LOCK_GIANT/VFS_UNLOCK_GIANT calls. This completely removes Giant acquisition in the syscall path for ffs. Bug fix to kern_fhstatfs from: Todd Miller <Todd.Miller@sparta.com> Sponsored by: Isilon Systems, Inc. Notes: svn path=/head/; revision=156977
* use strlcpy in cvtstatfs and copy_statfs instead of bcopy to ensurePaul Saab2006-03-041-4/+4
| | | | | | | | | the copied strings are properly terminated. bzero the statfs32 struct in copy_statfs. Notes: svn path=/head/; revision=156266
* Don't truncate f_mntfromname & f_mntonname to 16 characters whenPaul Saab2006-03-031-2/+2
| | | | | | | | translating statfs into ostatfs. This allows 4.x binaries making statfs calls to work on 6.x. Notes: svn path=/head/; revision=156237
* - Use vfs_ref/rel to protect a mountpoint from going away while VFS_STATFSJeff Roberson2006-02-231-10/+29
| | | | | | | | | | is being called. Be sure to grab the ref before we unlock the vnode to prevent the mount from disappearing. Tested by: kris Notes: svn path=/head/; revision=155939
* Add pathname and/or vnode argument auditing for the following system calls:Wayne Salamon2006-02-221-50/+129
| | | | | | | | | | | | | | | | | | | | | quotactl, statfs, fstatfs, fchdir, chdir, chroot, open, mknod, mkfifo, link, symlink, undelete, unlink, access, eaccess, stat, lstat, pathconf, readlink, chflags, lchflags, fchflags, chmod, lchmod, fchmod, chown, lchown, fchown, utimes, lutimes, futimes, truncate, ftruncate, fsync, rename, mkdir, rmdir, getdirentries, revoke, lgetfh, getfh, extattrctl, extattr_set_file, extattr_set_link, extattr_get_file, extattr_get_link, extattr_delete_file, extattr_delete_link, extattr_list_file, extattr_list_link. In many cases the pathname and vnode auditing is done within namei lookup instead of directly in the system call. Audit the remaining arguments to these system calls: fstatfs, fchdir, open, mknod, chflags, lchflags, fchflags, chmod, lchmod, fchmod, chown, lchown, fchown, futimes, ftruncate, fsync, mkdir, getdirentries. Notes: svn path=/head/; revision=155914
* - Revert r1.406 until a solution can be found that doesn't break nfs. TheJeff Roberson2006-02-221-28/+21
| | | | | | | | | | | statfs handler in nfs will lock vnodes which may lead to deadlock or recursion. Found by: kris Pointy hat to: me Notes: svn path=/head/; revision=155905
* - Hold the vnode used in the statfs related functions until we're done withJeff Roberson2006-02-221-21/+28
| | | | | | | | | | | the VFS_STATFS call to prevent the mount from disappearing while we're stating. - Convert these routines to use MPSAFE namei semantics. MFC After: 1 week Notes: svn path=/head/; revision=155900
* Add a kern_eaccess() function and use it to implement xenix_eaccess()John Baldwin2006-02-061-3/+9
| | | | | | | | | rather than kern_access(). Suggested by: rwatson Notes: svn path=/head/; revision=155401
* - Don't check v_mount for NULL to determine if a vnode has been recycled.Jeff Roberson2006-02-061-2/+4
| | | | | | | | | | Use the more appropriate VI_DOOMED flag instead. Sponsored by: Isilon Systems, Inc. MFC After: 1 week Notes: svn path=/head/; revision=155385
* In fchdir(), Giant must be separately acquired and dropped if the oldRobert Watson2006-02-031-0/+2
| | | | | | | | | | | vnode is from a file system that is not MPSAFE, as vrele() expects Giant to be held when it is called on a non-MPSAFE vnode. Spotted by: kris Tested by: glebius Notes: svn path=/head/; revision=155257
* - chroot and chdir need to lock giant as appropriate for the outgoing vpJeff Roberson2006-02-011-0/+5
| | | | | | | | | | as well as the new vp. Sponsored by: Isilon Systems, Inc. MFC After: 3 days Notes: svn path=/head/; revision=155167
* - Reorder calls to vrele() after calls to vput() when the vrele is aJeff Roberson2006-02-011-11/+11
| | | | | | | | | | | | | | | directory. vrele() may lock the passed vnode, which in these cases would give an invalid lock order of child -> parent. These situations are deadlock prone although do not typically deadlock because the vrele is typically not releasing the last reference to the vnode. Users of vrele must consider it as a call to vn_lock() and order it appropriately. MFC After: 1 week Sponsored by: Isilon Systems, Inc. Tested by: kkenn Notes: svn path=/head/; revision=155160
* Tweak previous vfs_lookup.c commit to return an EINVAL error fromDon Lewis2006-01-221-1/+1
| | | | | | | | | | | | | | lookup() instead of EPERM when a DELETE or RENAME operation is attempted on "..". In kern_unlink(), remap EINVAL errors returned from namei() to EPERM to match existing (and POSIX required) behaviour. Discussed with: bde MFC after: 3 days Notes: svn path=/head/; revision=154690
* Fix style bug.Diomidis Spinellis2006-01-041-2/+2
| | | | | | | Prompted by: bde Notes: svn path=/head/; revision=154011
* Replace tv_usec normalization with the return of EINVAL.Diomidis Spinellis2006-01-041-24/+6
| | | | | | | | | | This addresses two objections to the previous behavior, and unbreaks the alpha tinderbox build. TODO: update the utimes(2) man page. Notes: svn path=/head/; revision=154009
* Normalize the tv_usec part of the utimes(2) arguments to ensureDiomidis Spinellis2006-01-031-3/+24
| | | | | | | | | | | | | | that a file's atime and mtime are only set to correct fractional second values (0-999999000ns with the current interface). Prior to this change users could create files with values outside that range. Moreover, on 32-bit machines tv_usec offsets larger than 4.3s would result in an unnormalized AND wrong timestamp value, due to overflow. MFC after: 1 week Notes: svn path=/head/; revision=154003
* Reduce Giant scope a bit, as fdrop() is believed to be MPSAFE.Pawel Jakub Dawidek2005-12-201-9/+7
| | | | | | | | | | | The purpose of this change is consistency (not performance improvement:)), as it was hard to tell if fdrop() is MPSAFE or not when I saw it sometimes under the Giant and sometimes without it. Glanced at by: ssouhlal, kan Notes: svn path=/head/; revision=153547
* Implement new world order in VFS locking for extended attributes. This willChristian S.J. Peron2005-09-241-29/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove the unconditional acquisition of Giant for extended attribute related operations. If the file system is set as being MP safe and debug.mpsafevfs is 1, do not pickup Giant. Mark the following system calls as being MP safe so we no longer pickup Giant in the system call handler: o extattrctl o extattr_set_file o extattr_get_file o extattr_delete_file o extattr_set_fd o extattr_get_fd o extattr_delete_fd o extattr_set_link o extattr_get_link o extattr_delete_link o extattr_list_file o extattr_list_link o extattr_list_fd -Pass MPSAFE flags to namei(9) lookup and introduce vfslocked variable which will keep track of any Giant acquisitions. -Wrap any fd operations which manipulate vnodes in VFS_{UN}LOCK_GIANT -Drop VFS_ASSERT_GIANT into function which operate on vnodes to ensure that we are sufficiently protected. I've tested these changes with various TrustedBSD MAC policies which use extended attribute a lot on SMP and UP systems (thanks to Scott Long for making some SMP hardware available to me for testing). Discussed with: jeff Requested by: jhb, rwatson Notes: svn path=/head/; revision=150531
* Improve the MP safeness associated with the creation of symbolicChristian S.J. Peron2005-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | links and the execution of ELF binaries. Two problems were found: 1) The link path wasn't tagged as being MP safe and thus was not properly protected. 2) The ELF interpreter vnode wasnt being locked in namei(9) and thus was insufficiently protected. This commit makes the following changes: -Sets the MPSAFE flag in NDINIT for symbolic link paths -Sets the MPSAFE flag in NDINIT and introduce a vfslocked variable which will be used to instruct VFS_UNLOCK_GIANT to unlock Giant if it has been picked up. -Drop in an assertion into vfs_lookup which ensures that if the MPSAFE flag is NOT set, that we have picked up giant. If not panic (if WITNESS compiled into the kernel). This should help us find conditions where vnode operations are in-sufficiently protected. This is a RELENG_6 candidate. Discussed with: jeff MFC after: 4 days Notes: svn path=/head/; revision=150164
* In case of mac_check_vnode_rename_from() or vn_start_write() failure,Pawel Jakub Dawidek2005-09-011-1/+2
| | | | | | | | | | vn_finished_write() should not be called. Reviewed by: ssouhlal MFC after: 3 days Notes: svn path=/head/; revision=149697
* Actually only protect mount-point if security.jail.enforce_statfs is set to 2.Pawel Jakub Dawidek2005-06-231-10/+0
| | | | | | | | | | If we don't return statistics about requested file systems, system tools may not work correctly or at all. Approved by: re (scottl) Notes: svn path=/head/; revision=147559
* - Remove vnode lock asserts at the end of vfs syscalls. These asserts wereJeff Roberson2005-06-141-18/+0
| | | | | | | | | | | | | | | | used to ensure that we weren't exiting the syscall with a lock still held. This wasn't safe, however, because we'd already executed a vput() and on a loaded system the vnode may have been free'd by the time we assert. This functionality is also handled by the td_locks assert in userret, which doesn't tell you what the syscall was, but will at least panic before you deadlock. Sponsored by: Isilon Systems, Inc. Discovred by: Peter Holm Approved by: re (blanket vfs) Notes: svn path=/head/; revision=147352
* Do not allocate memory while holding a mutex.Pawel Jakub Dawidek2005-06-121-2/+4
| | | | | | | | | | | | I introduce a very small race here (some file system can be mounted or unmounted between 'count' calculation and file systems list creation), but it is harmless. Found by: FreeBSD Kernel Stress Test Suite: http://www.holm.cc/stress/ Reported by: Peter Holm <peter@holm.cc> Notes: svn path=/head/; revision=147309