Commit graph

380 commits

Author SHA1 Message Date
Solar Designer
3760e0e1bd Fix support for RHEL 9.0
This was very briefly broken with the previous commit
2023-11-08 19:50:58 +01:00
Adam_pi3
310e85d19c Add support for RHEL 8.8
A new 'text_poke_loc' was backported to RHEL 8.8+. This commit brings
the support for such kernels as well as addresses the #295 problem.
2023-11-08 19:39:30 +01:00
Adam_pi3
ee41d81599 kINT: Fix synchronization problem
The reported problem with integrity verification on ARM64 (#269)
is a result of a very tight race condition with tracepoints.
Changes which simplify synchronization with JUMP_LABEL engine:
f98da1b17c
affected differently ARM64 platform which made such race possible.
However, potentially the same race problem may exist on x86 and
this commit fixes it and should address #269
2023-10-25 14:56:11 +02:00
Adam_pi3
687c4790cd
kINT: P_LKRG_JUMP_LABEL_STEXT_DEBUG: bump log level
... for better debuggability. If non standard P_LKRG_JUMP_LABEL_STEXT_DEBUG
is enabled, it means that LKRG is being actively debugged.
In that case, we want to avoid unnecessary noise.
2023-10-24 09:46:15 +00:00
Solar Designer
55d28c9f23 Stop using register_sysctl_table()
This is needed for post-6.4 kernels.

Fixes #280
2023-07-15 19:45:48 -08:00
fluidog
001768de0c Simplify the use of P_SYM_INIT() 2023-05-19 14:09:29 +02:00
Adam_pi3
3d8e52e90b
Add support for Linux kernel post-6.3
Linux kernel post-6.3 modified the 'struct module' and introduced a new
substructure describing module's memory layout. Additionally, the logic for
dynamic debug (ddebug) has been modified and some of the functions which LKRG
uses are no longer exported. This commit adopts to these post-6.3 changed and
addresses #267
2023-05-03 00:47:51 +00:00
Solar Designer
f37b478d25 p_exploit_detection.c: Add static keywords to ease code review 2023-03-19 15:18:55 +01:00
Vladimir D. Seleznev
eaf8347646 RHEL 9.2 5.14.0-248.el9 aarch64: rename stackframe to unwind_state 2023-02-11 06:39:24 +00:00
RageLtMan
ef52dec6e1 Add UMH modprobe path for Arch Linux init context
Address #258 by adding /usr/bin/modprobe to the UMH allow-list.
2023-02-03 06:48:33 +00:00
Adam_pi3
0e46fc41a5
Add support for RHEL 9.1
Starting from kernel 5.14.0-162.12.1 (RHEL 9.1), a new 'text_poke_loc'
structure is used. This commit brings the support for such kernels as
well as addresses the #256 problem
2023-02-02 03:03:35 +00:00
Solar Designer
0fdb556076 kINT: P_LKRG_JUMP_LABEL_STEXT_DEBUG: Fix sign extension bug 2023-01-30 22:40:20 +01:00
Adam_pi3
26f36ed495 Add a kprobe verification functionality
Add a new logic to the integrity verification routine verifying if the
kprobes are enabled and correctly run.
This commit makes kprobe verification functionality as an independent
module invoked by integrity verification routine as well as during
initialization to make sure kprobes are enabled and run as intended
(otherwise, initialization fails).
2022-12-04 21:31:22 +01:00
Adam_pi3
1fc5312223 Add synchronization logic around sysctl interface
This commit fixes the race problem between 2+ concurrent sysctl updates.
It is part of the work related to #204
2022-11-19 19:55:46 +01:00
redp
2cd2c2bc00 add get_kprobe_maxactive to remaining kprobes
Co-authored-by: Solar Designer <solar@openwall.com>
2022-11-10 21:58:02 +01:00
redp
6736d568dc kretprobes.maxactive should depend on number of cores
Co-authored-by: Solar Designer <solar@openwall.com>
2022-11-10 21:58:02 +01:00
Solar Designer
3f7af09f5b UMH: Allow /usr/libexec/abrt-hook-ccpp for older Red Hat distros 2022-11-10 21:57:48 +01:00
Solar Designer
fc3545696b pINT: Make the real_cred check in p_cmp_tasks() unconditional
Fixes #240
2022-11-05 18:39:49 +01:00
Adam_pi3
ad03367344 Add support for new RHEL8.6+ kernels
Starting from RHEL8.6 4.18.0-372.32.1.el8_6 kernel struct text_poke_loc
is not exported and we need to correctly take this into account.
Previous RHEL8.6 kernels did not hide this structure so we need to find
some ways to disinguish them. We do it in this commit and it should fix #236
2022-11-05 18:38:12 +01:00
Vladimir D. Seleznev
a4e5c00f13 Add support for Kernel 5.19+ for aarch64
Since Linux Kernel 5.19 struct stackframe has been renamed to struct
unwind_state for arm64:

torvalds/linux@e9d75a0ba8
2022-11-05 14:15:44 +01:00
Vladimir D. Seleznev
8fbdbda372 Add support for RHEL 9.2 kernel
Reported-by: Alexey Gladkov <legion@altlinux.ru>
Signed-off-by: Vladimir D. Seleznev <vseleznv@altlinux.org>
2022-10-31 21:24:05 +01:00
Solar Designer
f32f627950 Simplify our get_random_long() wrapper (only used with old kernels)
Fixes #234
2022-10-17 22:20:20 +02:00
Solar Designer
11553ec0df Notifiers: Fix typo in the value of P_M_SS_MORE_OFTEN_RATE
Noticed by Jason A. Donenfeld
2022-10-17 22:20:20 +02:00
Solar Designer
2241a32231 Don't depend on get_random_int(), which Linux 6.1+ dropped
Fixes #233
2022-10-17 22:20:20 +02:00
Adam_pi3
717137dbd2
Remove IOMMU verification on kernel 5.19+
IOMMU table infrastructure was removed by this commit
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78013eaadf696d2105982abb4018fbae394ca08f

which breaks the way how LKRG could verify it.
This commit skips the IOMMU verification starting from kernels 5.19+
and fixes #226
2022-09-25 00:09:01 +00:00
mrl5
d7f079baa1 fix: umh - allow openrc cgroup release agent [#230]
closes #230
2022-09-11 03:34:53 +00:00
Solar Designer
333ae0774e Revert "Logging: Use KERN_EMERG in place of KERN_CRIT"
This reverts commit dfb60a6eb2.
2022-08-01 13:13:25 +02:00
Solar Designer
c58cb52145 Simplify the new logic supporting OverlayFS 2022-07-29 10:35:23 -07:00
Adam_pi3
6f3627e32c Rework the logic supporting OverlayFS/docker
The original logic was hooking 'ovl_create_or_link' function but it could be
inlined. This commit changes it by hooking 'ovl_dentry_is_whiteout' when
possible.

Fixes #215
2022-07-29 13:50:45 +02:00
Solar Designer
dfb60a6eb2 Logging: Use KERN_EMERG in place of KERN_CRIT
Fixes #222
2022-07-28 16:30:23 -07:00
Solar Designer
e773798649 kINT: Support variable length jump labels also for 5.10.133+
Extends b8ff7abcd0
Extends fb9e272f7d
Fixes #221
2022-07-28 16:30:23 -07:00
Solar Designer
ce3016b49a pCFI: Increase severity of "Frame pointer is not on the stack" 2022-07-21 21:47:37 +02:00
Solar Designer
f5286727b4 pCFI: Avoid skipping of stack frame checks when CONFIG_UNWINDER_ORC
Fixes #210
2022-07-21 21:47:37 +02:00
Solar Designer
a14d81e81f Logging: Make logging of sysctl value changes more consistent
Skip logging on no change and include old values for interval and
log_level, like we do for others.

Fixes #211
2022-07-21 21:47:37 +02:00
Solar Designer
93eda28b8b Logging: kINT: Don't skip any checks regardless of log level
The checks we tried to skip updated "p_mod_bad_nr", which affected how we
treat further violations.

Amends 8b7d68a4c7
Fixes #212
2022-07-21 21:47:37 +02:00
Solar Designer
49a3117542 Rename the module from p_lkrg to lkrg 2022-07-20 17:57:37 +02:00
Solar Designer
0f0f74fbcb Logging: Wrap panic() in a macro, log an alert before panic 2022-07-17 20:39:31 +00:00
Solar Designer
4e7dd0951f Logging: Expose the STATE, DYING, FATAL categories 2022-07-17 20:39:31 +00:00
Solar Designer
8b7d68a4c7 Logging: kINT: Change extra module messages from ALERT to WATCH
It was inconsistent to produce "alerts" that did not invoke any response
action, whereas downgrading them to informational messages lets us skip
a lengthy block of checks at default log level.
2022-07-17 20:39:31 +00:00
Solar Designer
e3badfaf73 Logging: Revise, unify, and reduce duplication of logging and responses
Use macros, move logging and enforcement responses from callers into
called functions, remove where it was duplicate.

Unify our log and kernel panic messages.
2022-07-17 20:39:31 +00:00
Solar Designer
f4dc1e31a9 Unify kernel symbol lookups through introduction of a macro 2022-07-17 20:39:31 +00:00
Solar Designer
4b9a74ad51 Logging: Revise messages from sysctl handlers 2022-07-17 20:39:31 +00:00
Solar Designer
68f649bb0c Logging: Replace '\n' within log messages with ' ' (space character)
sed -i 's/\\n/ /g' src/modules/database/p_database.c src/modules/integrity_timer/p_integrity_timer.c
2022-07-17 20:39:31 +00:00
Solar Designer
33dfb1474f Logging: Move trailing '\n' to inside of p_print_log()
sed -i 's/\\n"/"/g' `fgrep -rl '\n"' src`

Followed by manual re-alignment of trailing backslashes in a few places,
and indeed the edit of p_print_log().
2022-07-17 20:39:31 +00:00
Solar Designer
7956c28836 Drop trailing '\n' from panic() messages
panic() removes and re-adds them anyway:

	if (len && buf[len - 1] == '\n')
		buf[len - 1] = '\0';

	pr_emerg("Kernel panic - not syncing: %s\n", buf);
2022-07-17 20:39:31 +00:00
Solar Designer
08ff518bf9 Logging: Have P_TRY_OFFLOAD_NOTIFIER() construct messages 2022-07-17 20:39:31 +00:00
Solar Designer
db46f714ed Logging: Consistently use p_debug_log() for P_LOG_DEBUG messages 2022-07-17 20:39:31 +00:00
Solar Designer
24f7029ac3 Logging: Rename log severity macros
sed -i 's/P_LOG_LEVEL_MIN/P_LOG_MIN/g' `fgrep -rl P_LOG_LEVEL_MIN src`
sed -i 's/P_LOG_LEVEL_MAX/P_LOG_MAX/g' `fgrep -rl P_LOG_LEVEL_MAX src`
sed -i 's/P_LKRG_CRIT/P_LOG_ALERT/g' `fgrep -rl P_LKRG_CRIT src`
sed -i 's/P_LKRG_ALIVE/P_LOG_ALIVE/g' `fgrep -rl P_LKRG_ALIVE src`
sed -i 's/P_LKRG_ERR/P_LOG_FAULT/g' `fgrep -rl P_LKRG_ERR src`
sed -i 's/P_LKRG_WARN/P_LOG_ISSUE/g' `fgrep -rl P_LKRG_WARN src`
sed -i 's/P_LKRG_INFO/P_LOG_WATCH/g' `fgrep -rl P_LKRG_INFO src`
sed -i 's/P_LKRG_DBG/P_LOG_DEBUG/g' `fgrep -rl P_LKRG_DBG src`
sed -i 's/P_LKRG_STRONG_DBG/P_LOG_FLOOD/g' `fgrep -rl P_LKRG_STRONG_DBG src`

Followed by manual re-alignment of trailing backslashes in a few places.
2022-07-17 20:39:31 +00:00
Solar Designer
849e7e5dd9 Logging: Drop hard-coded "ERROR: " from more messages 2022-07-17 20:39:31 +00:00
Solar Designer
9f9ae6ff52 Logging: Drop hard-coded "ERROR: " from beginnings of messages
sed -i 's/"ERROR: /"/' `fgrep -lr '"ERROR: ' src`
2022-07-17 20:39:31 +00:00