@@ -677,34 +677,20 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data)
static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
{
- unsigned long flags;
- int error = -ESRCH;
+ if (unlikely(!child->last_siginfo))
+ return -EINVAL;
- if (lock_task_sighand(child, &flags)) {
- error = -EINVAL;
- if (likely(child->last_siginfo != NULL)) {
- copy_siginfo(info, child->last_siginfo);
- error = 0;
- }
- unlock_task_sighand(child, &flags);
- }
- return error;
+ copy_siginfo(info, child->last_siginfo);
+ return 0;
}
static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
{
- unsigned long flags;
- int error = -ESRCH;
+ if (unlikely(!child->last_siginfo))
+ return -EINVAL;
- if (lock_task_sighand(child, &flags)) {
- error = -EINVAL;
- if (likely(child->last_siginfo != NULL)) {
- copy_siginfo(child->last_siginfo, info);
- error = 0;
- }
- unlock_task_sighand(child, &flags);
- }
- return error;
+ copy_siginfo(child->last_siginfo, info);
+ return 0;
}
static int ptrace_peek_siginfo(struct task_struct *child,
Since commit 9899d11f6544 ("ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL") it has been unnecessary for ptrace_getsiginfo and ptrace_setsiginfo to use lock_task_sighand. Having the code taking an unnecessary lock is confusing as it suggests that other parts of the code need to take the unnecessary lock as well. So remove the unnecessary lock to make the code more efficient, simpler, and less confusing. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> --- kernel/ptrace.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)