VirtualBox

6 月 前 建立

11 天 前 結束

11 天 前 更新

#22165 closed defect (duplicate)

Bad address error copying files to shared folder with latest Rocky Linux 9.4 kernel

回報者: Guillermo Jano 負責人:
元件: guest additions 版本: VirtualBox-7.1.0
關鍵字: 副本:
Guest type: Linux Host type: Windows

描述

I have a sources directory mounted into a VM running Rocky Linux 9.4 on a Windows 10 host:

!sources on /sources type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=0,gid=0)

While building a Maven project within the folder, I encountered an issue when Maven tries copying some file from a local path (located in the VM disk) to a subdirectory located in the shared folder (within the project directory). First, I tried to reproduce the issue using cp, just copying the same file into the same location, but that worked just fine. So next I investigated a little into how Maven is trying to copy this file, and found it is using Files.copy, so I wrote a simple Java cp-clone and was able to reproduce the issue as well. Next, using strace I investigated a little and figured out what Java was doing under the hood, then I came up with this C-based implementation, which should make reproducing easier:

#include <stdio.h>
#include <fcntl.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <unistd.h>

int main(int argc, char* argv[]) {
  if (argc != 3) {
    printf("Usage: %s <source_file> <destination_file>\n", argv[0]);
    return 1;
  }

  const char* source_file = argv[1];
  const char* destination_file = argv[2];

  int source_fd = open(source_file, O_RDONLY);
  if (source_fd == -1) {
    perror("Failed to open source file");
    return 1;
  }

  int destination_fd = open(destination_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
  if (destination_fd == -1) {
    perror("Failed to open destination file");
    close(source_fd);
    return 1;
  }

  struct stat stat_buf;
  if (fstat(source_fd, &stat_buf) == -1) {
    perror("Failed to get source file size");
    close(source_fd);
    close(destination_fd);
    return 1;
  }

  off_t offset = 0;
  ssize_t bytes_sent = sendfile(destination_fd, source_fd, &offset, stat_buf.st_size);
  if (bytes_sent == -1) {
    perror("Failed to copy file");
    close(source_fd);
    close(destination_fd);
    return 1;
  }

  printf("File copied successfully.\n");

  close(source_fd);
  close(destination_fd);

  return 0;
}

I guess the most relevant detail here is Java is using sendfile:

...
[pid  6023] openat(AT_FDCWD, "/bin/ls", O_RDONLY) = 5
[pid  6023] openat(AT_FDCWD, "/sources/temp", O_WRONLY|O_CREAT|O_EXCL, 0100755) = 6
[pid  6023] sendfile(6, 5, NULL, 2147479552) = -1 EFAULT (Bad address)
...

Now, regarding the issue I am observing:

  • It occurs when copying files to the mounted shared folder (vboxsf filesystem)
  • Looks like it only happens for files over a certain size. I tried copying all binaries in /bin one by one to the same destination path and some worked while some did not.
  • I found the problem running kernel 5.14.0-427.33.1.el9_4.x86_64. I tried going back to 5.14.0-284.11.1.el9_2.x86_64 which I also had installed and that fixes the issue.
  • I have reproduced this with both 7.0.20 and 7.1.0. Tried multiple Guest Additions versions apart from 7.0.20 and 7.1.0 but found no differences.

So, it looks to me like there is some regression with Guest Additions and guests running recent Rocky Linux 9 (likely RHEL and clones as well) kernels.

更動歷史 (5)

comment:1 6 月 前Guillermo Jano 編輯

The issue persists with Rocky Linux release 9.5 and kernel version 5.14.0-427.35.1.el9_4.x86_64. Tested with Guest Additions 7.1.4r165100.

最後由 Guillermo Jano 編輯於 3 月 前 (上一筆) (差異)

comment:2 3 月 前Guillermo Jano 編輯

The issue persists with kernel version 5.14.0-503.15.1.el9_5.x86_64.

comment:3 2 月 前scampbell 編輯

I have encountered a similar issue with the write syscall on RHEL 9.4. I opened a bug report #22277.

comment:4 11 天 前Guillermo Jano 編輯

Looks like the changes to address #22277 also fix this one, tested with 7.1.7r167766 and Rocky Linux kernel 5.14.0-503.26.1.el9_5.x86_64.

comment:5 11 天 前galitsyn 編輯

狀態: newclosed
處理結果: duplicate

Duplicate of #22277. Issue should now be fixed in the latest test builds.

最後由 galitsyn 編輯於 11 天 前 (上一筆) (差異)
注意: 瀏覽 TracTickets 來幫助您使用待辦事項功能

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette