Linux host2.homegym.sg 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64
Apache
Server IP : 159.223.38.192 & Your IP : 159.223.38.192
Domains : 20 Domain
User : eachadea
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Lock Shell
Lock File++
Readme
/
usr /
src /
file_protector-1.1-1572 /
Delete
Unzip
Name
Size
Permission
Date
Action
common
[ DIR ]
drwxr-xr-x
2025-08-06 21:51
ftrace_hooks
[ DIR ]
drwxr-xr-x
2025-08-06 21:51
lsm_hooks
[ DIR ]
drwxr-xr-x
2025-08-06 21:51
syscall_hooks
[ DIR ]
drwxr-xr-x
2025-08-06 21:51
transport
[ DIR ]
drwxr-xr-x
2025-08-06 21:51
Kbuild
10.29
KB
-rw-r--r--
2025-08-06 21:51
Makefile
2.23
KB
-rw-r--r--
2025-08-06 21:51
compat.c
8.38
KB
-rw-r--r--
2025-08-06 21:51
compat.h
11.98
KB
-rw-r--r--
2025-08-06 21:51
debug.h
3.56
KB
-rw-r--r--
2025-08-06 21:51
dkms.conf
146
B
-rw-r--r--
2025-08-06 21:51
file_contexts.c
52.97
KB
-rw-r--r--
2025-08-06 21:51
file_contexts.h
2.86
KB
-rw-r--r--
2025-08-06 21:51
file_contexts_priv.h
5.33
KB
-rw-r--r--
2025-08-06 21:51
file_handle_tools.h
2.23
KB
-rw-r--r--
2025-08-06 21:51
file_key_tools.h
950
B
-rw-r--r--
2025-08-06 21:51
file_path_tools.h
2.09
KB
-rw-r--r--
2025-08-06 21:51
hashtable_compat.h
2.73
KB
-rw-r--r--
2025-08-06 21:51
hook_trampoline_common.h
4.29
KB
-rw-r--r--
2025-08-06 21:51
interval_tree.h
779
B
-rw-r--r--
2025-08-06 21:51
memory.c
3.31
KB
-rw-r--r--
2025-08-06 21:51
memory.h
2.99
KB
-rw-r--r--
2025-08-06 21:51
module.c
2.67
KB
-rw-r--r--
2025-08-06 21:51
module_ref.h
421
B
-rw-r--r--
2025-08-06 21:51
module_rundown_protection.c
3.64
KB
-rw-r--r--
2025-08-06 21:51
module_rundown_protection.h
743
B
-rw-r--r--
2025-08-06 21:51
path_tools.h
5.84
KB
-rw-r--r--
2025-08-06 21:51
rundown_protection.c
4.2
KB
-rw-r--r--
2025-08-06 21:51
rundown_protection.h
2.83
KB
-rw-r--r--
2025-08-06 21:51
safe_kobject.h
1.28
KB
-rw-r--r--
2025-08-06 21:51
si_common.h
4.23
KB
-rw-r--r--
2025-08-06 21:51
si_fp_properties.h
858
B
-rw-r--r--
2025-08-06 21:51
si_fp_properties_x.h
16.77
KB
-rw-r--r--
2025-08-06 21:51
si_fp_value_types.h
515
B
-rw-r--r--
2025-08-06 21:51
si_fp_value_types_x.h
1.25
KB
-rw-r--r--
2025-08-06 21:51
si_size.h
4.15
KB
-rw-r--r--
2025-08-06 21:51
si_templates.h
2.39
KB
-rw-r--r--
2025-08-06 21:51
si_writer.h
6.93
KB
-rw-r--r--
2025-08-06 21:51
si_writer_common.h
12.27
KB
-rw-r--r--
2025-08-06 21:51
stringify.h
261
B
-rw-r--r--
2025-08-06 21:51
task_info_map.c
14.61
KB
-rw-r--r--
2025-08-06 21:51
task_info_map.h
6.33
KB
-rw-r--r--
2025-08-06 21:51
task_info_map_common.h
4.15
KB
-rw-r--r--
2025-08-06 21:51
task_tools.h
1.34
KB
-rw-r--r--
2025-08-06 21:51
tracepoints.c
3.58
KB
-rw-r--r--
2025-08-06 21:51
tracepoints.h
299
B
-rw-r--r--
2025-08-06 21:51
write_protection.h
2.2
KB
-rw-r--r--
2025-08-06 21:51
Save
Rename
/** @file rundown_protection.cpp @brief Rundown Protection implementation for Linux kernel @details Copyright (c) 2022 Acronis International GmbH @author Denis Kopyrin (Denis.Kopyrin@acronis.com) @since $Id: $ */ #include "rundown_protection.h" #include "debug.h" #define RP_RUNDOWN_ACTIVE 1 #define RP_RUNDOWN_COUNT_SHIFT 1 #define RP_RUNDOWN_COUNT_INC (1 << RP_RUNDOWN_COUNT_SHIFT) #define RP_LOG IPRINTF static inline void rundown_wait_block_init(rundown_wait_block_t *rwb, rundown_protection_finalizer_t finalizer, void *finalizer_ctx) { atomic64_set(&rwb->ref_cnt, 0); init_waitqueue_head(&rwb->wait_queue); rwb->finalizer = finalizer; rwb->finalizer_ctx = finalizer_ctx; } static inline void rundown_wait_block_wait(rundown_wait_block_t *rwb) { wait_event(rwb->wait_queue, 0 == atomic64_read(&rwb->ref_cnt)); } static inline long rundown_wait_block_wait_timeout(rundown_wait_block_t *rwb, unsigned long timeout_jiffies) { return wait_event_timeout(rwb->wait_queue, 0 == atomic64_read(&rwb->ref_cnt), timeout_jiffies); } static inline int64_t rundown_wait_block_decrement_count_and_notify(rundown_wait_block_t *rwb) { int64_t leftCount = atomic64_sub_return(1, &rwb->ref_cnt); if (0 == leftCount) { wake_up(&rwb->wait_queue); if (rwb->finalizer) { IPRINTF("Invoking finalizer"); rwb->finalizer(rwb->finalizer_ctx); IPRINTF("Finalizer completed"); } } return leftCount; } static inline void rundown_wait_block_add_count(rundown_wait_block_t *rwb, int64_t cnt) { atomic64_add(cnt, &rwb->ref_cnt); } static inline int64_t rundown_wait_block_get_count(rundown_wait_block_t *rwb) { return atomic64_read(&rwb->ref_cnt); } void simple_rundown_protection_init(simple_rundown_protection_t *srp, rundown_protection_finalizer_t finalizer, void *finalizer_ctx, bool ready) { atomic64_set(&srp->data, ready ? 0 : RP_RUNDOWN_ACTIVE); rundown_wait_block_init(&srp->wait_block, finalizer, finalizer_ctx); } bool simple_rundown_protection_lock(simple_rundown_protection_t *srp) { int64_t old_value, new_value; do { old_value = atomic64_read(&srp->data); if (old_value & RP_RUNDOWN_ACTIVE) return false; new_value = old_value + RP_RUNDOWN_COUNT_INC; } while(old_value != atomic64_cmpxchg(&srp->data, old_value, new_value)); return true; } void simple_rundown_protection_unlock(simple_rundown_protection_t *srp) { int64_t value; while (true) { value = atomic64_read(&srp->data); if (!(value & RP_RUNDOWN_ACTIVE)) { // active int64_t new_value = value - RP_RUNDOWN_COUNT_INC; if (value == atomic64_cmpxchg(&srp->data, value, new_value)) return; } else { // rundown int64_t cnt; RP_LOG("releasing count..."); cnt = rundown_wait_block_decrement_count_and_notify(&srp->wait_block); RP_LOG("released count, left=%lld", cnt); return; } } } void simple_rundown_protection_set_rundown_active(simple_rundown_protection_t *srp) { int64_t count; int64_t value = atomic64_cmpxchg(&srp->data, 0, RP_RUNDOWN_ACTIVE); RP_LOG(""); if (value & RP_RUNDOWN_ACTIVE) return; do { value = atomic64_read(&srp->data); } while(value != atomic64_cmpxchg(&srp->data, value, RP_RUNDOWN_ACTIVE)); count = value >> RP_RUNDOWN_COUNT_SHIFT; rundown_wait_block_add_count(&srp->wait_block, count); RP_LOG("switched block count, left to wait for %lld unlocks", count); } void simple_rundown_protection_wait_for_rundown(simple_rundown_protection_t *srp) { RP_LOG("waiting..."); rundown_wait_block_wait(&srp->wait_block); RP_LOG("waiting done"); } static const char *convert_wait_result_to_string(long ret) { if (0 == ret) { return "timeout"; } else if (ret < 0) { return "interrupted"; } else { return "ok"; } } bool simple_rundown_protection_wait_for_rundown_timeout(simple_rundown_protection_t *srp, unsigned long timeout_jiffies) { long res; RP_LOG("waiting..."); res = rundown_wait_block_wait_timeout(&srp->wait_block, timeout_jiffies); RP_LOG("waiting done : %s[%ld]", convert_wait_result_to_string(res), res); return res > 0; } void simple_rundown_protection_set_ready(simple_rundown_protection_t *srp) { atomic64_set(&srp->data, 0); } int64_t simple_rundown_protection_get_pending_count(simple_rundown_protection_t *srp) { return rundown_wait_block_get_count(&srp->wait_block); }