Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
b353a1f7
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
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看板
提交
b353a1f7
编写于
3月 17, 2015
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
switch keyctl_instantiate_key_common() to iov_iter
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
0504c074
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
72 deletion
+40
-72
security/keys/compat.c
security/keys/compat.c
+10
-19
security/keys/internal.h
security/keys/internal.h
+3
-2
security/keys/keyctl.c
security/keys/keyctl.c
+27
-51
未找到文件。
security/keys/compat.c
浏览文件 @
b353a1f7
...
...
@@ -31,30 +31,21 @@ static long compat_keyctl_instantiate_key_iov(
key_serial_t
ringid
)
{
struct
iovec
iovstack
[
UIO_FASTIOV
],
*
iov
=
iovstack
;
struct
iov_iter
from
;
long
ret
;
if
(
!
_payload_iov
||
!
ioc
)
goto
no_payload
;
if
(
!
_payload_iov
)
ioc
=
0
;
ret
=
compat_
rw_copy_check_uvector
(
WRITE
,
_payload_iov
,
ioc
,
ARRAY_SIZE
(
iovstack
)
,
iovstack
,
&
iov
);
ret
=
compat_
import_iovec
(
WRITE
,
_payload_iov
,
ioc
,
ARRAY_SIZE
(
iovstack
),
&
iov
,
&
from
);
if
(
ret
<
0
)
goto
err
;
if
(
ret
==
0
)
goto
no_payload_free
;
ret
=
keyctl_instantiate_key_common
(
id
,
iov
,
ioc
,
ret
,
ringid
);
err:
if
(
iov
!=
iovstack
)
kfree
(
iov
);
return
ret
;
return
ret
;
no_payload_free:
if
(
iov
!=
iovstack
)
kfree
(
iov
);
no_payload:
return
keyctl_instantiate_key_common
(
id
,
NULL
,
0
,
0
,
ringid
);
ret
=
keyctl_instantiate_key_common
(
id
,
&
from
,
ringid
);
kfree
(
iov
);
return
ret
;
}
/*
...
...
security/keys/internal.h
浏览文件 @
b353a1f7
...
...
@@ -243,9 +243,10 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
unsigned
,
key_serial_t
);
extern
long
keyctl_invalidate_key
(
key_serial_t
);
struct
iov_iter
;
extern
long
keyctl_instantiate_key_common
(
key_serial_t
,
const
struct
iovec
*
,
unsigned
,
size_t
,
key_serial_t
);
struct
iov_iter
*
,
key_serial_t
);
#ifdef CONFIG_PERSISTENT_KEYRINGS
extern
long
keyctl_get_persistent
(
uid_t
,
key_serial_t
);
extern
unsigned
persistent_keyring_expiry
;
...
...
security/keys/keyctl.c
浏览文件 @
b353a1f7
...
...
@@ -997,21 +997,6 @@ static int keyctl_change_reqkey_auth(struct key *key)
return
commit_creds
(
new
);
}
/*
* Copy the iovec data from userspace
*/
static
long
copy_from_user_iovec
(
void
*
buffer
,
const
struct
iovec
*
iov
,
unsigned
ioc
)
{
for
(;
ioc
>
0
;
ioc
--
)
{
if
(
copy_from_user
(
buffer
,
iov
->
iov_base
,
iov
->
iov_len
)
!=
0
)
return
-
EFAULT
;
buffer
+=
iov
->
iov_len
;
iov
++
;
}
return
0
;
}
/*
* Instantiate a key with the specified payload and link the key into the
* destination keyring if one is given.
...
...
@@ -1022,20 +1007,21 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
* If successful, 0 will be returned.
*/
long
keyctl_instantiate_key_common
(
key_serial_t
id
,
const
struct
iovec
*
payload_iov
,
unsigned
ioc
,
size_t
plen
,
struct
iov_iter
*
from
,
key_serial_t
ringid
)
{
const
struct
cred
*
cred
=
current_cred
();
struct
request_key_auth
*
rka
;
struct
key
*
instkey
,
*
dest_keyring
;
size_t
plen
=
from
?
iov_iter_count
(
from
)
:
0
;
void
*
payload
;
long
ret
;
bool
vm
=
false
;
kenter
(
"%d,,%zu,%d"
,
id
,
plen
,
ringid
);
if
(
!
plen
)
from
=
NULL
;
ret
=
-
EINVAL
;
if
(
plen
>
1024
*
1024
-
1
)
goto
error
;
...
...
@@ -1054,20 +1040,19 @@ long keyctl_instantiate_key_common(key_serial_t id,
/* pull the payload in if one was supplied */
payload
=
NULL
;
if
(
payload_iov
)
{
if
(
from
)
{
ret
=
-
ENOMEM
;
payload
=
kmalloc
(
plen
,
GFP_KERNEL
);
if
(
!
payload
)
{
if
(
plen
<=
PAGE_SIZE
)
goto
error
;
vm
=
true
;
payload
=
vmalloc
(
plen
);
if
(
!
payload
)
goto
error
;
}
ret
=
copy_from_user_iovec
(
payload
,
payload_iov
,
ioc
)
;
if
(
ret
<
0
)
ret
=
-
EFAULT
;
if
(
copy_from_iter
(
payload
,
plen
,
from
)
!=
plen
)
goto
error2
;
}
...
...
@@ -1089,10 +1074,7 @@ long keyctl_instantiate_key_common(key_serial_t id,
keyctl_change_reqkey_auth
(
NULL
);
error2:
if
(
!
vm
)
kfree
(
payload
);
else
vfree
(
payload
);
kvfree
(
payload
);
error:
return
ret
;
}
...
...
@@ -1112,15 +1094,19 @@ long keyctl_instantiate_key(key_serial_t id,
key_serial_t
ringid
)
{
if
(
_payload
&&
plen
)
{
struct
iovec
iov
[
1
]
=
{
[
0
].
iov_base
=
(
void
__user
*
)
_payload
,
[
0
].
iov_len
=
plen
};
struct
iovec
iov
;
struct
iov_iter
from
;
int
ret
;
return
keyctl_instantiate_key_common
(
id
,
iov
,
1
,
plen
,
ringid
);
ret
=
import_single_range
(
WRITE
,
(
void
__user
*
)
_payload
,
plen
,
&
iov
,
&
from
);
if
(
unlikely
(
ret
))
return
ret
;
return
keyctl_instantiate_key_common
(
id
,
&
from
,
ringid
);
}
return
keyctl_instantiate_key_common
(
id
,
NULL
,
0
,
0
,
ringid
);
return
keyctl_instantiate_key_common
(
id
,
NULL
,
ringid
);
}
/*
...
...
@@ -1138,29 +1124,19 @@ long keyctl_instantiate_key_iov(key_serial_t id,
key_serial_t
ringid
)
{
struct
iovec
iovstack
[
UIO_FASTIOV
],
*
iov
=
iovstack
;
struct
iov_iter
from
;
long
ret
;
if
(
!
_payload_iov
||
!
ioc
)
goto
no_payload
;
if
(
!
_payload_iov
)
ioc
=
0
;
ret
=
rw_copy_check_uvector
(
WRITE
,
_payload_iov
,
ioc
,
ARRAY_SIZE
(
iovstack
),
iovstack
,
&
iov
);
ret
=
import_iovec
(
WRITE
,
_payload_iov
,
ioc
,
ARRAY_SIZE
(
iovstack
),
&
iov
,
&
from
);
if
(
ret
<
0
)
goto
err
;
if
(
ret
==
0
)
goto
no_payload_free
;
ret
=
keyctl_instantiate_key_common
(
id
,
iov
,
ioc
,
ret
,
ringid
);
err:
if
(
iov
!=
iovstack
)
kfree
(
iov
);
return
ret
;
ret
=
keyctl_instantiate_key_common
(
id
,
&
from
,
ringid
);
kfree
(
iov
);
return
ret
;
no_payload_free:
if
(
iov
!=
iovstack
)
kfree
(
iov
);
no_payload:
return
keyctl_instantiate_key_common
(
id
,
NULL
,
0
,
0
,
ringid
);
}
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录