Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 Fix use-after-free, the first m_copyback_cow ma...
details: https://anonhg.NetBSD.org/src/rev/874fd630b84c
branches: trunk
changeset: 359154:874fd630b84c
user: maxv <maxv%NetBSD.org@localhost>
date: Thu Feb 01 15:53:16 2018 +0000
description:
Fix use-after-free, the first m_copyback_cow may have freed the mbuf, so
it is wrong to read ip6->ip6_nxt.
diffstat:
sys/netinet6/raw_ip6.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (35 lines):
diff -r ad29da9fa2a7 -r 874fd630b84c sys/netinet6/raw_ip6.c
--- a/sys/netinet6/raw_ip6.c Thu Feb 01 14:50:36 2018 +0000
+++ b/sys/netinet6/raw_ip6.c Thu Feb 01 15:53:16 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_ip6.c,v 1.160 2018/01/30 14:49:25 maxv Exp $ */
+/* $NetBSD: raw_ip6.c,v 1.161 2018/02/01 15:53:16 maxv Exp $ */
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.160 2018/01/30 14:49:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.161 2018/02/01 15:53:16 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -475,6 +475,7 @@
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
in6p->in6p_cksum != -1) {
+ const uint8_t nxt = ip6->ip6_nxt;
int off;
u_int16_t sum;
@@ -496,7 +497,7 @@
error = ENOBUFS;
goto bad;
}
- sum = in6_cksum(m, ip6->ip6_nxt, sizeof(*ip6), plen);
+ sum = in6_cksum(m, nxt, sizeof(*ip6), plen);
m = m_copyback_cow(m, off, sizeof(sum), (void *)&sum,
M_DONTWAIT);
if (m == NULL) {
Home |
Main Index |
Thread Index |
Old Index