Commit Graph
100 Commits
Author SHA1 Message Date
Tomáš Rohlínek 9be9b3e60b fix(storage/fatfs): fix FAT32 mount integer overflow (CVE-2026-6682)
The initial CVE-2026-6682 fix hardened the exFAT mount path, but the CVE
as reported by runZero is a FAT32 defect in mount_volume() and is
reachable in the default configuration (exFAT and 64-bit LBA disabled).
This corrects the fix.

Root cause: `fasize *= fs->n_fats` is a DWORD multiply with no overflow
guard. A crafted BPB_FATSz32 such as 0x80000001 with NumFATs=2 wraps
`fasize` to 0x00000002. The wrapped (too-small) FAT size places
`fs->database` inside the FAT region, so a forged directory entry yields
an attacker-controlled `finfo.fsize`; a caller using it as a read length
overflows its buffer with attacker-controlled bytes (CVSS 7.6).

Fix: reject per-FAT and reserved+FAT+root system-area sizes that overflow
DWORD before they are used to derive the data-area base. The exFAT
cluster-heap/bitmap 64-bit promotions are retained as defense-in-depth
and relabeled (they are not CVE-2026-6682). SBOM reason updated.
2026-07-07 16:36:34 +02:00
Tomáš Rohlínek 655ff3269a fix(storage/fatfs): record non-applicable runZero 2026 CVEs in SBOM
Document the three runZero "Seven FatFs bugs" CVEs that require no source change
in this component, so vulnerability scanners have their disposition:

  - CVE-2026-6684: GPT partition-scan loop DoS. Already fixed upstream in R0.16,
    where test_gpt_header() caps the partition-entry count at 128.
  - CVE-2026-6686: read of uninitialized clusters after f_lseek() past EOF.
    Longstanding, behavioral; not a memory-safety defect and zero-filling every
    extended cluster is prohibitively costly on flash.
  - CVE-2026-6688: long-filename overflow in downstream callers. Not exposed in
    ESP-IDF; vfs_fat.c uses bounded copies and fname is bounded by FF_MAX_LFN.

Reference: https://www.runzero.com/blog/fatfs-bugs/
2026-07-06 16:19:16 +02:00
Tomáš Rohlínek 1cd2874952 fix(storage/fatfs): clamp exFAT volume-label length in f_getlabel() (CVE-2026-6687)
f_getlabel() extracts the exFAT volume label with a loop bounded by the on-disk
byte dj.dir[XDIR_NumLabel] (0-255):

    for (si = di = hs = 0; si < dj.dir[XDIR_NumLabel]; si++)
        wc = ld_16(dj.dir + XDIR_Label + si * 2);

The exFAT label field holds at most 11 UTF-16 units (22 bytes). A crafted
directory entry with a larger count both reads past the 22-byte label field and,
through put_utf(... &label[di], 4), writes past the end of the caller-provided
label buffer (the canonical API examples use small fixed stack buffers) -> stack
buffer overflow.

Clamp the character count to the exFAT maximum of 11 before the extraction loop.
Record the CVE in the component SBOM.

Note: f_getlabel() takes no destination-buffer size, so under UTF-8 output
(FF_LFN_UNICODE == 2) 11 units can still expand to up to 34 bytes; the clamp
downgrades this from attacker-unbounded to spec-bounded. ESP-IDF's VFS layer
does not call f_getlabel(); direct callers on untrusted media should size their
buffer accordingly. A complete fix requires an upstream size-aware API change.

Reference: https://www.runzero.com/blog/fatfs-bugs/
2026-07-06 14:52:36 +02:00
Tomáš Rohlínek 362fd7380e fix(storage/fatfs): guard dirty-cache refill against unsigned LBA wrap (CVE-2026-6685)
After a direct multi-sector disk_read()/disk_write(), FatFs decides whether the
cached sector overlaps the direct-I/O range with:

    fp->sect - sect < cc          (and the FF_FS_TINY variant fs->winsect - sect < cc)

`sect`, `fp->sect` and `fs->winsect` are unsigned LBA_t. On 32-bit LBA_t builds,
if the cached sector is below `sect`, the subtraction wraps to a huge value that
can still compare `< cc`, so the code computes a bogus large offset:

  - in f_write() it mis-copies from the direct write buffer (data corruption);
  - in f_read() it is worse: memcpy(rbuff + (wrapped_offset * SS), ...) is an
    out-of-bounds WRITE into the caller-supplied read buffer.

