AFLplusplus / AFLplusplus/LibAFL

`ShMem` should probably require stored values to be `Sync`

オープン
#2,809 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Rust
スター
2.6k
フォーク
481
平均マージ
2日 30分
マージ済み PR(30日)
16

説明

`ShMem` can be used to create data-races if you use it to store non-`Sync` types such as `Cell`. For example, the assertion at the end of the following program fails:
```rust
use std::cell::Cell;

use libafl_bolts::os::{fork, ForkResult};
use libafl_bolts::shmem::{ShMem, ShMemProvider as _};

fn do_stuff(shmem: &impl ShMem) {
let p = shmem.as_ptr_of::>().unwrap();
for i in 0..128 {
let val = unsafe { (*p).get() };
println!("val = {val}");
unsafe { (*p).set(val + 1) };
}
}

fn main() {
let mut shmem_provider = libafl_bolts::shmem::MmapShMemProvider::default();
let shmem = shmem_provider.new_on_shmem(Cell::new(0usize)).unwrap();
shmem_provider.pre_fork().unwrap();
match unsafe { fork() }.unwrap() {
ForkResult::Parent(handle) => {
shmem_provider.post_fork(false).unwrap();
do_stuff(&shmem);
handle.status();
}
ForkResult::Child => {
shmem_provider.post_fork(true).unwrap();
do_stuff(&shmem);
std::process::abort();
}
}
let p = shmem.as_ptr_of::>().unwrap();
assert_eq!(256, unsafe { (*p).get() });
}
```
Of course, you can *also* create data-races just by using `as_mut_ptr`... But fixing that would require a whole different design, whereas it would be pretty easy to add a `Sync` bound to `ShMemProvider::new_on_shmem`, `ShMem::as_ptr_of`, etc..

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by locating the ShMemProvider::new_on_shmem and ShMem::as_ptr_of entry points, then inspect the related as_mut_ptr APIs and the shared-memory example in the issue. Confirm which stored-value and pointer operations need Sync bounds, and consider existing tests around these APIs; done means non-Sync values such as Cell cannot be accepted through the affected safe interfaces.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。