Skip to content

open FIFOs with O_RDWR should be permitted or rejected #80

Description

@gwu-ddn

https://pubs.opengroup.org/onlinepubs/9799919799/functions/open.html#tag_17_372

RATIONALE

Some implementations **permit opening FIFOs with O_RDWR**. Since FIFOs could be implemented in other ways, and since two file descriptors can be used to the same effect, an implementation is allowed to **reject the use of O_RDWR on a FIFO**.

=====
Mostly filesystems will return EACCES from vfs layer (inode_permission ...).

For fuse, if "default_permissions" is turnned off, vfs inode_permission/fuse_permission will by-passed, and fifo_open will be invoked, then return 0 for opening fifo with O_RDWR:

1117 static int fifo_open(struct inode *inode, struct file filp)
...
1198 case FMODE_READ | FMODE_WRITE:
1199 /

1200 * O_RDWR
1201 * POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
1202 * This implementation will NEVER block on a O_RDWR open, since
1203 * the process can at least talk to itself.
1204 */
1205

pjdfstest/tests/open/06.t:

91 # FIFO.
92
93 expect 0 -u 65534 -g 65534 mkfifo ${n1} 0644
...
106 expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
107 expect 'EACCES|ENXIO' -u 65534 -g 65534 open ${n1} O_WRONLY,O_NONBLOCK
108 expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
109 expect 0 -u 65534 -g 65534 chmod ${n1} 0747
110 expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
111 expect 'EACCES|ENXIO' -u 65533 -g 65534 open ${n1} O_WRONLY,O_NONBLOCK
112 expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR

ok 77
not ok 78 - tried '-u 65534 -g 65534 open pjdfstest_329384feb34f4747fd994ebd6104ba81 O_RDWR', expected EACCES, got 0
ok 79
ok 80
ok 81
not ok 82 - tried '-u 65533 -g 65534 open pjdfstest_329384feb34f4747fd994ebd6104ba81 O_RDWR', expected EACCES, got 0
ok 83

The issue is similar as #78.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions