Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Don't forget to free the mbuf when we decide not to ...
details: https://anonhg.NetBSD.org/src/rev/2397532c5847
branches: trunk
changeset: 350847:2397532c5847
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Jan 24 18:37:20 2017 +0000
description:
Don't forget to free the mbuf when we decide not to reply to an ARP
request. This obviously is a terrible bug, since it allows a remote sender
to DoS the system with specially-crafted requests sent in a loop.
diffstat:
sys/net/if_arcsubr.c | 8 +++++---
sys/net/if_ecosubr.c | 17 +++++++++++------
sys/net/if_ethersubr.c | 5 +++--
sys/net/if_fddisubr.c | 10 ++++++----
sys/net/if_tokensubr.c | 8 +++++---
5 files changed, 30 insertions(+), 18 deletions(-)
diffs (173 lines):
diff -r d67f05f08f47 -r 2397532c5847 sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c Tue Jan 24 18:04:01 2017 +0000
+++ b/sys/net/if_arcsubr.c Tue Jan 24 18:37:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arcsubr.c,v 1.75 2017/01/11 13:08:29 ozaki-r Exp $ */
+/* $NetBSD: if_arcsubr.c,v 1.76 2017/01/24 18:37:20 maxv Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.75 2017/01/11 13:08:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.76 2017/01/24 18:37:20 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -171,8 +171,10 @@
adst = arcbroadcastaddr;
else {
uint8_t *tha = ar_tha(arph);
- if (tha == NULL)
+ if (tha == NULL) {
+ m_freem(m);
return 0;
+ }
adst = *tha;
}
diff -r d67f05f08f47 -r 2397532c5847 sys/net/if_ecosubr.c
--- a/sys/net/if_ecosubr.c Tue Jan 24 18:04:01 2017 +0000
+++ b/sys/net/if_ecosubr.c Tue Jan 24 18:37:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ecosubr.c,v 1.49 2016/10/03 11:06:06 ozaki-r Exp $ */
+/* $NetBSD: if_ecosubr.c,v 1.50 2017/01/24 18:37:20 maxv Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.49 2016/10/03 11:06:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.50 2017/01/24 18:37:20 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -210,8 +210,10 @@
case AF_ARP:
ah = mtod(m, struct arphdr *);
- if (ntohs(ah->ar_pro) != ETHERTYPE_IP)
- return EAFNOSUPPORT;
+ if (ntohs(ah->ar_pro) != ETHERTYPE_IP) {
+ error = EAFNOSUPPORT;
+ goto bad;
+ }
ehdr.eco_port = ECO_PORT_IP;
switch (ntohs(ah->ar_op)) {
case ARPOP_REQUEST:
@@ -221,7 +223,8 @@
ehdr.eco_control = ECO_CTL_ARP_REPLY;
break;
default:
- return EOPNOTSUPP;
+ error = EOPNOTSUPP;
+ goto bad;
}
if (m->m_flags & M_BCAST)
@@ -229,8 +232,10 @@
ECO_ADDR_LEN);
else {
tha = ar_tha(ah);
- if (tha == NULL)
+ if (tha == NULL) {
+ m_freem(m);
return 0;
+ }
memcpy(ehdr.eco_dhost, tha, ECO_ADDR_LEN);
}
diff -r d67f05f08f47 -r 2397532c5847 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c Tue Jan 24 18:04:01 2017 +0000
+++ b/sys/net/if_ethersubr.c Tue Jan 24 18:37:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.235 2017/01/13 06:11:56 msaitoh Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.236 2017/01/24 18:37:20 maxv Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.235 2017/01/13 06:11:56 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.236 2017/01/24 18:37:20 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -279,6 +279,7 @@
if (tha == NULL) {
/* fake with ARPHDR_IEEE1394 */
+ m_freem(m);
return 0;
}
memcpy(edst, tha, sizeof(edst));
diff -r d67f05f08f47 -r 2397532c5847 sys/net/if_fddisubr.c
--- a/sys/net/if_fddisubr.c Tue Jan 24 18:04:01 2017 +0000
+++ b/sys/net/if_fddisubr.c Tue Jan 24 18:37:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_fddisubr.c,v 1.103 2017/01/11 13:08:29 ozaki-r Exp $ */
+/* $NetBSD: if_fddisubr.c,v 1.104 2017/01/24 18:37:20 maxv Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.103 2017/01/11 13:08:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.104 2017/01/24 18:37:20 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -261,11 +261,13 @@
case AF_ARP: {
struct arphdr *ah = mtod(m, struct arphdr *);
if (m->m_flags & M_BCAST)
- memcpy(edst, etherbroadcastaddr, sizeof(edst));
+ memcpy(edst, etherbroadcastaddr, sizeof(edst));
else {
void *tha = ar_tha(ah);
- if (tha == NULL)
+ if (tha == NULL) {
+ m_freem(m);
return 0;
+ }
memcpy(edst, tha, sizeof(edst));
}
diff -r d67f05f08f47 -r 2397532c5847 sys/net/if_tokensubr.c
--- a/sys/net/if_tokensubr.c Tue Jan 24 18:04:01 2017 +0000
+++ b/sys/net/if_tokensubr.c Tue Jan 24 18:37:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tokensubr.c,v 1.79 2017/01/11 13:08:29 ozaki-r Exp $ */
+/* $NetBSD: if_tokensubr.c,v 1.80 2017/01/24 18:37:20 maxv Exp $ */
/*
* Copyright (c) 1982, 1989, 1993
@@ -92,7 +92,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.79 2017/01/11 13:08:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.80 2017/01/24 18:37:20 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -267,8 +267,10 @@
}
else {
void *tha = ar_tha(ah);
- if (tha == NULL)
+ if (tha == NULL) {
+ m_freem(m);
return 0;
+ }
memcpy(edst, tha, sizeof(edst));
trh = (struct token_header *)M_TRHSTART(m);
trh->token_ac = TOKEN_AC;
Home |
Main Index |
Thread Index |
Old Index