[BUG] xTaskCreate() unsigned integer overflow when calculating stack size

オープン
#1,472 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@JacksonBopp がすでに取り組んでいます。

2026年9月5日 から。

  • #1488 @JacksonBopp による — オープン
  • #1489 @saikumar-mandaji による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
20/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
c

調査の方向性

The overflow is in prvCreateTask() in FreeRTOS/Source/tasks.c, where uxStackDepth * sizeof(StackType_t) is passed to pvPortMallocStack(), and prvInitialiseNewTask() then uses the unchecked depth. Read the open pull requests #1488 and #1489 first, since they already target this bug, and check whether the discussion has settled the approach. Done means an overflow check before allocation that returns a creation failure, applied to every dynamic stack allocation path.

索引モデルが issue の本文から書いたものです。

説明

bug

Describe the bug
xTaskCreate() accepts a task stack depth in words. On 32-bit Cortex-M ports, the default configSTACK_DEPTH_TYPE and size_t are both 32-bit, but the kernel allocates the stack using unchecked uxStackDepth * sizeof(StackType_t). An oversized depth wraps to a small allocation; initialization then retains the original depth and performs stack pointer arithmetic using that value.

Target
FreeRTOS revision 592732b4d
FreeRTOS/Source/tasks.c, prvCreateTask() and prvInitialiseNewTask()
Cortex-M7 default port: FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/portmacro.h

Host

  • Host OS: Ubuntu 24

To Reproduce
On a 32-bit size_t / 32-bit StackType_t target, pass a depth greater than UINT32_MAX / 4; for example 0x40000020 words. The allocation expression wraps to 128 bytes, while prvInitialiseNewTask() computes a top-of-stack using pxStack[uxStackDepth - 1] and initializes the task from that original depth.

Expected behavior
The allocation-size multiplication is not checked before pvPortMallocStack(). The later initialization path assumes the requested word count was allocated.

Additional context
Before allocating, reject uxStackDepth > SIZE_MAX / sizeof(StackType_t) and return task-creation failure. Apply the same check to all dynamic stack allocation paths. A product should additionally impose a realistic maximum task-stack size at its API boundary.

主要言語
C
スター
4.6k
フォーク
1.6k
平均マージ
2日 22時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

FreeRTOS/FreeRTOS-Kernel のほかの issue

FreeRTOS/FreeRTOS-Kernel の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。