[RISC-V64/Linux] ftruncate succeeds on an O_RDONLY descriptor
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 66/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Start in the ftruncate handler in qiling/os/posix/syscall/unistd.py, which passes the host path to a path-based truncate helper. Check how the guest fd is mapped to its open file and whether its access mode is available there. Reproduce with the C probe from the issue on an RV64 rootfs. Done when ftruncate on an O_RDONLY descriptor returns EBADF and leaves the file size unchanged.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
On an RV64 Linux guest, ftruncate(fd, 0) succeeds when fd was opened with O_RDONLY, and the file is truncated. Linux returns EBADF for ftruncate on a descriptor that is not open for writing and leaves the file unchanged.
Sample Code
Create rootfs/scratch with the contents abc, then run this static RV64 guest:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void)
{
int fd = open("/scratch", O_RDONLY);
if (fd < 0)
return 2;
errno = 0;
int rc = ftruncate(fd, 0);
int err = errno;
struct stat st;
if (stat("/scratch", &st) != 0)
return 3;
printf("rc=%d errno=%d size=%ld\n", rc, err, (long)st.st_size);
return 0;
}
riscv64-linux-gnu-gcc -static -O2 -Wall -Wextra ftruncate_probe.c -o probe.elf
mkdir -p rootfs
printf abc > rootfs/scratch
cp probe.elf rootfs/probe.elf
python3 -c 'from qiling import Qiling; Qiling(["./rootfs/probe.elf"], "./rootfs").run()'
Linux returns -1/EBADF and leaves the size at 3. Qiling returns success and the size becomes 0.
Expected behavior
Qiling should check that the guest descriptor is open for writing before changing the file length. The current ftruncate handler passes the host path to a path-based truncate helper, which does not check the guest descriptor's access mode.
Additional context
Reproduced on Qiling v1.4.11 and the development snapshot for RV64 Linux. Current dev commit 23ad4fd369a360ad7992d90cb7577f0241061c2b still has the same ftruncate path. The current source was checked statically; full upstream CI has not been run.
- 主要言語
- 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 日以内に返信