-
Notifications
You must be signed in to change notification settings - Fork 171
Open
Description
When readonly_rootfs is enabled, open() with O_WRONLY or O_RDWR on device files like /dev/null returns EROFS. Such kernel interfaces should be exempt from the read-only filesystem checks because writes are to the device driver, not the readonly filesystem.
To reproduce, manifest with readonly_rootfs:true then build and run with QEMU:
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
int main() {
int fd;
fd = open("/dev/null", O_WRONLY);
if (fd < 0) printf("FAIL: open(/dev/null, O_WRONLY) = %s (errno %d)\n", strerror(errno), errno);
else { printf("OK: open(/dev/null, O_WRONLY) = fd %d\n", fd); close(fd); }
fd = open("/dev/null", O_RDWR);
if (fd < 0) printf("FAIL: open(/dev/null, O_RDWR) = %s (errno %d)\n", strerror(errno), errno);
else { printf("OK: open(/dev/null, O_RDWR) = fd %d\n", fd); close(fd); }
fd = open("/dev/null", O_RDONLY);
if (fd < 0) printf("FAIL: open(/dev/null, O_RDONLY) = %s (errno %d)\n", strerror(errno), errno);
else { printf("OK: open(/dev/null, O_RDONLY) = fd %d\n", fd); close(fd); }
return 0;
}This incorrectly prints:
FAIL: open(/dev/null, O_WRONLY) = Read-only file system (errno 30)
FAIL: open(/dev/null, O_RDWR) = Read-only file system (errno 30)
OK: open(/dev/null, O_RDONLY) = fd 3Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels