[ARM/Linux] fstat64 reports epoch nanoseconds as subsecond nanoseconds

Abierto
#1,682 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, python

Línea de trabajo

The bug is in the stat64 serializer at qiling/os/posix/syscall/stat.py, which writes the ARM32 Linux subsecond nanoseconds field. Start by reading how the nanosecond value is computed and packed for the ARM32 stat64 layout, then compare it with the layout the issue describes. Done means the field holds only the 0 to 999999999 fraction, and the sample prints mtime=1700000000.123456789 for the fixture created with touch -d.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

On an ARM32 Linux guest, Qiling v1.4.11's fstat64 result places the full epoch nanosecond value into the ABI's subsecond nanoseconds field. The field should contain only the nanosecond fraction within the second.

Sample Code

Create a fresh empty directory named rootfs, create the fixture there, then run an ARM EABI guest that calls fstat64:

mkdir rootfs
touch -d '@1700000000.123456789' rootfs/fixture
#define _GNU_SOURCE
#define _LARGEFILE64_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <time.h>

int main(void)
{
    int fd = open("fixture", O_RDONLY);
    struct stat64 st;
    if (fd < 0 || fstat64(fd, &st) != 0)
        return 1;
    printf("mtime=%lld.%09ld\n",
           (long long)st.st_mtim.tv_sec, st.st_mtim.tv_nsec);
    return 0;
}
arm-linux-gnueabihf-gcc -static -O2 probe.c -o fstat64-probe

Run the ARM guest with Qiling:

from qiling import Qiling

ql = Qiling(["./fstat64-probe"], "./rootfs")
ql.run()
Expected behavior

The mtime fields should be 1700000000 seconds and 123456789 nanoseconds. The nanoseconds field must be in the range 0 through 999999999. Qiling currently writes the epoch nanosecond count into the 32-bit subsecond field.

With this fixture, Qiling narrows 1700000000123456789 to 1032178965; the sample therefore prints mtime=1700000000.1032178965 instead of mtime=1700000000.123456789.

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. The affected serializer is in stat.py. The issue concerns the ARM32 Linux stat64 layout.

Lenguaje dominante
Python
Estrellas
6.2k
Forks
806
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de qilingframework/qiling

Todos los issues de qilingframework/qiling

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.