Commit Graph

134 Commits

Author SHA1 Message Date
maxv 05b3bfa0ba There's no need for this NULL-check. 2014-04-15 06:14:55 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
christos b4a250d75c Reorder code to avoid use-after-free on error. From Maxime Villard 2014-01-11 16:31:20 +00:00
christos 9d605174d9 Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
2013-11-27 17:24:43 +00:00
christos 0b725b63c7 change the mountlist CIRCLEQ into a TAILQ 2013-11-23 13:35:36 +00:00
elad 0c9d8d15c9 Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

    http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
    http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
    http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
2012-03-13 18:40:26 +00:00
hannken d3703f2f33 Fix locking against self in veriexec_fp_calc(). 2011-11-20 10:32:33 +00:00
hannken 2cc7a01f10 Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock.  Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
2011-10-14 09:23:28 +00:00
matt f68e927f9b Allocate a color compatible VA for the page we are entering. 2011-09-01 18:33:11 +00:00
christos f8dec0d4e9 allow get the size of the request sysctls to work. 2011-01-29 00:38:25 +00:00
christos 27ec421326 fix sysctl again. 2011-01-08 20:29:13 +00:00
christos 7e1e338bd2 Simplify and avoid kernel segv when the list is NULL. 2011-01-02 20:50:55 +00:00
dholland 06a95d4af1 typo in comment 2010-11-17 20:07:50 +00:00
elad ac90530da8 In veriexec_file_verify(), always check 'lockstate' before unlocking
'veriexec_op_lock'. Triggering a panic is possible in the path from
veriexec_openchk() (easily repeatable). The two switch cases at the
bottom of the function are going to panic anyway, but they might as well
panic as they're intended to as opposed to tripping over a locking
violation...
2009-12-28 07:16:41 +00:00
elad fa8206aeb0 Our error paths can call veriexec_file_free(), whicn in turn will try to
rw_destroy() the vfe lock. The easiest way to fix it for now is simply to
initialize the lock right after allocating the vfe...
2009-12-28 02:35:20 +00:00
elad d67e78d45a Only kmem_free() the filename if we have one. 2009-12-25 22:57:54 +00:00
cegger 9480c51b04 Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
2009-11-07 07:27:40 +00:00
elad 756638cf95 Factor out a block of code that appears in three places (Veriexec, keylock,
and securelevel) so that others can use it as well.
2009-10-06 04:28:10 +00:00
elad 54d08ac134 Update a comment. No functional change. 2009-10-03 21:03:55 +00:00
dholland effcf1af5c Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 05:08:15 +00:00
elad b1bd59c577 Fix locking around mountlist usage, as pointed out by ad@ in:
http://mail-index.netbsd.org/source-changes-d/2009/04/22/msg000322.html
  http://mail-index.netbsd.org/tech-kern/2009/04/22/msg004897.html

Use vfs_busy() and vfs_unbusy(), and properly iterate the mountlist.
2009-05-02 21:47:12 +00:00
elad d4cc1b437c PR/41251: YAMAMOTO Takashi: veriexec locking seems broken
Part 1: Take the mountlist_lock before traversing the mount list.
2009-04-20 22:09:54 +00:00
elad f4f1989ae8 PR/39559: Juan RP: veriexec(4): too easy to cause a NULL dereference
through it in kernel

Patch from PR applied with tiny modifications, thanks!

Discussed with blymn@ a while ago.
2008-12-14 23:20:23 +00:00
blymn 57614abcf2 Conditionalise bypass of veriexec routines on veriexec_strict to prevent
loophole if tables fail to load and strict is then raised.
2008-10-23 13:18:14 +00:00
blymn 6a3775d153 * Fix from Elad to correct a couple of places where functions exited
without releasing locks.
* Corrected a panic caused by veriexec_file_verify() not setting the
  returned struct veriexec_file_entry **vfep in all cases.

Thanks to Stathis Kamperis for finding the issues and testing the fixes.
2008-09-10 16:36:54 +00:00
blymn 762e875434 Add locking around veriexec operations to prevent all sorts of badness
happening.  This fixes kern/38646.
2008-07-20 08:50:20 +00:00
chris 2ff98bbc26 Add missing pmap_update(pmap_kernel()); calls after pmap_kenter_pa and
pmap_remove.
2008-02-23 16:05:17 +00:00
ad af6be237a6 Use vp->v_rdev. 2008-01-15 18:51:43 +00:00
elad 86f224903e Replace malloc/free usage with kmem_alloc/kmem_zalloc/kmem_free.
okay yamt@.
2008-01-03 17:51:05 +00:00
ad 4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
pooka db06a930e6 Remove cn_lwp from struct componentname. curlwp should be used
from on.  The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
2007-12-08 19:29:36 +00:00
pooka 61e8303e9d Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start.  In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
2007-11-26 19:01:26 +00:00
matt 11910619f7 Change some initialization of static queues to compile time.
(xxx_INIT to xxx_HEAD_INITIALIZER).  Drop code which inits
non-auto (global or static) variables to 0 since that's
already implied by being non-auto.  Init some static/global
cpu_simple_locks at compile time.
2007-11-11 23:22:23 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
christos 09a50be501 - remove pathname_ interface.
- use macros to deal with pathnames in userspace, when veriexec is used.
- reorder the veriexec_ call arguments for consistency.
With help from elad@ finding the last bug.
2007-05-19 22:11:22 +00:00
elad 6700cfccd6 Some Veriexec stuff that's been rotting in my tree for months.
Bug fixes:
  - Fix crash reported by Scott Ellis on current-users@.

  - Fix race conditions in enforcing the Veriexec rename and remove
    policies. These are NOT security issues.

  - Fix memory leak in rename handling when overwriting a monitored
    file.

  - Fix table deletion logic.

  - Don't prevent query requests if not in learning mode.


KPI updates:
  - fileassoc_table_run() now takes a cookie to pass to the callback.

  - veriexec_table_add() was removed, it is now done internally. As a
    result, there's no longer a need for VERIEXEC_TABLESIZE.

  - veriexec_report() was removed, it is now internal.

  - Perform sanity checks on the entry type, and enforce default type
    in veriexec_file_add() rather than in veriexecctl.

  - Add veriexec_flush(), used to delete all Veriexec tables, and
    veriexec_dump(), used to fill an array with all Veriexec entries.


New features:
  - Add a '-k' flag to veriexecctl, to keep the filenames in the kernel
    database. This allows Veriexec to produce slightly more accurate
    logs under certain circumstances. In the future, this can be either
    replaced by vnode->pathname translation, or combined with it.

  - Add a VERIEXEC_DUMP ioctl, to dump the entire Veriexec database.
    This can be used to recover a database if the file was lost.
    Example usage:

        # veriexecctl dump > /etc/signatures

    Note that only entries with the filename kept (that is, were loaded
    with the '-k' flag) will be dumped.

    Idea from Brett Lymn.

  - Add a VERIEXEC_FLUSH ioctl, to delete all Veriexec entries. Sample
    usage:

        # veriexecctl flush

  - Add a 'veriexec_flags' rc(8) variable, and make its default have
    the '-k' flag. On systems using the default signatures file
    (generaetd from running 'veriexecgen' with no arguments), this will
    use additional 32kb of kernel memory on average.

  - Add a '-e' flag to veriexecctl, to evaluate the fingerprint during
    load. This is done automatically for files marked as 'untrusted'.


Misc. stuff:
  - The code for veriexecctl was massively simplified as a result of
    eliminating the need for VERIEXEC_TABLESIZE, and now uses a single
    pass of the signatures file, making the loading somewhat faster.

  - Lots of minor fixes found using the (still under development)
    Veriexec regression testsuite.

  - Some of the messages Veriexec prints were improved.

  - Various documentation fixes.


All relevant man-pages were updated to reflect the above changes.

Binary compatibility with existing veriexecctl binaries is maintained.
2007-05-15 19:47:43 +00:00
yamt ef47d5b67e - don't use veriexec_mountspecific_key uninitialized.
- fix weird "Veriexec: IDS mode, allowing unmount" messages.
2007-04-03 09:17:31 +00:00
thorpej 4f3d5a9cc0 TRUE -> true, FALSE -> false 2007-02-22 06:34:42 +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
elad 119d4b5acd PR/35253: YAMAMOTO Takashi: fileassoc hash size problem
fileassoc_table_add() was removed from the KPI and made internal. From now
fileassoc(9) will manage the optimal table size internally.

Input from and okay yamt@.
2007-02-06 01:09:48 +00:00
elad 8ed50e44ae veriexec_file_delete() and veriexec_table_delete() now take 'struct lwp *'
too.
2007-01-11 16:24:47 +00:00
elad 4cc18ba6e8 Make 'veriexec_verbose' static. 2007-01-11 15:10:25 +00:00
elad d2e4f7167b Remove advertising clause from all of my stuff. 2007-01-09 12:49:36 +00:00
elad cf9d4bd6af Update copyright/license, okay blymn@ few days ago. 2007-01-07 13:55:17 +00:00
elad 2a32293a9f Make more things static. From halflife. 2007-01-03 18:32:11 +00:00
elad 8a4dd2d69d #if 0 -> #ifdef notyet, and no need to forward declare internal
data-structures anymore.
2006-12-31 12:07:16 +00:00
elad c5c6251521 Avoid TOCTOU in Veriexec by introducing veriexec_openchk() to enforce
the policy and using a single namei() call in vn_open().
2006-12-30 15:26:55 +00:00
elad 8657d4ffbb Veriexec should not explicitly allow anything (raw disk access). 2006-12-29 11:34:14 +00:00
elad 74409752fc Fix copy/paste error: Veriexec's sysctl setup routine was named after
PaX's.
2006-12-26 19:31:33 +00:00
elad ff39342b33 veriexec_lookup() should not return an internal data-structure, but rather
just a boolean value.
2006-12-26 07:50:40 +00:00