Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec ipsec: don't assert for the format of incoming ...
details: https://anonhg.NetBSD.org/src/rev/ddca3ddb7ce1
branches: trunk
changeset: 366391:ddca3ddb7ce1
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed May 25 04:15:44 2022 +0000
description:
ipsec: don't assert for the format of incoming packets
diffstat:
sys/netipsec/xform_esp.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diffs (35 lines):
diff -r 3c221d971004 -r ddca3ddb7ce1 sys/netipsec/xform_esp.c
--- a/sys/netipsec/xform_esp.c Tue May 24 21:42:37 2022 +0000
+++ b/sys/netipsec/xform_esp.c Wed May 25 04:15:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xform_esp.c,v 1.105 2022/05/22 11:40:29 riastradh Exp $ */
+/* $NetBSD: xform_esp.c,v 1.106 2022/05/25 04:15:44 ozaki-r Exp $ */
/* $FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.105 2022/05/22 11:40:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.106 2022/05/25 04:15:44 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -310,9 +310,13 @@
KASSERT(sav != NULL);
KASSERT(sav->tdb_encalgxform != NULL);
- KASSERTMSG((skip & 3) == 0 && (m->m_pkthdr.len & 3) == 0,
- "misaligned packet, skip %u pkt len %u",
- skip, m->m_pkthdr.len);
+ if (__predict_false((skip & 3) != 0 || (m->m_pkthdr.len & 3) != 0)) {
+ DPRINTF("%s: misaligned packet, skip %u pkt len %u", __func__,
+ skip, m->m_pkthdr.len);
+ stat = ESP_STAT_BADILEN; /* Same as FreeBSD */
+ error = EINVAL;
+ goto out;
+ }
/* XXX don't pullup, just copy header */
M_REGION_GET(esp, struct newesp *, m, skip, sizeof(struct newesp));
Home |
Main Index |
Thread Index |
Old Index