[RISC-V64/Linux] mprotect(addr, SIZE_MAX, ...) returns success
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 60/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- linux, python
調査の方向性
The bug is in the POSIX mprotect handler at qiling/os/posix/syscall/mman.py around lines 65-73, which calls ql.mem.protect(start, mlen, prot) and returns success even when the range is rejected. Start by reading that handler and the memory protect call it depends on, then run the probe from the issue with SIZE_MAX as the length. Done means the SIZE_MAX request returns -1 with errno ENOMEM on RV64 Linux, while the one-page control still returns 0.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
On an RV64 Linux guest, Qiling returns success for mprotect() when the requested length is SIZE_MAX and the start address is a valid mapped page. Linux returns ENOMEM because the range extends beyond the guest address space. A normal one-page protection change succeeds as a control.
Sample Code
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <unistd.h>
int main(void)
{
void *page = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (page == MAP_FAILED)
return 2;
errno = 0;
long invalid = syscall(SYS_mprotect, page, (size_t)-1, PROT_READ);
int invalid_errno = errno;
void *control_page = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (control_page == MAP_FAILED)
return 3;
errno = 0;
long control = syscall(SYS_mprotect, control_page, 4096, PROT_READ);
int control_errno = errno;
printf("invalid=%ld errno=%d control=%ld control_errno=%d\n",
invalid, invalid_errno, control, control_errno);
return 0;
}
Compile this as a static RV64 Linux guest and run it with Qiling 1.4.11 and the dev branch:
riscv64-linux-gnu-gcc -static -O2 -Wall -Wextra mprotect_probe.c -o probe.elf
mkdir -p rootfs
cp probe.elf rootfs/probe.elf
python3 -c 'from qiling import Qiling; Qiling(["./rootfs/probe.elf"], "./rootfs").run()'
Qiling returns success for the SIZE_MAX request. Native Linux and QEMU RV64 return -1 with errno=ENOMEM; all tested runtimes return 0 for the one-page control.
Expected behavior
The overflowing range should fail with ENOMEM. The report covers the return value for a page-aligned mapped start and SIZE_MAX length; it does not claim the state of page permissions after the rejected request.
Additional context
Reproduced with Qiling v1.4.11 on RV64 Linux. Current dev commit 23ad4fd369a360ad7992d90cb7577f0241061c2b still calls ql.mem.protect(start, mlen, prot) and returns success if that call silently rejects the invalid range; see mman.py. The current dev source was checked statically, not dynamically run for this report.
- 主要言語
- Python
- スター
- 6.2k
- フォーク
- 806
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
qilingframework/qiling のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
qilingframework/qiling#1690 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
qilingframework/qiling#1689 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
qilingframework/qiling#1688 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
qilingframework/qiling#1686 ·
-
難易度 2/5 半日 初心者へのやさしさ 82/100
qilingframework/qiling#1640 ·
qilingframework/qiling の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
huggingface/datasets#9128 ·
メンテナーはふだん 1 日以内に返信
-
priority:low ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
OpenHands/extensions#975 ·
メンテナーはふだん 1 日以内に返信
-
Function/dict state handlers can't supply provider-state injected values (`generate.provider_state`)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pact-foundation/pact-python#1789 ·
メンテナーはふだん 9 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
juandresrodca/AdminForge#66 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信