bytecodealliance / bytecodealliance/wasmtime

Permission denied

Offen
#7,331 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Rust
Sterne
18.6k
Forks
1.8k
Ø Merge
1 T. 14 Std.
Gemergte PRs (30 T.)
135

Beschreibung

### Steps to Reproduce
(1) The cfile is :
```
#include
#include
#include
#include
#include

int get_fd(const char* file_name, int open_style){
int fd = open(file_name, open_style);
if (fd == -1) {
perror("Failed to open the file");
return 1;
}

return fd;
}

int fd_readdir(const char *path) {
printf("Enter fd_readdir.\n");

DIR *directory;
struct dirent *entry;

directory = opendir(path);

if (directory == NULL) {
perror("opendir");
return 1;
}

while ((entry = readdir(directory)) != NULL) {
printf("%s\n", entry->d_name);
}

closedir(directory);
printf("Leave fd_readdir.\n");
return 0;
}

int readdirQ6TwcRnVK4 (const char *path) {
return fd_readdir(path);
}

int main() {
const char *dirPath = "Data/mydir";
int open_style= O_RDONLY;
int fd = get_fd(dirPath, open_style);
readdirQ6TwcRnVK4(dirPath);
return 0;
}
```
(2)compile the c file into wasm: `./wasi-sdk-16.0/bin/clang --target=wasm32-unkown-wasi --sysroot=./wasi-sdk-16.0/share/wasi-sysroot readdir.c -o readdir.wasm`
(3)exeute open.wasm
`wasmtime run --dir=./Data readdir.wasm`
The permission of Data/mydir is 0400 or 0500 or 0600, user1 create the Data/mydir directory before and user1 execute the Wasm file.

### Expected Results
Using `gcc readdir.c -o readdir` and `./readdir` to execute get the following result:
```
Enter fd_readdir.
.
..
test.txt
Leave fd_readdir.
```

And wamr, wasmedge also print the above message.

### Actual Results
wasmtime prints:
```
Enter fd_readdir.
opendir: Permission denied
```

I'm not sure whether wasmtime and native ubuntu and other runtimes get different could be a bug or only difference ? Maybe something error about the permission?
0400 r--
0500 r-x
0600 rw-

0400, 0500, and 0600 has the read permission

Sorry for bothering you. Thanks a lot !

### Versions and Environment
wasmtime 13.0.0
Operating system: Ubuntu 20.04

Architecture: x86_64

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Reproduziere das gemeldete C-Programm mit dem wasi-sdk-Kompilierungsbefehl und `wasmtime run --dir=./Data readdir.wasm` unter Verwendung der angegebenen Verzeichnisberechtigungen. Vergleiche das Verhalten von Wasmtime mit dem von nativem Ubuntu, WAMR und WasmEdge und bestimme anschließend, ob der Unterschied erwartbar oder ein Fehler ist; abgeschlossen bedeutet, dass das Verhalten behoben oder seine Berechtigungssemantik eindeutig dokumentiert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, linux, rust, wasm
Bereich
operating-systems, security
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.