Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
f5029855
K
Kernel
项目概览
openeuler
/
Kernel
接近 2 年 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f5029855
编写于
4月 08, 2017
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move compat_rw_copy_check_uvector() over to fs/read_write.c
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
2b891026
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
76 deletion
+75
-76
fs/compat.c
fs/compat.c
+0
-76
fs/read_write.c
fs/read_write.c
+75
-0
未找到文件。
fs/compat.c
浏览文件 @
f5029855
...
@@ -54,82 +54,6 @@
...
@@ -54,82 +54,6 @@
#include <asm/ioctls.h>
#include <asm/ioctls.h>
#include "internal.h"
#include "internal.h"
/* A write operation does a read from user space and vice versa */
#define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ)
ssize_t
compat_rw_copy_check_uvector
(
int
type
,
const
struct
compat_iovec
__user
*
uvector
,
unsigned
long
nr_segs
,
unsigned
long
fast_segs
,
struct
iovec
*
fast_pointer
,
struct
iovec
**
ret_pointer
)
{
compat_ssize_t
tot_len
;
struct
iovec
*
iov
=
*
ret_pointer
=
fast_pointer
;
ssize_t
ret
=
0
;
int
seg
;
/*
* SuS says "The readv() function *may* fail if the iovcnt argument
* was less than or equal to 0, or greater than {IOV_MAX}. Linux has
* traditionally returned zero for zero segments, so...
*/
if
(
nr_segs
==
0
)
goto
out
;
ret
=
-
EINVAL
;
if
(
nr_segs
>
UIO_MAXIOV
)
goto
out
;
if
(
nr_segs
>
fast_segs
)
{
ret
=
-
ENOMEM
;
iov
=
kmalloc
(
nr_segs
*
sizeof
(
struct
iovec
),
GFP_KERNEL
);
if
(
iov
==
NULL
)
goto
out
;
}
*
ret_pointer
=
iov
;
ret
=
-
EFAULT
;
if
(
!
access_ok
(
VERIFY_READ
,
uvector
,
nr_segs
*
sizeof
(
*
uvector
)))
goto
out
;
/*
* Single unix specification:
* We should -EINVAL if an element length is not >= 0 and fitting an
* ssize_t.
*
* In Linux, the total length is limited to MAX_RW_COUNT, there is
* no overflow possibility.
*/
tot_len
=
0
;
ret
=
-
EINVAL
;
for
(
seg
=
0
;
seg
<
nr_segs
;
seg
++
)
{
compat_uptr_t
buf
;
compat_ssize_t
len
;
if
(
__get_user
(
len
,
&
uvector
->
iov_len
)
||
__get_user
(
buf
,
&
uvector
->
iov_base
))
{
ret
=
-
EFAULT
;
goto
out
;
}
if
(
len
<
0
)
/* size_t not fitting in compat_ssize_t .. */
goto
out
;
if
(
type
>=
0
&&
!
access_ok
(
vrfy_dir
(
type
),
compat_ptr
(
buf
),
len
))
{
ret
=
-
EFAULT
;
goto
out
;
}
if
(
len
>
MAX_RW_COUNT
-
tot_len
)
len
=
MAX_RW_COUNT
-
tot_len
;
tot_len
+=
len
;
iov
->
iov_base
=
compat_ptr
(
buf
);
iov
->
iov_len
=
(
compat_size_t
)
len
;
uvector
++
;
iov
++
;
}
ret
=
tot_len
;
out:
return
ret
;
}
struct
compat_ncp_mount_data
{
struct
compat_ncp_mount_data
{
compat_int_t
version
;
compat_int_t
version
;
compat_uint_t
ncp_fd
;
compat_uint_t
ncp_fd
;
...
...
fs/read_write.c
浏览文件 @
f5029855
...
@@ -841,6 +841,81 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
...
@@ -841,6 +841,81 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
return
ret
;
return
ret
;
}
}
#ifdef CONFIG_COMPAT
ssize_t
compat_rw_copy_check_uvector
(
int
type
,
const
struct
compat_iovec
__user
*
uvector
,
unsigned
long
nr_segs
,
unsigned
long
fast_segs
,
struct
iovec
*
fast_pointer
,
struct
iovec
**
ret_pointer
)
{
compat_ssize_t
tot_len
;
struct
iovec
*
iov
=
*
ret_pointer
=
fast_pointer
;
ssize_t
ret
=
0
;
int
seg
;
/*
* SuS says "The readv() function *may* fail if the iovcnt argument
* was less than or equal to 0, or greater than {IOV_MAX}. Linux has
* traditionally returned zero for zero segments, so...
*/
if
(
nr_segs
==
0
)
goto
out
;
ret
=
-
EINVAL
;
if
(
nr_segs
>
UIO_MAXIOV
)
goto
out
;
if
(
nr_segs
>
fast_segs
)
{
ret
=
-
ENOMEM
;
iov
=
kmalloc
(
nr_segs
*
sizeof
(
struct
iovec
),
GFP_KERNEL
);
if
(
iov
==
NULL
)
goto
out
;
}
*
ret_pointer
=
iov
;
ret
=
-
EFAULT
;
if
(
!
access_ok
(
VERIFY_READ
,
uvector
,
nr_segs
*
sizeof
(
*
uvector
)))
goto
out
;
/*
* Single unix specification:
* We should -EINVAL if an element length is not >= 0 and fitting an
* ssize_t.
*
* In Linux, the total length is limited to MAX_RW_COUNT, there is
* no overflow possibility.
*/
tot_len
=
0
;
ret
=
-
EINVAL
;
for
(
seg
=
0
;
seg
<
nr_segs
;
seg
++
)
{
compat_uptr_t
buf
;
compat_ssize_t
len
;
if
(
__get_user
(
len
,
&
uvector
->
iov_len
)
||
__get_user
(
buf
,
&
uvector
->
iov_base
))
{
ret
=
-
EFAULT
;
goto
out
;
}
if
(
len
<
0
)
/* size_t not fitting in compat_ssize_t .. */
goto
out
;
if
(
type
>=
0
&&
!
access_ok
(
vrfy_dir
(
type
),
compat_ptr
(
buf
),
len
))
{
ret
=
-
EFAULT
;
goto
out
;
}
if
(
len
>
MAX_RW_COUNT
-
tot_len
)
len
=
MAX_RW_COUNT
-
tot_len
;
tot_len
+=
len
;
iov
->
iov_base
=
compat_ptr
(
buf
);
iov
->
iov_len
=
(
compat_size_t
)
len
;
uvector
++
;
iov
++
;
}
ret
=
tot_len
;
out:
return
ret
;
}
#endif
static
ssize_t
__do_readv_writev
(
int
type
,
struct
file
*
file
,
static
ssize_t
__do_readv_writev
(
int
type
,
struct
file
*
file
,
struct
iov_iter
*
iter
,
loff_t
*
pos
,
int
flags
)
struct
iov_iter
*
iter
,
loff_t
*
pos
,
int
flags
)
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录