Add an explicit lower-bound check (fp->sect >= sect, resp. fs->winsect >= sect)
before the range test on both the read and write paths and both the FF_FS_TINY
and normal variants, so the condition is exactly "cached sector lies within
[sect, sect + cc)". Record the CVE in the component SBOM.

Reference: https://www.runzero.com/blog/fatfs-bugs/
2026-07-06 14:52:36 +02:00
Tomáš Rohlínek 0efd85ffea fix(storage/fatfs): reject empty exFAT cluster heap (CVE-2026-6683)
CVE-2026-6683 is an exFAT divide-by-zero: with NumClusters == 0 the filesystem
object has fs->n_fatent == 2, and the exFAT "percent in use" update in sync_fs()
computes ... * 100 / (fs->n_fatent - 2) -> division by zero.

That vulnerable exFAT PercInUse sync path was introduced in FatFs R0.16 and is
NOT present in this R0.15 release, so the divide-by-zero itself is not reachable
here. As defense-in-depth (and to keep parity with newer releases) reject an
empty exFAT cluster heap at mount time, which is a malformed volume regardless.

Record the CVE disposition in the component SBOM.

Reference: https://www.runzero.com/blog/fatfs-bugs/
2026-07-06 14:52:36 +02:00
Tomáš Rohlínek 94a6d8143e fix(storage/fatfs): fix exFAT mount integer overflow (CVE-2026-6682)
The exFAT mount path validates that the media is large enough to hold the
declared cluster heap with:

    if (maxlba < (QWORD)fs->database + ncl * fs->csize) ...

`ncl` (DWORD, up to MAX_EXFAT) and `fs->csize` (WORD) are both promoted to
`unsigned int`, so `ncl * fs->csize` is evaluated in 32-bit arithmetic and can
wrap before the QWORD promotion of the sum. A crafted image with a large
NumClusters/SecPerClus can therefore make an undersized volume pass the "size
is large enough" check; subsequent cluster->sector math then addresses media
outside the actual device.

Promote the multiply to 64-bit ((QWORD)ncl * fs->csize). Apply the same
promotion to the bitmap-base computation ((LBA_t)fs->csize * (bcl - 2)), which
has the identical overflow shape. Record the CVE in the component SBOM.

Reference: https://www.runzero.com/blog/fatfs-bugs/
2026-07-06 14:52:36 +02:00
Tomas Rohlinek 6fe27247e6 fix(network/http_server): fix clang-tidy warnings for missing close
Cherry-picked from 68b37333049383659d6ea73fa11a1d942994535a
2026-06-22 11:02:00 +02:00
Tomáš Rohlínek 99dcfc522e fix(storage/vfs): Fix typo in code snippet in docs 2026-03-17 18:36:05 +01:00
Tomas Rohlinek bf1b16554a Merge branch 'feat/socket_count_checks' into 'master'
feat(network/lwip): Add checks for maximum socket count

Closes IDF-12788

See merge request espressif/esp-idf!38642
2025-04-30 14:52:01 +08:00
Tomáš Rohlínek fccd8d1a5b feat(network/lwip): Add checks for maximum socket count 2025-04-23 08:36:43 +02:00
Tomas Rohlinek 7005b101bf Merge branch 'fix/fatfs_use_dyn_buf_kconfig_mistake' into 'master'
fix(fatfs): Mistake in Kconfig for FATFS_USE_DYN_BUFFERS

Closes IDF-11789

See merge request espressif/esp-idf!35182
2025-04-09 23:45:03 +08:00
Tomáš Rohlínek b1997ebab6 feat(storage/fatfs): add dynamic buffer usage test 2025-04-09 14:02:44 +02:00
Tomas Rohlinek f945dae618 Merge branch 'contrib/github_pr_15247' into 'master'
refactor(components/fatfs): replace assert expression (GitHub PR)

Closes IDFGH-14473

See merge request espressif/esp-idf!38194
2025-04-02 18:21:55 +08:00
Tomáš Rohlínek be6e24370f fix(storage/nvf_flash): fixup additions from PR 2025-03-28 12:57:33 +01:00
Tomas Rohlinek 7d365f7b42 Merge branch 'fix/fatfsgen_tests' into 'master'
fix(storage/fatfsgen): increase test timeout

Closes IDFCI-2681

