Commit Graph

273 Commits

Author SHA1 Message Date
reinoud 0ce809091d Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

An extra benefit is the removal of the ugly hack from the Berkly days on
LFS.

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.
2006-10-20 18:58:12 +00:00
christos 152eb5a9c3 according to the manual, the last argument of quotactl(2) is a void *,
not a caddr_t.
2006-10-17 15:06:18 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
elad bada0c776a Don't use KAUTH_RESULT_* where it's not applicable.
Prompted by yamt@.
2006-09-13 10:07:42 +00:00
elad 0e73c20464 Oops, add forgotten 'if'.
From Geoff Wing, thanks!
2006-09-12 07:51:29 +00:00
elad 5f7169ccb1 First take at security model abstraction.
- Add a few scopes to the kernel: system, network, and machdep.

- Add a few more actions/sub-actions (requests), and start using them as
  opposed to the KAUTH_GENERIC_ISSUSER place-holders.

- Introduce a basic set of listeners that implement our "traditional"
  security model, called "bsd44". This is the default (and only) model we
  have at the moment.

- Update all relevant documentation.

- Add some code and docs to help folks who want to actually use this stuff:

  * There's a sample overlay model, sitting on-top of "bsd44", for
    fast experimenting with tweaking just a subset of an existing model.

    This is pretty cool because it's *really* straightforward to do stuff
    you had to use ugly hacks for until now...

  * And of course, documentation describing how to do the above for quick
    reference, including code samples.

All of these changes were tested for regressions using a Python-based
testsuite that will be (I hope) available soon via pkgsrc. Information
about the tests, and how to write new ones, can be found on:

	http://kauth.linbsd.org/kauthwiki

NOTE FOR DEVELOPERS: *PLEASE* don't add any code that does any of the
following:

  - Uses a KAUTH_GENERIC_ISSUSER kauth(9) request,
  - Checks 'securelevel' directly,
  - Checks a uid/gid directly.

(or if you feel you have to, contact me first)

This is still work in progress; It's far from being done, but now it'll
be a lot easier.

Relevant mailing list threads:

http://mail-index.netbsd.org/tech-security/2006/01/25/0011.html
http://mail-index.netbsd.org/tech-security/2006/03/24/0001.html
http://mail-index.netbsd.org/tech-security/2006/04/18/0000.html
http://mail-index.netbsd.org/tech-security/2006/05/15/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/01/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/25/0000.html

Many thanks to YAMAMOTO Takashi, Matt Thomas, and Christos Zoulas for help
stablizing kauth(9).

Full credit for the regression tests, making sure these changes didn't break
anything, goes to Matt Fleming and Jaime Fournier.

Happy birthday Randi! :)
2006-09-08 20:58:56 +00:00
yamt 56d02ae53a vfs_copyinfh_alloc: kludge for nfsv2 file handles. 2006-08-08 13:08:08 +00:00
yamt ac0b9042bb sys___fhstatvfs140: update a comment. 2006-08-04 17:07:32 +00:00
yamt 4977b4bbc0 some filehandle syscall related changes.
- remove the support of variable-sized filehandle from compat version of
  syscalls.  (strictly speaking, it breaks abi.  i don't think it's a problem
  because this feature is short-lived and there are no affected in-tree
  filesystems.)
- unify vfs_copyinfh_alloc and vfs_copyinfh_alloc_size.
- vfs_copyinfh_alloc_size: check fhsize strictly.
- reduce code duplication between compat and current syscalls.
2006-08-04 16:29:51 +00:00
yamt e99f3cca81 vfs_copyinfh_alloc_size: fix indent. 2006-08-04 13:31:51 +00:00
martin b4cb63a646 Make filehandles opaque to userland 2006-07-31 16:34:42 +00:00
elad ebdd7412b5 sync kpi with docs, remove old comments 2006-07-26 16:34:07 +00:00
dogcow c959b3c4bd at the request of elad, as veriexec.h has returned, revert the changes
from 2006-07-25.
2006-07-26 09:33:57 +00:00
dogcow cc44d2fe07 mechanically go through and
s,include "veriexec.h",include <sys/verified_exec.h>,
as the former has apparently gone away.
2006-07-25 00:23:06 +00:00
elad 05eb39fb84 replace magic numbers for strict levels (0-3) with defines. 2006-07-24 21:32:39 +00:00
elad 5d611badde some fixes:
- adapt to NVERIEXEC in init_sysctl.c.
  - we now need "veriexec.h" for NVERIEXEC.
  - "opt_verified_exec.h" -> "opt_veriexec.h", and include it only where
    it is needed.
