From nobody Wed May 22 17:34:53 2024 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 4Vkz2j3tfRz5M664; Wed, 22 May 2024 17:34:53 +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 4Vkz2j3JMTz4jrG; Wed, 22 May 2024 17:34:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716399293; 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=hjJ7McacaeCkCoKYnq5xtIVWsXb0wkz5oy5fHiTs5Mk=; b=XghmgYOZwpHtF1Q7j5p21j1L/CTDVpkBWxiwFcHsL/66OK+tKUMw60Tl3sILU+F4R8sZII +4rLHErDJRuFHQTK3Qq3tOqA4VYZ8TIDYXzWx266b323TDlAiPTdV6swDAOmIVPbdQlGRW //Vqn5bbPY2TjiQgcQBCosnTECI1dHQencpzMKxfV+3oSzQ6S8XtrH8piHjfPD5Q1IImgy sNHu3QXiLXwdqHHq4OYZxYjFDWd7EJYKZvdD2lPDrGchg5cZFa5Mt1SRZzRgew8I55lMe9 htbIAUs7eEoBvkgBdSlDIj7Jkj5Jmd7PR9FjQQQQTRXXO7AcUsX7gStGPEpaYA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716399293; a=rsa-sha256; cv=none; b=q8p2aKpSxvrft5Tj9eY/D9dY9NbRH3etoJCWkHWYgp56u+7bXJR1g5Fp+4YdsRWrlW94zD 5AAYYdf1VpvFoO2HVHy9lyWne+Ithm8oojcGQFODxqIbqj5PBNG+R7iYdfeNQN4kyTjmZ1 Xs7ZBaDnus55idnnTosan/qWocnpjN128GKwA88eud9pdBaETpIx+85g9hKG8ufl4sUXse jpyIsVY7vUug/mvRgRBdNHIotQthtUVWrKg+dvHbpJXSQLdKFL5/zOlUt2gnxAKkkaC2FP bRZqsTkin3/8YYzCRcU3whYksL1olf4v3WDLiKp4adQZAiLqge6tJuKWF2p9Ag== 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=1716399293; 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=hjJ7McacaeCkCoKYnq5xtIVWsXb0wkz5oy5fHiTs5Mk=; b=wN4NxqzjfVuMvlRKSWhCdohYH84xAFpTAiqXs+tFgBMdRzjJlWnPtwQ9KKkOT36wPHlrtC AZUN3ShylhXtESJ4Le/v0OfZGU60qd8jeOM1pOTPfKhBuYyE2QCAAJvQEFA61urtuhP777 bmAQ7B5wbNRswebUAtuQNcR/tEhzpp5zppaFBlu7/zg+vsVfr6jRnt3y7s73DPau9hw5HJ g7x7M/ymDcWVGFohApphHSTllraMqy/og+wLJL6VYxnci9r6Wj7WbNKx4vUIMkPwh2faCK p6gRmQy1QHKmFSkHg5riHHJu5WzcphZWcHh9jB8G0OAS+izrX446dxrU4gJy5w== 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 4Vkz2j2vCxzFZW; Wed, 22 May 2024 17:34:53 +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 44MHYr0B026518; Wed, 22 May 2024 17:34:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44MHYrFt026515; Wed, 22 May 2024 17:34:53 GMT (envelope-from git) Date: Wed, 22 May 2024 17:34:53 GMT Message-Id: <202405221734.44MHYrFt026515@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: d6e32525c778 - stable/14 - fib_dxr: check if cached fib_data matches the new request in dxr_init() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/14 X-Git-Reftype: branch X-Git-Commit: d6e32525c778d92c26a37f4e1b562e80b18a9af7 Auto-Submitted: auto-generated The branch stable/14 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=d6e32525c778d92c26a37f4e1b562e80b18a9af7 commit d6e32525c778d92c26a37f4e1b562e80b18a9af7 Author: Marko Zec AuthorDate: 2024-05-17 15:55:43 +0000 Commit: Marko Zec CommitDate: 2024-05-22 17:34:05 +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);