From nobody Mon Aug 01 19:52:39 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 4LxTLH4xs8z4XmV9; Mon, 1 Aug 2022 19:52:39 +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 4LxTLH4SqYz3v28; Mon, 1 Aug 2022 19:52:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659383559; 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=WrOhe03QbCYRo0Yq7f6EPRwGC1XOsm2b0fZanqskjuw=; b=e9XWY4A9EqVgektt+Awc6fRFaJNY5fgWtwi2m9kSw3DKzHQ5KGKl23P/DhPaztwlsqj48p 0W2ULkKBNjl8O8NE4z0j9mOqkfJWKupZFXiCAH6g7FqxMDdYD0iNH17f162Si/JKhdhQ7c CnszJo8aGToVtqjS8VvZ8Vx0+12pelpPzhUY0GalA8ZhHjRK0d+QH5IyUqIfbrRPbGKs12 Awk6TPpf1FzwWkYadnwLEBO6kPcCHc4WxoqosKkFNh25JZgdXiR6sCZSo/juhWwPcwv7w2 B0Uizlu3kidA/RSuAU3YWrooGRFK01qcQZheJndxwEtQJhLT8QoiElgAqEoeFQ== 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 4LxTLH3BSpzm52; Mon, 1 Aug 2022 19:52:39 +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 271JqdBC084977; Mon, 1 Aug 2022 19:52:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 271Jqdpf084976; Mon, 1 Aug 2022 19:52:39 GMT (envelope-from git) Date: Mon, 1 Aug 2022 19:52:39 GMT Message-Id: <202208011952.271Jqdpf084976@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: fb1526ca2783 - main - wtap(4): Fix bug in wtap_node_write() and wtap_vap_create() 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: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb1526ca278301a495ea547ba18e22c4509e36e5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659383559; 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=WrOhe03QbCYRo0Yq7f6EPRwGC1XOsm2b0fZanqskjuw=; b=RTDmgB1gc7CHTkrs9dbDCBBP5gyoCnIshBwdq8Ka7EGINf2HwpmpzsmpOyB2to5smg3Ex1 QFlgBTUoQ4FhBEZE66RpajY8dJnDr1HZKLAVbN0Aah9Xz4LUSFW6M3v0LYnll3ASrDg72b CY3tRQy4aqvPoYACeregESMtpJqQxeQ0PYbP47QZZZ4VIgGKx6IFlQf+rg2yiurn993b8S s+8vDTiY1o/GJgtz8KiK7+eHvjYroG+u86X8QIAnyaKHLxtp1+EYx3CqKE5zlZ3XeCLPmh E9RVAwMqROW69n3pfYt9Yj5Wmlo5OiNEszDLtPaj/JbAaEBjCTBs+03CPntLnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659383559; a=rsa-sha256; cv=none; b=cZ6WV2zGcTVxREineM4qrq+s224MPXvC2t14fYdUA0XspxuDbWhu2ASjxCiSsITts6sJdt RW5R/BBe0lw+LB1Jbv8OikWv+NdOwo2ZlSTZ3AWenaDZQKpVwFaFwGuv37TFvk9tNGdqgo hKIyN9Eo2wJkb1pkU7s6GhEMGBhN40TdkClNEr2FUzoB2ty+cVJ99S4F4KoALSY0lCHw+P Pm20leeJ1ZE94EaRSSWH4nLt//zxt193AI/jqpjJXpNqjTMAHGO/uZo2u7aInGHodpfaSD +u2e3AvsiRXAvJZSb2f0zDDT1R4NLvv17xQHO56TKeok83kCtgN7fkZ2ogtI9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=fb1526ca278301a495ea547ba18e22c4509e36e5 commit fb1526ca278301a495ea547ba18e22c4509e36e5 Author: En-Wei Wu AuthorDate: 2022-08-01 19:40:13 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-08-01 19:40:13 +0000 wtap(4): Fix bug in wtap_node_write() and wtap_vap_create() Originally, wtap_node_write() gets the wrong softc by iterating V_inet and gets the ifp by string comparison, then gets softc by ifp->if_softc. However, ifp->if_softc will not point to the correct softc owned by ieee80211com, and thus causes a kernel panic. Fix it by assigning softc to cdev's si_drv1 in wtap_vap_create() and get the softc directly via dev->si_drv1 in wtap_node_write(). The cdev created by wtap_vap_create() use the name of ieee80211com rather than the vap's name. It will cause the second vap based on the same ieee80211com as first vap fail to create a device node because the device node is already exists. Fix it by assigning vap->iv_ifp->if_xname to cdev's name. Sponsored by: Google, Inc. (GSoC 2022) Reviewed by: adrian, cy, bz Differential Revision: https://reviews.freebsd.org/D35752 --- sys/dev/wtap/if_wtap.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c index 26d932f250c7..214f9f739407 100644 --- a/sys/dev/wtap/if_wtap.c +++ b/sys/dev/wtap/if_wtap.c @@ -88,7 +88,6 @@ wtap_node_write(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; struct mbuf *m; - struct ifnet *ifp; struct wtap_softc *sc; uint8_t buf[1024]; struct epoch_tracker et; @@ -106,22 +105,13 @@ wtap_node_write(struct cdev *dev, struct uio *uio, int ioflag) MGETHDR(m, M_NOWAIT, MT_DATA); m_copyback(m, 0, buf_len, buf); - CURVNET_SET(TD_TO_VNET(curthread)); NET_EPOCH_ENTER(et); - CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { - printf("ifp->if_xname = %s\n", ifp->if_xname); - if(strcmp(devtoname(dev), ifp->if_xname) == 0){ - printf("found match, correspoding wtap = %s\n", - ifp->if_xname); - sc = (struct wtap_softc *)ifp->if_softc; - printf("wtap id = %d\n", sc->id); - wtap_inject(sc, m); - } - } + sc = (struct wtap_softc *)dev->si_drv1; + printf("wtap id = %d\n", sc->id); + wtap_inject(sc, m); NET_EPOCH_EXIT(et); - CURVNET_RESTORE(); return(err); } @@ -345,7 +335,8 @@ wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status, mac); avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, - "%s", (const char *)sc->name); + "%s", (const char *)vap->iv_ifp->if_xname); + avp->av_dev->si_drv1 = sc; /* TODO this is a hack to force it to choose the rate we want */ ni = ieee80211_ref_node(vap->iv_bss);