Commit Graph

894 Commits

Author SHA1 Message Date
enami 780e071921 Don't expand RCS id of ancestor file. The id itself is actually copied
from null_vnops.c since the log message of rev. 1.1 implies the copy.
2007-04-16 08:10:58 +00:00
chs aba740b225 define a pager flag PGO_RECLAIM, similar to FSYNC_RECLAIM, and use it
to skip unnecessary flushing when layered file system vnodes are recycled.
this also prevents a deadlock with the dodgy LFS putpages routine.
fixes the non-LFS part of PR 36150.
2007-04-16 05:14:54 +00:00
hannken fc6776f366 Remove now obsolete vn_start_write() and vn_finished_write() and
corresponding flags.

Revert softdep_trackbufs() to its state before vn_start_write() was added.

Remove from struct mount now unneeded flags IMNT_SUSPEND* and
members mnt_writeopcountupper, mnt_writeopcountlower and mnt_leaf.

Welcome to 4.99.17
2007-04-08 11:20:42 +00:00
hannken e956461048 Remove calls to now obsolete vn_start_write() and vn_finished_write(). 2007-04-07 15:06:53 +00:00
rmind 0a747ea89c Unfortunately, missed procfs_proc_unlock() in previous.
Pointed out by pooka@
2007-04-04 10:50:42 +00:00
rmind 199691e947 procfs_readlink: Handle a possible fail of fd_getfile(), also, we
do not need to check for error again.
CID: 4436
2007-04-04 01:27:32 +00:00
christos a7761fd2c5 Instead of reading and writing little by little, allocate memory and
write the whole map in one shot so that we don't have to deal with the
map changing under us. Fixes the linux emulated jdk-1.6 where it was
losing the last map entry and could not find the stack on startup.
2007-04-01 03:18:57 +00:00
christos 6a4825167b return a page less than the actual top of stack so that linux-java works. 2007-04-01 03:16:44 +00:00
ad 0b43c20288 Remove useless cast. 2007-03-11 22:07:32 +00:00
ad c147748d84 - Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.
2007-03-09 14:11:22 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
salo 20af5e4fd5 Don't prepend rootvnode to the path in non-NULL case for exe links.
It breaks procfs in chroot.

from <christos>, tested by me.
2007-03-03 01:18:32 +00:00
ad b89010bfa3 Destroy the hash locks on final unmount. 2007-02-27 16:11:51 +00:00
thorpej 7cc07e11dc TRUE -> true, FALSE -> false 2007-02-22 06:16:03 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
ad 4abc9f506a Add genfs_node_destroy(). Fixes a lock "leak" seen when running LOCKDEBUG
kernels.
2007-02-20 16:19:42 +00:00
pooka 76aba343c2 When checking for file validity under pid/, do proper proc->lwp
lookup (fsvo proper) instead of fiddling directly with the lwp
list.
2007-02-19 00:08:18 +00:00
ad 42a7dff463 procfs_map():
- Drop the target's vm_map lock before calling uiomove(). We could
  deadlock if inspecting /proc/curproc/map.
- If the vm_map might have changed, restart the operation, but give
  up after 250 retries if the map keeps changing.  XXX This is not
  ideal.
2007-02-18 20:03:44 +00:00
pooka 7b63f0de5d Don't check for validity of p in lookup for root nodes, since it
will always be NULL.  Rather, just call pt_valid with NULL directly
and let it decide if we're a linux mount or not.
2007-02-18 01:55:26 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
2007-02-17 22:31:36 +00:00
pooka 85cb1a4957 In lookup, when checking for procfs process node validity, target the
process we're trying to get information about through procfs, not
the caller of lookup.

fixes 'ls -l /proc/*/file' panic, which would occur when trying to
lookup "file" for a kernel thread, which doesn't have p->p_textvp.
2007-02-16 21:37:56 +00:00
ad 9abeea588a Replace some uses of lockmgr() / simplelocks. 2007-02-15 15:40:50 +00:00
ad f8fe10ea6a Need to acquire procp->p_mutex for procfs_dir(). 2007-02-15 15:35:45 +00:00
ad c18c0d2eaa Eliminate a couple of reference count and mutex leaks. 2007-02-11 17:16:08 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
hannken 4d607243ba Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>
2007-01-29 15:42:50 +00:00
hannken 1b9c6382e3 New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE.  This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).
2007-01-19 14:49:08 +00:00
elad b2eb9a5389 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 19:07:03 +00:00
elad 5d2c44c76f PR/32877: Geoff C. Wing: mount_procfs(8) doesn't null-terminate cmdline
output

