-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #61: issue with kretprobe not surviving to suspend/resume cycle
Signed-off-by: qjerome <qjerome@rawsec.lu>
- Loading branch information
Showing
8 changed files
with
311 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::bpf_events::Event; | ||
|
||
pub type SysCoreResumeEvent = Event<SysCoreResumeData>; | ||
|
||
#[repr(C)] | ||
pub struct SysCoreResumeData {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use aya_ebpf::programs::ProbeContext; | ||
|
||
use super::*; | ||
|
||
// this probe is hit when the system is resumed, it is a way to | ||
// create a trigger for program reload as a bug has been identified | ||
// for some kretprobes not surviving to a suspend/resume cycle | ||
// https://bugzilla.kernel.org/show_bug.cgi?id=218775 | ||
#[kprobe(function = "syscore_resume")] | ||
pub fn enter_syscore_resume(ctx: ProbeContext) -> u32 { | ||
match unsafe { try_syscore_resume(&ctx) } { | ||
Ok(_) => errors::BPF_PROG_SUCCESS, | ||
Err(s) => { | ||
error!(&ctx, s); | ||
errors::BPF_PROG_FAILURE | ||
} | ||
} | ||
} | ||
|
||
unsafe fn try_syscore_resume(ctx: &ProbeContext) -> ProbeResult<()> { | ||
let evt = alloc::alloc_zero::<SysCoreResumeEvent>()?; | ||
|
||
evt.init_from_current_task(Type::SyscoreResume)?; | ||
|
||
pipe_event(ctx, evt); | ||
Ok(()) | ||
} |
Oops, something went wrong.