[RISC-V/Linux] newfstatat ignores unsupported flags
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 62/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- operating-systems
Rechercherichtung
The newfstatat handler lives in qiling/os/posix/syscall/stat.py; start there and check how the flags argument is read and whether unknown bits are rejected before the stat buffer is written. The reproducer is the C program in the issue, built as a static RV64 binary and run with Qiling against a rootfs containing a file named probe. Done means the invalid-flag call returns -1 with EINVAL and leaves the guest buffer untouched, while the flags-zero control call still succeeds.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
On an RV64 Linux guest, Qiling v1.4.11 accepts an unknown newfstatat flag bit and returns success. Linux returns EINVAL for the same request. Qiling also writes a stat structure to the guest buffer even though the request should fail.
Sample Code
Place a regular file named probe in the guest rootfs and run this static RV64 guest:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>
int main(void)
{
struct stat st;
long control = syscall(SYS_newfstatat, AT_FDCWD, "probe", &st, 0);
if (control != 0)
return 2;
memset(&st, 0xaa, sizeof(st));
errno = 0;
long rc = syscall(SYS_newfstatat, AT_FDCWD, "probe", &st, 0x40000000);
int invalid_errno = errno;
printf("control=%ld invalid=%ld errno=%d mode=%o\n",
control, rc, invalid_errno, st.st_mode);
return !(rc == -1 && invalid_errno == EINVAL &&
st.st_mode == (mode_t)0xaaaaaaaa);
}
mkdir -p rootfs
riscv64-linux-gnu-gcc -static -O2 probe.c -o probe.elf
touch rootfs/probe
Run it with the current Qiling dev checkout:
from qiling import Qiling
ql = Qiling(["./probe.elf"], "./rootfs")
ql.run()
Expected behavior
The syscall should return -1 with errno EINVAL before writing the output structure. Qiling v1.4.11 returns success and modifies the buffer.
Additional context
Reproduced with Qiling v1.4.11. The current dev source was checked at commit 23ad4fd369a360ad7992d90cb7577f0241061c2b; that exact commit was not dynamically re-run. Its handler is in stat.py; Linux's supported flag set is described by fstatat(2).
- Vorherrschende Sprache
- Python
- Sterne
- 6.2k
- Forks
- 806
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus qilingframework/qiling
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
qilingframework/qiling#1690 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
qilingframework/qiling#1689 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
qilingframework/qiling#1688 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
qilingframework/qiling#1686 ·
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 82/100
qilingframework/qiling#1640 ·
Alle Issues in qilingframework/qiling
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
huggingface/datasets#9128 ·
Maintainer antworten meist innerhalb von 1 Tag
-
priority:low ready-for-dev
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
OpenHands/extensions#975 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Function/dict state handlers can't supply provider-state injected values (`generate.provider_state`)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
pact-foundation/pact-python#1789 ·
Maintainer antworten meist innerhalb von 9 Tagen
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
juandresrodca/AdminForge#66 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag