From nobody Thu Nov 24 19:47:18 2022 X-Original-To: dev-commits-src-main@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 4NJ7n24Gdbz4j0sm; Thu, 24 Nov 2022 19:47:18 +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 4NJ7n23n81z3vt5; Thu, 24 Nov 2022 19:47:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669319238; 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=pzl1QRutftPCPP0N3q2l30mTqRgGznWF2Igx3bASfTk=; b=isEdRpDmHGPXaIV79MYhUutMFH+cXIxtzLz29hpF9QwIPSQepZ99c2Uj/Iv/t9G7bOg+p+ WJOy/bJV1rUwanX9Mvsh7vsJtX5xY5nPXgIkvKeva7IkdOjwfHvZt832ka3Gf3L5nRunDJ 0in+gsvrbQXw24iAT8AkgDnq/KFxZo4mqIfprvi32ayKKOLOUTqj/gvgCHo2E2cF3YbPd8 08G7WhUB960pLnxPYujRA6wyqCt0+8TieDxjcY0nLo8NCh7uZ7RJMCtDqOp/q0+wnK69Fm YSs9Gu+ULIDOTK8OOQiCx1VBazTGBpR0ESkZdwggsNi94XFz/Cw0hMlPekU2MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669319238; 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=pzl1QRutftPCPP0N3q2l30mTqRgGznWF2Igx3bASfTk=; b=CBCIpVMmSdIBUiuw6HMmxaqXudpPbbc1MkC7oRGjxK4UpTrVbz/XORRv3omQOwE06cYqFU Av6qwGLRRo16pEJWit2CJ4pnhbXIEJa5J3PbnWRfyMXBmJjngpRSHigEE52YnZKqxI4Jm6 ZWEytolZr1nAJnu7Kdx6L8OMIXzAhcnFGwWqaO2bB1zj0LaphOZ5ciMMjOenBsvSNGYeIC 8+YAckZcbfZRkhZgBIcfRW2Pu2djWrf97BpnBWfiaa1fBXtsg8fIw/CHLeVWAj9SDF5VJ9 lv29e1wj1u0hpFz7uSO8pTfifSyrMyckkUtm8aOF72QCGjyNPDv47URSKttGiQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669319238; a=rsa-sha256; cv=none; b=InwAJIKinctyBc3P9x9ZhTKZm2RtX7zFqt0NDyu5LEVdQfVUW68vKkpeMNssbMkpwyugSi hpZMGfg4xhIHQlf3rO40rf2naAfb2nESbRcA0ULLxN26/wnPuF5m4NX8i3UDIYo2zlfwDb MrDGl8KHWtP7g/LyTpc7XIfmk/GTCzO5Ns0rWIg6DLMwZfMJbyGbLnla8+MozbRmonfyOs KI8qDS79CzVsUlIKImx0INzJg7oh8dfj62ngPN/MjZPYGlN8Rw2myI2UwbSDXYP5bR6Dzs 9xAUJV1EkiYsGMQVgBmsFVeXNxAXATWWP7T5l72k4UGvir8s9DYUIpvi38FdeQ== 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 4NJ7n22csBz1Chl; Thu, 24 Nov 2022 19:47:18 +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 2AOJlIhj008447; Thu, 24 Nov 2022 19:47:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AOJlIpl008446; Thu, 24 Nov 2022 19:47:18 GMT (envelope-from git) Date: Thu, 24 Nov 2022 19:47:18 GMT Message-Id: <202211241947.2AOJlIpl008446@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 8288117a6174 - main - bpf: only access refcounts using dedicated primitives List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8288117a6174f6ac9f761e90fd0998bb992e58a4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8288117a6174f6ac9f761e90fd0998bb992e58a4 commit 8288117a6174f6ac9f761e90fd0998bb992e58a4 Author: Mateusz Guzik AuthorDate: 2022-11-24 10:33:37 +0000 Commit: Mateusz Guzik CommitDate: 2022-11-24 19:44:25 +0000 bpf: only access refcounts using dedicated primitives Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/bpf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index eded898d2fc3..1885f1fd3733 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -973,7 +973,7 @@ bpfopen(struct cdev *dev, int flags, int fmt, struct thread *td) d->bd_bufmode = BPF_BUFMODE_BUFFER; d->bd_sig = SIGIO; d->bd_direction = BPF_D_INOUT; - d->bd_refcnt = 1; + refcount_init(&d->bd_refcnt, 1); BPF_PID_REFRESH(d, td); #ifdef MAC mac_bpfdesc_init(d); @@ -2776,7 +2776,7 @@ bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, bp->bif_dlt = dlt; bp->bif_hdrlen = hdrlen; bp->bif_bpf = driverp; - bp->bif_refcnt = 1; + refcount_init(&bp->bif_refcnt, 1); *driverp = bp; /* * Reference ifnet pointer, so it won't freed until @@ -3146,6 +3146,7 @@ bpf_show_bpf_if(struct bpf_if *bpf_if) return; db_printf("%p:\n", bpf_if); #define BPF_DB_PRINTF(f, e) db_printf(" %s = " f "\n", #e, bpf_if->e); +#define BPF_DB_PRINTF_RAW(f, e) db_printf(" %s = " f "\n", #e, e); /* bif_ext.bif_next */ /* bif_ext.bif_dlist */ BPF_DB_PRINTF("%#x", bif_dlt); @@ -3153,7 +3154,7 @@ bpf_show_bpf_if(struct bpf_if *bpf_if) /* bif_wlist */ BPF_DB_PRINTF("%p", bif_ifp); BPF_DB_PRINTF("%p", bif_bpf); - BPF_DB_PRINTF("%u", bif_refcnt); + BPF_DB_PRINTF_RAW("%u", refcount_load(&bpf_if->bif_refcnt)); } DB_SHOW_COMMAND(bpf_if, db_show_bpf_if)