Commit Graph

74 Commits

Author SHA1 Message Date
elad 646f2112d3 Make Veriexec use proplib(3) for kernel-userland data passing.
Obviously, this breaks the already unstable Veriexec ABI, but that's
it. Some cool additions are planned to be introduced, and this just
makes it so that NetBSD 4.0 users will be able to easily use them as
well.

This also removes the fingerprint type name limit, so relevant code
was adjusted.

Thoroughly tested (even uncovered a bug in proplib! thanks for fixing
that cube@!). Documentation updated.
2006-11-28 22:22:02 +00:00
elad e0d8be4efc Move Veriexec's sysctl(9) setup routine and helper to kern_verifiedexec.c. 2006-11-27 17:45:36 +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 df07d5d652 I wanted to do this for so long: veriexec_init_fp_ops() -> veriexec_init(). 2006-11-26 16:22:36 +00:00
elad f1e710a4d8 Document flaw in veriexec_rawchk(). This is what I added to the comment:
* XXX: This is bogus. There's an obvious race condition between the time
 * XXX: the disk is open for writing, in which an attacker can access a
 * XXX: monitored file to get its signature cached again, and when the raw
 * XXX: file is overwritten on disk.
 * XXX:
 * XXX: To solve this, we need something like the following:
 * XXX:         open raw disk:
 * XXX:           - raise refcount,
 * XXX:           - invalidate fingerprints,
 * XXX:           - mark all entries with "no cache" flag
 * XXX:
 * XXX:         veriexec_verify:
 * XXX:           - if "no cache", don't cache evaluation result
 * XXX:
 * XXX:         close raw disk:
 * XXX:           - lower refcount,
 * XXX:           - if refcount == 0, remove "no cache" flag from all entries
2006-11-23 13:11:29 +00:00
elad ff7c31739a Use consistent logging messages. 2006-10-30 11:29:12 +00:00
christos 31a62606ea Merge kernel and userland rmd160 and sha2 implementation.
XXX: We still install rmd160.h and sha2.h in /usr/include/crypto, unlike
the other hash functions which get installed in /usr/include for compatibility.
2006-10-27 21:20:48 +00:00
elad 2d8eaf9b86 Various cleanups.
Make some "#ifdef DIAGNOSTIC" blocks always compiled in; others
convert to KASSERT() where appropriate.

Add some sanity checks and comments while here.
2006-10-24 22:38:41 +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
elad ebdd7412b5 sync kpi with docs, remove old comments 2006-07-26 16:34:07 +00:00
elad 22e1a583a2 fix logic in veriexec_report() 2006-07-26 15:14:24 +00:00
elad 05eb39fb84 replace magic numbers for strict levels (0-3) with defines. 2006-07-24 21:32:39 +00:00
elad 32e391d158 finally do things properly. veriexec_report() takes flags, not three ints. 2006-07-24 21:15:05 +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
elad 93a2eaef51 prevent removal of monitored files as early as ids mode.
okay blymn@
2006-07-24 16:27:15 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
blymn 36c3e07ffa Add destination file vnode to rename checking. 2006-07-19 12:45:19 +00:00
elad 4f60437127 minor api cleanup, and remove useless VOP_GETATTR() calls. 2006-07-15 20:07:36 +00:00
elad a904c6895a update my email on the copyright to @netbsd.org 2006-07-15 16:48:51 +00:00
elad a890e27076 move veriexec_clear() from dev/verified_exec.c to kern/kern_verifiedexec.c 2006-07-15 16:43:35 +00:00
elad 904a157292 some cleanup and fixes:
- fix possible panic and vfs refcnt issue
  - use log(9) instead of printf(9) where possible
  - indent
  - stop logging fsid/fileid
2006-07-15 16:33:16 +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
blymn af4af92111 Fix behaviour of files with no signatures on exec. 2006-07-09 10:13:53 +00:00
blymn 3018e35533 Add kauth header for function prototypes
Whitespace clean up.
2006-05-25 11:23:11 +00:00
elad 215bd95ba4 integrate kauth. 2006-05-14 21:15:11 +00:00
chs 60b21d1590 use uvm_km_alloc() instead of uvm_map(). 2006-03-30 04:05:05 +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
yamt 6bba73019a use VM_PAGE_TO_PHYS macro. 2005-12-08 22:41:44 +00:00
elad d51a16a060 Remove few no longer needed XXX comments about fsid/fileid being
not the same type as dev_t/ino_t.
2005-11-25 12:02:09 +00:00
elad d4a8a9ec63 Debug nits from Brett Lymn:
- The fingerprint should be printed before we increment the pointer.
  - Add missing index increment.
2005-10-12 14:26:47 +00:00
elad 5068eab154 - Don't pass NULL to free().
Fixes local crash reported by Matthew Sporleder.

