From nobody Fri Aug 05 20:47:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LzyMY3lDbz4XhvH; Fri, 5 Aug 2022 20:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LzyMY30Y4z42wk; Fri, 5 Aug 2022 20:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659732441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3yvA0ChfwON/eYAihZelFh77irdJNyhHeGsj/lfJRJ4=; b=LtU0dmgpXzyjmLEMohfJ5feTIgNxNUc3Q49muGVrGsCjMjpyoSCH1vwqL8+jc8P3syWDRW 6PSKGagVwuRpz6ekL2ZbijH8f0ylkQs1PWHVRzkLBvWhiyAPE4FkxFDE6GDrgy0b0akkFE pvTwGnjdh95+ZXhifRtWGbJ6JjTic70sCyiwVx5vVYsuoa1v4uwCuxXfUsmNdMknpbh/UF 5NjG/QzHl877IsjJASBRl/M96rq1wB6iQra6P8KwdCx1OZcfgpomLQVlRpJNkAJnUKaUfF sgiEDnaEqvoJSmVNX1KeTDBx02LHg0KadSAPYI14ybfcNfxQWthKUpd6AgYBCw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LzyMY23NNz16fK; Fri, 5 Aug 2022 20:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 275KlLU0070657; Fri, 5 Aug 2022 20:47:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 275KlLWG070656; Fri, 5 Aug 2022 20:47:21 GMT (envelope-from git) Date: Fri, 5 Aug 2022 20:47:21 GMT Message-Id: <202208052047.275KlLWG070656@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 220818ac0307 - main - bpf: Fix BIOCPROMISC locking List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 220818ac030726c24cbf9df6df5c9d019993b875 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659732441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3yvA0ChfwON/eYAihZelFh77irdJNyhHeGsj/lfJRJ4=; b=lWXCthCVPtD2DW5jG5FkPuwaMUHoqLIz/g0+j8bzWR8xcDow3B4RCIDK7imHwMelAAI7dC T/dkBOuxWi0HRk7vOlhm2bRRRy6S03QYR2aevZyR3qnvHhT1HOyYrebBFsoMp5h2MYrqSB 5kYSfNop7VP8U4w8jKmmUUv1m9YD2mBy4JUPTpI2IyxnKVJ3u1w748e8S8nXUK0zRZ8qKJ 8vCzZb0FiLZAblWJ/f7D08D7K6SijvZSzM+BhNsyQhWwpMI6vlt1LvGdkFXX93radjyfsb Oq0exIUm9yYRwGZ7Wz1Fs1Pghxf2ubVV+fUSu4Epz/nfpsnwO3yPwxJXdcauwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659732441; a=rsa-sha256; cv=none; b=q+RWJ9SNa8xRR9ukwwwd6tHvOxaM9VjUAPbkhnPEmu+C65HYlabrFIm2jqTmiXKf05t7h9 PMKcVsgruCJBmxH8TCElB3ZjU4OtXB9ZuBvmIfee9N8sspXg/rbXMZevv+FbqkeaiYuHo1 XkD2jxaKf7e1D6wbrIcTZSz5Xh3la6Ys+ValYuUUMh+h/uy9aCz1RoAsC14liq5+e1oW/6 2RmyPVF6EqBVcAHuBC6GcGhlJSwZhRWOZX5oE8i0C1uuNU9si7kAg8GP2lFlkeh5vcwUC8 hRXZiyUuFoaMP0rohpmbiwQHQRU5oDzW6A0kvBLIuuJA9+rNO+1DhBdknepg4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=220818ac030726c24cbf9df6df5c9d019993b875 commit 220818ac030726c24cbf9df6df5c9d019993b875 Author: Mark Johnston AuthorDate: 2022-08-05 20:25:05 +0000 Commit: Mark Johnston CommitDate: 2022-08-05 20:26:34 +0000 bpf: Fix BIOCPROMISC locking BPF might put an interface in promiscuous mode when handling the BIOCSDLT ioctl. When this happens, a flag is set in the BPF descriptor so that the old interface can be restored when the BPF descriptor is destroyed. The BIOCPROMISC ioctl can also be used to put a BPF descriptor's interface into promiscuous mode, but there was nothing synchronizing the flag. Fix this by modifying the ioctl handler to acquire the global BPF mutex, which is used to synchronize ifpromisc() calls elsewhere in BPF. Reviewed by: kp, melifaro MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36045 --- sys/net/bpf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 2a390c1e7d30..4c8c77d1e948 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1515,18 +1515,18 @@ bpfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, * Put interface into promiscuous mode. */ case BIOCPROMISC: + BPF_LOCK(); if (d->bd_bif == NULL) { /* * No interface attached yet. */ error = EINVAL; - break; - } - if (d->bd_promisc == 0) { + } else if (d->bd_promisc == 0) { error = ifpromisc(d->bd_bif->bif_ifp, 1); if (error == 0) d->bd_promisc = 1; } + BPF_UNLOCK(); break; /*