NetBSD Problem Report #856
From gnats Wed Mar 8 15:06:04 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id PAA21955 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Wed, 8 Mar 1995 15:06:00 -0800
Message-Id: <199503082306.QAA05151@willett.math.utah.edu>
Date: Wed, 8 Mar 1995 14:14:29 MST
From: Lon Willett <lon%softt.uucp@math.utah.edu>
Reply-To: willett@math.utah.edu
To: gnats-bugs@NetBSD.ORG
Subject: tcpdump can cause kernel panic; fix included
X-Send-Pr-Version: 3.2
>Number: 856
>Category: kern
>Synopsis: tcpdump can cause kernel panic; fix included
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 08 15:20:04 +0000 1995
>Closed-Date: Wed Mar 22 15:58:31 +0000 1995
>Last-Modified:
>Originator: Lon Willett
>Release: NetBSD-current 8 Mar 95
>Organization:
none
>Environment:
System: NetBSD hilly 1.0A NetBSD 1.0A (HILLY) #150: Wed Mar 8 13:40:25 MST 1995 lon@hilly:/usr/src/sys/arch/i386/compile/HILLY i386
>Description:
If an interface that bpf (i.e. tcpdump) has put in promiscuous mode goes
down, then when the bpf device is closed out (i.e. tcpdump exits), the
kernel panics. NB: this also includes PPP interfaces, even though they
don't have a promiscuous mode, because they are perfectly willing to let
you set the IFF_PROMISC flag without complaining.
>How-To-Repeat:
e.g. How I came across it:
# pppd ...
(now ppp0 is up)
# tcpdump -i ppp0
(now it is marked in promiscuous mode)
(interface goes down, e.g. on another tty:
# ifconfig ppp0 down # does this work? or must you kill PPPD-PID
)
Type ^C to kill tcpdump.
You should get a panic: "ifpromisc failed".
>Fix:
Here's a "diff -u" of how I fixed it. The problem is that "ifpromisc" was
checking IFF_UP too soon when turning promiscuous mode off.
--- usr/src/sys/net/bpf.c.orig Fri Feb 24 04:20:37 1995
+++ usr/src/sys/net/bpf.c Wed Mar 8 11:22:01 1995
@@ -245,8 +245,10 @@
* If so, turn it off.
*/
if (d->bd_promisc) {
+ int error;
d->bd_promisc = 0;
- if (ifpromisc(bp->bif_ifp, 0))
+ if ((error = ifpromisc(bp->bif_ifp, 0)) != 0 &&
+ error != EINVAL) /* PPP/SLIP/etc. return EINVAL */
/*
* Something is really wrong if we were able to put
* the driver into promiscuous mode, but can't
@@ -1240,14 +1242,14 @@
int pswitch;
{
struct ifreq ifr;
- /*
- * If the device is not configured up, we cannot put it in
- * promiscuous mode.
- */
- if ((ifp->if_flags & IFF_UP) == 0)
- return (ENETDOWN);
if (pswitch) {
+ /*
+ * If the device is not configured up, we cannot put it in
+ * promiscuous mode.
+ */
+ if ((ifp->if_flags & IFF_UP) == 0)
+ return (ENETDOWN);
if (ifp->if_pcount++ != 0)
return (0);
ifp->if_flags |= IFF_PROMISC;
@@ -1255,6 +1257,14 @@
if (--ifp->if_pcount > 0)
return (0);
ifp->if_flags &= ~IFF_PROMISC;
+ /*
+ * If the device is not configured up, we should not need to
+ * turn off promiscuous mode (device should have turned it
+ * off when interface went down; and will look at IFF_PROMISC
+ * again next time interface comes up).
+ */
+ if ((ifp->if_flags & IFF_UP) == 0)
+ return (0);
}
ifr.ifr_flags = ifp->if_flags;
return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr));
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: mycroft
State-Changed-When: Wed Mar 22 07:58:31 PST 1995
State-Changed-Why:
Patch applied.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.