Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/kern_fileassoc.c
RevisionDateAuthorComments
 1.38  28-Dec-2023  hannken Initialize mutex fileassoc_global.lock.
 1.37  02-Aug-2023  riastradh fileassoc(9): Fast paths to skip global locks when not in use.

PR kern/57552
 1.36  10-Jul-2014  christos table can't be NULL here.
 1.35  22-Jan-2012  rmind branches: 1.35.6; 1.35.20;
fileassoc_file_delete: pre-check whether fileassoc was used and thus avoid
acquiring kernel-lock, which damages sys_unlink() performance.
 1.34  25-Dec-2009  elad branches: 1.34.12; 1.34.16;
Oops - unintentional locking bit that's not yet ready.
 1.33  25-Dec-2009  elad This subsystem had leftovers from the time it was part of Veriexec, and then
from when I first implemented it as "metahook."

Cleanup a lot of the mess by unifying variable names, add struct member
prefixes, adjust comments, etc.

No functional change intended.
 1.32  25-Dec-2009  elad No need for these prototypes here.
 1.31  05-May-2008  ad - Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
 1.30  02-Jan-2008  ad branches: 1.30.6; 1.30.8; 1.30.10;
Merge vmlocking2 to head.
 1.29  15-May-2007  elad branches: 1.29.8; 1.29.14; 1.29.16; 1.29.20;
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.
 1.28  05-Apr-2007  rmind Revert the latest changes back to 1.25 rev.
 1.27  04-Apr-2007  rmind Fix tbl, which was misstyped as tlb.
 1.26  03-Apr-2007  rmind fileassoc_file_delete: Handle an error case of fileassoc_table_lookup().
CID: 4431
 1.25  09-Mar-2007  yamt branches: 1.25.2; 1.25.4;
fileassoc_table_lookup: call fileassoc_init if it has not been done yet.
fixes crashes sys_unlink when there are no users of fileassoc.
 1.24  08-Feb-2007  elad branches: 1.24.2;
remove empty line
 1.23  07-Feb-2007  elad - Properly autocreate tables,
- Properly track number of used slots in the table,
- Track number of "assocs" per entry.
 1.22  06-Feb-2007  elad 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@.
 1.21  26-Jan-2007  elad Add missing specificdata_key_delete() in fileassoc_deregister().
 1.20  25-Jan-2007  elad Update comment: device -> mount. No functional change.
 1.19  09-Jan-2007  elad Remove advertising clause from all of my stuff.
 1.18  26-Dec-2006  elad branches: 1.18.2;
Fix a comment. No functional change.
 1.17  23-Dec-2006  yamt - remove the fileassoc "tabledata" functionality. use mountspecific instead.
- make pax_segvguard_cb static.

tested and ok'ed by elad.
 1.16  14-Dec-2006  yamt - just associate fileassoc "table" to struct mount.
because the latter is always available during the lifetime of the former,
there is little point to use another global list to keep track of them.
it also allows to remove an #ifdef FILEASSOC.

- avoid some operations (memory allocation and VOP) in fileassoc_file_lookup,
when fileassoc table is not used.

ok'ed by elad.
 1.15  12-Dec-2006  yamt make fileassoc_tables static.
 1.14  11-Dec-2006  yamt - remove a static configuration, FILEASSOC_NHOOKS. do it dynamically instead.
- make fileassoc_t a pointer and remove FILEASSOC_INVAL.
- clean up kern_fileassoc.c. unify duplicated code.
- unexport fileassoc_init using RUN_ONCE(9).
- plug memory leaks in fileassoc_file_delete and fileassoc_table_delete.
- always call callbacks, regardless of the value of the associated data.

ok'ed by elad.
 1.13  08-Dec-2006  yamt don't expose FILEASSOC_NHOOKS.
 1.12  20-Nov-2006  elad compare pointer against null, not zero
 1.11  27-Oct-2006  elad Don't leak handle.
 1.10  08-Sep-2006  blymn branches: 1.10.2; 1.10.4;
