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

src: remove usages of GetBackingStore in crypto #44079

Merged
merged 2 commits into from
Aug 4, 2022

Conversation

kvakil
Copy link
Contributor

@kvakil kvakil commented Aug 1, 2022

This removes all usages of GetBackingStore in crypto. See the
linked issue for an explanation.

Note: I am not sure of the lifetime semantics intended by
ArrayBufferOrViewContents -- I am pretty sure it is correct based on a
manual audit of the callsites & by analogy to ArrayBufferViewContents,
but please ensure that it is correct. If we are at all unsure of the
safety here, I would prefer to abandon this change.

Refs: #32226
Refs: #43921

This removes all usages of GetBackingStore in `crypto`. See the
linked issue for an explanation.

Note: I am not sure of the lifetime semantics intended by
`ArrayBufferOrViewContents` -- I am pretty sure it is correct based on
a manual audit of the callsites, but please ensure that it is correct.

Refs: nodejs#32226
Refs: nodejs#43921
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Aug 1, 2022
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

src/crypto/crypto_util.h Outdated Show resolved Hide resolved
@F3n67u F3n67u added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Aug 1, 2022
@kvakil kvakil added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 1, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 1, 2022
@nodejs-github-bot
Copy link
Collaborator

src/crypto/README.md Show resolved Hide resolved
@kvakil kvakil requested a review from addaleax August 1, 2022 20:53
@kvakil kvakil added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 1, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 1, 2022
@nodejs-github-bot
Copy link
Collaborator

kvakil added a commit to kvakil/node that referenced this pull request Aug 2, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: nodejs#44079 (comment)
@kvakil kvakil added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2022
@nodejs-github-bot
Copy link
Collaborator

@kvakil kvakil added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 2, 2022
@kvakil kvakil self-assigned this Aug 2, 2022

inline explicit ArrayBufferOrViewContents(v8::Local<v8::Value> buf) {
if (buf.IsEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

I understand why this exists, but it feels somewhat strange to explicitly allow passing in empty Locals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. An alternative would be to allocate an empty ArrayBuffer and pass it into this function. None of the current callsites looked particularly hot, but I wasn't sure.

Do you think that would be acceptable wrt to performance?

(P.S. if your concern here is blocking, feel free to request changes on the PR.)

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 4, 2022
@nodejs-github-bot nodejs-github-bot merged commit 4c725f4 into nodejs:main Aug 4, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 4c725f4

nodejs-github-bot pushed a commit that referenced this pull request Aug 6, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: #44079 (comment)
PR-URL: #44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
danielleadams pushed a commit that referenced this pull request Aug 16, 2022
This removes all usages of GetBackingStore in `crypto`. See the
linked issue for an explanation.

Note: I am not sure of the lifetime semantics intended by
`ArrayBufferOrViewContents` -- I am pretty sure it is correct based on
a manual audit of the callsites, but please ensure that it is correct.

Refs: #32226
Refs: #43921
PR-URL: #44079
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
danielleadams pushed a commit that referenced this pull request Aug 16, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: #44079 (comment)
PR-URL: #44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
ruyadorno pushed a commit that referenced this pull request Aug 23, 2022
This removes all usages of GetBackingStore in `crypto`. See the
linked issue for an explanation.

Note: I am not sure of the lifetime semantics intended by
`ArrayBufferOrViewContents` -- I am pretty sure it is correct based on
a manual audit of the callsites, but please ensure that it is correct.

Refs: #32226
Refs: #43921
PR-URL: #44079
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
ruyadorno pushed a commit that referenced this pull request Aug 23, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: #44079 (comment)
PR-URL: #44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
targos pushed a commit that referenced this pull request Sep 5, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: #44079 (comment)
PR-URL: #44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Fyko pushed a commit to Fyko/node that referenced this pull request Sep 15, 2022
This removes all usages of GetBackingStore in `crypto`. See the
linked issue for an explanation.

Note: I am not sure of the lifetime semantics intended by
`ArrayBufferOrViewContents` -- I am pretty sure it is correct based on
a manual audit of the callsites, but please ensure that it is correct.

Refs: nodejs#32226
Refs: nodejs#43921
PR-URL: nodejs#44079
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Fyko pushed a commit to Fyko/node that referenced this pull request Sep 15, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: nodejs#44079 (comment)
PR-URL: nodejs#44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
juanarbol pushed a commit that referenced this pull request Oct 10, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: #44079 (comment)
PR-URL: #44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
juanarbol pushed a commit that referenced this pull request Oct 11, 2022
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: #44079 (comment)
PR-URL: #44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Jan 3, 2023
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: nodejs/node#44079 (comment)
PR-URL: nodejs/node#44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
guangwong pushed a commit to noslate-project/node that referenced this pull request Jan 3, 2023
It is error-prone to copy or heap-allocate `ArrayBufferViewContents`,
because you might accidentally cause it to exceed the lifetime of its
argument. Let's make it impossible to do so. Fortunately we were not
doing so anywhere already, so this diff is purely defensive.

Refs: nodejs/node#44079 (comment)
PR-URL: nodejs/node#44091
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants