-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
syscall: ReadLink() & Utimes() arguments for access-mode & share-mode are wrong #35150
Comments
PoC reproducer? |
This works on my Win7 box. EDIT: this fails with EDIT: the failure is reported in #35219. It could be unrelated to the CreateFile() share-mode issue.
|
Because the code is doing that in same process. |
We already proved that file_share_delete is an issue within the same process, and the CreateFile docs are consistent for file_share_* EDIT: but if the above fails with two processes, that proves my point :-) https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea |
I filed a bug report re os.Stat() vs os.Open() in Win10: #35219 This issue should consider necessary & optional share-mode arguments for CreateFile() invocations. @gopherbot remove release-blocker |
Although this is not documented well (that I can find), Windows will ignore the share flags if the requested access does not include FILE_READ_DATA, FILE_WRITE_DATA, FILE_EXECUTE, or DELETE. The only case that you've pointed out above is the one in ReadLink, which specifies GENERIC_READ (which is translated internally to FILE_GENERIC_READ, which includes FILE_READ_DATA). And to fix ReadLink, you can probably just remove GENERIC_READ and replace it with 0 or READ_FILE_ATTRIBUTES--according to my reading of the Windows code, issuing FSCTL_GET_REPARSE_POINT does not require any special permissions on the file. And indeed, internally we generally pass 0 or READ_FILE_ATTRIBUTES when opening files for the purpose of issuing this FSCTL. Having said all that, adding these share flags in these cases certainly doesn't hurt either--it just isn't necessary to fix any functional bug. |
Thanks for the drill down! Are you certain that concurrent rename/delete works in the above cases without |
Except for ReadLink, they should work, yes. |
@zx2c4 wanna patch the access-mode for syscall.ReadLink()? And drop Then we can close this... |
@alexbrainman and @mattn, do you think we should just hard-code FILE_SHARE_DELETE in these ephemeral, non-os.Open uses of syscall.CreateFile? |
Sorry, I should have changed the title to be about syscall.ReadLink() & .Utimes() FILE_SHARE_DELETE is not at issue here. |
What is the problem? How do I reproduce the problem? Thank you. Alex |
@alexbrainman two things:
|
I still do not see any problem here. Sorry. Alex |
Alex, did you see #35150 (comment)? @mattn could you help here? |
Yes, I did. Alex |
@networkimprov I don't still understand why you point with example code using FILE_SHARE_DELETE. #35150 (comment) is related on this issue? Anyway, AFAIK, eventhough using FILE_SHARE_DELETE, CreateFile possibly be fail when another thread start transaction. |
@mattn these are the issues:
The other posts aren't important. I was seeing a sharing error (due to a OneDrive bug), and thought it might be caused by CreateFile() missing file_share_delete arguments, but it wasn't. |
A search for CreateFile() finds the following read-only functions with a zero share-mode argument. I think their share-mode should be
FILE_SHARE_READ
, and in some cases alsoFILE_SHARE_WRITE
.EDIT: They would also need
FILE_SHARE_DELETE
in apps that expect to rename or remove a file concurrently with any of these ops.EDIT: these should probably get
| FILE_SHARE_READ
This simple patch adds
FILE_SHARE_DELETE
in syscall.Open(), but it doesn't help the above cases:cc @alexbrainman @zx2c4 @mattn
@gopherbot add OS-Windows
The text was updated successfully, but these errors were encountered: