kernel/fs: Add some missing descriptor open_mode checks.
This commit is contained in:
@@ -4117,6 +4117,8 @@ read_file_io_vec_pages(int fd, const file_io_vec* fileVecs, size_t fileVecCount,
|
|||||||
FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, true));
|
FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, true));
|
||||||
if (!descriptor.IsSet())
|
if (!descriptor.IsSet())
|
||||||
return B_FILE_ERROR;
|
return B_FILE_ERROR;
|
||||||
|
if ((descriptor->open_mode & O_RWMASK) == O_WRONLY)
|
||||||
|
return B_FILE_ERROR;
|
||||||
|
|
||||||
status_t status = common_file_io_vec_pages(vnode, descriptor->cookie,
|
status_t status = common_file_io_vec_pages(vnode, descriptor->cookie,
|
||||||
fileVecs, fileVecCount, vecs, vecCount, _vecIndex, _vecOffset, _bytes,
|
fileVecs, fileVecCount, vecs, vecCount, _vecIndex, _vecOffset, _bytes,
|
||||||
@@ -4135,6 +4137,8 @@ write_file_io_vec_pages(int fd, const file_io_vec* fileVecs, size_t fileVecCount
|
|||||||
FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, true));
|
FileDescriptorPutter descriptor(get_fd_and_vnode(fd, &vnode, true));
|
||||||
if (!descriptor.IsSet())
|
if (!descriptor.IsSet())
|
||||||
return B_FILE_ERROR;
|
return B_FILE_ERROR;
|
||||||
|
if ((descriptor->open_mode & O_RWMASK) == O_RDONLY)
|
||||||
|
return B_FILE_ERROR;
|
||||||
|
|
||||||
status_t status = common_file_io_vec_pages(vnode, descriptor->cookie,
|
status_t status = common_file_io_vec_pages(vnode, descriptor->cookie,
|
||||||
fileVecs, fileVecCount, vecs, vecCount, _vecIndex, _vecOffset, _bytes,
|
fileVecs, fileVecCount, vecs, vecCount, _vecIndex, _vecOffset, _bytes,
|
||||||
|
|||||||
@@ -504,6 +504,13 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs,
|
|||||||
|
|
||||||
struct vnode* vnode;
|
struct vnode* vnode;
|
||||||
file_descriptor* descriptor = get_fd_and_vnode(fd, &vnode, true);
|
file_descriptor* descriptor = get_fd_and_vnode(fd, &vnode, true);
|
||||||
|
FileDescriptorPutter descriptorPutter(descriptor);
|
||||||
|
if (descriptor != NULL && (request->IsWrite()
|
||||||
|
? (descriptor->open_mode & O_RWMASK) == O_RDONLY
|
||||||
|
: (descriptor->open_mode & O_RWMASK) == O_WRONLY)) {
|
||||||
|
descriptor = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (descriptor == NULL) {
|
if (descriptor == NULL) {
|
||||||
if (finished != NULL)
|
if (finished != NULL)
|
||||||
finished(cookie, request, B_FILE_ERROR, true, 0);
|
finished(cookie, request, B_FILE_ERROR, true, 0);
|
||||||
@@ -511,8 +518,6 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs,
|
|||||||
return B_FILE_ERROR;
|
return B_FILE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDescriptorPutter descriptorPutter(descriptor);
|
|
||||||
|
|
||||||
if (!HAS_FS_CALL(vnode, io)) {
|
if (!HAS_FS_CALL(vnode, io)) {
|
||||||
// no io() call -- fall back to synchronous I/O
|
// no io() call -- fall back to synchronous I/O
|
||||||
return do_synchronous_iterative_vnode_io(vnode, descriptor->cookie,
|
return do_synchronous_iterative_vnode_io(vnode, descriptor->cookie,
|
||||||
|
|||||||
Reference in New Issue
Block a user