Blame SOURCES/fapolicyd-falcon-sensor.patch

1bfbac
diff -up ./src/library/event.c.event ./src/library/event.c
1bfbac
--- ./src/library/event.c.event	2022-06-21 16:55:47.000000000 +0200
1bfbac
+++ ./src/library/event.c	2022-12-22 13:12:58.226816235 +0100
1bfbac
@@ -132,7 +132,15 @@ int new_event(const struct fanotify_even
1bfbac
 		if ((s->info->state == STATE_COLLECTING) &&
1bfbac
 			(e->type & FAN_OPEN_PERM) && !rc) {
1bfbac
 			skip_path = 1;
1bfbac
+
1bfbac
 			s->info->state = STATE_REOPEN;
1bfbac
+
1bfbac
+			// special branch after ld_so exec
1bfbac
+			// next opens will go fall trough
1bfbac
+			if (s->info->path1 &&
1bfbac
+				(strcmp(s->info->path1, SYSTEM_LD_SO) == 0))
1bfbac
+				s->info->state = STATE_DEFAULT_REOPEN;
1bfbac
+
1bfbac
 		}
1bfbac
 
1bfbac
 		// If not same proc or we detect execution, evict
1bfbac
@@ -149,7 +157,6 @@ int new_event(const struct fanotify_even
1bfbac
 				skip_path = 1;
1bfbac
 			}
1bfbac
 			evict = 0;
1bfbac
-			skip_path = 1;
1bfbac
 			subject_reset(s, EXE);
1bfbac
 			subject_reset(s, COMM);
1bfbac
 			subject_reset(s, EXE_TYPE);
1bfbac
@@ -165,6 +172,7 @@ int new_event(const struct fanotify_even
1bfbac
 			skip_path = 1;
1bfbac
 		}
1bfbac
 
1bfbac
+
1bfbac
 		// If we've seen the reopen and its an execute and process
1bfbac
 		// has an interpreter and we're the same process, don't evict
1bfbac
 		// and don't collect the path since reopen interp will. The
1bfbac
@@ -173,14 +181,25 @@ int new_event(const struct fanotify_even
1bfbac
 		if ((s->info->state == STATE_REOPEN) && !skip_path &&
1bfbac
 				(e->type & FAN_OPEN_EXEC_PERM) &&
1bfbac
 				(s->info->elf_info & HAS_INTERP) && !rc) {
1bfbac
+			s->info->state = STATE_DEFAULT_REOPEN;
1bfbac
 			evict = 0;
1bfbac
 			skip_path = 1;
1bfbac
 		}
1bfbac
 
1bfbac
+
1bfbac
+		// this is what differs between STATE_REOPEN and
1bfbac
+		// STATE_DEFAULT_REOPEN
1bfbac
+		// in STATE_REOPEN path is always skipped
1bfbac
+		if ((s->info->state == STATE_REOPEN) && !skip_path &&
1bfbac
+				(e->type & FAN_OPEN_PERM) && !rc) {
1bfbac
+			skip_path = 1;
1bfbac
+		}
1bfbac
+
1bfbac
 		if (evict) {
1bfbac
 			lru_evict(subj_cache, key);
1bfbac
 			q_node = check_lru_cache(subj_cache, key);
1bfbac
 			s = (s_array *)q_node->item;
1bfbac
+
1bfbac
 		} else if (s->cnt == 0)
1bfbac
 			msg(LOG_DEBUG, "cached subject has cnt of 0");
1bfbac
 	}
1bfbac
diff -up ./src/library/process.h.event ./src/library/process.h
1bfbac
--- ./src/library/process.h.event	2022-06-21 16:55:47.000000000 +0200
1bfbac
+++ ./src/library/process.h	2022-12-22 13:10:23.260996771 +0100
1bfbac
@@ -31,7 +31,8 @@
1bfbac
 #include "gcc-attributes.h"
1bfbac
 
1bfbac
 typedef enum {	STATE_COLLECTING=0,	// initial state - execute
1bfbac
-		STATE_REOPEN,		// anticipating open perm next
1bfbac
+		STATE_REOPEN,		// anticipating open perm next, always skips the path
1bfbac
+		STATE_DEFAULT_REOPEN,  // reopen after dyn. linker exec, never skips the path
1bfbac
 		STATE_STATIC_REOPEN,	// static app aniticipating
1bfbac
 		STATE_PARTIAL,		// second path collected
1bfbac
 		STATE_STATIC_PARTIAL,	// second path collected