From nobody Wed May 22 17:38:08 2024 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 4Vkz6S6YlRz5M66l; Wed, 22 May 2024 17:38:08 +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 4Vkz6S60ZTz4l09; Wed, 22 May 2024 17:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716399488; 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=463fwtfwyjdMrW/s+o0/iBzIBAnOj0G87zz7zOnI/XA=; b=nv2wdeCgxX66E9tG/uNoMiLPPMxLdpYfQw5Y8ay69UFAfa6izyUaQ5KX5c1mvxVJdcZzOd ggLQudebyOo21V8u4xbrJB0i/f2iizZ6C3eUPsWPkHH+QS+/lP8r6p25BgO8LD8WOqHDVJ phKD1TnCNbyM9JhLdNvlvPRXnQ/Fd2Dt9iqF+MmXC8iL3Ss9avTB4EE/3Agk9H+lRqr8bQ rQNLJzgTdFKHMWf6r7F0RcY9QuCZ7f+TujI6YsrQo9oCzbpaY3ctWuUw3H/CdmgKTQ2tYr SiuNgHF1g5qh450iqsUBWXkki5XucVKwadyb3ro5H3+F0dRkzgZLNLNrVRMGdw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716399488; a=rsa-sha256; cv=none; b=BEZplMA0GfOgH+1+EDZ741QpMpcpA+IgtKIcBFQsH2UD5/AxaJQ7Q3u4gc1DuWIkCDyYrb 67qftdh6KoPnOvKIGF6umBem8PxPG9X3zVGSzu0LZF7Xs+bSrnaLShUrwu0O0qygMtXHG7 9oev0ZdZShKBKvGafXe3gRUNWn25G2ldVppZ/k5qP534Le45kPwPbv9PQxMew4q+MEQjtU UIzxYJ/Yghkn9krqGCGWBsncpJCudScE1o0QLnh9Bn2WqiZuEWVCiddeDzrkjUJ57RBmZO zWUW/LHO6lFhJ4PZXYi56FHN4GRq/+75+ThWiZaZXzfaGq3gw1fa4wmyXKSWiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716399488; 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=463fwtfwyjdMrW/s+o0/iBzIBAnOj0G87zz7zOnI/XA=; b=MzwHK2LqSvsXPMT8BnGUPA5gEtZlWAw0rtted4OtCMFWIe0fLfbH87ZOw0LU/Lk7G98Bar yuHKMChzZR2LS+Hlgz0sclm3AUn5PrYKxvJaGe1tIj6sGmMv3OEuz7AWteAvTVTM+GE5jm jCBY/+JK0D/CAjtyaVXsseecZvKK18G2Vn4aUyr4Kc0N6CUBH/ITX7O0ZUYs5iEVm6Frai B2urovvgAf5jNZ3U6UIuYalN2vj2hsv/ajuAR5sUszKfArML/VjAAC64+hTYLz8iIbw0Qk FtB9ebhYk74510QCDkv5deBqnMiQOuq9/oZ/752YMF9UK34T7jWQhU5Y+eDSYA== 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 4Vkz6S5c1nzFX0; Wed, 22 May 2024 17:38:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44MHc8T1027235; Wed, 22 May 2024 17:38:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44MHc8Bc027232; Wed, 22 May 2024 17:38:08 GMT (envelope-from git) Date: Wed, 22 May 2024 17:38:08 GMT Message-Id: <202405221738.44MHc8Bc027232@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 9629a4b6865c - stable/13 - fib_dxr: check if cached fib_data matches the new request in dxr_init() 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9629a4b6865c5c56804f79a62f45512b175776e2 Auto-Submitted: auto-generated The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=9629a4b6865c5c56804f79a62f45512b175776e2 commit 9629a4b6865c5c56804f79a62f45512b175776e2 Author: Marko Zec AuthorDate: 2024-05-17 15:55:43 +0000 Commit: Marko Zec CommitDate: 2024-05-22 17:37:31 +0000 fib_dxr: check if cached fib_data matches the new request in dxr_init() When calling dxr_init(), the FIB_ALGO infrastructure may provide a pointer to a previous dxr instance, which permits reuse of auxiliary dxr structures, i.e. incremental lookup structure updates. For dxr this is a crucial feature provided by FIB_ALGO, since dxr incremental updates are typically several orders of magnitude faster than full lookup table rebuilds. However, the auxiliary dxr structure caches a pointer to struct fib_data and relies upon it for performing incremental updates. Apparently, incremental rebuild requests from FIB_ALGO, i.e. a calls to dxr_init() with a pointer old_data set, may (under not yet fully understood circumstances) be invoked within a different fib_data context than the one cached in the previous version of dxr auxiliary structures. In such (rare) events, we ignore the offered old dxr context, and proceed with a full lookup structure rebuild instead of attempting an incremental one using a fib_data context which may or may not no longer be valid, and thus lead to a system crash. PR: 278422 MFC after: 1 week (cherry picked from commit 4ab122e8ef127d36d95f874e85600c36c87c8c22) --- sys/netinet/in_fib_dxr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c index 82245ecf6e66..539d7fe6c96f 100644 --- a/sys/netinet/in_fib_dxr.c +++ b/sys/netinet/in_fib_dxr.c @@ -1139,7 +1139,8 @@ dxr_init(uint32_t fibnum, struct fib_data *fd, void *old_data, void **data) } /* Check whether we may reuse the old auxiliary structures */ - if (old_dxr != NULL && old_dxr->aux != NULL) { + if (old_dxr != NULL && old_dxr->aux != NULL && + old_dxr->aux->fd == fd) { da = old_dxr->aux; atomic_add_int(&da->refcnt, 1); } @@ -1275,7 +1276,7 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q, da = dxr->aux; MPASS(da != NULL); - MPASS(da->fd != NULL); + MPASS(da->fd == dxr->fd); MPASS(da->refcnt > 0); FIB_PRINTF(LOG_INFO, da->fd, "processing %d update(s)", q->count);