From nobody Fri May 20 12:51:16 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 16FB11AE0ACE; Fri, 20 May 2022 12:51:17 +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 4L4RRm6pv7z4vwr; Fri, 20 May 2022 12:51:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653051077; 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=/n5uZL/BvRzsOe7PZJ8W+0T45gnX9wIr75hMb1IzvUY=; b=jcKEeT9VJoecpbCyQbNzOgF8XvywgQVP6v/RBibsO2QG4pWX7VM0iuDZg3Mv4aSpypT55Z LH4Bb2AGnFFFA/eTbQ6ke75oJMfwKOpudL38byGHam0tYX5dL0V5HdRYDdqTjS3RhtENT7 p/wN92tyJ7JuQfgA1dMxcablQsWfRbMxQX91E5uzO5OsH7WafuNRksHhF/LdCS/aFMWwy5 cB6We73MWlISXdCOIPnSdiVTQbNT89l8u1HkWq/sLimhkAYF4usTrRjYSX/ruRmBYQW0pW jN9w5a554zMLzIRLbbE62ceFTw6x2i5i+6oiDcDVeI1y4x17Xz9QNfdHqexTJA== 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 BF21B128DE; Fri, 20 May 2022 12:51:16 +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 24KCpG4T086974; Fri, 20 May 2022 12:51:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24KCpGRB086973; Fri, 20 May 2022 12:51:16 GMT (envelope-from git) Date: Fri, 20 May 2022 12:51:16 GMT Message-Id: <202205201251.24KCpGRB086973@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 12c542cd0e9e - main - dummynet: do not store struct ifnet pointers 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 12c542cd0e9efc1ad9f20f1035402c0acf6d403f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653051077; 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=/n5uZL/BvRzsOe7PZJ8W+0T45gnX9wIr75hMb1IzvUY=; b=Srx328sUaf9PqmiWEMPhGllRpu2iy0IcD8/VCRcbxtOetBJcf/3Fqr2ajrMiO+4RCVycaA +oFRh/4NYBsesSaVyCH6G3S5jRMSCBWbOmBqn0hcog5CoBwZd0jQgLSxN24LhTHEucqsY4 iOLXqsGQPFRDjoZOVc2XG9adx3I+Ocfy6+6WmxQXvb7jbS8g1uvPcd6BD75C491ONsdUaD P9uglWlOvgH497jFO2NK5A7v7h5clYADImPiN93rBLdRyYtAogv9rO/ZlIuTVSRm9/EgxI 9GCb3BBej0UCM0ZvXrExXK4fzH1LMiA3LbaCoj2vLvPwjx6xdjq2X2QPChig6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653051077; a=rsa-sha256; cv=none; b=eiuRoT/cODVe8389cDR+wnR0pQHrh3/1GTpH9KHLYKIllApYRrRfS2iDphw5k6dpGqwqiD XNP6PNorjhL/1xBozHI80AgAZwBjYJsnyeckkWFsR+Ty8e6r0HiPGKLzQJF5pPioA2d+Ie +4LjRbKeZ57NO/AacTbcWrzyiSvQ41yFlV9oJrnHxRChAkQW+7sp3nDVBL3a4PZ2dxNH5x UpjjJwhdr/NuSjsb57ygb+Y1U1Xzrr0PA+b7CaXKnBwzPhNmJU41VHmoVh0JAxtEKPPK3p AQfjEmVKIVmy7pmlv0fT42bvA3TAlO3VcKC+3e907e3yi88dlUj9DBPRR3PBrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=12c542cd0e9efc1ad9f20f1035402c0acf6d403f commit 12c542cd0e9efc1ad9f20f1035402c0acf6d403f Author: Kristof Provost AuthorDate: 2022-05-19 13:12:54 +0000 Commit: Kristof Provost CommitDate: 2022-05-20 12:49:30 +0000 dummynet: do not store struct ifnet pointers The dn_pkt_tag tag contained a struct ifnet pointer. If we persist that across NET_EPOCH boundaries (as we did in dummynet) we risk panics if the interface is removed between the packet being enqueued and it being dequeued. Convert the pointer into an index/generation pair and restore it when the packet is taken out of the queue. Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D35256 --- sys/netpfil/ipfw/ip_dn_io.c | 10 +++++++--- sys/netpfil/ipfw/ip_dn_private.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c index 824e7450fb8f..98f9d08495df 100644 --- a/sys/netpfil/ipfw/ip_dn_io.c +++ b/sys/netpfil/ipfw/ip_dn_io.c @@ -766,12 +766,12 @@ dummynet_send(struct mbuf *m) /* extract the dummynet info, rename the tag * to carry reinject info. */ + ifp = ifnet_byindexgen(pkt->if_index, pkt->if_idxgen); if (pkt->dn_dir == (DIR_OUT | PROTO_LAYER2) && - pkt->ifp == NULL) { + ifp == NULL) { dst = DIR_DROP; } else { dst = pkt->dn_dir; - ifp = pkt->ifp; tag->m_tag_cookie = MTAG_IPFW_RULE; tag->m_tag_id = 0; } @@ -852,7 +852,11 @@ tag_mbuf(struct mbuf *m, int dir, struct ip_fw_args *fwa) /* only keep this info */ dt->rule.info &= (IPFW_ONEPASS | IPFW_IS_DUMMYNET); dt->dn_dir = dir; - dt->ifp = fwa->flags & IPFW_ARGS_OUT ? fwa->ifp : NULL; + if (fwa->flags & IPFW_ARGS_OUT && fwa->ifp != NULL) { + NET_EPOCH_ASSERT(); + dt->if_index = fwa->ifp->if_index; + dt->if_idxgen = fwa->ifp->if_idxgen; + } /* dt->output tame is updated as we move through */ dt->output_time = V_dn_cfg.curr_time; dt->iphdr_off = (dir & PROTO_LAYER2) ? ETHER_HDR_LEN : 0; diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h index d7df31b85345..1cd38a2c94d8 100644 --- a/sys/netpfil/ipfw/ip_dn_private.h +++ b/sys/netpfil/ipfw/ip_dn_private.h @@ -374,7 +374,8 @@ struct dn_pkt_tag { int dn_dir; /* action when packet comes out.*/ /* see ip_fw_private.h */ uint64_t output_time; /* when the pkt is due for delivery*/ - struct ifnet *ifp; /* interface, for ip_output */ + uint16_t if_index; + uint16_t if_idxgen; struct _ip6dn_args ip6opt; /* XXX ipv6 options */ uint16_t iphdr_off; /* IP header offset for mtodo() */ };