kernel/vfs: Validate that only one of O_RDWR or O_WRONLY is used, if any.
Otherwise we will have open modes that could have both and lead to
confusion in code that presumes only one will be set.
This catches the cause of some ported software (e.g. Wayland layer)
misbehaving with ramfs mounted in /var/shared_memory: the ramfs does not
properly handle both flags set, and due to another bug, they are for
shm_open'ed files.
(cherry picked from commit 9bc250e28d
)
Change-Id: I9e98be89b6d4a2da90f74c048b4f762ca9cf8738
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5852
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
6dd06f66d0
commit
7cc1c1af2e
@ -2831,6 +2831,9 @@ get_new_fd(int type, struct fs_mount* mount, struct vnode* vnode,
|
||||
&& (type == FDTYPE_FILE || type == FDTYPE_DIR))
|
||||
return B_BUSY;
|
||||
|
||||
if ((openMode & O_RDWR) != 0 && (openMode & O_WRONLY) != 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
descriptor = alloc_fd();
|
||||
if (!descriptor)
|
||||
return B_NO_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user