See merge request espressif/esp-idf!37702
2025-03-13 16:30:31 +08:00
Tomáš Rohlínek f416523e16 fix(storage/fatfsgen): increase test timeout 2025-03-12 14:45:39 +01:00
Tomáš Rohlínek df8a16281b feat(storage/fatfs): increase log legibility for fatfs mount 2025-02-28 14:59:48 +01:00
Tomáš Rohlínek 09aae72bfa docs(storage/fatfs): discrepancies between FATFS and POSIX
Closes https://github.com/espressif/esp-idf/issues/15187
2025-02-13 10:15:52 +01:00
Tomáš Rohlínek 67638981ec feat(storage/vfs): cleanup path prefix handling 2025-02-07 10:34:24 +01:00
Tomáš Rohlínek a45b12a68b feat(storage/vfs): improve mountpoint table memory usage 2025-01-30 09:07:51 +01:00
Tomas Rohlinek 9f253c7d7c Merge branch 'fix/fatfs_use_standard_flex_arrays' into 'master'
fix(storage/fatfs): use standard flex-array fields, instead of extension

See merge request espressif/esp-idf!36666
2025-01-29 17:31:56 +08:00
Tomáš Rohlínek a700e7c210 fix(storage/fatfs): use standard flex-array fields, instead of extension 2025-01-29 09:08:44 +01:00
Tomáš Rohlínek f9d6e356bf fix(storage/fatfsgen): broken test_apps scripts for fatfsgen 2025-01-16 13:41:57 +01:00
Tomáš Rohlínek 2140c9b688 fix(storage/fatfsgen): broken test_apps scripts for fatfsgen 2025-01-16 12:13:16 +01:00
Tomas Rohlinek 89045a1ff2 Merge branch 'feat/bump_esp_littlefs_1_16_0' into 'master'
feat(storage/examples): bump littlefs version to 1.16.0

Closes IDF-11691

See merge request espressif/esp-idf!35823
2024-12-23 17:04:52 +08:00
Tomas Rohlinek b5ac4fbdf9 Merge branch 'fix/esp_vfs_register_fd_range_warning_message' into 'master'
fix(storage/vfs): incorrect log level in esp_vfs_register_fd_range

Closes IDFGH-13421

See merge request espressif/esp-idf!35682
2024-12-19 22:22:31 +08:00
Tomáš Rohlínek 0fe0637cfe feat(storage/examples): bump littlefs version to 1.16.0 2024-12-19 14:11:15 +01:00
Tomáš Rohlínek 5e53f2975e fix(storage/vfs): incorrect log level in esp_vfs_register_fd_range
Closes https://github.com/espressif/esp-idf/issues/14327
2024-12-16 15:12:11 +01:00
Tomáš Rohlínek 86e5039fc9 feat(storage/vfs): make all member pointer of vfs_ops struct const 2024-12-12 13:03:30 +01:00
Tomáš Rohlínek d5d295cf7a fix(storage/console): fix test configuration 2024-11-28 13:34:25 +01:00
Tomáš Rohlínek f59362266a fix(storage/vfs_console): stop new console opens from overwriting existing fds 2024-11-28 13:12:22 +01:00
Tomas Rohlinek 408ae4c560 Merge branch 'feature/switch_to_new_vfs_api' into 'master'
feat(storage): switch to new VFS API

Closes IDF-11473

See merge request espressif/esp-idf!32029
2024-11-22 16:51:46 +08:00
Tomáš Rohlínek 65575bfe4d feat(storage/vfs): move semihost to new vfs API 2024-11-21 07:41:43 +01:00
Tomáš Rohlínek 9b4d11fb3c feat(storage/vfs): move l2tap to new vfs API 2024-11-21 07:41:43 +01:00
Tomáš Rohlínek aae0825587 feat(storage/esp_vfs_console): move console to new vfs API 2024-11-21 07:41:42 +01:00
Tomáš Rohlínek fbb5d9063e feat(storage/vfs): move jtag driver to new vfs API 2024-11-21 07:41:42 +01:00
Tomáš Rohlínek 2821ad7920 feat(storage/vfs): move uart driver to new vfs API 2024-11-21 07:41:42 +01:00
Tomáš Rohlínek 19eb0d6d02 feat(storage/vfs): move nullfs to new API 2024-11-21 07:41:42 +01:00
Tomáš Rohlínek 3d079312b1 feat(storage/vfs): make part of nullfs API private 2024-11-21 07:41:41 +01:00
Tomáš Rohlínek 10e74d3abb feat(storage/esp_vfs_console): move cdcacm driver to new vfs API 2024-11-21 07:41:41 +01:00
Tomáš Rohlínek ae1e8a2ea3 feat(storage/vfs): update docs to new version of API 2024-11-21 07:41:41 +01:00
Tomáš Rohlínek d7c487178c feat(storage/spiffs): move spiffs to new VFS API 2024-11-21 07:41:41 +01:00
Tomáš Rohlínek fdffba6f4c feat(storage/fatfs): move fatfs to new VFS API 2024-11-21 07:41:40 +01:00
Tomáš Rohlínek 5109f08dfa feat(storage/vfs): make subcomponent pointers const 2024-11-21 07:41:40 +01:00
Tomáš Rohlínek 18e20c0bc5 feat(storage/vfs): change names related to minified vfs 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek 040ad5ca20 feat(storage/vfs): add test for ESP_VFS_FLAG_STATIC 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek 3cab84f033 fix(storage/vfs): clarify minified related documentation 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek 923fb635b4 feat(storage/vfs): add documentation for minified_vfs 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek 3cfc78ee67 feat(storage/vfs): update documentation for minified vfs functions 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek 755adf3b4f feat(storage/vfs): impelement sparse vfs struct 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek cec0525460 fix(storage/vfs): update select sanity checks 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek fe0fc40049 fix(storage/vfs): incorrect registration checks 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek 36d821f70c feat(storage/vfs): add more extensive checks to vfs tests 2024-10-22 14:50:31 +08:00
Tomáš Rohlínek b6a9acfc07 feat(storage/vfs): Add minified vfs implementation 2024-10-22 14:50:31 +08:00
Tomas Rohlinek fe51222a02 Merge branch 'feat/simplify_storage_examples' into 'master'
feat(storage/fatfs): update fatfs examples

