Repository navigation
multikernel: read a message's sizes once from its ring slot - #59
Merged
congwang-mk merged 1 commit intoNov 24, 2026
Merged
Conversation
mk_message_type_ipi_callback() runs on the ring slot itself, which the sending kernel can still write. It checks payload_len against data_size and then reads both again: to compute the bound, and to hand the length to the handler. A sender that rewrites either one between the check and the use makes the handler read past the slot, from hard IRQ context of the receiving kernel. data_size was checked against MK_MAX_DATA_SIZE by the drain, but is read again here too. Read each size once with READ_ONCE(), check that copy against both bounds, and pass it on. Fixes: 4f676d2 ("multikernel: Add messaging layer for inter-kernel communication") Signed-off-by: Utkarsh Maurya <projects.utkarshMaurya@gmail.com>
This was referenced Nov 24, 2026
Author
|
Tested at runtime on RISC-V QEMU (#49 head + #55–#59): a test-only hook in the spawn sent 2000 messages with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mk_message_type_ipi_callback()works on the ring slot itself, which the sending kernel can still write. It checkspayload_lenagainstdata_size, then reads both again to compute the bound and to pass the length to the handler. A sender that rewrites either between the check and the use makes the handler read past the slot, in hard IRQ context of the receiving kernel.Read each size once with
READ_ONCE(), check that copy against both bounds, and pass it on.Tested: RISC-V QEMU virt (aia=aplic-imsic, OpenSBI v1.8.1), #49 head b4be1bf with #55–#59 applied: all message traffic (halts, hotplug requests and ACKs, NIC lending) still works, 28 spawns. A sender that rewrites the sizes was not tested at runtime. Builds on current master (fca2f47): x86_64 clang W=1 with no new warnings, also with PCI=n and with MULTIKERNEL=n; checkpatch --strict clean.