Repository navigation
fix: Check op arg counts when loading .oso files - #2231
Merged
Merged
Conversation
fpsunflower
approved these changes
Nov 26, 2026
We had previously assumed that as long as oslc wrote a correct .oso file, liboslexec could make strong assumptions about validity. At most, some codegen or constfold functions OSL_DASSERT on the argument numbers and types, mostly to help catch bugs as I was writing the compiler. The DASSERT does nothing in release builds, and a process abort isn't what you'd want when encountering a faulty oso file. This is, of course, wholly inadequate in a world where a renderer might encounter a corrupted or maliciously crafted oso file. This patch is just one step toward a future of being impervious to inavlid oso. In this patch, we augment the opcode table in liboslexec to have min and max arity (including being able to say that the max is "any") and check the number of arguments as we are reading the oso file, which lets everything downstream make certain assumptions and precludes whole classes of trouble without needing to change every op individually (the information is all in the central table). Assisted-by: Claude Code / Claude Opus 5.5 Signed-off-by: Larry Gritz <lg@larrygritz.com>
lgritz
merged commit Nov 26, 2026
073f1a2
into
AcademySoftwareFoundation:main
22 of 23 checks passed
lgritz
added a commit
to lgritz/OpenShadingLanguage
that referenced
this pull request
Nov 30, 2026
…dation#2231) We had previously assumed that as long as oslc wrote a correct .oso file, liboslexec could make strong assumptions about validity. At most, some codegen or constfold functions OSL_DASSERT on the argument numbers and types, mostly to help catch bugs as I was writing the compiler. The DASSERT does nothing in release builds, and a process abort isn't what you'd want when encountering a faulty oso file. This is, of course, wholly inadequate in a world where a renderer might encounter a corrupted or maliciously crafted oso file. This patch is just one step toward a future of being impervious to inavlid oso. In this patch, we augment the opcode table in liboslexec to have min and max arity (including being able to say that the max is "any") and check the number of arguments as we are reading the oso file, which lets everything downstream make certain assumptions and precludes whole classes of trouble without needing to change every op individually (the information is all in the central table). Assisted-by: Claude Code / Claude Opus 5.5 Signed-off-by: Larry Gritz <lg@larrygritz.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.
We had previously assumed that as long as oslc wrote correct .oso files, liboslexec could make strong assumptions about validity of anything it read. At most, some codegen or constfold functions OSL_DASSERT on the argument numbers and types, mostly to help catch bugs as I was writing the compiler. The DASSERT does nothing in release builds, and a process abort isn't what you'd want when encountering a faulty oso file.
This is, of course, wholly inadequate in a world where a renderer might encounter a corrupted or maliciously crafted oso file. This patch is just one step toward a future of being impervious to inavlid oso.
In this patch, we augment the opcode table in liboslexec to have min and max arity (including being able to say that the max is "any") and check the number of arguments as we are reading the oso file, which lets everything downstream make certain assumptions and precludes whole classes of trouble without needing to change every op individually (the information is all in the central table).
Assisted-by: Claude Code / Claude Opus 5.5