Closes IDF-5705

See merge request espressif/esp-idf!31174
2024-10-18 15:28:44 +08:00
Tomáš Rohlínek 5841495e7f fix(storage/fatfs): fix CMake project names in fatfs examples 2024-10-17 09:21:33 +02:00
Tomas Rohlinek ee6742d764 Merge branch 'fix/incorrect_test_case_spiffs_linux' into 'master'
fix(storage/spiffs): fix incorrect test case configuration

Closes IDFCI-2179

See merge request espressif/esp-idf!33323
2024-10-10 19:50:11 +08:00
Tomáš Rohlínek bcc060b98e docs(storage/fatfs): fix relative links in fatfs examples 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek 908c4c7ce6 docs(storage/fatfs): fix fatfs example links in docs 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek 46982e69da feat(storage/vfs): update example references in documentation 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek d43669b2d7 feat(storage/fatfs): restructure fatfsgen example 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek 33788de979 feat(storage/fatfs): restructure ext_flash example 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek 587290567d feat(storage/fatfs): restructure advanced example 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek 85b5869053 feat(storage/fatfs): restructure basic example 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek f633839ece feat(storage/fatfs): add advanced example for fatfs 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek b9a54fb1f3 feat(storage/fatfs): add minimal FatFS example 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek 84ba1a323c fix(storage/fatfs): move test app to correct directory 2024-10-10 16:41:58 +08:00
Tomáš Rohlínek bab9498a52 docs(storage/vfs): add documentation for existing automounted vfs drivers 2024-09-20 11:49:47 +02:00
Tomáš Rohlínek 1f0763b932 fix(storage/example): correct alloc function 2024-09-09 07:54:42 +02:00
Tomáš Rohlínek 4a185b824d fix(storage/vfs): fix incorrect test case configuration 2024-09-04 12:11:43 +02:00
Tomas Rohlinek 2806ef1e5c Merge branch 'fix/missing_include_guard_ff_conf' into 'master'
fix(fatfs): Add missing include guard to ff_conf.h

Closes IDFGH-13046

See merge request espressif/esp-idf!31769
2024-07-11 13:34:42 +08:00
Tomas Rohlinek 2ccc9bcef9 Merge branch 'fix/unopened_stdout_console' into 'master'
fix(newlib/stdio): incorrect stdout redirect with /dev/console

Closes IDFGH-12416

