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

child_process: fix handling of incorrect uid/gid in spawn #22574

Closed

Conversation

lundibundi
Copy link
Member

@lundibundi lundibundi commented Aug 29, 2018

uid/gid must be int32, which is asserted on a c++ side but wasn't
checked on a JS side and therefore resulted in a process crash.

Refs: #22570

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Also, I'm not sure about the 'correct type' in TypeError, is 'int32' okay?

uid/gid must be uint32, which is asserted on a c++ side but wasn't
checked on a JS side and therefore resulted in a process crash.

Refs: nodejs#22570
@lundibundi lundibundi added the child_process Issues and PRs related to the child_process subsystem. label Aug 29, 2018
@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Aug 29, 2018
@lundibundi
Copy link
Member Author

@lundibundi lundibundi added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 29, 2018
if (options.uid != null && !Number.isInteger(options.uid)) {
throw new ERR_INVALID_ARG_TYPE('options.uid', 'integer', options.uid);
if (options.uid != null &&
(!Number.isInteger(options.uid) || !isUint32(options.uid))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the Number.isInteger() check still needed? Also, don't we want int32 checks to match the C++ checks?

Copy link
Member Author

@lundibundi lundibundi Aug 29, 2018

Choose a reason for hiding this comment

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

It will look kind of strange (especially if it's an object: {} >>> 1 and {} | 0) but I guess it is redundant.

I actually thought maybe it's worth changing them too, though I don't have enough knowledge of the topic. Linux usage and googling tell me that uid/gid must be non-negative, though maybe some of the systems we support actually support negative uid/gid. Therefore I'd also like some input on this.
In the end, I can always change those to isint32 and a topic of changing them to uint checks may be resolved in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

After some more googling OpenBSD seem to use -2 as internal "nobody" still.
For now, I'll change it to Int32 and we can discuss this later.

@lundibundi
Copy link
Member Author

lundibundi commented Aug 29, 2018

@addaleax
Copy link
Member

Landed in 22789fd

@addaleax addaleax closed this Aug 31, 2018
addaleax pushed a commit that referenced this pull request Aug 31, 2018
uid/gid must be uint32, which is asserted on a c++ side but wasn't
checked on a JS side and therefore resulted in a process crash.

Refs: #22570

PR-URL: #22574
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Weijia Wang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
addaleax pushed a commit that referenced this pull request Aug 31, 2018
uid/gid must be uint32, which is asserted on a c++ side but wasn't
checked on a JS side and therefore resulted in a process crash.

Refs: #22570

PR-URL: #22574
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Weijia Wang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 3, 2018
uid/gid must be uint32, which is asserted on a c++ side but wasn't
checked on a JS side and therefore resulted in a process crash.

Refs: #22570

PR-URL: #22574
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Weijia Wang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 6, 2018
uid/gid must be uint32, which is asserted on a c++ side but wasn't
checked on a JS side and therefore resulted in a process crash.

Refs: #22570

PR-URL: #22574
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Weijia Wang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Trivikram Kamat <[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. child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants