linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] prctl: fix PR_SET_MM_AUXV kernel stack leak
@ 2021-03-14 20:51 Alexey Dobriyan
  2021-03-14 21:40 ` Linus Torvalds
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Alexey Dobriyan @ 2021-03-14 20:51 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, gorcunov, security

	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;

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-03-16 18:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-14 20:51 [PATCH] prctl: fix PR_SET_MM_AUXV kernel stack leak Alexey Dobriyan
2021-03-14 21:40 ` 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

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).