-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4174b03
commit ffcd324
Showing
8 changed files
with
229 additions
and
133 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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod bpf_probe_read; | ||
mod btf_relocations; | ||
mod elf; | ||
mod inode_storage; | ||
mod load; | ||
mod log; | ||
mod rbpf; | ||
|
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,49 @@ | ||
use std::{ | ||
error::Error, | ||
fs::OpenOptions, | ||
os::{fd::IntoRawFd, unix::fs::OpenOptionsExt}, | ||
}; | ||
|
||
use aya::{programs::Lsm, Ebpf}; | ||
use aya_obj::btf::Btf; | ||
use libc::{linkat, AT_EMPTY_PATH, AT_FDCWD, O_TMPFILE}; | ||
|
||
use crate::INODE_STORAGE_TEST; | ||
|
||
#[test] | ||
fn no_link_to_tmp() -> Result<(), Box<dyn Error>> { | ||
let mut bpf = Ebpf::load(INODE_STORAGE_TEST)?; | ||
let btf = Btf::from_sys_fs()?; | ||
|
||
let rename: &mut Lsm = bpf | ||
.program_mut("inode_post_create_tmpfile") | ||
.unwrap() | ||
.try_into()?; | ||
rename.load("inode_post_create_tmpfile", &btf)?; | ||
rename.attach()?; | ||
|
||
let link: &mut Lsm = bpf.program_mut("inode_link").unwrap().try_into()?; | ||
link.load("inode_link", &btf)?; | ||
link.attach()?; | ||
|
||
// create a temporary file | ||
let tmpfile = OpenOptions::new() | ||
.custom_flags(O_TMPFILE) | ||
.create_new(true) | ||
.open("/tmp/")?; | ||
|
||
let fd = tmpfile.into_raw_fd(); | ||
let res = unsafe { | ||
linkat( | ||
fd, | ||
c"".as_ptr(), | ||
AT_FDCWD, | ||
c"/tmp/blah".as_ptr(), | ||
AT_EMPTY_PATH, | ||
) | ||
}; | ||
|
||
assert_eq!(130, res); | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.