Skip to content

Conversation

@yamt
Copy link
Collaborator

@yamt yamt commented Jul 3, 2025

…ook their access modes (#3694)"

This reverts commit 67fa155.

because it broke certain use cases while
it isn't clear what it fixed.

tested with:
https://github.com/yamt/garbage/tree/master/wasm/httpd
https://github.com/yamt/garbage/tree/master/wasm/tty

cf.
#4447
#3686 (comment)

@lum1n0us
Copy link
Collaborator

lum1n0us commented Jul 3, 2025

I mostly agree that STDXXX can have variant st_filetype because of those tricks,

But, are you suggesting that removing read/write bits based on the access mode is acceptable according to STDXX?

switch (access_mode) {
    case WASI_LIBC_ACCESS_MODE_READ_ONLY:
        *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_WRITE;
        break;
    case WASI_LIBC_ACCESS_MODE_WRITE_ONLY:
        *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_READ;
        break;
}

@yamt
Copy link
Collaborator Author

yamt commented Jul 3, 2025

But, are you suggesting that removing read/write bits based on the access mode is acceptable according to STDXX?

yes. i think it's the most straightforward behavior.
what's your concern?

@lum1n0us lum1n0us added the bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs. label Jul 14, 2025
@yamt
Copy link
Collaborator Author

yamt commented Sep 10, 2025

@lum1n0us
can we decide on this? (and/or #4395)
or, do you have some more info? (eg. need a research on something)

@lum1n0us
Copy link
Collaborator

The main concern is that after this modification, the code below will allow STDIN to be unreadable and STDOUT to be unwritable in some scenarios, which I don't think should be permitted.

switch (access_mode) {
    case WASI_LIBC_ACCESS_MODE_READ_ONLY:
        *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_WRITE;
        break;
    case WASI_LIBC_ACCESS_MODE_WRITE_ONLY:
        *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_READ;
        break;
}

In my view, the access mode (fcntl() & O_ACCMODE) of STDIN and STDOUT should remain untouchable. Therefore, the rights of STDIN and STDOUT should also be constant.

@yamt
Copy link
Collaborator Author

yamt commented Sep 16, 2025

The main concern is that after this modification, the code below will allow STDIN to be unreadable and STDOUT to be unwritable in some scenarios, which I don't think should be permitted.

switch (access_mode) {
    case WASI_LIBC_ACCESS_MODE_READ_ONLY:
        *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_WRITE;
        break;
    case WASI_LIBC_ACCESS_MODE_WRITE_ONLY:
        *rights_base &= ~(__wasi_rights_t)__WASI_RIGHT_FD_READ;
        break;
}

In my view, the access mode (fcntl() & O_ACCMODE) of STDIN and STDOUT should remain untouchable. Therefore, the rights of STDIN and STDOUT should also be constant.

do you mean that wasi should be different from the most of posix platforms in the regard? why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants