#18737 closed defect (fixed)
Linux guests: open(filename, O_CREAT|..., mode) fails inside shared folder => fixed in SVN/6.0.x x>10
Reported by: | jamesba | Owned by: | paulson |
---|---|---|---|
Component: | shared folders | Version: | VirtualBox 6.0.8 |
Keywords: | file create shared permissions | Cc: | |
Guest type: | Linux | Host type: | Linux |
Description
The following C code produces a simple executable which will attempt to create and open a read only test file in a single operation.
Expected behaviour when run:
- A newly created file called test.txt is created on disk with read only permissions
- A read-write file-handle for the file is returned by the open call
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> int main() { int fd = open("test.txt", O_CREAT | O_EXCL | O_RDWR, 0444); if (fd < 0) { perror("Could not create file: "); return -fd; } return 0; }
When run on other file systems this works correctly but when run on a virtualbox shared folder the file is created correctly but the program exits with the error message:
Could not create file: : Permission denied
This can be bypassed by running the command with sudo, in which case it succeeds normally.
This is not a purely hypothetical problem, since the same error occurs when attempting to use any programme that makes this system call, such as a git clone.
Attachments (1)
Change History (10)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Can confirm this was an issue for me on 6.0.8 and is still an issue on 6.0.10.
- Host: Debian Linux
- Guest: Debian Linux (running Guest Additions 6.0.10)
- Host filesystem: ext4 (mounted rw,relatime,data=ordered)
- Guest: vboxsf volume mounted rw,nodev,relatime,iocharset=utf8,uid=<my_uid>,gid=<my_gid>
OP's reproducer reproduces the issue for me.
I'm also having issues with git repos on a vboxsf volume.
comment:3 by , 5 years ago
See also some of the comments in #18569 (they directly relate to the git failure)
by , 5 years ago
Attachment: | poc_18737.py added |
---|
comment:4 by , 5 years ago
I've written a reproducer in Python and tried all file modes from 0o000 to 0o777 using flags O_CREAT | O_EXCL | O_RDWR.
If I map /home/justin/shared to my VirtualBox guest (mounted as /home/justin/shared within the guest) and place the reproducer in shared/test_file_creation, then the poc runs fine from my host but exhibits failures when run from the guest.
In summary, the following file modes are OK in the guest but everything else fails:
0o0 --------- PASS 0o2 -------w- PASS 0o20 ----w---- PASS 0o22 ----w--w- PASS 0o6** rw-****** PASS 0o7** rwx****** PASS
(Where "*" is of course anything)
Curiously, mode 0o222 fails:
% python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.open("testfile", os.O_CREAT | os.O_EXCL | os.O_RDWR, 0o222) Traceback (most recent call last): File "<stdin>", line 1, in <module> PermissionError: [Errno 13] Permission denied: 'testfile'
I've attached poc_18737.py from which I got the above results.
comment:6 by , 5 years ago
Owner: | set to |
---|---|
Status: | new → accepted |
Summary: | Open system call to create and open read only file fails on shared folder → Linux guests: open(filename, O_CREAT|..., mode) fails inside shared folder |
follow-up: 8 comment:7 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Summary: | Linux guests: open(filename, O_CREAT|..., mode) fails inside shared folder → Linux guests: open(filename, O_CREAT|..., mode) fails inside shared folder => fixed in SVN/6.0.x x>10 |
This is a regression which was introduced in VirtualBox 6.0.6 and affects Linux guests which have a kernel > 3.16.0 and utilize the atomic_open() filesystem interface. The file creation succeeds but the follow-up call to the Linux kernel routine finish_open() happened without FMODE_CREATED set in the file->f_mode structure element which then erroneously returns EACCES for unprivileged users.
This has been fixed in trunk and the fix has also been backported to VirtualBox 6.0.x (x > 10) and any 6.0.x Testbuilds with a revision >= r132861. This issue doesn't apply to VirtualBox 5.2.x.
comment:8 by , 5 years ago
Replying to paulson:
This is a regression which was introduced in VirtualBox 6.0.6 ... This has been fixed ... with a revision >= r132861.
I added the ticket and the fixed revision in the Discuss the 6.0.6 release thread in the forums, thanks @paulson.
comment:9 by , 5 years ago
The issue is fixed for me using VBoxGuestAdditions_6.0.11-132973.iso on VirtualBox 6.0.10 (Both the Python reproducer, as well as "git clone")
Thanks @paulson
Can confirm that this problem is not present on v6.0.4.