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

fs: fix realpath inode link caching #33945

Closed
wants to merge 2 commits into from

Conversation

lundibundi
Copy link
Member

The fs.realpath / fs.realpathSync cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

I don't think it is possible to write a test for this as it depends on specific inode numbers being bigger than 2**53.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

/cc @nodejs/fs @bnoordhuis

The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: nodejs#33936
@lundibundi lundibundi added the fs Issues and PRs related to the fs subsystem / file system. label Jun 18, 2020
@nodejs-github-bot

This comment has been minimized.

@jasnell
Copy link
Member

jasnell commented Jun 18, 2020

@MMhunter ... can you verify whether this fixes the issue you reported in #33936?

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM so long as we can get verification that it fixes the originally reported problem.

@nodejs-github-bot
Copy link
Collaborator

@ShadyZOZ
Copy link

ShadyZOZ commented Jun 19, 2020

fix verified!
image
image

@ShadyZOZ
Copy link

image

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Thanks for finishing it up, Denys. :-)

@MMhunter
Copy link

@MMhunter ... can you verify whether this fixes the issue you reported in #33936?

Yep, it fixes the issue.

@addaleax addaleax added lts-watch-v12.x author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Jun 19, 2020
@nodejs-github-bot
Copy link
Collaborator

jasnell pushed a commit that referenced this pull request Jun 24, 2020
The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

PR-URL: #33945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@jasnell
Copy link
Member

jasnell commented Jun 24, 2020

Landed in bd8a719

@jasnell jasnell closed this Jun 24, 2020
codebytere pushed a commit that referenced this pull request Jun 27, 2020
The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

PR-URL: #33945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@codebytere codebytere mentioned this pull request Jun 28, 2020
codebytere pushed a commit that referenced this pull request Jun 30, 2020
The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

PR-URL: #33945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
codebytere pushed a commit that referenced this pull request Jul 10, 2020
The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

PR-URL: #33945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
codebytere pushed a commit that referenced this pull request Jul 12, 2020
The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

PR-URL: #33945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@codebytere codebytere mentioned this pull request Jul 13, 2020
codebytere pushed a commit that referenced this pull request Jul 14, 2020
The `fs.realpath` / `fs.realpathSync` cache already seen symbolic links
using the inode number which may be longer that max supported
JS number (2**53) and will therefore be incorrectly handled by possibly
entering infinite loop of calling stat on the same node.

This PR changes those functions (where appropriate) to use
bigint for inode numbers.

Fixes: #33936

PR-URL: #33945
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[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. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite event loop after calling fs.realpath on 16-inch Macbook
8 participants