summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_lock.c
Commit message (Collapse)AuthorAgeFilesLines
* For reasons unknown, the nfs locking code used a fifo to send requests tophk2004-12-061-58/+156
| | | | | | | | | | | | | userland and a dedicated system call to get replies. The vnode-bypass of fifos broke this into a panic. Ditch all the magic and create a device /dev/nfslock instead, and use that for both directions apart from the shorter path, this is also faster because the device driver runs Giant free using the vnode bypass. Noticed by: marcel
* University of Michigan's Citi NFSv4 kernel client code.alfred2003-11-141-0/+2
| | | | Submitted by: Jim Rees <rees@umich.edu>
* Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.phk2003-07-271-1/+1
|
* Add the comment I meant to add about not passing in PCATCH to therwatson2003-06-111-0/+8
| | | | tsleep(). Note the XXX.
* rpc.lockd stability workaround: remove PCATCH from the tsleep() inrwatson2003-05-301-1/+1
| | | | | | | | | | | | | | | | | nfs_lock.c. Right now, if we permit a signal to interrupt the sleep, we will slip the lock and no process on that client, the server, or any other client will be able to acquire the lock. This can happen, for example, if a user hits Ctrl-C or Ctrl-T while a process is waiting for the lock. By removing PCATCH, we prevent that from happening, at the cost of not permitting a user-requested lock abort: also nasty. However, a user interface bug might be preferable to a serious semantic bug, so we go with that for now. We need to teach the rpc.lockd/kernel protocol how to abort lock requests, and rpc.lockd how to handle aborted lock requests; patches for the kernel bit are floating around, but no rpc.lockd bit yet. Approved by: re (scottl)
* Instead of recording the Unix time in a process when it starts, record thedes2003-05-011-0/+1
| | | | | | | uptime. Where necessary, convert it back to Unix time by adding boottime to it. This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process.
* Deprecate machine/limits.h in favor of new sys/limits.h.kan2003-04-291-2/+1
| | | | | | | Change all in-tree consumers to include <sys/limits.h> Discussed on: standards@ Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>
* Add O_NONBLOCK to the vn_open_cred() flags for NFS client locking whenrwatson2003-03-261-3/+13
| | | | | | | | | | | | | | | opening the POSIX fifo; convert ENXIO error returns to EOPNOTSUPP. This improves handling of the case where the /var/run/lock fifo exists but there is no listener: we immediately return EOPNOTSUPP rather than blocking until a listener turns up. This could occur during a diskless boot before rpc.lockd is loaded, or if the lock file persists across a reboot following the disabling of rpc.lockd. This may have suddenly started to occur due to fifo blocking fixes--previously it looks like attempts to read on a fifo with no listener would time out due to insufficient resources. Reviewed by: alfred
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* reapply 1.26 through 1.28.alfred2002-11-201-18/+6
| | | | Approved by: re
* forgot about 5.x freeze, backout 1.26 through 1.28 pending re@ appoval.alfred2002-11-201-6/+18
|
* remove useless casts, unused macros and cleanup a line wrap.alfred2002-11-201-9/+3
|
* comment and untwist error return logicalfred2002-11-201-4/+3
|
* Remove an outdated comment complaining about exporting struct ucredalfred2002-11-201-5/+0
| | | | to userspace, I fixed it a while ago.
* Remove a case of exposing 'struct ucred' to userspace. Use a struct xucredalfred2002-08-151-1/+1
| | | | | | for LOCKD_MSG instead. Requested by: rwatson
* In order to better support flexible and extensible access control,rwatson2002-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make a series of modifications to the credential arguments relating to file read and write operations to cliarfy which credential is used for what: - Change fo_read() and fo_write() to accept "active_cred" instead of "cred", and change the semantics of consumers of fo_read() and fo_write() to pass the active credential of the thread requesting an operation rather than the cached file cred. The cached file cred is still available in fo_read() and fo_write() consumers via fp->f_cred. These changes largely in sys_generic.c. For each implementation of fo_read() and fo_write(), update cred usage to reflect this change and maintain current semantics: - badfo_readwrite() unchanged - kqueue_read/write() unchanged pipe_read/write() now authorize MAC using active_cred rather than td->td_ucred - soo_read/write() unchanged - vn_read/write() now authorize MAC using active_cred but VOP_READ/WRITE() with fp->f_cred Modify vn_rdwr() to accept two credential arguments instead of a single credential: active_cred and file_cred. Use active_cred for MAC authorization, and select a credential for use in VOP_READ/WRITE() based on whether file_cred is NULL or not. If file_cred is provided, authorize the VOP using that cred, otherwise the active credential, matching current semantics. Modify current vn_rdwr() consumers to pass a file_cred if used in the context of a struct file, and to always pass active_cred. When vn_rdwr() is used without a file_cred, pass NOCRED. These changes should maintain current semantics for read/write, but avoid a redundant passing of fp->f_cred, as well as making it more clear what the origin of each credential is in file descriptor read/write operations. Follow-up commits will make similar changes to other file descriptor operations, and modify the MAC framework to pass both credentials to MAC policy modules so they can implement either semantic for revocation. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Pass IO_NOMACCHECK to vn_rdwr() in the following checks to preventrwatson2002-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | enforcement of MAC policy on the read or write operations: - In ext2fs, don't enforce MAC on loop-back reads and writes supporting directory read operations in lookup(), directory modifications in rename(), directory write operations in mkdir(), symlink write operations in symlink(). - In the NFS client locking code, perform vn_rdwr() on the NFS locking socket without enforcing MAC, since the write is done on behalf of the kernel NFS implementation rather than the user process. - In UFS, don't enforce MAC on loop-back reads and writes supporting directory read operations in lookup(), and symlink write operations in symlink(). Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Add IPv6 support.alfred2002-07-151-3/+2
| | | | Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-1/+1
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Use thread0.td_ucred instead of proc0.p_ucred. This change is cosmeticjhb2002-02-271-4/+4
| | | | | | and isn't strictly required. However, it lowers the number of false positives found when grep'ing the kernel sources for p_ucred to ensure proper locking.
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-2/+2
| | | | reference.
* o Modify nfslockdans() to accept a thread reference instead of a procrwatson2001-11-141-12/+14
| | | | | | | | | | | reference: with td->td_ucred, it will be desirable to authorize based on td->td_ucred, rather than p->p_ucred. o Since the same variable 'p' was later used with pfind() on the target process for the wakeup, introduce a new local variable 'targetp' to use instead. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* turn vn_open() into a wrapper around vn_open_cred() which allowsalfred2001-11-111-15/+1
| | | | | | | | one to perform a vn_open using temporary/other/fake credentials. Modify the nfs client side locking code to use vn_open_cred() passing proc0's ucred instead of the old way which was to temporary raise privs while running vn_open(). This should close the race hopefully.
* o Note an additional potential problem here: LOCKD_MSG directly exportsrwatson2001-10-241-0/+4
| | | | | | struct ucred to userland. In 5.0-CURRENT, it is desirable to instead export struct xucred, as ucred contains mutexes, pointers, and other kernel evil. I'll add it to my work queue.
* o Add two comments identifying problems with the current nfs_lock.crwatson2001-10-231-0/+7
| | | | | | | | | implementation, so that the information doesn't get lost. (1) /var/run/lock is looked up relative to the current thread's root directory, but it's not clear that's desirable. (2) A race condition associated with live credential modification on a shared credential is present when privilege is granted for the purposes of talking to /var/run/lock.
* Cleanup and split of nfs client and server code.peter2001-09-181-22/+15
| | | | This builds on the top of several repo-copies.
* KSE Milestone 2julian2001-09-121-7/+10
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Stupid error from my side in prev. commit: || -> &&ache2001-08-231-1/+1
|
* Implement l_len<0 per POSIX check.ache2001-08-231-4/+6
| | | | Check for valid l_whence too.
* Even better move: suppose that server is able to handle SEEK_END,ache2001-08-231-6/+6
| | | | | so check arguments for all but not SEEK_END case, leaving SEEK_END handling for server
* Apparently SEEK_END locking not supported by NFS. Previous variantache2001-08-231-1/+5
| | | | returns EINVAL in that case, change it to EOPNOTSUPP.
* Move <machine/*> after <sys/*>ache2001-08-231-1/+2
| | | | Pointed by: bde
* adv. lock:ache2001-08-231-5/+5
| | | | | detect off_t overflow _before_ it occurse and return EOVERFLOW instead of EINVAL
* Unlock the process returned from pfind() if it does not return NULL.jake2001-06-011-1/+4
| | | | | | | | This fixes a witness lock violation for nfssvc returning with locks held. Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr> PR: kern/27776
* o Merge contents of struct pcred into struct ucred. Specifically, add therwatson2001-05-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | real uid, saved uid, real gid, and saved gid to ucred, as well as the pcred->pc_uidinfo, which was associated with the real uid, only rename it to cr_ruidinfo so as not to conflict with cr_uidinfo, which corresponds to the effective uid. o Remove p_cred from struct proc; add p_ucred to struct proc, replacing original macro that pointed. p->p_ucred to p->p_cred->pc_ucred. o Universally update code so that it makes use of ucred instead of pcred, p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo, cr_{r,sv}{u,g}id instead of p_*, etc. o Remove pcred0 and its initialization from init_main.c; initialize cr_ruidinfo there. o Restruction many credential modification chunks to always crdup while we figure out locking and optimizations; generally speaking, this means moving to a structure like this: newcred = crdup(oldcred); ... p->p_ucred = newcred; crfree(oldcred); It's not race-free, but better than nothing. There are also races in sys_process.c, all inter-process authorization, fork, exec, and exit. o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid; remove comments indicating that the old arrangement was a problem. o Restructure exec1() a little to use newcred/oldcred arrangement, and use improved uid management primitives. o Clean up exit1() so as to do less work in credential cleanup due to pcred removal. o Clean up fork1() so as to do less work in credential cleanup and allocation. o Clean up ktrcanset() to take into account changes, and move to using suser_xxx() instead of performing a direct uid==0 comparision. o Improve commenting in various kern_prot.c credential modification calls to better document current behavior. In a couple of places, current behavior is a little questionable and we need to check POSIX.1 to make sure it's "right". More commenting work still remains to be done. o Update credential management calls, such as crfree(), to take into account new ruidinfo reference. o Modify or add the following uid and gid helper routines: change_euid() change_egid() change_ruid() change_rgid() change_svuid() change_svgid() In each case, the call now acts on a credential not a process, and as such no longer requires more complicated process locking/etc. They now assume the caller will do any necessary allocation of an exclusive credential reference. Each is commented to document its reference requirements. o CANSIGIO() is simplified to require only credentials, not processes and pcreds. o Remove lots of (p_pcred==NULL) checks. o Add an XXX to authorization code in nfs_lock.c, since it's questionable, and needs to be considered carefully. o Simplify posix4 authorization code to require only credentials, not processes and pcreds. Note that this authorization, as well as CANSIGIO(), needs to be updated to use the p_cansignal() and p_cansched() centralized authorization routines, as they currently do not take into account some desirable restrictions that are handled by the centralized routines, as well as being inconsistent with other similar authorization instances. o Update libkvm to take these changes into account. Obtained from: TrustedBSD Project Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-3/+5
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Revert consequences of changes to mount.h, part 2.grog2001-04-291-2/+0
| | | | Requested by: bde
* Correct #includes to work with fixed sys/mount.h.grog2001-04-231-0/+2
|
* Implement client side NFS locks.alfred2001-04-171-0/+269
Obtained from: BSD/os Import Ok'd by: mckusick, jkh, motd on builder.freebsd.org
OpenPOWER on IntegriCloud