From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, gorcunov@openvz.org, security@kernel.org
Subject: [PATCH] prctl: fix PR_SET_MM_AUXV kernel stack leak
Date: Sun, 14 Mar 2021 23:51:14 +0300 [thread overview]
Message-ID: <YE53QiJuxsCUeoiu@localhost.localdomain> (raw)
prctl(PR_SET_MM, PR_SET_MM_AUXV, addr, 1);
will copy 1 byte from userspace to (quite big) on-stack array
and then stash everything to mm->saved_auxv.
AT_NULL terminator will be inserted at the very end.
/proc/*/auxv handler will find that AT_NULL terminator
and copy original stack contents to userspace.
This devious scheme requires CAP_SYS_RESOURCE.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
apply to >=3.5
kernel/sys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2079,7 +2079,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,
* up to the caller to provide sane values here, otherwise userspace
* tools which use this vector might be unhappy.
*/
- unsigned long user_auxv[AT_VECTOR_SIZE];
+ unsigned long user_auxv[AT_VECTOR_SIZE] = {};
if (len > sizeof(user_auxv))
return -EINVAL;
next reply other threads:[~2021-03-14 20:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-14 20:51 Alexey Dobriyan [this message]
2021-03-14 21:40 ` [PATCH] prctl: fix PR_SET_MM_AUXV kernel stack leak Linus Torvalds
2021-03-14 22:24 ` Cyrill Gorcunov
2021-03-15 6:00 ` auxv stuff (Re: [PATCH] prctl: fix PR_SET_MM_AUXV kernel stack leak) Alexey Dobriyan
2021-03-15 6:42 ` Cyrill Gorcunov
2021-03-16 18:50 ` Alexey Dobriyan
2021-03-16 18:51 ` Cyrill Gorcunov
2021-03-14 22:18 ` [PATCH] prctl: fix PR_SET_MM_AUXV kernel stack leak Cyrill Gorcunov
2021-03-15 10:29 ` Dan Carpenter
2021-03-15 13:30 ` Alexey Dobriyan
2021-03-15 12:08 ` Oleg Nesterov
2021-03-15 12:54 ` Cyrill Gorcunov
2021-03-15 13:19 ` Oleg Nesterov
2021-03-15 13:52 ` Cyrill Gorcunov
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=YE53QiJuxsCUeoiu@localhost.localdomain \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=gorcunov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=security@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).