Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
bcfe8ad8
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bcfe8ad8
编写于
5月 27, 2017
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
do_sigaltstack(): lift copying to/from userland into callers
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
613763a1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
61 deletion
+46
-61
kernel/signal.c
kernel/signal.c
+46
-61
未找到文件。
kernel/signal.c
浏览文件 @
bcfe8ad8
...
...
@@ -3113,78 +3113,68 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
}
static
int
do_sigaltstack
(
const
stack_t
__user
*
uss
,
stack_t
__user
*
u
oss
,
unsigned
long
sp
)
do_sigaltstack
(
const
stack_t
*
ss
,
stack_t
*
oss
,
unsigned
long
sp
)
{
stack_t
oss
;
int
error
;
struct
task_struct
*
t
=
current
;
oss
.
ss_sp
=
(
void
__user
*
)
current
->
sas_ss_sp
;
oss
.
ss_size
=
current
->
sas_ss_size
;
oss
.
ss_flags
=
sas_ss_flags
(
sp
)
|
if
(
oss
)
{
memset
(
oss
,
0
,
sizeof
(
stack_t
));
oss
->
ss_sp
=
(
void
__user
*
)
t
->
sas_ss_sp
;
oss
->
ss_size
=
t
->
sas_ss_size
;
oss
->
ss_flags
=
sas_ss_flags
(
sp
)
|
(
current
->
sas_ss_flags
&
SS_FLAG_BITS
);
}
if
(
u
ss
)
{
void
__user
*
ss_sp
;
size_t
ss_size
;
unsigned
ss_flags
;
if
(
ss
)
{
void
__user
*
ss_sp
=
ss
->
ss_sp
;
size_t
ss_size
=
ss
->
ss_size
;
unsigned
ss_flags
=
ss
->
ss_flags
;
int
ss_mode
;
error
=
-
EFAULT
;
if
(
!
access_ok
(
VERIFY_READ
,
uss
,
sizeof
(
*
uss
)))
goto
out
;
error
=
__get_user
(
ss_sp
,
&
uss
->
ss_sp
)
|
__get_user
(
ss_flags
,
&
uss
->
ss_flags
)
|
__get_user
(
ss_size
,
&
uss
->
ss_size
);
if
(
error
)
goto
out
;
error
=
-
EPERM
;
if
(
on_sig_stack
(
sp
))
goto
out
;
if
(
unlikely
(
on_sig_stack
(
sp
)))
return
-
EPERM
;
ss_mode
=
ss_flags
&
~
SS_FLAG_BITS
;
error
=
-
EINVAL
;
if
(
ss_mode
!=
SS_DISABLE
&&
ss_mode
!=
SS_ONSTACK
&&
ss_mode
!=
0
)
goto
out
;
if
(
unlikely
(
ss_mode
!=
SS_DISABLE
&&
ss_mode
!=
SS_ONSTACK
&&
ss_mode
!=
0
))
return
-
EINVAL
;
if
(
ss_mode
==
SS_DISABLE
)
{
ss_size
=
0
;
ss_sp
=
NULL
;
}
else
{
error
=
-
ENOMEM
;
if
(
ss_size
<
MINSIGSTKSZ
)
goto
out
;
if
(
unlikely
(
ss_size
<
MINSIGSTKSZ
))
return
-
ENOMEM
;
}
curren
t
->
sas_ss_sp
=
(
unsigned
long
)
ss_sp
;
curren
t
->
sas_ss_size
=
ss_size
;
curren
t
->
sas_ss_flags
=
ss_flags
;
t
->
sas_ss_sp
=
(
unsigned
long
)
ss_sp
;
t
->
sas_ss_size
=
ss_size
;
t
->
sas_ss_flags
=
ss_flags
;
}
error
=
0
;
if
(
uoss
)
{
error
=
-
EFAULT
;
if
(
!
access_ok
(
VERIFY_WRITE
,
uoss
,
sizeof
(
*
uoss
)))
goto
out
;
error
=
__put_user
(
oss
.
ss_sp
,
&
uoss
->
ss_sp
)
|
__put_user
(
oss
.
ss_size
,
&
uoss
->
ss_size
)
|
__put_user
(
oss
.
ss_flags
,
&
uoss
->
ss_flags
);
}
out:
return
error
;
return
0
;
}
SYSCALL_DEFINE2
(
sigaltstack
,
const
stack_t
__user
*
,
uss
,
stack_t
__user
*
,
uoss
)
{
return
do_sigaltstack
(
uss
,
uoss
,
current_user_stack_pointer
());
stack_t
new
,
old
;
int
err
;
if
(
uss
&&
copy_from_user
(
&
new
,
uss
,
sizeof
(
stack_t
)))
return
-
EFAULT
;
err
=
do_sigaltstack
(
uss
?
&
new
:
NULL
,
uoss
?
&
old
:
NULL
,
current_user_stack_pointer
());
if
(
!
err
&&
uoss
&&
copy_to_user
(
uoss
,
&
old
,
sizeof
(
stack_t
)))
err
=
-
EFAULT
;
return
err
;
}
int
restore_altstack
(
const
stack_t
__user
*
uss
)
{
int
err
=
do_sigaltstack
(
uss
,
NULL
,
current_user_stack_pointer
());
stack_t
new
;
if
(
copy_from_user
(
&
new
,
uss
,
sizeof
(
stack_t
)))
return
-
EFAULT
;
(
void
)
do_sigaltstack
(
&
new
,
NULL
,
current_user_stack_pointer
());
/* squash all but EFAULT for now */
return
err
==
-
EFAULT
?
err
:
0
;
return
0
;
}
int
__save_altstack
(
stack_t
__user
*
uss
,
unsigned
long
sp
)
...
...
@@ -3207,29 +3197,24 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
{
stack_t
uss
,
uoss
;
int
ret
;
mm_segment_t
seg
;
if
(
uss_ptr
)
{
compat_stack_t
uss32
;
memset
(
&
uss
,
0
,
sizeof
(
stack_t
));
if
(
copy_from_user
(
&
uss32
,
uss_ptr
,
sizeof
(
compat_stack_t
)))
return
-
EFAULT
;
uss
.
ss_sp
=
compat_ptr
(
uss32
.
ss_sp
);
uss
.
ss_flags
=
uss32
.
ss_flags
;
uss
.
ss_size
=
uss32
.
ss_size
;
}
seg
=
get_fs
();
set_fs
(
KERNEL_DS
);
ret
=
do_sigaltstack
((
stack_t
__force
__user
*
)
(
uss_ptr
?
&
uss
:
NULL
),
(
stack_t
__force
__user
*
)
&
uoss
,
ret
=
do_sigaltstack
(
uss_ptr
?
&
uss
:
NULL
,
&
uoss
,
compat_user_stack_pointer
());
set_fs
(
seg
);
if
(
ret
>=
0
&&
uoss_ptr
)
{
if
(
!
access_ok
(
VERIFY_WRITE
,
uoss_ptr
,
sizeof
(
compat_stack_t
))
||
__put_user
(
ptr_to_compat
(
uoss
.
ss_sp
),
&
uoss_ptr
->
ss_sp
)
||
__put_user
(
uoss
.
ss_flags
,
&
uoss_ptr
->
ss_flags
)
||
__put_user
(
uoss
.
ss_size
,
&
uoss_ptr
->
ss_size
))
compat_stack_t
old
;
memset
(
&
old
,
0
,
sizeof
(
old
));
old
.
ss_sp
=
ptr_to_compat
(
uoss
.
ss_sp
);
old
.
ss_flags
=
uoss
.
ss_flags
;
old
.
ss_size
=
uoss
.
ss_size
;
if
(
copy_to_user
(
uoss_ptr
,
&
old
,
sizeof
(
compat_stack_t
)))
ret
=
-
EFAULT
;
}
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录