See merge request espressif/esp-idf!30324
2024-05-29 18:40:09 +08:00
Tomáš Rohlínek c44da2f222 feat(storage/spiffs): add host test for disabled erase check 2024-05-29 11:00:25 +02:00
Tomáš Rohlínek 97af825b14 feat(storage/vfs): make automatic nullfs initialization optional 2024-05-29 10:39:55 +02:00
Tomáš Rohlínek f2a278191b feat(storage/vfs): add documentation for nullfs 2024-05-29 10:39:55 +02:00
Tomáš Rohlínek f753434640 fix(storage/esp_partition): add option to control erase check during write for linux target 2024-05-28 10:05:58 +02:00
Tomáš Rohlínek a30d27e01e feat(storage/vfs): add nullfs test cases for vfs 2024-05-28 08:06:33 +02:00
Tomáš Rohlínek 2b75ed37b9 fix(storage/vfs): always register /dev/null on startup 2024-05-28 07:55:37 +02:00
Tomáš Rohlínek a615f487dd feat(storage/vfs): add /dev/null for unwanted output redirection 2024-05-28 07:54:35 +02:00
Tomáš Rohlínek 0b4fff69c5 fix(newlib/stdio): remove incorrect check in /dev/console init
Closes https://github.com/espressif/esp-idf/issues/13439
2024-05-27 10:43:13 +02:00
Tomáš Rohlínek 0ed8ebddb6 fix(storage/vfs_console): remove possible infinite recursion 2024-05-27 14:11:49 +08:00
Tomas Rohlinek f375125e28 Merge branch 'feature/fatfs_ff_strfunc_support' into 'master'
feat(storage/fatfs): add Kconfig settings for FF_USE_STRFUNC

Closes IDFGH-12317

See merge request espressif/esp-idf!30141
2024-05-16 14:20:23 +08:00
Tomas Rohlinek 22d3473f18 Merge branch 'feature/fatfs_use_dynamic_buffer' into 'master'
feat(storage/fatfs): Use dynamic buffers for fatfs

Closes IDFGH-9561

See merge request espressif/esp-idf!27501
2024-04-19 13:15:38 +08:00
Tomáš Rohlínek ede737763c feat(storage/fatfs): update deprecated syntax for tests 2024-04-17 10:37:31 +02:00
Tomáš Rohlínek b5d78549a5 feat(storage/fatfs): add tests for dynamic buffers 2024-04-17 10:37:31 +02:00
Tomáš Rohlínek 1447420a91 feat(storage/fatfs): add Kconfig option to enable dynamic window buffers 2024-04-17 10:37:31 +02:00
Tomáš Rohlínek 0bd6330e91 feat(storage/fatfs): add dynamic buffers support to FatFS
Closes https://github.com/espressif/esp-idf/issues/10913
2024-04-17 10:37:28 +02:00
Tomáš Rohlínek 161604c33c fix(storage/fatfs): change indentation in kconfig 2024-04-16 07:55:46 +02:00
Tomáš Rohlínek 615a9c6742 feat(storage/example): enable host test for flash wl fatfs 2024-04-12 10:26:25 +02:00
Tomáš Rohlínek 7c3b9bde0e feat(storage/fatfs): add testcase with erased spi partition 2024-04-12 10:26:25 +02:00
Tomáš Rohlínek f398b7923a fix(storage/fatfs): fix double mouting of spiflash 2024-04-12 10:26:22 +02:00
Tomas Rohlinek f5d49570ee Merge branch 'feature/optimize_fatfs_on_sdmmc' into 'master'
feat(examples/storage): update perf benchmark example

Closes IDF-8420

See merge request espressif/esp-idf!27678
2024-04-09 15:02:06 +08:00
Tomas Rohlinek 0c9937570f feat(examples/storage): update perf benchmark example 2024-04-09 15:02:05 +08:00
Tomáš Rohlínek a17ef2f8d8 feat(storage/fatfs): move fatfs related scripts under control of the storage team 2024-03-19 13:36:40 +01:00
Tomas Rohlinek f8054b1e66 Merge branch 'fix/wl_fatfsgen_safe_mode' into 'master'
fix(storage/fatfs): make wl_fatfsgen.py safe mode aware

Closes IDF-9379

See merge request espressif/esp-idf!29621
2024-03-19 16:19:24 +08:00
Tomáš Rohlínek 7854b955a1 fix(storage/fatfs): make wl_fatfsgen.py safe mode aware 2024-03-13 12:49:49 +01:00
Tomáš Rohlínek 1297a0628a fix(storage/fatfs): check whether sdcard supports triming
Closes https://github.com/espressif/esp-idf/issues/12912
2024-01-05 10:31:56 +01:00
Tomáš Rohlínek 092f5aff29 feat(storage): Update build test rules for storage related components 2024-01-02 13:10:59 +01:00
Tomas Rohlinek 88cc473910 Merge branch 'docs/fatfs_link_lock' into 'master'
Docs(storage/fatfs): Add documentation for FATFS_LINK_LOCK Kconfig option

Closes IDF-8739

See merge request espressif/esp-idf!27472
2023-12-19 18:37:52 +08:00
Tomáš Rohlínek 577af7d6ef docs(storage/fatfs): Refactor FatFs documentation 2023-12-19 08:11:05 +01:00