Skip to content
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

Add safety checks when rendering kernel key strings #8327

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

dbort
Copy link
Contributor

@dbort dbort commented Feb 8, 2025

Summary:
The old code assumed that it was handed a MAX_SIZE buffer, and that the list of TensorMeta values would never generate a string longer than that size.

This PR adds explicit size tracking and an error code to the API, and now returns an error if the buffer is too small for the provided values.

While I'm here, move MAX_SIZE out of the public API, since it's not an intrinsic aspect of kernel keys. This is technically a BC-breaking change, but I don't expect that any users are actually depending on it.

Also:

  • Fix some unused var warnings, which uncovered a couple places where we ignored an Error. Along similar lines, replaced EXPECT with ASSERT when validating kernel registration so we don't try to run the rest of the test after a registration error.
  • Silence the Meta-internal linter by moving to std::array in several code chunks I needed to touch anyway because of the new make_kernel_key parameter.

Add unit tests for all modified code.

Differential Revision: D69324821

Copy link

pytorch-bot bot commented Feb 8, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8327

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit e9926e7 with merge base 8697fe4 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 8, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69324821

Copy link
Contributor

@larryliu0820 larryliu0820 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding the check! Just left one comment

dbort added a commit to dbort/executorch that referenced this pull request Feb 10, 2025
Summary:

The old code assumed that it was handed a MAX_SIZE buffer, and that the list of TensorMeta values would never generate a string longer than that size.

This PR adds explicit size tracking and an error code to the API, and now returns an error if the buffer is too small for the provided values.

While I'm here, move MAX_SIZE out of the public API, since it's not an intrinsic aspect of kernel keys. This is technically a BC-breaking change, but I don't expect that any users are actually depending on it.

Also:
 - Fix some unused var warnings (one of which was a real bug where we ignored an Error)
- Silence the Meta-internal linter by moving to std::array in several places, code chunks I needed to touch anyway because of the new `make_kernel_key` parameter

Add unit tests for all modified code.

Reviewed By: larryliu0820

Differential Revision: D69324821
dbort added a commit to dbort/executorch that referenced this pull request Feb 10, 2025
Summary:

The old code assumed that it was handed a MAX_SIZE buffer, and that the list of TensorMeta values would never generate a string longer than that size.

This PR adds explicit size tracking and an error code to the API, and now returns an error if the buffer is too small for the provided values.

While I'm here, move MAX_SIZE out of the public API, since it's not an intrinsic aspect of kernel keys. This is technically a BC-breaking change, but I don't expect that any users are actually depending on it.

Also:
 - Fix some unused var warnings (one of which was a real bug where we ignored an Error)
- Silence the Meta-internal linter by moving to std::array in several code chunks I needed to touch anyway because of the new `make_kernel_key` parameter

Add unit tests for all modified code.

Reviewed By: larryliu0820

Differential Revision: D69324821
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69324821

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69324821

Summary:

The old code assumed that it was handed a MAX_SIZE buffer, and that the list of TensorMeta values would never generate a string longer than that size.

This PR adds explicit size tracking and an error code to the API, and now returns an error if the buffer is too small for the provided values.

While I'm here, move MAX_SIZE out of the public API, since it's not an intrinsic aspect of kernel keys. This is technically a BC-breaking change, but I don't expect that any users are actually depending on it.

Also:
 - Fix some unused var warnings, which uncovered a couple places where we ignored an Error. Along similar lines, replaced EXPECT with ASSERT when validating kernel registration so we don't try to run the rest of the test after a registration error.
- Silence the Meta-internal linter by moving to std::array in several code chunks I needed to touch anyway because of the new `make_kernel_key` parameter.

Add unit tests for all modified code.

Reviewed By: larryliu0820

Differential Revision: D69324821
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69324821

@facebook-github-bot facebook-github-bot merged commit 70143a2 into pytorch:main Feb 11, 2025
46 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants