Skip to content

Commit

Permalink
kINT: Fix synchronization problem
Browse files Browse the repository at this point in the history
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:
f98da1b
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
  • Loading branch information
Adam-pi3 authored and solardiz committed Oct 25, 2023
1 parent 687c479 commit ee41d81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/modules/database/p_database.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ int p_create_database(void) {

P_SYM_INIT(jump_label_mutex)
P_SYM_INIT(text_mutex)
P_SYM_INIT(tracepoints_mutex)

/*
* First gather information about CPUs in the system - CRITICAL !!!
Expand Down
2 changes: 2 additions & 0 deletions src/modules/database/p_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ static inline void p_text_section_lock(void) {
mutex_lock(P_SYM(p_module_mutex));
while (mutex_is_locked(P_SYM(p_jump_label_mutex)))
schedule();
mutex_lock(P_SYM(p_tracepoints_mutex));
#if defined(P_LKRG_CI_ARCH_STATIC_CALL_TRANSFORM_H)
do {
p_lkrg_counter_lock_lock(&p_static_call_spinlock, &p_text_flags);
Expand All @@ -225,6 +226,7 @@ static inline void p_text_section_unlock(void) {
#if defined(P_LKRG_CI_ARCH_STATIC_CALL_TRANSFORM_H)
p_lkrg_counter_lock_val_dec(&p_static_call_spinlock);
#endif
mutex_unlock(P_SYM(p_tracepoints_mutex));
/* Release the 'module_mutex' */
mutex_unlock(P_SYM(p_module_mutex));
#if defined(CONFIG_DYNAMIC_FTRACE)
Expand Down
1 change: 1 addition & 0 deletions src/p_lkrg_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ typedef struct _p_lkrg_global_symbols_structure {
pmd_t *(*p_mm_find_pmd)(struct mm_struct *mm, unsigned long address);
struct mutex *p_jump_label_mutex;
struct mutex *p_text_mutex;
struct mutex *p_tracepoints_mutex;
struct text_poke_loc **p_tp_vec;
int *p_tp_vec_nr;
#if defined(CONFIG_DYNAMIC_DEBUG)
Expand Down

0 comments on commit ee41d81

Please sign in to comment.