Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Fix panic when ipsecif(4) adds discard policy. Point...



details:   https://anonhg.NetBSD.org/src/rev/bd57776672b5
branches:  trunk
changeset: 319411:bd57776672b5
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Tue May 29 03:38:24 2018 +0000

description:
Fix panic when ipsecif(4) adds discard policy. Pointed out by ohishi@IIJ, thanks.

diffstat:

 sys/net/if_ipsec.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r dc261c4f12a8 -r bd57776672b5 sys/net/if_ipsec.c
--- a/sys/net/if_ipsec.c        Tue May 29 02:53:24 2018 +0000
+++ b/sys/net/if_ipsec.c        Tue May 29 03:38:24 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ipsec.c,v 1.14 2018/05/24 07:00:28 knakahara Exp $  */
+/*     $NetBSD: if_ipsec.c,v 1.15 2018/05/29 03:38:24 knakahara Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.14 2018/05/24 07:00:28 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipsec.c,v 1.15 2018/05/29 03:38:24 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1599,11 +1599,11 @@
                 */
                if_ipsec_add_mbuf_addr_port(m, src, sport, false);
                if_ipsec_add_mbuf_addr_port(m, dst, dport, false);
+
+               padlen = PFKEY_UNUNIT64(xpl.sadb_x_policy_len) - sizeof(xpl);
+               padlen -= PFKEY_ALIGN8(src->sa_len + dst->sa_len);
+               if_ipsec_add_pad(m, padlen);
        }
-       padlen = PFKEY_UNUNIT64(xpl.sadb_x_policy_len) - sizeof(xpl);
-       if (src != NULL && dst != NULL)
-               padlen -= PFKEY_ALIGN8(src->sa_len + dst->sa_len);
-       if_ipsec_add_pad(m, padlen);
 
        /* key_kpi_spdadd() has already done KEY_SP_REF(). */
        return key_kpi_spdadd(m);



Home | Main Index | Thread Index | Old Index