NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/55143: pflogd uses internal libpcap state
>Number: 55143
>Category: lib
>Synopsis: pflogd uses internal libpcap state
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Apr 05 06:25:00 +0000 2020
>Originator: Martin Husemann
>Release: NetBSD 9.99.52
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD seven-days-to-the-wolves.aprisoft.de 9.99.52 NetBSD 9.99.52 (GENERIC) #378: Tue Mar 31 11:09:27 CEST 2020 martin%seven-days-to-the-wolves.aprisoft.de@localhost:/work/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Pflogd is compiled against libpcap:
/sbin/pflogd:
-lpcap.8 => /lib/libpcap.so.8
-lc.12 => /lib/libc.so.12
-lutil.7 => /lib/libutil.so.7
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.
>How-To-Repeat:
Code inspection (actually found by a #else #error added to pcap-int.h and
the #ifdef ENABLE_REMOTE clause)
>Fix:
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
Home |
Main Index |
Thread Index |
Old Index