From nobody Fri Aug 19 11:54:32 2022 X-Original-To: dev-commits-src-branches@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 4M8KtJ585lz4YvMC; Fri, 19 Aug 2022 11:54:32 +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 4M8KtJ4ZC1z3ybr; Fri, 19 Aug 2022 11:54:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660910072; 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=SV9cc9ecmBeN0fPL7SrRUlOUJaMEE6O1s+yoV2kqNj4=; b=GmPBpTfSccUOutQtLI43USAzsTCYBqm45WUxvujR1jgoGAqSOKaPK55y4lk7l3swZQSYda PQkCCgAvFauZEi/ERonAkvPrXnLTPOkMFewnSYc6oG5r0Z49y1zoTufNB0IUljrxLfyYuj w1h/5HnSu0CiEBngcf6EU6Y9kH1xU9MsYTjI6drxesOvnQ5oOQFVj+AgxHtM1IXLdbpJCq s6zcFVTEZ3cwnRVwWG46747oCdI0Qs4jFYnC3u3D++fhdi1ZFZYkEbHP6yHhyUjP58ep7j cCMcjoj0vnNZmSYSOfxP6oS9i6aI+wakDitW8Hy/Epoa5IxdmiKteUYva6KNVw== 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 4M8KtJ3bQrzrGf; Fri, 19 Aug 2022 11:54:32 +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 27JBsWgV080860; Fri, 19 Aug 2022 11:54:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27JBsWKY080859; Fri, 19 Aug 2022 11:54:32 GMT (envelope-from git) Date: Fri, 19 Aug 2022 11:54:32 GMT Message-Id: <202208191154.27JBsWKY080859@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 057b43b26235 - stable/13 - bpf: Fix BIOCPROMISC locking List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 057b43b262350c60409fc1eaa34a61259b64f57f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660910072; 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=SV9cc9ecmBeN0fPL7SrRUlOUJaMEE6O1s+yoV2kqNj4=; b=iq7QYxI4STQ6XlM+k9Ixck5ngR54/IAR4tvHC7d3yYSleljztvJYPzpmuUV6/dNdYnF3ae yVr366bKSKOoqizBhvDASrWKBWfPGZtnsJ6rIU3puOHN6vD5fAV0lM2Wu3jvE6+54y+fr9 kDmHDFKLbJUnmIiKyTbr0vnUv3Qt18ZIgs6FNbDnu1Vcu3QaKLmso8w7THE3E5vKIjmR3+ duUwvS7VTXYvIjuWbVQHzhvHU+qla6uQMhXZpVV2Hq4h9oFBHqf6oZf6yjJVv4Z1gVoTb1 kdfmLlI4rE9wJL8pJRPJz+ZX+i6bx8RpWK6EUmeQ2882SNdBgReOgtQ9MnzRjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660910072; a=rsa-sha256; cv=none; b=KGYlPWFgM4avwUvsEGsV5MA2vcVLe0/yyo3n6jerI3yIHcLdfIEVQohsqPiQgfzTJPmLOa 4E3pWdRKpTVuNJ7ZUKUKZXi6KC61Oy3h4953t3uDegXFmZTmRCIoin+ZaJBVjk7dpy7WuB JugFYgqHnAUPx9ZjzVrpVZ2gPpPZYhkaczmey1uZFvdZj0Iw1jWk3pjKaPH2PuWcXrcFHV rRWBF5p56rVnTgJWaPKQb29Sw8BhAOac33BhgrUFjGWRq4SSM4q0qcBpTcWNLjbVykFqIb Px4iAW/N5KrimiFE87ttFaWwY/Ntyd/PnnBoMNgh5chesClH7/x637750x0uKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=057b43b262350c60409fc1eaa34a61259b64f57f commit 057b43b262350c60409fc1eaa34a61259b64f57f Author: Mark Johnston AuthorDate: 2022-08-05 20:25:05 +0000 Commit: Mark Johnston CommitDate: 2022-08-19 11:54:04 +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 Sponsored by: The FreeBSD Foundation (cherry picked from commit 220818ac030726c24cbf9df6df5c9d019993b875) --- 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 81d88305e1a1..ff00112d6538 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1503,18 +1503,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; /*