Repository navigation
Conversation
O_CLOEXEC was being passed to open() as the mode, where it is ignored, rather than as one of the flags. As a result the PIO device was inherited by any program that the application went on to execute. Signed-off-by: Phil Elwell <phil@raspberrypi.com> Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The instructions of a program are copied into the fixed-size buffer in the ioctl arguments, but the only checks on the length of the program were parameter assertions, which are normally compiled out. A program of more than 32 instructions would therefore overflow the buffer on the stack by up to 446 bytes. Add a real check, and fail the operation if the program is too big or doesn't fit at the requested offset. Signed-off-by: Phil Elwell <phil@raspberrypi.com> Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
An IRQ thread was created for every PIO instance as soon as it was opened, and it then blocked indefinitely in the kernel, waiting for an interrupt. pio_close did nothing to stop it, and because the thread was still using the device, closing the file descriptor didn't release the device either - any state machines, programs and DMA channels remained claimed until the process exited. Should the thread ever wake up, it would then use a file descriptor number that could by then refer to a completely different file. Instead, only start the thread when the first IRQ is mapped, make it wait with a timeout so that it can notice a request to stop, and have pio_close stop it and wait for it before closing the device. Forget the file descriptor once it has been closed. While here: - don't call a NULL handler if an interrupt arrives when no handler is registered, - remove the leftover debug thread in the RP1 backend, which competed with the real IRQ thread for interrupts and discarded any it got, - initialise the handle lock statically, so that it can also protect pio_init against concurrent callers. Signed-off-by: Phil Elwell <phil@raspberrypi.com> Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
pio_irq_map indexes the per-instance IRQ table with a value that was only checked by a parameter assertion, which is normally compiled out (and was off by one). Make it a real check, and also check the IRQ number returned by the kernel. Make sure that pio_init stays within the instance and IRQ handler tables, however many devices and IRQs there are, and that pio_open_helper doesn't read beyond the end of the instance table. Signed-off-by: Phil Elwell <phil@raspberrypi.com> Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
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.
Fix a number of issues found by a security audit of PIOLib.