From nobody Fri May 17 16:22:07 2024 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 4Vgsg34ndkz5LPsb; Fri, 17 May 2024 16:22:07 +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 4Vgsg34Cbtz4SqD; Fri, 17 May 2024 16:22:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715962927; 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=k3f1CT138rK9Oc2DleBBp6fcKATrW2Cbe8P3Pw8Xek8=; b=T6hQqW8mxmHMLWE6n0fM2HhMagg2wEwPmhv19lu03toMk3p9EP7KO63dx75FNAZZYMIkpL EBPZAL1KcFCFGxfW97pyuWl6DzsAD666ke6C1GEnicC4BKYG5qMZZ6TigodeU13756m9aY +KP1iUm6LZ54Z2q9q/jSGn3azyc4TMOP+mf7KF8Q4nNzqmiqFype8mKQwZVBQupbNRvVG+ s3O/tNtH3zsmE7mxuYsBk9imHnwdXC2AHLXI31KoNpNPUa+/FfoWirGeoi3sNpCQK7c78+ axIMmz+94YnLizVortjlf40nBs2l4Nv9Y5eE1/gj0cp80RtHzO2kDm6QjofKTg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715962927; a=rsa-sha256; cv=none; b=wQMYQzqBrv3SXVHQmjdmyP2ytnVVEWxOeaeb7+B81BUDWvgtmJQ66W6tAXtQOXWIwUQvuj A+kmSvcGxRKobGJ214UH0zZZ2N1+TOI3SWfEweRUZpGe5pjniMdwhT79UxznxEpylVjhZX pEyfxSDndv+lknFSXkXEWrjLxB4AGLDPjZO6/WrupIu1hiBX+5ZY2h1zGpS5+hVo9V9f2y /rqP7ITLHuYActJl22gGK7OuDnFjK6e3rOuVo+yZKnPTaK83nZpxi+7FCrSxV0TfAjTixb hXgNwxkTcTPOnXIz+ZeNVwjlUQWS20zKCAHy0lf6j/9vmb//cZPdwA/HEZTMLw== 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=1715962927; 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=k3f1CT138rK9Oc2DleBBp6fcKATrW2Cbe8P3Pw8Xek8=; b=oXAvTvwK5qjCdwwAMkPNv/XmQEVClf3eibAUoAPfYqi/kADWUWOkOVOHjA3WYK/PNChSj/ jc3EKA/GgvvVbaeFLhIf6GnKewSLuQOk8q9oJkIZ908YIk5D83KAA2WrsJlQyJe7ohp/kG by7JAgytGbjQSuSkqMEGX6rxraFVShYGja+ykb5/AZyZNM0rfngzWr0OqdZNt+2eyTOeWm eXAiKpbWy0P308t4Vtre318GF7HZx7Pxkpbs0sXpEuzUcSZIUlITcoevFk6msQdfoer+Ko ZATeVeIU3GIojXsK7v6FEQ3jsQxFSZv+XoRDMT022Qy2HIOtAkM6BiaKb5k1IA== 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 4Vgsg33mXxzpyW; Fri, 17 May 2024 16:22:07 +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 44HGM73S079632; Fri, 17 May 2024 16:22:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44HGM7TV079629; Fri, 17 May 2024 16:22:07 GMT (envelope-from git) Date: Fri, 17 May 2024 16:22:07 GMT Message-Id: <202405171622.44HGM7TV079629@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marko Zec Subject: git: 4ab122e8ef12 - main - fib_dxr: check if cached fib_data matches the new request in dxr_init() 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 4ab122e8ef127d36d95f874e85600c36c87c8c22 Auto-Submitted: auto-generated The branch main has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=4ab122e8ef127d36d95f874e85600c36c87c8c22 commit 4ab122e8ef127d36d95f874e85600c36c87c8c22 Author: Marko Zec AuthorDate: 2024-05-17 15:55:43 +0000 Commit: Marko Zec CommitDate: 2024-05-17 16:21:54 +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 --- 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);