bytecodealliance / bytecodealliance/wasmtime

Permission denied

Aperta
#7,331 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Rust
Stelle
18.6k
Fork
1.8k
Merge medio
1g 14h
PR unite (30g)
135

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci il programma C segnalato con il comando di compilazione di wasi-sdk e `wasmtime run --dir=./Data readdir.wasm`, utilizzando i permessi della directory indicati. Confronta il comportamento di Wasmtime con quello di Ubuntu nativo, WAMR e WasmEdge, quindi determina se la differenza è prevista o se si tratta di un bug; il lavoro è concluso quando il comportamento è stato corretto oppure la semantica dei relativi permessi è documentata chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, linux, rust, wasm
Ambito
operating-systems, security
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.