2006-07-24 16:37:28 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
elad a92c1615a4 deprecate the VERIFIED_EXEC option; now we only need the pseudo-device to
enable it. while here, some config file tweaks.

tons of input from cube@ (thanks!) and okay blymn@.
2006-07-22 10:34:26 +00:00
christos cb6bd87d8a PR/34043: mrt at notwork dot org: 3.99.22 kernel crashes at *_vptofh() called
from vfs_composefh_alloc() due to uninitialized "fidsize".
2006-07-20 16:18:14 +00:00
blymn 36c3e07ffa Add destination file vnode to rename checking. 2006-07-19 12:45:19 +00:00
elad 8ee43586ab move the fileassoc_delete_file() call above the VOP_REMOVE() one, yamt@
says vp might not be valid after it.
2006-07-17 19:05:36 +00:00
martin 631d071e84 FHANDLE_SIZE_MIN is an allowed value for the requested size (it happens
to be the old static size on 32bit archs, so the compat_30 code uses it)
2006-07-15 16:32:29 +00:00
elad b5d09ef065 okay, since there was no way to divide this to two commits, here it goes..
introduce fileassoc(9), a kernel interface for associating meta-data with
files using in-kernel memory. this is very similar to what we had in
veriexec till now, only abstracted so it can be used more easily by more
consumers.

this also prompted the redesign of the interface, making it work on vnodes
and mounts and not directly on devices and inodes. internally, we still
use file-id but that's gonna change soon... the interface will remain
consistent.

as a result, veriexec went under some heavy changes to conform to the new
interface. since we no longer use device numbers to identify file-systems,
the veriexec sysctl stuff changed too: kern.veriexec.count.dev_N is now
kern.veriexec.tableN.* where 'N' is NOT the device number but rather a
way to distinguish several mounts.

also worth noting is the plugging of unmount/delete operations
wrt/fileassoc and veriexec.

tons of input from yamt@, wrstuden@, martin@, and christos@.
2006-07-14 18:41:40 +00:00
yamt a1c2fd0906 introduce filehandle size limits:
- FHANDLE_SIZE_MAX: refuse unreasonable size allocation, esp. when
  it's a user-specified value.

- FHANDLE_SIZE_MIN: pad small filehandles with zero for compatibility.
  XXX it might be better to push this into filesystem dependent code so that
  new filesystems can choose smaller handles.
2006-07-14 18:30:35 +00:00
yamt cf80fa09d3 - sys___getfh30:
- restructure code so that it doesn't try to allocate user-specified
	  unbound amount of memory.
	- don't ignore copyout failure in the case of E2BIG.
