From 8cf7d6358cc885ac8fa66bc9942ba511fdc40f42 Mon Sep 17 00:00:00 2001 From: dlg Date: Fri, 14 Nov 2025 21:47:31 +0000 Subject: [PATCH] only try BIOCLOCK against bpf if tcpdump is using bpf. fixes tcpdump -r pcapfile, which is getting packets from a file, not the kernel via bpf. problem found by bluhm@ and regress tests ok deraadt@ --- usr.sbin/tcpdump/privsep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/tcpdump/privsep.c b/usr.sbin/tcpdump/privsep.c index 514be6c7e51..5b978e3365f 100644 --- a/usr.sbin/tcpdump/privsep.c +++ b/usr.sbin/tcpdump/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.58 2025/11/13 20:46:39 deraadt Exp $ */ +/* $OpenBSD: privsep.c,v 1.59 2025/11/14 21:47:31 dlg Exp $ */ /* * Copyright (c) 2003 Can Erkin Acar @@ -476,7 +476,7 @@ impl_init_done(int fd, int *bpfd) logmsg(LOG_DEBUG, "[priv]: msg PRIV_INIT_DONE received"); /* lock the descriptor */ - if (ioctl(*bpfd, BIOCLOCK, NULL) == -1) + if (*bpfd != -1 && ioctl(*bpfd, BIOCLOCK, NULL) == -1) err(1, "BIOCLOCK"); ret = 0;