- Notifications
You must be signed in to change notification settings - Fork3.8k
win,fs: get fstat of AppExecLink reparse points#4663
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:v1.x
Are you sure you want to change the base?
win,fs: get fstat of AppExecLink reparse points#4663
Uh oh!
There was an error while loading.Please reload this page.
Conversation
vtjnash left a comment
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.
IIUC, you actually need to replace the firstCreateFileW on this code path with this fallback, otherwise (here) you introduced a TOCTOU bug into the code. And also replace almost allCreateFileW calls in this fs.c file with this retry strategy, like this pseudo code:
if (!do_lstat) { for (i = 0; i < 255; i++) /* Try to open the file using kernel filters */ if (CreateFileW()) break /* The kernel doesn't implement all filters, as some must be emulated in userspace by every application: see if this is a tag that libuv knows about */ if (! CreateFileW(FILE_FLAG_OPEN_REPARSE_POINT)) return error if (! fs__readlink_handle()) return error CloseHandle()}else CreateFileW(FILE_FLAG_OPEN_REPARSE_POINT)if (error) return errorreturn handlee08364d tobe96774Comparehuseyinacacak-janea commentedJan 3, 2025
Thanks for the review. I've applied your suggestion to the respective place. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| stat_info.CreationTime.QuadPart=dir_info.CreationTime.QuadPart; | ||
| stat_info.LastAccessTime.QuadPart=dir_info.LastAccessTime.QuadPart; | ||
| stat_info.LastWriteTime.QuadPart=dir_info.LastWriteTime.QuadPart; | ||
| if (stat_info.FileAttributes&FILE_ATTRIBUTE_REPARSE_POINT) { |
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.
There should not need to be any changes tofs__stat_directory function, as you're introducing a TOCTOU bug by doing so
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.
I tried to fix it. Hope there is no TOCTOU bug.
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
huseyinacacak-janea commentedJan 24, 2025
Is there anything I can do to help this PR move forward? |
vtjnash left a comment
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.
I need you to rework the changes such that the only code being changed in stat is that any existing call to CreateFile are replaced by your new helperfs__create_file (fs__stat_get_handle), instead of changing thestat functions themselves. That should avoid any time-of-check issues and then give us a drop-in replacement function to fix all of the other CreateFile calls later also. I have been trying to find time to do it myself to better explain what I mean, but other concerns have kept me too busy lately.
huseyinacacak-janea commentedJan 31, 2025
Sorry, I couldn't quite understand what you meant. Let me explain the options I have in mind.
|
huseyinacacak-janea commentedFeb 7, 2025
I'll be stepping down from the project in 2 weeks. If there is anything I can do to help this PR move forward, feel free to reach out to me until then. |
This fixes the problem of getting the fstat of AppExecLink reparse points (e.g. Windows Apps).
Refs:nodejs/node#36790