Commit Graph
36 Commits
Author SHA1 Message Date
Andrew Tridgell 86a4387efb AP_Filesystem: expose only flash-backed crash dumps 2026-08-25 10:46:36 +10:00
Peter Barker 7311d16c5f AP_FileSystem: add comment about sysfs out-of-bounds check
Co-authored-by: Peter Barker <pb-gh@barker.dropbear.id.au>
2026-05-27 09:27:43 +10:00
Peter Barker 7f593b195c AP_Filesystem_Sys: ensure final offset in file within boundaries 2026-05-27 09:27:43 +10:00
zuwasiandAmp a975cac236 AP_Filesystem_Sys: reject negative lseek offsets to prevent wild OOB read
rfile::file_ofs is uint32_t but lseek()'s offset is int32_t. The
previous SEEK_SET path performed MIN(int32_t offset, int32_t length)
and assigned the int32_t result into the uint32_t file_ofs slot. A
negative offset (e.g. -1) became 0xFFFFFFFF.

The subsequent read() then computed
    count = MIN(count, get_length() - file_ofs)
which underflows when file_ofs > length, producing a huge unsigned
value. memcpy(buf, get_string()[file_ofs], count) then reads from a
wild address relative to the underlying buffer base.

This is reachable over MAVFTP (any client can lseek a @SYS file via
FTP_OP_OpenFileRO + offset field) and the underlying buffer for
@SYS/storage.bin is the live EEPROM pointer from
hal.storage->get_storage_ptr(), while @SYS/flash.bin points at
0x08000000 internal flash. Either path leaks adjacent memory.

Fix: reject negative SEEK_SET offsets; compute SEEK_CUR in int64_t
and clamp into [0, length]. SEEK_END continues to return EINVAL.

Found via offensive-security benchmark on ArduPilot Plane 4.6.3
(ESL / claude-mythos main_prompt run via Factory Droid, 2026-05-21).

Amp-Thread-ID: https://ampcode.com/threads/T-019e4710-85bb-77d1-b50a-ba871a28d82b
Co-authored-by: Amp <amp@ampcode.com>
2026-05-27 09:27:43 +10:00
bugobliterator ac1a805802 AP_Filesystem: drop can_log.txt sys file
The CAN log buffer it read from is being removed in favour of
sending CAN status messages through GCS_SEND_TEXT.
2026-05-18 20:58:47 -05:00
Peter Barker 6338d10b5f global: create and use HAL_PROGRAM_SIZE_LIMIT_KB
We will reserve BOARD_FLASH_SIZE for the internal flash on stm32 flash processors, use HAL_PROGRAM_SIZE_LIMIT_KB in the general code base.

Notable change here is that boards with external flash will start to get features only available with more than 2MB of program storage
2025-02-26 10:06:39 +11:00
Andrew Tridgell f8ce4183b8 AP_Filesystem: support QURT with posix filesystem
some features disabled
2024-07-12 15:56:48 +10:00
Andrew Tridgell a241b13f45 AP_Filesystem: use NEW_NOTHROW for new(std::nothrow) 2024-06-04 09:20:21 +10:00
Andrew Tridgell 11ea2cf5c1 AP_Filesystem: added option @SYS/flash.bin
useful for speed tests
2023-12-11 18:00:38 +11:00
Peter Barker bee1f2785a AP_Filesystem: rename HAL_SCHEDULER_ENABLED to AP_SCHEDULER_ENABLED
there's AP_HAL::Scheduler which confuses this
2023-02-28 11:26:04 +11:00
Peter Barker b5165b6d7f AP_FileSystem: add AP_FILESYSTEM_*_ENABLED 2022-09-15 10:53:02 +10:00
Peter Barker 680d158f59 AP_Filesystem: do not gate AP_CRASHDUMP_ENABLED on bootloader
Also rename from HAL_CRASHDUMP_ENABLE