- %ld -> PRIu64 for inodes.
2005-10-11 23:59:40 +00:00
elad 95d7879011 Style changes, lots of input from blymn@. 2005-10-10 17:36:29 +00:00
elad 2de72bfe34 Various fixes from blymn@ and myself.
Also, put genfs changes under #if 0, and don't do per-page fingerprints
until this is properly discussed, as requested by yamt@.
2005-10-07 18:07:46 +00:00
elad 314759431d Don't forget to unmap memory once we're done with it.
Pointed out by yamt@.
2005-10-05 16:21:46 +00:00
elad 4daa338c1a Don't use static variables here.
Pointed out by yamt@.
2005-10-05 15:59:31 +00:00
elad 8fc0d7a9c3 Introduce per-page fingerprints in Veriexec.
This closes a hole pointed out by Thor Lancelot Simon on tech-kern ~3
years ago.

The problem was with running binaries from remote storage, where our
kernel (and Veriexec) has no control over any changes to files.

An attacker could, after the fingerprint has been verified and
program loaded to memory, inject malicious code into the backing
store on the remote storage, followed by a forced flush, causing
a page-in of the malicious data from backing store, bypassing
integrity checks.

Initial implementation by Brett Lymn.
2005-10-05 13:48:48 +00:00
elad b0e6e3b381 Sync comments with 64-bit inode changes. 2005-09-02 14:16:50 +00:00
christos b33f6da979 more 64 bit inode lossage. 2005-08-19 16:58:29 +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
elad c62f8b0f18 The veriexec API uses dev_t and ino_t for device and inode numbers.
VOP_GETATTR() fills a struct vattr, where va_fsid and va_fileid (device
and inode..) are typed as long.

Add some casts when using these values and surround them with XXXs about
the potential size mismatch, as long can be 64 bits but dev_t and ino_t
are always 32 bits. This is safe because *for now* we're still using
32 bit inode numbers.

Discussed with blymn@.
2005-08-13 12:56:44 +00:00
elad 79b2f66712 Fix printing formats.
- size_t is %zu
  - dev_t is uint32_t is %u
  - long is %ld
2005-08-13 12:08:34 +00:00
elad 6e4a854552 Support multiple entry types. Direct, indirect, and file can now be
combined in the signatures file using commas.
2005-08-02 16:14:10 +00:00
christos 1510fe1543 defopt verified_exec. 2005-07-16 22:47:18 +00:00
elad ab856de1bc Use `const struct sysctlnode *veriexec_count_node' so it works with the
recent changes in sysctl(9).
2005-07-01 19:50:04 +00:00
elad 6e7c7658ef Fix logic in verbose printing. 2005-06-22 21:50:27 +00:00
elad 0e4dfe1792 - Use more calls to veriexec_report() where possible.
- Change #ifdef VERIFIED_EXEC_VERBOSE to another verbose level, 2. Add
  sysctl(3) bits.

- Simplify access type conflict handling during load. This depends on
  the values of access type defines to be ordered from least to most
  'strict'.
2005-06-20 15:06:18 +00:00
elad c3caa55d4d - Avoid pollution of struct vnode. Save the fingerprint evaluation status
in the veriexec table entry; the lookups are very cheap now. Suggested
  by Chuq.

- Handle non-regular (!VREG) files correctly).

- Remove (no longer needed) FINGERPRINT_NOENTRY.
2005-06-19 18:22:36 +00:00
elad 97d75abb70 Oops. Don't allow file delete even if it's not monitored if we're in
lockdown mode (strict level 3).
2005-06-17 22:39:08 +00:00
elad ad7b01f7d0 More veriexec changes:
- Better organize strict level. Now we have 4 levels:
  - Level 0, learning mode: Warnings only about anything that might've
      resulted in 'access denied' or similar in a higher strict level.

  - Level 1, IDS mode:
    - Deny access on fingerprint mismatch.
    - Deny modification of veriexec tables.

  - Level 2, IPS mode:
    - All implications of strict level 1.
    - Deny write access to monitored files.
    - Prevent removal of monitored files.
    - Enforce access type - 'direct', 'indirect', or 'file'.

  - Level 3, lockdown mode:
    - All implications of strict level 2.
    - Prevent creation of new files.
    - Deny access to non-monitored files.

- Update sysctl(3) man-page with above. (date bumped too :)

- Remove FINGERPRINT_INDIRECT from possible fp_status values; it's no
  longer needed.

- Simplify veriexec_removechk() in light of new strict level policies.

- Eliminate use of 'securelevel'; veriexec now behaves according to
  its strict level only.
2005-06-17 17:46:18 +00:00
elad 8863b29522 Sync reality with comments. This makes strict level 1 work as expected.
Reported by Nino Dehne.
2005-06-14 21:55:21 +00:00