Skip to content

signal: add signal number bound check#475

Open
etiaro wants to merge 4 commits into
masterfrom
etiaro/signal-small-fixes
Open

signal: add signal number bound check#475
etiaro wants to merge 4 commits into
masterfrom
etiaro/signal-small-fixes

Conversation

@etiaro
Copy link
Copy Markdown
Contributor

@etiaro etiaro commented May 8, 2026

Description

Avoid Out Of Bounds accesses to static array _signals_posix2phx.

JIRA: RTOS-1309

Additional change with a signalHandle syscall signature adjustment: not marked as breaking, as missing arguments can still be obtained from stack garbage in kernel, as their resulting values were unused anyway.

Motivation and Context

Resolves phoenix-rtos/phoenix-rtos-project#1453

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces bounds checking for signal numbers in the raise, kill, killpg, and signalPostPosix functions to prevent out-of-bounds access to the internal signal mapping table. The review feedback correctly identifies that the current implementation incorrectly rejects signal 0, which is a valid 'null signal' used in POSIX for process and thread existence checks. It is recommended to update the lower bound check from sig <= 0 to sig < 0 across all modified functions to maintain standard behavior.

Comment thread signal/signal.c Outdated
Comment thread signal/signal.c Outdated
Comment thread signal/signal.c Outdated
Comment thread signal/signal.c Outdated
@etiaro etiaro force-pushed the etiaro/signal-small-fixes branch from bf26779 to 3b1c190 Compare May 8, 2026 12:07
@etiaro etiaro requested a review from Darchiv May 8, 2026 12:33
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Unit Test Results

10 543 tests  ±0   9 881 ✅ ±0   52m 43s ⏱️ - 1m 9s
   649 suites ±0     662 💤 ±0 
     1 files   ±0       0 ❌ ±0 

Results for commit 37508ed. ± Comparison against base commit 1383f55.

♻️ This comment has been updated with latest results.

@etiaro etiaro requested review from adamgreloch and agkaminski May 8, 2026 14:46
adamgreloch
adamgreloch previously approved these changes May 8, 2026
Comment thread signal/signal.c Outdated
etiaro added 3 commits May 13, 2026 17:04
Avoid Out Of Bounds accesses to static array _signals_posix2phx.

JIRA: RTOS-1309
Process-wide sigmask that was set here was left unused in kernel.

JIRA: RTOS-1309
Ensure no unexpected out-of-bounds errors will happen.

JIRA: RTOS-1309
@etiaro etiaro force-pushed the etiaro/signal-small-fixes branch from c3cb17f to 37508ed Compare May 13, 2026 15:04
adamgreloch
adamgreloch previously approved these changes May 14, 2026
@etiaro etiaro requested a review from ziemleszcz May 14, 2026 09:26
required by POSIX

JIRA: RTOS-736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kill() doesn't fail on invalid negative signal number

2 participants