@@ -14,6 +14,19 @@ BUILDING
1414
1515See [ BUILD.md] ( ./BUILD.md ) for build-time dependencies and instructions for building.
1616
17+ DEPRECATION NOTICES
18+ -------------------
19+
20+ ### dir=untrusted rules
21+
22+ The ` dir=untrusted ` rule macro is deprecated and is planned for removal in the
23+ 2.1 release. Existing rules continue to parse for compatibility, but they emit
24+ a deprecation warning.
25+
26+ New policy should match trust explicitly. Use object trust rules for the file
27+ being controlled instead of relying on the legacy ` dir=untrusted ` path
28+ exception.
29+
1730POLICIES
1831--------
1932The current design for policy is that it is split up into units of rules
@@ -322,6 +335,11 @@ pressure. The metrics report includes rule hit counts, default-allow
322335fallthrough decisions, cache effectiveness, and subject/object attribute
323336lookup activity.
324337
338+ Starting with 1.6, status and metrics reports also identify the active
339+ configuration, ruleset, trust database, and LMDB environment generations. This
340+ helps correlate a report with the live state that was active after a reload,
341+ trust database rebuild, or controlled compaction.
342+
325343State and metrics reports can be scheduled periodically by setting the
326344configuration option ` report_interval ` . This option is set to ` 0 ` by default,
327345which disables the reporting interval. A positive value for this option
@@ -389,55 +407,70 @@ Starting with fapolicyd-1.3.8, there is a new performance option, ignore_mounts.
389407
390408MEMORY USAGE
391409------------
392- Fapolicyd uses lmdb as its trust database. The database has very fast
393- performance because it uses the kernel virtual memory system to put the
394- whole database in memory. If the database is sized wrongly, then fapolicyd
395- will reserve too much memory. Don't worry too much about this. The kernel is
396- very smart and doesn't actually allocate the memory unless its used. However,
397- we'd like to get it right sized.
410+ Fapolicyd uses LMDB as its trust database. LMDB is fast because it uses the
411+ kernel virtual memory system to map the database. The ` db_max_size `
412+ configuration option controls the maximum LMDB map size.
413+
414+ Starting with the 1.6 release, the shipped default is:
398415
399- Starting with the 0.9.3 version of fapolicyd, statistics about the database
400- is output when the program shuts down. On my system, it looks like this:
416+ ```
417+ db_max_size = auto
418+ ```
419+
420+ Users with an older numeric ` db_max_size ` setting should migrate to
421+ ` db_max_size = auto ` with this release unless they have a specific operational
422+ requirement for a fixed manual limit. Auto sizing starts from the historical
423+ 100 MiB baseline and lets the daemon grow or shrink the LMDB map as the trust
424+ database and package set change.
425+
426+ Auto sizing is also aware of reload headroom. A trust database reload builds a
427+ candidate generation while the current generation remains available to active
428+ readers. That means safe sizing needs room for the active trust database, the
429+ candidate generation, and LMDB copy-on-write metadata.
430+
431+ Use the status report to inspect the current trust database sizing state:
401432
402433```
403- Database max pages: 9728
404- Database pages in use: 7314 (75%)
434+ fapolicyd-cli --check-status
405435```
406436
407- This also correlates to the following setting in the fapolicyd.conf file :
437+ The most useful fields are :
408438
409439```
410- db_max_size = 38
440+ Trust database max pages
441+ Trust database pages in use
442+ Trust database allocated high-water pages
443+ Retired trust database generations
444+ Trust database resize recommended
445+ Trust database resize target
446+ Trust database compaction recommended
447+ Trust database compaction target
411448```
412449
413- This size is in megabytes. So, if you take that and multiply by 1024 * 1024,
414- we get 39845888. A page of memory is defined as 4096. So, if we divide
415- max_size by the page size, we get 9728 which matches the setting. Each entry
416- in the lmdb database is 512 bytes. So, for each 4k page, we can have data on
417- 8 trusted files.
450+ ` Trust database pages in use ` is the active trust database footprint.
451+ ` Trust database allocated high-water pages ` is LMDB's physical allocation
452+ high-water mark. The high-water value can be larger than active use after
453+ reload churn.
418454
419- An ideal size for the database is for the statistics to come up around 75% in
420- case you decide to install new software some day. The formula is
455+ Manual numeric values are not changed by the daemon. If a system keeps a
456+ manual ` db_max_size ` and the status report says resize is recommended, either
457+ set ` db_max_size ` to at least the reported target or migrate the system to:
421458
422459```
423- ( db_max_size x percentage in use) / desired percentage = new db_max_size
460+ db_max_size = auto
424461```
425462
426- So, working with example numbers, suppose max_size is 160 and it says it was
427- 68% occupied. That is wasting a little space. Putting the numbers in the
428- formula, we get (160 x 68) / 75 = 145.
463+ If the status report says compaction is recommended, use the controlled
464+ maintenance command:
429465
430- If you have an embedded system and are not using rpm. But instead use the file
431- trust source and you have a list of files, then your calculation is very
432- different. Suppose for the sake of discussion, you have 317 files that are
433- trusted. We take that number and divide by 8. We'll round that up to 40. Take
434- that number and multiply by 100 and divide by 75. We come up with 53.33. So,
435- let's call it 54. This is how many pages is needed. Turning that into real
436- memory, it's 216K. One megabyte is the smallest allocation, so you would set
437466```
438- db_max_size = 1
467+ sudo fapolicyd-cli --compact-trustdb
439468```
440469
470+ This rebuilds and validates a replacement LMDB environment, then swaps it into
471+ place during a controlled handoff. Normal package and trust file updates
472+ should still use ` fapolicyd-cli --update ` .
473+
441474Starting with the 0.9.4 release, the rpm backend filters most files in the
442475 /usr/share directory. It keeps anything with a with a python extension or
443476a libexec directory. It also keeps /usr/src/kernel so that Akmod can still
@@ -525,11 +558,11 @@ capabilities.
525558| --check-config | 1.1 | Parse fapolicyd.conf for syntax errors. |
526559| --check-trustdb | 1.1 | Check the trustdb against files on disk for mismatches that can cause run time problems. |
527560| --check-watch_fs | 1.1 | Compare mounted file systems with the watch_fs daemon configuration. |
528- | --check-status | 1.1.4 | Output daemon health and configuration state. |
561+ | --check-status | 1.1.4 | Output daemon health and configuration state. Starting in 1.6, active generations and trust DB sizing guidance. |
529562| --check-path | 1.1.5 | Check that every file in $PATH is in the trustdb. |
530563| --test-filter | 1.3.6 | Test a path against filter rules to see whether it will be trusted. |
531564| --check-ignore_mounts | 1.4 | Check ignored mounts for noexec and suspicious files. |
532- | --check-metrics | 1.5 | Output runtime counters, rule hits, cache effectiveness, and attribute lookup metrics. |
565+ | --check-metrics | 1.5 | Output runtime counters, rule hits, cache effectiveness, and attribute lookup metrics. Starting in 1.6, generation context. |
533566| --check-rules [ path] | 1.5 | Validate rule syntax without loading the rules; use --lint for policy-shape warnings. |
534567| --reset-metrics | 1.5 | Output metrics and request a counter reset when the daemon configuration allows it. |
535568| --timing-start | 1.5 | Start a manual decision timing collection run. |
@@ -596,10 +629,12 @@ database should be known files that will get executed. See the fapolicyd-filter.
596629man page for more information about writing filter rules.
597630
598631One last thing about the trustdb, lmdb is a very fast database. Normally it
599- works fine. But it does not tolerate malformed databases. When this happens,
600- it can segfault fapolicyd. The fix is to delete the database and restart
601- the daemon. It will then rebuild the database and work as it should. To do
602- this, run the following command:
632+ works fine. But it does not tolerate malformed databases. If the status report
633+ recommends compaction because the LMDB high-water mark is much larger than the
634+ active trust database, use ` fapolicyd-cli --compact-trustdb ` . If the database
635+ is malformed and cannot be opened, the fix is to delete the database and
636+ restart the daemon. It will then rebuild the database and work as it should.
637+ To do this, run the following command:
603638
604639```
605640fapolicyd-cli --delete-db
0 commit comments