Windows Version
Microsoft Windows [Version 10.0.26200.8457]
WSL Version
2.5.9.0
Are you using WSL 1 or WSL 2?
Kernel Version
4.4.0-26100-Microsoft
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
WSL uses drvfs to mount network shares over the SMB protocol. When a git repository is stored on a network share you can perform read operations such as 'git status' and 'git log' but write operations such as 'git add' and 'git tag' will fail with an error like this:
# git tag -a -m "" my_tag
error: insufficient permission for adding an object to repository database .git/objects
error: unable to write tag file
If you run the command under strace you will see an error like this:
# strace git tag -a -m "" my_tag
...
openat(AT_FDCWD, ".git/objects/f1/tmp_obj_yHk6zM", O_RDWR|O_CREAT|O_EXCL, 0444) = -1 EACCES (Permission denied)
...
The same error can be reproduced outside a git repository (but still on a network share) with the following test program:
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
int fd = open("new.txt", O_RDWR | O_CREAT | O_EXCL, 0444);
if (fd == -1) { perror("open failed"); }
else { close(fd); unlink("new.txt"); printf("success\n"); }
}
This operation is valid and permissible according to the POSIX documentation for open(2):
Note that mode applies only to future accesses of the newly
created file; the open() call that creates a read-only file
may well return a read/write file descriptor.
Therefore this appears to be a defect in the drvfs filesystem plugin. You can observe when running the test program that the file does get created with the correct permissions despite the open() failure. It seems like this atomic operation has been split into two operations (create + open) inside the drvfs plugin.
Expected Behavior
POSIX compliance
Actual Behavior
violation of POSIX
Diagnostic Logs
No response
Windows Version
Microsoft Windows [Version 10.0.26200.8457]
WSL Version
2.5.9.0
Are you using WSL 1 or WSL 2?
Kernel Version
4.4.0-26100-Microsoft
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
WSL uses drvfs to mount network shares over the SMB protocol. When a git repository is stored on a network share you can perform read operations such as 'git status' and 'git log' but write operations such as 'git add' and 'git tag' will fail with an error like this:
If you run the command under strace you will see an error like this:
The same error can be reproduced outside a git repository (but still on a network share) with the following test program:
This operation is valid and permissible according to the POSIX documentation for open(2):
Therefore this appears to be a defect in the drvfs filesystem plugin. You can observe when running the test program that the file does get created with the correct permissions despite the open() failure. It seems like this atomic operation has been split into two operations (create + open) inside the drvfs plugin.
Expected Behavior
POSIX compliance
Actual Behavior
violation of POSIX
Diagnostic Logs
No response