* Correct hashing macro so it uses FHANDLE_SIZE()
* Stop fhandle memory leaks and use the correct fhandle dealloc routine
(thanks to Elad for these fixes)
* Remove include of kmem.h, it is not required.
 1.9  06-Sep-2006  blymn branches: 1.9.2;
* Remove "hinted" interface
* Modify fileassoc internals to use fhandle_t instead of fileid
 1.8  20-Aug-2006  blymn Add functions to the fileassoc interface to allow a "hint" to be provided
instead of performing an implicit VOP_GETATTR() when adding/looking up
fileassoc entries.
 1.7  13-Aug-2006  xtraeme Add __KERNEL_RCSID()
 1.6  11-Aug-2006  christos 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@.
 1.5  23-Jul-2006  ad branches: 1.5.2; 1.5.4;
Use the LWP cached credentials where sane.
 1.4  20-Jul-2006  cube Fix an obvious overlook (struct fileassoc_hook is not defined in
fileassoc.h anymore). I could say "please compile-test", but then, I'm not
doing it either for that commit.
 1.3  16-Jul-2006  elad expose less api; prompted by yamt@.
 1.2  15-Jul-2006  elad dont use magic numbers.
 1.1  14-Jul-2006  elad 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@.
 1.5.4.4  14-Sep-2006  yamt sync with head.
 1.5.4.3  03-Sep-2006  yamt sync with head.
 1.5.4.2  11-Aug-2006  yamt sync with head
 1.5.4.1  23-Jul-2006  yamt file kern_fileassoc.c was added on branch yamt-pdpolicy on 2006-08-11 15:45:46 +0000
 1.5.2.1  14-Aug-2006  tron Pull up following revision(s) (requested by elad in ticket #15):
sys/miscfs/specfs/spec_vnops.c: revision 1.88
share/man/man9/fileassoc.9: revision 1.7
sys/kern/kern_verifiedexec.c: revision 1.66
sys/sys/verified_exec.h: revision 1.39
sys/sys/fileassoc.h: revision 1.3
lib/libc/gen/sysctl.3: revision 1.178
share/man/man9/veriexec.9: revision 1.4
sys/kern/kern_fileassoc.c: revision 1.6
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@.
 1.9.2.4  09-Feb-2007  ad Sync with HEAD.
 1.9.2.3  01-Feb-2007  ad Sync with head.
 1.9.2.2  12-Jan-2007  ad Sync with head.
 1.9.2.1  18-Nov-2006  ad Sync with head.
 1.10.4.2  18-Dec-2006  yamt sync with head.
 1.10.4.1  10-Dec-2006  yamt sync with head.
 1.10.2.2  09-Sep-2006  rpaulo sync with head
 1.10.2.1  08-Sep-2006  rpaulo file kern_fileassoc.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:57:16 +0000
 1.18.2.5  21-Jan-2008  yamt sync with head
 1.18.2.4  03-Sep-2007  yamt sync with head.
 1.18.2.3  26-Feb-2007  yamt sync with head.
 1.18.2.2  30-Dec-2006  yamt sync with head.
 1.18.2.1  26-Dec-2006  yamt file kern_fileassoc.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:05 +0000
 1.24.2.2  17-May-2007  yamt sync with head.
 1.24.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.25.4.1  11-Jul-2007  mjf Sync with head.
 1.25.2.1  08-Jun-2007  ad Sync with head.
 1.29.20.1  02-Jan-2008  bouyer Sync with HEAD
 1.29.16.1  01-Jan-2008  ad fileassoc_file_delete: acquire kernel_lock.
 1.29.14.1  18-Feb-2008  mjf Sync with HEAD.
 1.29.8.1  09-Jan-2008  matt sync with HEAD
 1.30.10.2  11-Mar-2010  yamt sync with head
 1.30.10.1  16-May-2008  yamt sync with head.
 1.30.8.1  18-May-2008  yamt sync with head.
 1.30.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.34.16.1  18-Feb-2012  mrg merge to -current.
 1.34.12.1  17-Apr-2012  yamt sync with head
 1.35.20.1  10-Aug-2014  tls Rebase.
 1.35.6.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.

RSS XML Feed