NetBSD Problem Report #55143

From  Sun Apr  5 06:20:46 2020
Return-Path: <>
Received: from ( [])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 30F671A9213
	for <>; Sun,  5 Apr 2020 06:20:46 +0000 (UTC)
Message-Id: <>
Date: Sun,  5 Apr 2020 08:20:36 +0200 (CEST)
Subject: pflogd uses internal libpcap state
X-Send-Pr-Version: 3.95

>Number:         55143
>Category:       lib
>Synopsis:       pflogd uses internal libpcap state
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 05 06:25:00 +0000 2020
>Closed-Date:    Sun Apr 05 06:29:57 +0000 2020
>Last-Modified:  Sun Apr 05 06:29:57 +0000 2020
>Originator:     Martin Husemann
>Release:        NetBSD 9.99.52
The NetBSD Foundation, Inc.
System: NetBSD 9.99.52 NetBSD 9.99.52 (GENERIC) #378: Tue Mar 31 11:09:27 CEST 2020 amd64
Architecture: x86_64
Machine: amd64

Pflogd is compiled against libpcap:

        -lpcap.8 => /lib/
        -lc.12 => /lib/
        -lutil.7 => /lib/

and it abuses internal state from it, noticable if you remove the include of
(the not publically installed header) pcap-int.h from the source:

/work/src/dist/pf/sbin/pflogd/privsep.c: In function 'set_snaplen':
/work/src/dist/pf/sbin/pflogd/privsep.c:200:7: error: dereferencing pointer to incomplete type 'pcap_t' {aka 'struct pcap'}
  hpcap->snapshot = snap;
Now unfortunately libpcap has an #ifdef ENABLE_REMOTE in that struct, and
it is not defined when compiling pflogd, but is compiled when compiling
our in-tree libpcap.

This means the pcap_t seen by pflogd differs from the pcap_t actually created
and populated by libpcap. And even more unfortunate, the "snapshot" member
is later in the structure than the #ifdef'd part, so pflogd will actually
set hpcap->linktype_ext instead of hpcap->snapshot.

Code inspection (actually found by a #else #error added to pcap-int.h and
the #ifdef ENABLE_REMOTE clause)

One of:
 1) avoid using pcap internal state in pflogd (unfortunately there seems to
    be only a query function for snapshot, not a set function)
 2) add -DENABLE_REMOTE to the pflogd compilation
 3) remove the #ifdef from pcap-int.h
 4) remove pflogd



State-Changed-From-To: open->closed
State-Changed-When: Sun, 05 Apr 2020 06:29:57 +0000
Christos applied suggestion #3 already


NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.