summaryrefslogtreecommitdiff
path: root/sys/nfs/nfs_serv.c
AgeCommit message (Collapse)Author
2019-01-19Move boottime into the timehands.cheloha
To protect the timehands we first need to protect the basis for all UTC time in the kernel: the boottime. Because the boottime can be changed at any time it needs to be versioned along with the other members of the timehands to enable safe lockless reads when using it for anything. So the global boottime timespec goes away and the static boottimebin becomes a member of the timehands. Instead of reading the global boottime you use one of two interfaces: binboottime(9) or microboottime(9). nanoboottime(9) can trivially be added later, though there are no consumers for it at the moment. This introduces one small change in behavior. We used to advance the reported boottime just before launching kernel threads from main(). This makes it look to userland like we "booted" moments before those threads were launched. Because there is no longer a boottime global we can no longer trivially do this from main(), so the boottime we report to userspace via e.g. kern.boottime will now reflect whatever the time was when we bootstrapped the timehands via inittodr(9). This is usually no more than a minute before the kernel threads are launched from main(). The prior behavior can be restored by adding a new interface to the timecounter layer in a future commit. Based on FreeBSD r303387. Discussed with mpi@ and visa@. ok visa@
2019-01-18Check for negative length integers in NFS server. A maliciousAlexander Bluhm
client could crash the server. OK tedu@
2018-11-09M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers forClaudio Jeker
m_leadingspace() and m_trailingspace(). Convert all callers to call directly the functions and remove the defines. OK krw@, mpi@
2018-06-13Make the VFS layer responsible for preventing the deletionVisa Hankala
of mounted on directories. OK guenther@, mpi@
2018-06-07Make callers of VOP_CREATE(9) and VOP_MKNOD(9) responsible forVisa Hankala
unlocking the directory vnode. OK mpi@, helg@
2018-05-02Remove proc from the parameters of vn_lock(). The parameter isVisa Hankala
unnecessary because curproc always does the locking. OK mpi@
2018-04-28Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysVisa Hankala
curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
2017-12-30Delete unnecessary <sys/file.h> includesPhilip Guenther
ok millert@ krw@
2017-02-22Keep local definitions local.Martin Pieuchot
"good work" deraadt@, ok visa@
2016-09-21Fix nfsrv_symlink() indentation. No binary change.Jonathan Gray
ok mpi@ deraadt@
2016-07-04Add missing vput() in error path to prevent a vnode getting stuck with aMartin Natano
stale reference and lock, while it shouldn't hold either. "makes sense to me" beck@
2016-04-29Fix some gibbering horrors due to uninitialized struct nameidata'sBob Beck
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@
2016-03-19Remove the unused flags argument from VOP_UNLOCK().natano
torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
2015-08-30Keep track of a length for free() in error paths. Be careful,Theo de Raadt
because the nfsm_strsiz() macro sneakily modifies a parameter! ok beck
2015-07-15m_freem() can handle NULL, do not check for this condition beforehands.Theo de Raadt
ok stsp mpi
2015-06-11Avoid double-free in error path by cribbing the HASBUF flagBret Lambert
logic from the rest of the kernel that deals with filename lookups. In snaps for some time. Initially found by jsg@ Prodded by deraadt@
2015-05-06add missing bracesJonathan Gray
ok guenther@ miod@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2014-12-16primary change: move uvm_vnode out of vnode, keeping only a pointer.Ted Unangst
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
2014-11-18Reduce scope of iovec variables, use mallocarray, and record size forTed Unangst
free. Change rbuf malloc argument to fullsiz, which then makes clear it's the correct size to pass to free. ok millert
2014-11-14bzero -> memsetTed Unangst
2014-11-03include sys/unistd.h where needed instead of indirect reliance. ok jsgTed Unangst
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-07-08decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.hTheo de Raadt
don't need to be married. ok guenther miod beck jsing kettenis
2014-04-21Back out most of v1.47 changes which mess up the block size on theseBob Beck
reads. ok deraadt@ guenther@
2013-08-13Switch time_t, ino_t, clock_t, and struct kevent's ident and dataPhilip Guenther
members to 64bit types. Assign new syscall numbers for (almost all) the syscalls that involve the affected types, including anything with time_t, timeval, itimerval, timespec, rusage, dirent, stat, or kevent arguments. Add a d_off member to struct dirent and replace getdirentries() with getdents(), thus immensely simplifying and accelerating telldir/seekdir. Build perl with -DBIG_TIME. Bump the major on every single base library: the compat bits included here are only good enough to make the transition; the T32 compat option will be burned as soon as we've reached the new world are are happy with the snapshots for all architectures. DANGER: ABI incompatibility. Updating to this kernel requires extra work or you won't be able to login: install a snapshot instead. Much assistance in fixing userland issues from deraadt@ and tedu@ and build assistance from todd@ and otto@
2013-06-03Convert some internal APIs to use timespecs instead of timevalsPhilip Guenther
ok matthew@ deraadt@
2012-03-21Prevent vrele() being called with a NULL argument if nfs_namei() returns anMark Kettenis
error in several places. Should fix the "vrele: null vp" panic that henning@ has been seeing lately. ok tedu@, krw@, deraadt@
2010-09-09Rename lookup/relookup to vfs_lookup/vfs_relookup.Thordur I. Bjornsson
OK oga@, beck@, matthew@
2010-03-29Initialize various uninitialized variables. Found by jsg@ via Clang.Kenneth R Westerback
Feedback from miod@ and kettenis@. ok beck@
2009-10-19antsyJonathan Gray
no binary change apart from nfsm_reqhead() which is clearly correct. ok thib@
2009-08-30if nfs_namei() fails, there's no ni_startdir and the pathname buffer hasThordur I. Bjornsson
already been freed, thus make the callers of nfs_namei() bail out early, instead of jumping to nfsmout as there they will try to vrele() vnodes that don't exists (NULL pointers) and free the pathname buffer. this is way nicer then adding checks after the nfsmout label. OK blambert@
2009-08-14Avoid double-release of vnodes in several functionsBret Lambert
ok thib@
2009-08-14Initialize len variable; found by Martynas VenckusBret Lambert
ok thib@
2009-08-13change version 3 post-operation attribute building function to notBret Lambert
use mbufs directly, but the shiny new nfsm_info struct ok thib@
2009-08-11Fix a few bugs in nfsrv_rename() error recovery code.Thordur I. Bjornsson
- Prevent a double vrele() by setting the vnode pointer to NULL. - Check if vnode pointers have been set to NULL before trying to vrele(). - don't double free the component path name buffer. - Add a workaround for multiple vnode pointers all pointing to the same vnode and the code doing vrele() on all of them, leading to botched refcounts. This is a horrible hack, but a real fix is being worked on. OK blambert@
2009-08-10AnotherBret Lambert
error = operation(); memory = malloc(); if (error) free(memory); gets relegated to the dustbin of history ok thib@
2009-08-10Remove the v2 writegather code. It did help alot back in the 80sThordur I. Bjornsson
but extensive performance benchmarking done by myself and jasper@ has shown that it doesn't help, at all - even on vaxens and in some cases it makes things significantly slower. "this excites me sexually" jetpack@ Tested by jasper@. OK blambert@
2009-08-09MLEN < NFS_MAXPATHLEN < MCLBYTES, so there's no need toBret Lambert
loop over allocating a chain of mbufs to store <= NFS_MAXPATHLEN bytes. Clean up some variables, which thib@ likes. ok thib@
2009-08-09error = operation();Bret Lambert
memory = malloc(); if (error) free(memory); makes no sense; move error checking to above memory allocation ok thib@
2009-08-09set the mrq pointer (request) in the nfsm_reply() macro, as we can return ↵Thordur I. Bjornsson
from it. This can cause us to follow garbage in the nfsd loop, causing two kinds of hell. problem noticed by nicm@. OK blambert@.
2009-08-04group all of the on-stack variables that are uses by the nfsm_macrosThordur I. Bjornsson
to keep the data munging "state" into an nfsm_info structure. Each function now has this structure on its stack, and it and its members are now passed around so that the macros/functions can work there magic. this will make removing the nfsm_* macros way easier. Idea/code picked up from DragonflyBSD. Tested by krw@, jacekm@ and myself. OK blambert@.
2009-07-20(struct foo *)0 -> NULL, every where I could find it.Thordur I. Bjornsson
OK blambert@
2009-07-17Initialize a variable that was previously using a mystery value inBret Lambert
some error cases ok thib@
2009-06-06Don't allocate an mbuf cluster without checking to see if it willBret Lambert
actually get us anything. ok thib@
2009-06-06Consolidate error handling in read case.Bret Lambert
ok thib@
2009-06-06Consolidate error handling code. Much less atrocious than before.Bret Lambert
"get it in" thib@
2009-06-05bring back rev1.70Thordur I. Bjornsson
2009-06-05revert to 1.67 to unbreak NFS writes; ok beck@ thib@Christian Weisgerber
2009-06-05EPERM from VOP_ACCESS() is always an error, so don't hide it.Thordur I. Bjornsson
Diff from FreeBSD. OK blambert@