Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern If no auxv is present, don't kmem_alloc(0). Easy to...
details: https://anonhg.NetBSD.org/src/rev/7b8d073a2d37
branches: trunk
changeset: 357864:7b8d073a2d37
user: maxv <maxv%NetBSD.org@localhost>
date: Thu Nov 30 18:44:16 2017 +0000
description:
If no auxv is present, don't kmem_alloc(0). Easy to panic the kernel by
typing 'cat /proc/aout_pid/auxv' on whatever a.out binary you're running.
Fortunately, amd64 does not enable EXEC_AOUT by default. Unfortunately,
i386 does enable it by default.
diffstat:
sys/kern/kern_proc.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (40 lines):
diff -r 3aaccc394268 -r 7b8d073a2d37 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Thu Nov 30 18:29:25 2017 +0000
+++ b/sys/kern/kern_proc.c Thu Nov 30 18:44:16 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.208 2017/11/07 19:44:04 christos Exp $ */
+/* $NetBSD: kern_proc.c,v 1.209 2017/11/30 18:44:16 maxv Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.208 2017/11/07 19:44:04 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.209 2017/11/30 18:44:16 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@@ -2463,16 +2463,19 @@
struct ps_strings pss;
int error;
void *uauxv, *kauxv;
+ size_t size;
if ((error = copyin_psstrings(p, &pss)) != 0)
return error;
+ if (pss.ps_envstr == NULL)
+ return EIO;
- if (pss.ps_envstr == NULL)
+ size = p->p_execsw->es_arglen;
+ if (size == 0)
return EIO;
size_t ptrsz = PROC_PTRSZ(p);
uauxv = (void *)((char *)pss.ps_envstr + (pss.ps_nenvstr + 1) * ptrsz);
- size_t size = p->p_execsw->es_arglen;
kauxv = kmem_alloc(size, KM_SLEEP);
Home |
Main Index |
Thread Index |
Old Index