Source-Changes-HG archive

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

[src/trunk]: src/sys/net vlan: added NULL check for the parent interface



details:   https://anonhg.NetBSD.org/src/rev/d8f0b229f72a
branches:  trunk
changeset: 1022137:d8f0b229f72a
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Tue Jul 06 02:34:12 2021 +0000

description:
vlan: added NULL check for the parent interface

The pointer may set to NULL by vlan_unconfig
while packet processing

diffstat:

 sys/net/if_vlan.c |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (44 lines):

diff -r 105f091aa673 -r d8f0b229f72a sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Tue Jul 06 01:18:22 2021 +0000
+++ b/sys/net/if_vlan.c Tue Jul 06 02:34:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vlan.c,v 1.155 2021/07/06 01:16:01 yamaguchi Exp $  */
+/*     $NetBSD: if_vlan.c,v 1.156 2021/07/06 02:34:12 yamaguchi Exp $  */
 
 /*
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.155 2021/07/06 01:16:01 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.156 2021/07/06 02:34:12 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1328,6 +1328,12 @@
        mib = vlan_getref_linkmib(ifv, &psref);
        if (mib == NULL)
                return;
+
+       if (__predict_false(mib->ifvm_p == NULL)) {
+               vlan_putref_linkmib(mib, &psref);
+               return;
+       }
+
        p = mib->ifvm_p;
        ec = (void *)mib->ifvm_p;
 
@@ -1471,6 +1477,12 @@
                return ENETDOWN;
        }
 
+       if (__predict_false(mib->ifvm_p == NULL)) {
+               vlan_putref_linkmib(mib, &psref);
+               m_freem(m);
+               return ENETDOWN;
+       }
+
        p = mib->ifvm_p;
        ec = (void *)mib->ifvm_p;
 



Home | Main Index | Thread Index | Old Index