- rename vfs_copyinfh to vfs_copyinfh_alloc for consistency.
2006-07-14 18:29:40 +00:00
yamt 2d1ef0388d - fix buffer overruns in fhopen and friends.
- share some code among them.
2006-07-14 15:59:29 +00:00
yamt e221f55a3b sys___getfh30: fix a vnode lock botch in rev.1.244. 2006-07-14 14:28:58 +00:00
yamt 387e1097ba sys___getfh30: remove unnecessary casts. 2006-07-14 14:00:46 +00:00
martin edf136d748 fix typo 2006-07-13 21:51:50 +00:00
martin a3b5baed42 Fix alignement problems for fhandle_t, exposed by gcc4.1.
While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
2006-07-13 12:00:24 +00:00
yamt 7d3142aa6a - introduce vfs_composefh() and use it where appropriate.
- fix lock/unlock mismatch in sys_getfh.
2006-06-17 07:06:50 +00:00
elad 215bd95ba4 integrate kauth. 2006-05-14 21:15:11 +00:00
yamt 7729c57a0f don't allocate struct statvfs on stack as it's too large. 2006-05-10 11:02:29 +00:00
christos 9ec9aed92e fhstat needs to be versioned too (for ino_t). Pointed out by Izumi Tsutsui 2006-05-04 17:48:56 +00:00
martin d6d75eaf5d KASSERT that the returned file id length from VPTOFH is <= the
maximum allowed value (_VFS_MAXFIDSZ).
2006-03-27 20:20:45 +00:00
yamt ec5a93183a merge yamt-uio_vmspace branch.
- use vmspace rather than proc or lwp where appropriate.
  the latter is more natural to specify an address space.
  (and less likely to be abused for random purposes.)
- fix a swdmover race.
2006-03-01 12:38:10 +00:00
chs 899d1b31b2 convert "magiclinks" from a per-fs mount option to a system-wide sysctl.
as discussed on tech-kern quite some time ago.
2006-02-12 01:32:06 +00:00
yamt 5a3e361753 for some random places, use PNBUF_GET/PUT rather than
- on-stack buffer
	- malloc(MAXPATHLEN)
2006-02-04 12:09:50 +00:00
elad 6590e0e201 Catch up with ktrace-lwp merge.
While I'm here, stop using cur{lwp,proc}.
2005-12-12 16:26:33 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
yamt 163be2ac64 change_utimes: use nanotime(9) rather than time(9). 2005-10-01 06:13:42 +00:00
jmmv 3955cf65f9 Add some COMPAT_30 code to let old mountd binaries work after the NFS
exports rototill.
2005-09-25 21:57:40 +00:00
jmmv 2a3e5eeb7c Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
  function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
  file sys/nfs/nfs_export.c.  The former was becoming large and its code
  is always compiled, regardless of the build options.  Using the latter,
  the code is only compiled in when NFSSERVER is enabled.  While doing this,
  also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
  path and a set of export entries.  At the moment it can only clear the
  exports list or append entries, one by one, but it is done in a way that
  allows setting the whole set of entries atomically in the future (see the
  comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
  that it becomes file system agnostic.  In fact, all this whole thing was
  done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
  exports initialization; done internally by the kernel when initializing
  the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
  subsystems can run arbitrary code upon receipt of specific VFS events.
  At the moment, this only provides support for unmount and is used to
  destroy NFS exports lists from the file systems being unmounted, though it
  has room for extension.

Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
2005-09-23 12:10:31 +00:00
jmmv 0562a5484c Make all creation operations (mkdir, create, mknod and symlink) consistent
by changing the symlink one to set vap's vatype to VLNK.  All the other three
already set vatype to the correct type.  Note that, however, in the mkdir
case (and now symlink too) this is not strictly necessary.
2005-08-30 09:37:41 +00:00
elad 5f794fb20d Introduce veriexec_renamechk().
Rename policy:
  - Strict levels 0, 1: Log renames of monitored files.
  - Strict level 2: Prevent renames of monitored files.
  - Strict level 3: Prevent renames.
2005-08-19 12:30:02 +00:00
christos 50f8955b6e 64 bit inode changes. 2005-08-19 02:04:03 +00:00
jmmv 5aff10d277 Fix some typos in comments. 2005-08-05 13:22:23 +00:00
christos 1510fe1543 defopt verified_exec. 2005-07-16 22:47:18 +00:00
cube cbb77bc452 The comment listing the arguments of fsync_range(2) wrongly described
"length" as an int.  It is an off_t.
2005-07-10 14:26:02 +00:00
thorpej 76fd10b45a Move VFS extended attribute support to its own file. 2005-07-09 01:05:23 +00:00