Patch applied, thanks!
2006-12-28 09:17:52 +00:00
elad 8e5a82bb94 Revert bogus NULL check introduced in revision 1.96 that generated false
Coverity "bugs".
2006-12-28 09:12:38 +00:00
alc 8f1ebe33c9 revert previous, after inspection `kfs->kfs_kt' could really not be NULL here.
reported/requested by elad@
2006-12-28 05:51:56 +00:00
alc 94d1925ccb fix comment (forgotten in rev 1.19):
- pfsnode -> kernfs_node
 - procfs -> kernfs
2006-12-28 05:49:05 +00:00
yamt ccfd2c0df0 remove nqnfs. 2006-12-27 12:10:09 +00:00
alc 8ffa4fbf16 CID-3855: check if 'kfs->kfs_kt != NULL' before dereferencing it 2006-12-26 00:01:48 +00:00
elad f02f51a039 PR/35226: Johann Franz: Problems with permissions in
/usr/pkg/emul/linux/proc .

Okay mlelstv@
2006-12-25 12:13:54 +00:00
christos b5fb56163d fix permissions on /proc/<pid> node. From elad. 2006-12-24 17:37:35 +00:00
elad a687717695 Add two comments. No functional change. 2006-12-24 16:45:23 +00:00
elad f1a69ab3ea Some changes to get rid of another KAUTH_GENERIC_ISSUSER usage:
- Make procfs_control() in procfs_ctl.c static,
  - Add an argument to the above, 'pfs', for the pfsnode,
  - Add another request type to KAUTH_PROCESS_CANPROCFS named
    KAUTH_REQ_PROCESS_CANPROCFS_CTL (and update documentation),
  - Use the above combination in a call to kauth_authorize_process().
2006-12-19 09:58:34 +00:00
yamt fc88d88996 put ->K loaned pages on the page queue, so that page loaning doesn't
disturb pagedaemon/pdpolicy.
2006-12-15 13:51:30 +00:00
pooka 4013808f45 Teach deadfs about vm object locking for getpages. This avoids
errors resulting from situations where we take a page fault for a
vnode which has been converted a deadfs vnode.

wrstuden ok
2006-12-10 23:57:33 +00:00
chs c398ae9734 a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
   these now always return the parent vnode locked.  namei() works as before.
   lookup() and various other paths no longer acquire vnode locks in the
   wrong order via vrele().  fixes PR 32535.
   as a nice side effect, path lookup is also up to 25% faster.
 - the above allows us to get rid of PDIRUNLOCK.
 - also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
 - remove an assumption in layer_node_find() that all file systems implement
   a recursive VOP_LOCK() (unionfs doesn't).
 - require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
   fill in eopnotsupp() for file systems that don't support being exported
   and remove the checks for NULL.  (layerfs calls these without checking.)
 - in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
   adjust which vnode is locked.  fixes PR 33374.
 - apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
2006-12-09 16:11:50 +00:00
christos 33b30b1ee3 From Nicolas Joly: restore previous behavior in procfs_validfile_linux, since
readdir passes a NULL lwp.
2006-12-04 18:27:52 +00:00
elad 8a806df7dc Move kauth(9) call to where it belongs. Noticed by Nicolas Joly, thanks! 2006-12-03 13:24:10 +00:00
pooka 5f132bf76c * update comments before putpages(): the vm object is always returned
unlocked instead of locked.  chuq agrees
* use slock set to &uobj->vmobjlock also for the last simple lock
  operation to be consistent with the rest of the function
2006-11-30 06:11:03 +00:00
elad 8bb202af97 Move ktrace, ptrace, systrace, and procfs to use kauth(9).
First, remove process_checkioperm() calls from MD code. Similar checks
using kauth(9) routines (on the process scope, using appropriate action)
are done in the callers.

Add secmodel back-end to handle each subsystem.
2006-11-28 17:27:09 +00:00
elad 21bc112176 Implement Veriexec's raw disk policy on-top of kauth(9)'s device scope,
using both the rawio_spec and passthru actions to detect raw disk
activity. Same for kernel memory policy.

Update documentation (no longer need to expose veriexec_rawchk()) and
remove all Veriexec-related bits from specfs.
2006-11-26 20:27:27 +00:00
elad 98f4b1ff55 Part of PR/33280: Christian Ehrhardt: If LK_INTERLOCK is set
vp->v_interlock may be unlocked twice: Once explicitly and a second time
implicilty by lockmgr. LK_INTERLOCK is cleared from the variable flags but
not from ap->a_flags which is used with lockmgr. This is not so much of a
problem because there seems to be no call site that actually uses
LK_INTERLOCK with layer_unlock or VOP_UNLOCK.

okay martin@
2006-11-25 22:36:24 +00:00
elad 895827f391 Part of PR/33280: Christian Ehrhardt: In the error path (which probably
can't happen) lmp->layerm_hashlock is not unlocked.
2006-11-25 22:14:38 +00:00
christos 52411aad22 instead of const int, use a #define which most of the time will evaluate
in a compile-time constant.
2006-11-25 21:15:01 +00:00
skrll 45ea587c94 Expose the 'exe' symlink to the process realpath in NetBSD as well. An
example user is gdb.

OK'd by christos.
2006-11-25 09:39:34 +00:00
wiz 09cb1d6f1c s/existance/existence/, from Zafer. 2006-11-24 22:52:16 +00:00
elad 72438de6ef Remove redundant securelevel check; this is already done in procfs_rw()
and we can't get here (procfs_control()) without being there first.

Pointed out by yamt@.
2006-11-22 15:48:11 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
reinoud dc6975451a Add missing space in comment 2006-11-10 22:31:19 +00:00
jmmv 9d877d347c Use size_t in a couple of places as it makes more sense WRT the places
where the variables are later used.  From PR kern/25277 by Jeff Ito.
2006-11-04 20:51:32 +00:00
elad fe9e2303fd Change KAUTH_SYSTEM_RAWIO to KAUTH_DEVICE_RAWIO_SPEC (moving the raw i/o
requests to the device scope) and add KAUTH_DEVICE_RAWIO_PASSTHRU.

Expose iskmemdev() through sys/conf.h.

okay yamt@
2006-11-04 09:30:00 +00:00
elad 7e8b842ffa Redo Veriexec raw disk/memory access policies so they hold only if the
request is for write access.
2006-11-02 12:48:35 +00:00
elad 45f88cbee1 Only use blkdev/bvp for the Veriexec case. While here, fix up IPS mode
restrictions on kernel memory.

okay yamt@
2006-11-01 09:37:28 +00:00
elad ea927d2c6a oops, remove debug printf slipped in. good catch from yamt@, thanks! 2006-10-30 12:19:23 +00:00
christos 3f792e2267 add an "emul" file node. 2006-10-29 22:35:35 +00:00
christos 26bb1685bd don't allocate large buffers on the stack. 2006-10-27 16:49:01 +00:00
christos e8926fa3f7 1. fix procfs_validfile{,_linux} to test for NULL pointers properly.
2. make "exe" entry be a symlink to the executable, instead of pointing
   directly to the vnode of the executable.
3. factor out commonly used code.
2006-10-25 18:59:52 +00:00
elad 59e67acd85 kauth_cred_geteuid() is okay for the purposes of these checks. Revert
conversion to kauth_authorize_generic() done some time ago.
2006-10-25 11:59:34 +00:00
elad af94ee3081 PR/34888: Nicolas Joly: kernel panic while trying to access
/emul/linux/proc/0/stat

Patch applied, thanks for the report!
2006-10-23 18:19:14 +00:00
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
yamt 37c68a65cf add wrapper functions of lockmgr on g_glock. 2006-10-14 09:16:28 +00:00
yamt eee3695a7f genfs_getpages: use kmem_zalloc. 2006-10-14 09:15:52 +00:00
yamt c2ae921270 genfs_do_io: iodone handler should be called at splbio. 2006-10-14 08:31:14 +00:00
yamt 35048d7491 genfs_putpages: don't try to deactivate loaned pages.
reported and tested by Nicolas Joly on current-users@.
2006-10-12 10:10:48 +00:00
thorpej 867f8cb239 genfs_lease_check(): Consume the arguments even if NFSSERVER is not defined. 2006-10-12 04:25:43 +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
dogcow 62ce183fe4 fix build error in mount_sysvbfs. 2006-10-06 02:17:25 +00:00
chs 33c1fd1917 add support for O_DIRECT (I/O directly to application memory,
bypassing any kernel caching for file data).
2006-10-05 14:48:32 +00:00
jld 0ebf778b9d The poll routine needs to return POLLERR on error, not an errno. Sorry
about that.  Pointed out by Juergen Hannken-Illjes in mail.
2006-09-30 21:00:13 +00:00
jld 754d606748 Protect spec_poll from racing against revocation and thus dereferencing a
NULL v_specinfo.  Mostly copied (with understanding) from rev 1.83's fix
to spec_ioctl, and needed for the same reason (kern/vfs_subr.c r1.231).
2006-09-21 09:28:37 +00:00
manu a540ef296e Emulate Linux's /proc/devices 2006-09-20 08:09:05 +00:00
elad 3964702f3a For the VBLK case, we always check vfs_mountedon() and it has nothing
to do with the security model used. Move back the call to spec_open(),
which can now return the real return value from vfs_mountedon() (EBUSY)
and not EPERM, changing semantics.
2006-09-19 16:41:57 +00:00
yamt 9d3e3eab23 merge yamt-pdpolicy branch.
- separate page replacement policy from the rest of kernel
	- implement an alternative replacement policy
2006-09-15 15:51:12 +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 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
christos 4e6ffbfcf0 add missing initializers 2006-09-03 22:28:53 +00:00
christos df1dfef2bc add missing initializers 2006-09-03 21:01:12 +00:00
christos 309d51fb22 add missing initializers 2006-09-03 04:56:33 +00:00
christos e89033a3e5 add missing initializers 2006-09-03 04:54:24 +00:00
christos 3c95928caf add missing initializers. 2006-09-02 06:37:41 +00:00
cube bd859bd3de Restore dependency on PTRACE for PROCFS.
Bump required config(1) version.
2006-08-30 13:49:27 +00:00
jnemeth 944592a2ee revert previous as it breaks the build due to invalid syntax 2006-08-30 07:46:37 +00:00
christos 676e77765a fix missing initializers 2006-08-30 01:28:53 +00:00
matt 9e0ec4816e Make PTRACE and COREDUMP optional. Make the default (status quo) by putting
them in conf/std.
2006-08-29 23:34:48 +00:00
christos ce0ef6cfc4 Pretending to be Elad's keyboard:
fileassoc.diff adds a fileassoc_table_run() routine that allows you to
pass a callback to be called with every entry on a given mount.

veriexec.diff adds some raw device access policies: if raw disk is
opened at strict level 1, all fingerprints on this disk will be
invalidated as a safety measure. level 2 will not allow opening disk
for raw writing if we monitor it, and prevent raw writes to memory.
level 3 will not allow opening any disk for raw writing.

both update all relevant documentation.

veriexec concept is okay blymn@.
2006-08-11 19:17:47 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
yamt 54a9d2b0f7 - genfs_getpages: in the case of PGO_LOCKED, check if we can acquire
g_glock as suggested by Chuck Silvers on tech-kern@.
- genfs_rel_pages: handle PGO_DONTCARE so that it can be used for the above.
2006-07-22 08:49:13 +00:00
yamt f9458a6ba1 - in genfs_getpages, take g_glock earlier so that it can't be
intervened by truncation.
  it also fixes a deadlock.  (g_glock vs pages locking order)
- uvm_vnp_setsize: modify v_size while holding v_interlock.

reviewed by Chuck Silvers.
2006-07-22 08:47:56 +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
christos f36aa0cd37 PR/33815: Nicolas Joly: /emul/linux/proc/#/stat always report current
process status
2006-06-24 16:34:02 +00:00
christos 7173cfeec6 remove useless genop 2006-06-23 20:54:21 +00:00
bouyer 14349e5550 For internal types call kernfs_default_xread() directly, as no entry in
the splay tree has been added for these types. Fix kern/33797 by
Geoff C. Wing.
While here also fix writes the same way (probably broken for 2 years),
and properly implement KERNFS_XREAD.
The IPsec code could probably be moved out now, and use kernfs_alloctype().
2006-06-23 20:30:11 +00:00
bouyer 82722a8d91 Backout previous: of course the change
"Allow optional /kern regular files to have custom read methods..."
works, it's used by Xen.
2006-06-23 16:26:59 +00:00
christos c8ee2595ab PR/33797: Geoff C. Wing: kernfs files are not supplying information
Roll back the change:
    'Allow optional /kern regular files to have custom read methods...'
which does not work.
2006-06-23 14:59:40 +00:00
yamt f7c7538921 use KAUTH_PROCESS_CANSEE rather than CURTAIN where appropriate. 2006-06-13 13:57:33 +00:00