-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Quentin JEROME <[email protected]>
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# the bug needs debug info so that it triggers | ||
[profile.release] | ||
debug = true | ||
|
||
[profile.dev] | ||
debug = true |
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,47 @@ | ||
// this file aims at reproducing the bug reported here: https://github.com/aya-rs/aya/issues/808 | ||
#![no_std] | ||
#![no_main] | ||
|
||
use aya_bpf::{helpers::bpf_get_prandom_u32, macros::kprobe, programs::ProbeContext}; | ||
use aya_log_ebpf::{error, info}; | ||
|
||
#[repr(C)] | ||
enum Error { | ||
Foo, | ||
Bar, | ||
} | ||
|
||
impl Error { | ||
const fn into_str(self) -> &'static str { | ||
match self { | ||
Self::Foo => "foo", | ||
Self::Bar => "bar", | ||
} | ||
} | ||
} | ||
|
||
#[kprobe] | ||
pub fn log_str_random(ctx: ProbeContext) -> u32 { | ||
match try_log_str_random(ctx) { | ||
Ok(ret) => ret, | ||
Err(ret) => ret, | ||
} | ||
} | ||
|
||
fn try_log_str_random(ctx: ProbeContext) -> Result<u32, u32> { | ||
let err = { | ||
if unsafe { bpf_get_prandom_u32() } % 2 == 0 { | ||
Error::Bar | ||
} else { | ||
Error::Foo | ||
} | ||
}; | ||
error!(&ctx, "{}", err.into_str()); | ||
Ok(0) | ||
} | ||
|
||
#[cfg(not(test))] | ||
#[panic_handler] | ||
fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} |
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