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

"Invalid argument" on creating file in 9p filesystem (Linux) #996

Closed
SuperMaxusa opened this issue Feb 28, 2024 · 13 comments
Closed

"Invalid argument" on creating file in 9p filesystem (Linux) #996

SuperMaxusa opened this issue Feb 28, 2024 · 13 comments
Labels

Comments

@SuperMaxusa
Copy link
Contributor

SuperMaxusa commented Feb 28, 2024

Linux (from 6.6.x) can't create file on mounted host9p by mount -t 9p host9p /mnt, returning an error Invalid argument (-1 EINVAL), also this error showing on ls.

error

strace (ls)
execve("/bin/ls", ["ls", "/mnt"], 0xbfdeff4c /* 12 vars */) = 0
set_thread_area({entry_number=-1, base_addr=0xb7f7bc64, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=6)
set_tid_address(0xb7f7bcfc)             = 1930
brk(NULL)                               = 0x13d4000
brk(0x13d6000)                          = 0x13d6000
mmap2(0x13d4000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x13d4000
mprotect(0xb7f79000, 4096, PROT_READ)   = 0
mprotect(0x551000, 8192, PROT_READ)     = 0
getuid32()                              = 0
ioctl(0, TIOCGWINSZ, {ws_row=48, ws_col=128, ws_xpixel=0, ws_ypixel=400}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=48, ws_col=128, ws_xpixel=0, ws_ypixel=400}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=48, ws_col=128, ws_xpixel=0, ws_ypixel=400}) = 0
statx(AT_FDCWD, "/mnt", AT_STATX_SYNC_AS_STAT, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=STATX_ATTR_MOUNT_ROOT, stx_mode=S_IFDIR|0777, stx_size=0, ...}) = 0
open("/mnt", O_RDONLY|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ed1000
getdents64(3, 0xb7ed1038 /* 4 entries */, 2048) = 120
statx(AT_FDCWD, "/mnt/testfile", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, 0xbf8d56c0) = -1 EINVAL (Invalid argument)
write(2, "ls: /mnt/testfile: Invalid argum"..., 36) = 36
statx(AT_FDCWD, "/mnt/file_from_host.txt", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0666, stx_size=0, ...}) = 0
getdents64(3, 0xb7ed1038 /* 0 entries */, 2048) = 0
close(3)                                = 0
munmap(0xb7ed1000, 8192)                = 0
ioctl(1, TIOCGWINSZ, {ws_row=48, ws_col=128, ws_xpixel=0, ws_ypixel=400}) = 0
writev(1, [{iov_base="\33[0;0mfile_from_host.txt\33[m", iov_len=27}, {iov_base="\n", iov_len=1}], 2) = 28
exit_group(1)                           = ?
+++ exited with 1 +++
strace (touch)
execve("/bin/touch", ["touch", "/mnt/testfile"], 0xbf92b1bc /* 12 vars */) = 0
set_thread_area({entry_number=-1, base_addr=0xb7f7cc64, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=6)
set_tid_address(0xb7f7ccfc)             = 1923
brk(NULL)                               = 0x1723000
brk(0x1725000)                          = 0x1725000
mmap2(0x1723000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x1723000
mprotect(0xb7f7a000, 4096, PROT_READ)   = 0
mprotect(0x546000, 8192, PROT_READ)     = 0
getuid32()                              = 0
utimensat(AT_FDCWD, "/mnt/testfile", NULL, 0) = -1 ENOENT (No such file or directory)
open("/mnt/testfile", O_RDWR|O_CREAT|O_LARGEFILE, 0666) = -1 EINVAL (Invalid argument)
write(2, "touch: /mnt/testfile: Invalid ar"..., 39) = 39
exit_group(1)                           = ?
+++ exited with 1 +++

Note for Alpine Linux: the bug is only on v3.19 (from 3.19.0 RC2 and above, this does not apply to previous versions):

Alpine's version Kernel version Have a bug?
3.18.6 6.1.75 no
3.19.0 RC1 6.1.62 no
3.19.0 RC2 6.6.3 yes
3.19.1 6.6.14 yes
@copy copy added the bug label Feb 28, 2024
@farhan-ct
Copy link

I have a similar issue when trying to open node console on alpine. It gives me an error saying 'x' invalid argument found or something. Will add more details later. Please ignore if this is irrelevant.

@SuperMaxusa
Copy link
Contributor Author

trying to open node console on alpine.

did you tried run node with script without repl (or node -e "console.log('hello')") or this is also not working?

@farhan-ct
Copy link

did you tried run node with script without repl (or node -e "console.log('hello')") or this is also not working?

Am able to run node scripts without issues. issue was for node console only. Will try node -e "console.log('hello')" too and update here.

@farhan-ct
Copy link

@SuperMaxusa regarding the node issue I mentioned earlier, nothing to worry about, it's #875 . I noticed it earlier but just confirming the same here.

@SuperMaxusa
Copy link
Contributor Author

This also reproduces in Void Linux 2024-03-14, so it's problem of Linux kernel 6.6.x (or earlier), not just Alpine

void

@SuperMaxusa SuperMaxusa changed the title "Invalid argument" on creating file in 9p filesystem (Alpine Linux) "Invalid argument" on creating file in 9p filesystem (Linux) Mar 20, 2024
@farhan-ct
Copy link

Issue in debian too :( with 9pfs

@farhan-ct
Copy link

How do we fix this? I can try but will need some guidance. Issue is reproducable in the provided debian docker build in this repo too.

@SuperMaxusa
Copy link
Contributor Author

I have some thoughts about this commit in linux repo: torvalds/linux@3866584, but I'm not entirely sure. Because of that reason, probably, open() and statx() returns EINVAL about incorrect flags.

Issue is reproducable in the provided debian docker build in this repo too.

Can you provide which kernel version is installed in rootfs? Seems a Dockerfile created on Debian Buster, which linux-image-686 has latest version as 4.19, or it's automatically updates?

@farhan-ct
Copy link

Seems a Dockerfile created on Debian Buster, which linux-image-686 has latest version as 4.19

Its auto-updated so the current version in it is 6.6.15-686

However, I downloaded and installed linux-image 5.10.0 (5.10.0-0.deb10.28-686) kernel but trying to figure out where I can change the default kernel version when booting :(

I am trying to see if 9p mounted with 5.10.0 linux-image would resolve the problem if its due to compatibility like you mentioned.

@farhan-ct
Copy link

My above reply is wrong, I changed it to trixie earlier. Buster doesn't have the 9p issue, working perfectly fine.

@copy
Copy link
Owner

copy commented Apr 23, 2024

Will be fixed in 2ca82a5.

@SuperMaxusa
Copy link
Contributor Author

Thanks, works for me on Linux 6.6 without any problems.
9p-alpine

@farhan-ct can you try build v86 from wip branch and test on newer Alpine (3.18.6+) or Debian (trixie+) versions?

@farhan-ct
Copy link

Yes this issue is fixed and works in debian trixie+ too.

We can close this issue now (or maybe after new release)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants