-
Notifications
You must be signed in to change notification settings - Fork 607
Fix null-deref in parse_cond_value #12294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary: The crash is a null-deref that occurs in the `parse_cond_value` function when executing a JumpFalse instruction in the Executorch runtime. The crash happens because the program attempts to access the data pointer of a tensor without checking if it is null. The root cause of the crash is that the `parse_cond_value` function does not validate if the tensor's data pointer is null before accessing its elements. This can happen when the input tensor is empty or its storage is not properly allocated. The function assumes that the tensor's data pointer is always valid, which is not the case when the tensor is empty. The patch fixes the crash by adding a null check for the tensor's data pointer before accessing its elements. Specifically, it adds the following code: `if (cond_data == nullptr) { ET_LOG(Error, "Tensor data is null"); return Error::InvalidArgument; }`. This check ensures that the function returns an error when the tensor's data pointer is null, preventing the null-deref crash. Other considerations that reviewers should take into account when validating the patch include verifying that the fix does not introduce any new errors or affect the normal execution of the Executorch runtime. Reviewers should also check that the patch handles edge cases, such as when the input tensor is not of type `Bool` or when the tensor is not properly initialized. Additionally, reviewers should ensure that the error handling mechanism is properly implemented and that the error message is informative and helpful for debugging purposes. In particular, reviewers should verify that the `ET_LOG` statement is properly logging the error and that the `Error::InvalidArgument` return value is correctly handled by the calling function. They should also check that the fix does not affect the performance of the Executorch runtime or introduce any new security vulnerabilities. NOTE: This diff is entirely auto-generated by LLM-based patch generator. Reviewer should carefully examine this diff as Lionhead does not guarrantee the correctnesss of the patch beyond fixing the crash and passing existing tests. Please commandeer this diff and revise as needed. Our bot does not respond to comments or revision requests (yet). Differential Revision: D77827830
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/12294
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Cancelled Job, 19 Unrelated FailuresAs of commit e79fd08 with merge base 6b3f172 ( CANCELLED JOB - The following job was cancelled. Please retry:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This pull request was exported from Phabricator. Differential Revision: D77827830 |
This PR needs a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Howd you run into this?
@@ -270,6 +270,10 @@ Result<bool> parse_cond_value(const EValue& cond_value) { | |||
static_cast<int8_t>(cond_val.scalar_type())); | |||
|
|||
const bool* cond_data = cond_val.const_data_ptr<bool>(); | |||
if (cond_data == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually can we use ET_CHECK_OR_RETURN_ERROR instead
Summary:
The crash is a null-deref that occurs in the
parse_cond_value
function when executing a JumpFalse instruction in the Executorch runtime. The crash happens because the program attempts to access the data pointer of a tensor without checking if it is null.The root cause of the crash is that the
parse_cond_value
function does not validate if the tensor's data pointer is null before accessing its elements. This can happen when the input tensor is empty or its storage is not properly allocated. The function assumes that the tensor's data pointer is always valid, which is not the case when the tensor is empty.The patch fixes the crash by adding a null check for the tensor's data pointer before accessing its elements. Specifically, it adds the following code:
if (cond_data == nullptr) { ET_LOG(Error, "Tensor data is null"); return Error::InvalidArgument; }
. This check ensures that the function returns an error when the tensor's data pointer is null, preventing the null-deref crash.Other considerations that reviewers should take into account when validating the patch include verifying that the fix does not introduce any new errors or affect the normal execution of the Executorch runtime. Reviewers should also check that the patch handles edge cases, such as when the input tensor is not of type
Bool
or when the tensor is not properly initialized. Additionally, reviewers should ensure that the error handling mechanism is properly implemented and that the error message is informative and helpful for debugging purposes.In particular, reviewers should verify that the
ET_LOG
statement is properly logging the error and that theError::InvalidArgument
return value is correctly handled by the calling function. They should also check that the fix does not affect the performance of the Executorch runtime or introduce any new security vulnerabilities.NOTE: This diff is entirely auto-generated by LLM-based patch generator.
Reviewer should carefully examine this diff as Lionhead does not guarrantee the
correctnesss of the patch beyond fixing the crash and passing existing tests.
Please commandeer this diff and revise as needed. Our bot does not respond to
comments or revision requests (yet).
Differential Revision: D77827830