[BUG] Potential bug when size of free Heap is too large and sets allocation-bit mask
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Bắt đầu tại portable/MemMang/heap_4.c với các định nghĩa heapBLOCK_ALLOCATED_BITMASK và heapBLOCK_SIZE_IS_VALID, sau đó đọc prvHeapInit(), nơi pxFirstFreeBlock->xBlockSize được gán từ uxEndAddress. Quyết định xem có thêm configASSERT cho kích thước đã tính hay chỉ ghi chú giới hạn trong tài liệu, vì issue đưa ra cả hai lựa chọn. Hoàn thành khi kiểm tra hoặc ghi chú đã có mặt và các bài kiểm tra heap trong repo vẫn pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
heap_4.c reserves the most significant bit of BlockLink_t.xBlockSize as an allocation-status flag:
#define heapBLOCK_ALLOCATED_BITMASK \
( ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ) )
prvHeapInit() does not explicitly validate the computed size of the initial free block:
pxFirstFreeBlock->xBlockSize = ( size_t ) ( uxEndAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFreeBlock );
If an implementation permitted a heap whose usable size was greater than or equal to heapBLOCK_ALLOCATED_BITMASK (i.e. 0x8000000 in 32 bit systems), the initial free block would already have the allocation-status bit set as part of its size.
The allocator would then be unable to distinguish that size bit from the allocation flag.
Similarly, coalescing free blocks assumes that the resulting size remains below heapBLOCK_ALLOCATED_BITMASK. That assumption follows from the initial-heap-size, but that is not checked explicitly.
Target
- Development board: N/A; source-level and compile-time investigation
- Instruction Set Architecture: Armv7E-M/Thumb-2, 32-bit
size_t - IDE and version: N/A; command-line Makefile
- Toolchain and version: Arm GNU Toolchain 15.2.Rel1, GCC 15.2.1
Host
- Host OS: Linux under WSL2
- Version: Debian GNU/Linux 13 (trixie) Linux 6.18.33.2-microsoft-standard-WSL2, x86_64
To Reproduce
- Use
portable/MemMang/heap_4.cfrom latest FreeRTOS-Kernel commit. - Select a 32-bit Arm port where
sizeof(size_t) == 4. - Observe that bit 31 is reserved by
heapBLOCK_ALLOCATED_BITMASK. - Observe that
prvHeapInit()assigns the initial free-block size without applyingheapBLOCK_SIZE_IS_VALID()to the result. - Attempt to configure a heap large enough for the initial usable block to be at least
0x80000000bytes.
The concern would apply only to a compiler or nonstandard heap-placement mechanism that permits an object large enough to use the reserved
bit.
If tried using standard heap allocation
extern uint8_t ucHeap[ 0x80000000ULL ];
Would produce the following compiler output:
error: size of array 'ucHeap' is too large
Expected behavior
The size limitation should either be documented explicitly or checked by the implementation. For example, after calculating the initial free-block size, prvHeapInit() could assert the representation invariant:
configASSERT( heapBLOCK_SIZE_IS_VALID( pxFirstFreeBlock->xBlockSize ) != 0);
Screenshots
Not applicable
Additional context
On a target with 32-bit size_t:
heapBLOCK_ALLOCATED_BITMASK = 0x80000000
maximum representable block size without the flag = 0x7fffffff
The invalid condition is specifically when computed initial usable block size >= heapBLOCK_ALLOCATED_BITMASK
- Ngôn ngữ chính
- C
- Star
- 4.6k
- Fork
- 1.6k
- Merge trung bình
- 2 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của FreeRTOS/FreeRTOS-Kernel
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
FreeRTOS/FreeRTOS-Kernel#1542 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[BUG] Release asset FreeRTOS-KernelV11.3.2.zip has the files of main, not of the tag V11.3.2Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
FreeRTOS/FreeRTOS-Kernel#1520 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
FreeRTOS/FreeRTOS-Kernel#1554 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[BUG] event_wait_timed can't return falseCó thể đã có người làm @TedLyngmo đã nhận 39 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
FreeRTOS/FreeRTOS-Kernel#1546 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
FreeRTOS/FreeRTOS-Kernel#1545 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của FreeRTOS/FreeRTOS-Kernel
Issue tương tự
-
RecompLauncher supportĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
shinyquagsire23/OpenJKDF2#540 ·
Maintainer thường phản hồi trong vòng 12 ngày
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or signĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Life-Framework/Life-Framework#5939 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
autoconf failes to find libsodium even when present due to implicit function declarationCó thể đã có người làm @coderjoe đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 13 ngày
-
SessionInterfaceHandler is throwing a deprecation notice as a warning instead of a deprecationĐang mởBug Status: Needs Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement_package: a site operand of another JSON type raises TypeError, not a named refusalĐang mởbug python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
Jstar269/nakagawa-recomp#3521 ·
Maintainer thường phản hồi trong vòng 1 ngày