From nobody Wed Jan 01 00:05:14 2025 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 4YN98B6gQgz5hyXJ; Wed, 01 Jan 2025 00:05:14 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YN98B67VTz41Xk; Wed, 1 Jan 2025 00:05:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735689914; 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=C4W8q+kHU8LDvwrRbiCZ2Ik9nGHe5SKC/3ATe3wJlig=; b=afi0GEcjaJ6zB038J8ak4Aj4TA82Z1U6lLHhcC68jtpgIm7uvKbzzHJRAsQDBvYs6WWR4g BDpehLNaKReuJX3rRUt11UXsGTMBRWxrCr9RBqWMsRHf/2R/LLBOBJlO395xPazUKUelKP DYp6e7Fve5qW/Kk+bXO1QoYrG1oLS2eH9L2RF/MYInxeS12vQ8jyYu680xQZR2z0GFSvFR HLfYhOdQuL79C0+/ydZbWPB5EXePSDPhe9iUnbeAcR1hAh1hIsu9eGkmahZH/RW7x9Ba4e pLm4161wfH79fXVtCqQ+gThpeAHKmdOd6EFZ4dW2BH9acgskzmuibW/0VhcwTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735689914; 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=C4W8q+kHU8LDvwrRbiCZ2Ik9nGHe5SKC/3ATe3wJlig=; b=vjght6/hid0tXBSgG+4ENJ1jULfCqF1RoS0S/Gu/fphxaMFVwv1/bLA2pwFXVTxdWGqPBO +YzId3Wf/LlspfVmszpkgMxn4LYUq+tU7d8CWdoSQpGF3HRcyxB/BvODHPwbL2K1zW2kcU kUW9DFETgdpnRPtENYm8Jx2atiG4of7V0cTVOjsFCk7HHVxidyIdGUYzxeA3zGH3+hkdq4 77hVS4B4cYrOor/UBZPncqpsToXzhbwDYJic9XWnt2BPlSylJ4NktG8XOLzZrDL4frhpxC FDHk8GhcTImkHL8X26MHHbS+WbXrRSwRChk1/cUW8Xgd5t3MCLNT3AZD/KPaAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735689914; a=rsa-sha256; cv=none; b=ggQ9EkC4iauA1SyBr2ZobBWMRzDdciv6Cnah/48pAjsolOKrQxPbSghbJSgoze5temjXu1 nhxR/W/RKst+ccUk1issqtujEVyPmhECagKPyXJKY3KGMdv/WFhZFblWTS6YfHVQWSpL5v cYCcmLwcvE/LQMXUGXtKtJsVTC04/Bmy4l6OjM5ntTYNCf6CqBnzpizFVPpsCQPBqH8NtU 3dOn+6KR6FQOt819bBqNa3qAC/o9LfiEHTS//moa8L5v7UJZPvBiuVZ6GwG/V420Ybz2lo Ac975uJjspfWuzBQq4SClXWX2UXNdtHjzRB02KvF5ivoXjpL8uDfvHNEn3jjcg== 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 4YN98B5dsgz120h; Wed, 1 Jan 2025 00:05:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50105EBr003274; Wed, 1 Jan 2025 00:05:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50105ENB003271; Wed, 1 Jan 2025 00:05:14 GMT (envelope-from git) Date: Wed, 1 Jan 2025 00:05:14 GMT Message-Id: <202501010005.50105ENB003271@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4196f227aa84 - main - libdtrace: Be less strict when comparing pointer types 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4196f227aa84448ef3cae9e99678fbe787726cf7 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4196f227aa84448ef3cae9e99678fbe787726cf7 commit 4196f227aa84448ef3cae9e99678fbe787726cf7 Author: Mark Johnston AuthorDate: 2024-12-31 19:25:52 +0000 Commit: Mark Johnston CommitDate: 2025-01-01 00:05:03 +0000 libdtrace: Be less strict when comparing pointer types If one of two pointers refers to a forward declaration, let the pointers be compatible so long as the referred types have the same name. Otherwise we can get spurious errors. To give a specific example, this can happen when ipfw_nat.ko is loaded before ipfw.ko and /usr/lib/dtrace/ipfw.d is processed. Currently, ipfw_nat.ko does not have a definition for struct inpcb (i.e., none of its files include in_pcb.h), so in the CTF type graph, struct ip_fw_args' "inp" member refers to a forward declaration, represented in CTF with CTF_K_FORWARD. Then, when libdtrace processes the ipfw_match_info_t translator in ipfw.d, it decides that the "inp" field assignment is incorrect because the two pointers are incompatible. However, there's no harm in allowing this assignment. Add some logic to dt_node_is_ptrcompat() to detect this case and declare the pointers as compatible so long as the name of the thing they refer to is the same, similar to how any pointer is compatible with a void *. Reported by: marck Reviewed by: Domagoj Stolfa MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D48254 --- .../opensolaris/lib/libdtrace/common/dt_parser.c | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c index 2b85dd2b26b6..d1ebaa8791da 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c @@ -1130,6 +1130,29 @@ dt_node_is_ptrcompat(const dt_node_t *lp, const dt_node_t *rp, lp_is_void = ctf_type_encoding(lfp, lref, &e) == 0 && IS_VOID(e); rp_is_void = ctf_type_encoding(rfp, rref, &e) == 0 && IS_VOID(e); + /* + * Let a pointer to a forward declaration be compatible with a pointer + * to a struct or union of the same name. + */ + if (lkind == CTF_K_POINTER && rkind == CTF_K_POINTER) { + int lrkind, rrkind; + + lrkind = ctf_type_kind(lfp, lref); + rrkind = ctf_type_kind(rfp, rref); + if (lrkind == CTF_K_FORWARD || rrkind == CTF_K_FORWARD) { + const char *lname, *rname; + char ln[DT_TYPE_NAMELEN], rn[DT_TYPE_NAMELEN]; + + lname = ctf_type_name(lfp, lref, ln, sizeof (ln)); + rname = ctf_type_name(rfp, rref, rn, sizeof (rn)); + if (lname != NULL && rname != NULL && + strcmp(lname, rname) == 0) { + lp_is_void = lrkind == CTF_K_FORWARD; + rp_is_void = rrkind == CTF_K_FORWARD; + } + } + } + /* * The types are compatible if both are pointers to the same type, or * if either pointer is a void pointer. If they are compatible, set