From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+cfc08744435c4cf94a40@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, luto@kernel.org,
peterz@infradead.org, syzkaller-bugs@googlegroups.com,
tglx@linutronix.de, xrivendell7@gmail.com
Subject: [PATCH] ptrace: fix kernel-infoleak-after-free in copy_siginfo_to_user
Date: Sun, 31 Dec 2023 10:41:08 +0800 [thread overview]
Message-ID: <tencent_7ECF840DDF25850DD4923CDDD3DDE1197A07@qq.com> (raw)
In-Reply-To: <000000000000a9d761060d5ce6cf@google.com>
To avoid kernel memory leakage into user space, memory should be manually
allocated instead of using memory from the kernel stack.
Reported-and-tested-by: syzbot+cfc08744435c4cf94a40@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
kernel/ptrace.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d8b5e13a2229..8bd346b10c6e 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1033,7 +1033,7 @@ int ptrace_request(struct task_struct *child, long request,
{
bool seized = child->ptrace & PT_SEIZED;
int ret = -EIO;
- kernel_siginfo_t siginfo, *si;
+ kernel_siginfo_t siginfo, *si, *psiginfo;
void __user *datavp = (void __user *) data;
unsigned long __user *datalp = datavp;
unsigned long flags;
@@ -1061,9 +1061,13 @@ int ptrace_request(struct task_struct *child, long request,
break;
case PTRACE_GETSIGINFO:
- ret = ptrace_getsiginfo(child, &siginfo);
+ psiginfo = kvmalloc(sizeof(kernel_siginfo_t), GFP_KERNEL);
+ if (!psiginfo)
+ break;
+ ret = ptrace_getsiginfo(child, psiginfo);
if (!ret)
- ret = copy_siginfo_to_user(datavp, &siginfo);
+ ret = copy_siginfo_to_user(datavp, psiginfo);
+ kvfree(psiginfo);
break;
case PTRACE_SETSIGINFO:
--
2.43.0
next prev parent reply other threads:[~2023-12-31 2:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 18:49 [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
2023-12-25 22:15 ` syzbot
2023-12-31 1:51 ` Edward Adam Davis
2023-12-31 2:15 ` syzbot
2023-12-31 2:41 ` Edward Adam Davis [this message]
2024-03-24 9:13 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_7ECF840DDF25850DD4923CDDD3DDE1197A07@qq.com \
--to=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=syzbot+cfc08744435c4cf94a40@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@linutronix.de \
--cc=xrivendell7@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®