From nobody Tue Sep 13 14:24:27 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 4MRm1m1RW7z4cVCH; Tue, 13 Sep 2022 14:24:28 +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 4MRm1m10W4z3xqt; Tue, 13 Sep 2022 14:24:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663079068; 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=moRwAyKzQ1XjsDD0MYiMAfQNfKw1P8lF+3hea1UdgmA=; b=goEe1obOBWE2gwt+xAESE43a4u5lCgfKRDRf5nPjh5OMxOoKXebPuNsEOe5ajOgbeySSOV 8wD+GqdLCaigX8/6ZaNErvhwVqcljls3Od5YzoKIqoORd7woZXAlCtYDrgfLhbtnGmXlkC GdlW5PYxTQ9CffGEWbqID6DNzxqyfX46IIkaQOWOkUPV7+4e7Ag+4z5geJFek3efVXNRkf ++Jwx48pagePEUZKl77/y8bsDphZkDn/i9qOXFDK7ycnWxXREnh3r5Qs2xhrMbOx60fNqa /7RY/GAZY55B/eYaLXynLKc4/bKM/6p5qzcjqkDeKJ/+DZoc0o2gcm1EXsMzkw== 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 4MRm1m052MzMVx; Tue, 13 Sep 2022 14:24:28 +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 28DEORUT005665; Tue, 13 Sep 2022 14:24:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28DEORRb005664; Tue, 13 Sep 2022 14:24:27 GMT (envelope-from git) Date: Tue, 13 Sep 2022 14:24:27 GMT Message-Id: <202209131424.28DEORRb005664@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Aleksandr Fedorov Subject: git: 0e6e2c4ef3d1 - main - netgraph(4): Don't process NGQF_MESG items in NET_EPOCH context. 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: afedorov X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0e6e2c4ef3d1244fa21e7b691e76fdc09f8eacae Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663079068; 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=moRwAyKzQ1XjsDD0MYiMAfQNfKw1P8lF+3hea1UdgmA=; b=y3B6W/4Zny2t8oQBFhU51Uh0lWTSA7xx4DeOEO40Ox2XwnXHlHODqfVaC/UAKcKgY1J7nL Wa8N2SGhFgoN72i9CduDlnXC0EIuA3+qmnbrtyGORk350kUfcDdiKwi2NcnD3ouG346baD 6FKw05OYYhUYtSNSLn/+1Ab0FCt1k7y2iEGjt5vxMo2O6WtHhlcFLJOuwmXLJqon6CWhBD Nw3bfdRSmtWN8TMFAodvohalufOmYDIvWat3eXm162jGefD/yPswge3WMfgbNZFBxZBWfZ SvcLfRAUCVCIOOHl8jcb2pE6y/Ql0H1qdglpGPYCZWMI9fcQsBacjdw4nvGnNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663079068; a=rsa-sha256; cv=none; b=jTEQGYdl/01RSNvsXQkYCPlgG786vHNl8f5aJTV2haPw5o7LfKTt1Ez6ZDcSd+ryY+5rx/ Rtq07B7/RYPaQOR93rCdGS7vi8VJ2INH9HPAFrjPe6j17/Soq9Y8VDd/6FjAOfblqYcBcH efJLTymmg6a+6blqCekyxB3zM/+4dxTPubtli9Y03CvbMua6WLM7Stto8xtyMScGF+hu83 1DujcK1zfRa8RK8eD9OlEtR33632qx60AhwgqcwC6rf9ga6fjmPt8o/WT/jzigA2xFHh6z L8psG9vH+uFs4s6k5tvAy6y7SnJOFp3icnryWUfTioCA6pHCqW8ocZp2AuHfhw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by afedorov: URL: https://cgit.FreeBSD.org/src/commit/?id=0e6e2c4ef3d1244fa21e7b691e76fdc09f8eacae commit 0e6e2c4ef3d1244fa21e7b691e76fdc09f8eacae Author: Aleksandr Fedorov AuthorDate: 2022-09-13 14:15:23 +0000 Commit: Aleksandr Fedorov CommitDate: 2022-09-13 14:20:41 +0000 netgraph(4): Don't process NGQF_MESG items in NET_EPOCH context. Netgraph has two main types of message items: - NGQF_DATA items are used for data processing. This is a hot path that should be called from a NET_EPOCH context. - NGQF_MESG items are used for node configuration. There are many places in netgraph(4) where processing the NGQF_MESG item can call sections of code that are forbidden in the NET_EPOCH context. All item types can be queued and then processed using ngthread(). But ngthread() is unconditionally enter in the NET_EPOCH section for all types. This causes panic/deadlocks when processing NGQF_MESG elements. Reported by: mjg Reviewed by: glebius, vmaffione (mentor) Tested by: mjg, afedorov Approved by: glebius, vmaffione (mentor) Sponsored by: vstack.com Differential Revision: https://reviews.freebsd.org/D36496 --- sys/netgraph/ng_base.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index ac9d55a6f703..092231850f18 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -3439,7 +3439,19 @@ ngthread(void *arg) } else { NG_QUEUE_UNLOCK(&node->nd_input_queue); NGI_GET_NODE(item, node); /* zaps stored node */ - ng_apply_item(node, item, rw); + + if ((item->el_flags & NGQF_TYPE) == NGQF_MESG) { + /* + * NGQF_MESG items should never be processed in + * NET_EPOCH context. So, temporary exit from EPOCH. + */ + NET_EPOCH_EXIT(et); + ng_apply_item(node, item, rw); + NET_EPOCH_ENTER(et); + } else { + ng_apply_item(node, item, rw); + } + NG_NODE_UNREF(node); } }