From nobody Mon Aug 10 14:34:22 2026 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 4hJchc36mkz6nsZD for ; Mon, 10 Aug 2026 14:34:24 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hJchb0Pppz3bQw for ; Mon, 10 Aug 2026 14:34:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786372463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SLCLNOg4XEaUNWsYQDTV5jdmi3iTlDPw6wYKXgwtdPA=; b=OO6yv7/uMcO+84bL5yVRqGyqzCJ/3pQZGvNHElXjO8tDY/bsgJoO1/7fhtbx+u+c5aaVeS JI+PJsZkY3b8TIVOdfTSH5ZLbh/Lc/qmoHtJQGa52Q6YRdv8ajN5//5BFeP7SoIfZ29n70 3cS9Y1nCD/xNPKX/ZV3glR8UQTI8dCx1Z4Z07sIgMeai8DaIbhqFj+3qjfdVB5ltQ/TezJ F+KDqh091ExOFzX3hMwgaqehepNeKUoiYdok4qEucLR703AmT2eQPvEr87QUfYju6C+qk3 nsiuLgdXYMDRGniA5/vLDvsAzYjd19cOofx9T0OuKzd+rn+ZIXFi5Yp1CTKD8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786372463; a=rsa-sha256; cv=none; b=PBzpNvIxfGwCoLW2Ig2CN3I0DC+VyI7k9DLuh41Zs0w8U2OVbhYh8krv83stH2zPh8d2LL EUNPZSB1KpOq1K8XQLDsn8zYTz0OjdZ7rNxrV5Ag118sOfb+LpRk1nDlp70ZMX8S6+HqCr 9X5sKn2dLn5T27MtddRpMVpkd/2NGMtfvKtYQDnuv34HHsQWBCNIlJm5Lo/XS+uzPTxf7w NorRMo3hGGCT1HrLhCKWCgUP/RlVjz2RPY7aPAwjTBPa6EHodmBsEVkpvvsg522ZGh59YY 5Hg4K0J4K2QKanIYtt0CuVtduHJKTNLvH8YfJzXJlZRa40mWcwV25itc+wth/w== 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=1786372463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SLCLNOg4XEaUNWsYQDTV5jdmi3iTlDPw6wYKXgwtdPA=; b=BughWTwkSsIKeT+b1jGCIIcxxWRv4GPIb2M9FLsixoG8jKijzaKSAewTGerbZPIUBTz5Jh U+SXaGAu1632cAtZZ/a+aaeqUMJYgEfvzSkqXUW5EaVy1Nd26bweGQo/UmTManc3CEOmKd 7knrR63SRZWmAqYuRLKuu2x12XqPUgljgLFXzKNY3kQaZ373DS/9Y5wGrk4tGvHljOtpAs +rGzjOdWRDLLBaFti3sNPBMDGRn2XtbwXxCkRy/yLEe8QuuhIBrMdTZfJE+sW4tZWJoTmk aWS0hNQLEi1U+ozKNFjcQzWGH5nD3I+dRdpNpoBGevS1fE/7EnEEAzRS/skWoQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hJchZ4sfRz1C4h for ; Mon, 10 Aug 2026 14:34:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24f7d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 10 Aug 2026 14:34:22 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Ishan Agrawal From: Kristof Provost Subject: git: 0f2e98c1515d - main - libsysdecode: verify decoder tables are sorted 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0f2e98c1515d2bfc05701d5e19aac16a985ae5f4 Auto-Submitted: auto-generated Date: Mon, 10 Aug 2026 14:34:22 +0000 Message-Id: <6a79e16e.24f7d.46729963@gitrepo.freebsd.org> The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=0f2e98c1515d2bfc05701d5e19aac16a985ae5f4 commit 0f2e98c1515d2bfc05701d5e19aac16a985ae5f4 Author: Ishan Agrawal AuthorDate: 2026-08-09 06:24:18 +0000 Commit: Kristof Provost CommitDate: 2026-08-10 14:33:32 +0000 libsysdecode: verify decoder tables are sorted Add assertions to validate decoder table ordering required by binary search. Signed-off-by: Ishan Agrawal Sponsored-by: Google LLC (GSoC 2026) Reviewed by: kp --- lib/libsysdecode/netlink.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/libsysdecode/netlink.c b/lib/libsysdecode/netlink.c index 2785b23cb98b..22ccf1fc2acb 100644 --- a/lib/libsysdecode/netlink.c +++ b/lib/libsysdecode/netlink.c @@ -340,6 +340,28 @@ static const struct nlattr_decoder nla_d_clear_states[] = { }; NL_DECLARE_ATTR_DECODER(killclear_states_decoder, nla_d_clear_states); +static inline void +nl_verify_decoders(const struct nlattr_decoder_set **decoder, size_t count) +{ + for (size_t i = 0; i < count; i++) { + const struct nlattr_decoder_set *p = decoder[i]; + for (size_t j = 1; j < p->count; j++) { + assert(p->decoders[j].type > p->decoders[j-1].type); + } + } +} +#define NL_VERIFY_DECODERS(_p) nl_verify_decoders((_p), nitems(_p)) + +static const struct nlattr_decoder_set *all_decoders[] = { + &getrules_decoder, + &set_limit_decoder, + &addr_wrap_decoder, + &pool_addr_decoder, + &addr_decoder, + &rule_addr_decoder, + &killclear_states_decoder, +}; + static const struct pfnl_cmd_decoder cmd_decoder[] = { { .cmd_num = PFNL_CMD_GETRULES, .ds = &getrules_decoder }, { .cmd_num = PFNL_CMD_KILLSTATES, .ds = &killclear_states_decoder }, @@ -390,6 +412,8 @@ sysdecode_netlink(FILE *fp, const void *buf, size_t len, int protocol) return (false); if (family_table == NULL) { + NL_VERIFY_DECODERS(all_decoders); + family_table = malloc((num_family + 1) * sizeof(struct name_table)); family_table[num_family] = (struct name_table){0, NULL};