Skip to content

[kernel] Fix medium-model signal handler range#2748

Closed
parabyte wants to merge 1 commit into
ghaerr:masterfrom
parabyte:agent/gem-medium-signal-range
Closed

[kernel] Fix medium-model signal handler range#2748
parabyte wants to merge 1 commit into
ghaerr:masterfrom
parabyte:agent/gem-medium-signal-range

Conversation

@parabyte

Copy link
Copy Markdown

Summary

This fixes sys_signal() validation for medium-model executables whose combined code allocation crosses 64 KiB.

The current check converts the allocation from paragraphs to bytes with s->size << 4. That 16-bit expression wraps at 64 KiB, and requiring the handler segment to equal the allocation base also rejects valid far-text handlers.

The replacement:

  • keeps the complete check in native 16-bit paragraph units
  • accepts a handler segment within the process code allocation
  • accounts for complete paragraphs in the 16-bit handler offset
  • orders subtraction and bounds checks so no intermediate can wrap
  • retains the existing default and ignore signal behavior

The byte offset is converted with four single-bit 8086 shifts, avoiding a division helper or variable-count shift.

Validation

Validated at commit 548d73db1fc57f4f11c7e7379f87461077ca23eb on upstream master b7cfe4973487ab235169dd9eb489285409fb8b2a:

  • full IBM PC ibmpc-1440 kernel build: pass
  • resulting kernel: 113056 bytes, including 62352 bytes near code and 32112 bytes far text
  • changed sys_signal disassembly: 16-bit 8086 instructions only
  • no multiply, divide, wide helper, or later-CPU opcode in the changed routine
  • patch whitespace and one-commit branch audit: pass

Related signal audit discussions: #2646 and #2649.

@parabyte parabyte marked this pull request as ready for review July 15, 2026 00:07
@parabyte parabyte closed this Jul 16, 2026
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.

1 participant