Removes code based on define rather than creating empty functions.  Makes it clearer what's going on in the callers.
2022-08-17 17:34:00 +10:00
Willian Galvani 0e62d561d9 AP_Filesystem: add allow_absolute_paths to open(), implement it for posix backend 2022-03-22 10:19:21 +11:00
Andy Piper 9cccab2de7 AP_Filesystem: add support for @SYS/timers.txt. 2022-02-16 15:28:04 +11:00
Peter Barker aaf8de88d8 AP_Filesystem: add HAL_UART_STATS_ENABLED to disable stats gathering 2022-01-12 18:30:49 +11:00
bugobliterator 3855767ff2 AP_FileSystem: mention of HAL_CRASH_DUMP_FLASHPAGE not required 2021-12-01 18:17:50 +11:00
bugobliterator b1e25ec4fd AP_Filesystem: fetch crash_log directly rather than via buffer 2021-12-01 18:17:50 +11:00
bugobliterator 528e57c2ae AP_Filesystem: add support for downloading raw storage via ftp sysfs 2021-11-10 17:21:35 +11:00
bugobliterator 2af001541e AP_FileSystem: add crash_dump.bin 2021-10-30 19:24:57 +11:00
bugobliterator 6b64cfd6c1 AP_FileSystem_Sys: allow sending stats via mavftp on AP_Periph 2021-08-19 14:20:58 +10:00
Siddharth Purohit ee22747b48 AP_Filesystem: Use HAL_CANMANAGER_ENABLED instead of HAL_ENABLE_LIBUAVCAN_DRIVERS 2021-06-24 09:02:42 +10:00
Peter Barker c11a6bbb47 AP_Filesystem: add support for AP_Logger into AP_Periph 2021-06-08 09:57:55 +10:00
Andy Piper c388fd9214 AP_Filesystem: add @SYS/uarts.txt 2021-02-20 14:37:11 +11:00
Andy PiperandAndrew Tridgell cfac268f13 AP_Filesystem: add @SYS/memory.txt
Co-authored-by: Andrew Tridgell <andrew@tridgell.net>
2021-02-03 23:35:44 +11:00
Andrew Tridgell 9561f24c0e AP_Filesystem: added @SYS/persistent.parm 2021-01-21 13:09:21 +11:00
Andrew Tridgell c924a9917e AP_Filesystem: use ExpandingString class 2021-01-05 10:52:00 +11:00
Andy Piper b6a008c73d AP_Filesystem: increase ftp thread buffer size when HAL_ENABLE_THREAD_STATISTICS is defined 2020-12-30 18:15:05 +11:00
Andy Piper 32edb6d0cd AP_Filesystem: add support for @SYS/dma.txt for DMA contention 2020-12-02 18:17:23 +11:00
Andrew Tridgell 02e9519ab0 AP_Filesystem: fixed stat call for @SYS files 2020-11-12 08:42:44 +11:00
Andrew Tridgell 6f92abea63 AP_Filesystem: fixed build on gcc 9.3 2020-10-27 10:45:47 +11:00
bugobliterator 308bc64f35 AP_Filesystem: add support for listing @SYS files 2020-10-21 18:16:50 +11:00
Andy Piper ac8dc26d41 AP_Filesystem: increase tasks buffer size 2020-09-30 17:37:20 +10:00
Andy Piper f70f13e620 AP_Filesystem: add support for @SYS/tasks.txt 2020-09-09 17:06:12 +10:00
Siddharth Purohit 20edecc340 AP_Filesystem: publish can info over FS Sys iface 2020-08-19 17:31:09 +10:00
Andrew Tridgell 9b14fa7ed9 AP_Filesystem: enable @PARAM, @ROMFS and @SYS with no microSD 2020-04-29 07:36:55 +10:00
Andrew Tridgell cd3b4dcc7d AP_Filesystem: added @SYS filesystem backend 2020-04-29 07:36:55 +10:00