mtd: RAM consolidation reads past its block buffer on a malformed entry
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c
Línea de trabajo
El fallo está en mtdconfig_ramconsolidate() en drivers/mtd/mtd_config.c, donde la copia del payload en torno a la línea 685 usa phdr->len sin una comprobación de los límites de origen. Lee el análisis del encabezado justo antes y luego añade una comprobación de que src_offset + sizeof(hdr) + phdr->len <= dev->erasesize, saltando a errout cuando falle. Está terminado cuando una entrada malformada devuelve un error y el harness de ASan con CONFIG_MTD_CONFIG_RAM_CONSOLIDATE=1 no informa de ningún desbordamiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Mechanism. mtdconfig_ramconsolidate() allocates pbuf = kmm_malloc(dev->erasesize) (:579) and walks the source entries of one block. At :685 it copies the entry payload with
mtdconfig_writebytes(dev, dst_offset, &pbuf[src_offset + sizeof(hdr)], phdr->len)
using the on-flash phdr->len without checking that src_offset + sizeof(hdr) + phdr->len fits inside dev->erasesize. Destination space is checked; the source bound is not.
Effect. A header at offset 499 with len = 200 passes the header read (499 + 6 = 505 ≤ 512) but starts a 200-byte copy at 505, so 119 bytes are read past the 512-byte pbuf.
Trigger. RAM consolidation processes a malformed active entry. Corrupt flash is a robustness case; this function-level test does not establish that an attacker can supply such an image on a deployed device.
Location. NuttX nuttx-13.1.0, commit 2b5c0de5e933281c209f954a63b99cf10c132346, drivers/mtd/mtd_config.c, sha256 30b2de5e6c7e4fc28df2401d3b6d13926abe84d70274c227efbdb28c12ab6aa3:
| Anchor | Line | Code |
|---|---|---|
| allocation | :579 |
pbuf = kmm_malloc(dev->erasesize); |
| payload copy | :685 |
mtdconfig_writebytes(dev, dst_offset, &pbuf[src_offset + sizeof(hdr)], phdr->len) |
| error exit | :730 |
label errout: |
Line numbers in other renderings differ; the code text locates each anchor.
Evidence. One before/after function-level ASan run, harness geometry blocksize=128, erasesize=512, neraseblocks=2, CONFIG_MTD_CONFIG_RAM_CONSOLIDATE=1, image with 31 well-formed active entries followed by an active header at offset 499 with len=200: before.log reports heap-buffer-overflow, READ of size 119 at mtd_config.c:685, past a 512-byte region allocated at :579; with the patch, returned -5 and no ASan report.
Expected. Consolidation rejects an entry whose declared payload runs past the block end instead of copying it.
Patch. Validate src_offset + sizeof(hdr) + phdr->len <= dev->erasesize before the copy and take the errout path when it does not hold.
- Lenguaje dominante
- C
- Estrellas
- 4.1k
- Forks
- 1.8k
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 900
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/nuttx
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/nuttx#22270 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
apache/nuttx#22171 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Please rerun `pre-commit run -a`AbiertoArch: all Arch: arm Area: Build system OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/nuttx#19435 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/nuttx
Issues similares
-
nuttx/esp32s3: sdkconfig.h has no "no console" case, so CONFIG_NO_SERIAL_CONSOLE builds failAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Document the isv:HDFGroup Linux package repositories and signing keyPosiblemente ocupada @brtnfld la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug status: planned
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ChupathingyCE/chupathingyce#1834 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día