avoid use-after-free in *coredump().
fixes kernel crashes during coredump on sparc64.
This commit is contained in:
parent
ece76c8800
commit
dd411234d3
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: core_elf32.c,v 1.42 2014/01/04 00:10:03 dsl Exp $ */
|
||||
/* $NetBSD: core_elf32.c,v 1.43 2014/01/05 00:53:53 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.42 2014/01/04 00:10:03 dsl Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.43 2014/01/05 00:53:53 mrg Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_coredump.h"
|
||||
|
@ -116,6 +116,7 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
|
|||
|
||||
struct note_state ns;
|
||||
struct note_buf *nb;
|
||||
struct note_buf *nb_next;
|
||||
|
||||
psections = NULL;
|
||||
|
||||
|
@ -256,8 +257,10 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
|
|||
out:
|
||||
if (psections)
|
||||
kmem_free(psections, psectionssize);
|
||||
for (; (nb = ns.ns_first) != NULL; ns.ns_first = nb->nb_next)
|
||||
for (; (nb = ns.ns_first) != NULL; ns.ns_first = nb_next) {
|
||||
nb_next = nb->nb_next;
|
||||
kmem_free(nb, sizeof *nb);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue