From nobody Sat Nov 15 12:46:56 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1752144451; cv=none; d=zohomail.com; s=zohoarc; b=hnDj0he68GiuOL4QYBf8ytqwFhfQrAjAjf72zCo+wuYqJXgGCJEld/5JhIpR+rnLi4jWGzuMcmmwgMdDJdzjOiNdaytj/Wiauko2dX4ZvZ/DAYzyLlOVrguLB9uTGYsMUKkReunaQHI4MfF1dJjGt4K0DlSJbePzb6sB7P4eiSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752144451; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nY9RxYXq4hHZTz7eLFjHXNzOsjF0/KQbibaEjOzCsCE=; b=b99+ksKlaedA6cdVDWIFE+eAGzCk0M1javP3gmPDkPnTkBQZB++WOi14DGJR5HaIzcNVK8bM7lYmo+uoF+w/eCQ+8g1hBEEp2KefJAwJ8bo0dwTyqYapEpcLXz8QcT+HeQuJGsgP0Cl0+zbiAvnP3QAIOjIIT6TbAdI7OJjdFgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752144451923929.9021860357342; Thu, 10 Jul 2025 03:47:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZon4-00025c-N2; Thu, 10 Jul 2025 06:46:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uZomg-0001r5-4r for qemu-devel@nongnu.org; Thu, 10 Jul 2025 06:45:50 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZomZ-00077v-SC for qemu-devel@nongnu.org; Thu, 10 Jul 2025 06:45:43 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4530921461aso5253605e9.0 for ; Thu, 10 Jul 2025 03:45:37 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b5e8dc22a8sm1574575f8f.34.2025.07.10.03.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jul 2025 03:45:32 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7AE8A5F87D; Thu, 10 Jul 2025 11:45:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752144335; x=1752749135; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nY9RxYXq4hHZTz7eLFjHXNzOsjF0/KQbibaEjOzCsCE=; b=W7dyQx2EfsAPLbQ//IH5Pr5/iO7R5DW4SN/NXFvSCMaIIHNpLltAIkcSO5czucb0C7 QkfgETjer6HsKZxgXC7M66JUEPs83VyRLzWuvohIsjxMn2yWYGlZ7wvVIqHwolD+q+l3 kz2HetxPnSvONZZDS252creNNTGehDP/mlyuo6UBG46HC2Ks0gNflRZrluTXEcExjdWh i5ZRykit1X8eFgkF5tsSSp2l7/hBQVmhF3ifCvlr5HfK60ZlfWhLUKkCVFh0K0WwGpDG T2s+CT1zhsZrzYEjK9YwuEQQJ8DlMDhHtI/laOj1h9FHf/UCA4T9OzLwSl9C2/Vpn4+3 BWpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752144335; x=1752749135; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nY9RxYXq4hHZTz7eLFjHXNzOsjF0/KQbibaEjOzCsCE=; b=Rvlm0k8ec33G/QmiGLL189JMde2TrGHUkw5v9FDGjeFBpj07Huw9+FgSTVCm8Tk5xu LIUrUMg0UuhAkrPt8WV810g7EJo2XmLGPe9Pwd/f+s3z8Eyi7pyQ6msZ/cDPOiGhiIkM cquvlZJv1tN/OGW9F4Crq7kzLS5zmWdTDqGeKylnB3tzKwkMLDRWg+iMK1LU/6n5viRw zHbgqmZzCXNKlZy/67ij6tXPBBdQ0ZP301byDqzL5UHiDIrtIBzmMm9W2IxGRJSTMlGu SLbbP+z0dxSJ3keeeg/ElwREtZq9GyubBR2yO11iCZ6qpNrAb86pQxNddFaDzbhDrag8 cCIA== X-Gm-Message-State: AOJu0YyKGD5W/0wntagNC7kGnlCZObiMkcBEJOt3W1F4OBP0vMwlDvH2 MKc6lGCrmh1z6zn4hZMr9x3wrSA/ISF75Hv6GpKk7n0OB9nzkxbNxd0B4FpkMSo5ZKE= X-Gm-Gg: ASbGnct0CRL1eBNnkQ5T7lPilLVNSawKFEDnf14mBBsCHsdFbqYjVYP9e2iTGcURmbM KYB+uZ0oNTuVJLzBwNAfvgzA1Ww1XA9bUKEHb7JECTzZG2BJ1RYOxDX9oEK5TLZuHYywNsKxowo mKFPvu4LQcdFq+qlL7XCDWKjhCcZ+BpkS+3VUF0CWyJTLCFYXqBZKUTLunumXbbNiBR3b5nlwin cS+POY00NvMiElxj3FFxeLEjfTCJIw4cDoD+io8Ui2MEJ5YQz5BFaLkz3X4iM4HltvTikVgjXAd 9aL9gnwLuNfcx7UJXPzWYhKafaw1vfw3FSt3QmzdrACmquYaAAjFsrrhuKiJokKDUBa+oQi27A= = X-Google-Smtp-Source: AGHT+IFRgHg30ZwslKl1MTZnBnL4N3W1btuIHawrWJnd4x6DKfqZ111NWjsg2s7ZVnd+ZnlNIxukzw== X-Received: by 2002:a05:600c:1e0d:b0:442:d5dd:5b4b with SMTP id 5b1f17b1804b1-454d53bc8c5mr65998125e9.31.1752144335407; Thu, 10 Jul 2025 03:45:35 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alexandre Iooss , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Richard Henderson , Jason Wang , Riku Voipio , Laurent Vivier , Pierrick Bouvier , Yodel Eldar Subject: [PATCH 3/7] contrib/plugins/execlog: Add tab to the separator search of insn_disas Date: Thu, 10 Jul 2025 11:45:26 +0100 Message-ID: <20250710104531.3099313-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250710104531.3099313-1-alex.bennee@linaro.org> References: <20250710104531.3099313-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1752144452962116600 From: Yodel Eldar Currently, execlog searches for a space separator between the instruction mnemonic and operands, but some disassemblers, e.g. Alpha's, use a tab separator instead; this results in a null pointer being passed as the haystack in g_strstr during a subsequent register search, i.e. undefined behavior, because of a missing null check. This patch adds tab to the separator search and a null check on the result. Also, an affected pointer is changed to const. Lastly, a break statement was added to immediately terminate the register search when a user-requested register is found in the current instruction as a trivial optimization, because searching for the remaining requested registers is unnecessary once one is found. Suggested-by: Alex Benn=C3=A9e Signed-off-by: Yodel Eldar Message-ID: <20250630164124.26315-2-yodel.eldar@gmail.com> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Pierrick Bouvier --- contrib/plugins/execlog.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index d67d010761..06ec76d6e9 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -232,12 +232,15 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct= qemu_plugin_tb *tb) */ if (disas_assist && rmatches) { check_regs_next =3D false; - gchar *args =3D g_strstr_len(insn_disas, -1, " "); - for (int n =3D 0; n < all_reg_names->len; n++) { - gchar *reg =3D g_ptr_array_index(all_reg_names, n); - if (g_strrstr(args, reg)) { - check_regs_next =3D true; - skip =3D false; + g_auto(GStrv) args =3D g_strsplit_set(insn_disas, " \t", 2); + if (args && args[1]) { + for (int n =3D 0; n < all_reg_names->len; n++) { + const gchar *reg =3D g_ptr_array_index(all_reg_names, = n); + if (g_strrstr(args[1], reg)) { + check_regs_next =3D true; + skip =3D false; + break; + } } } } --=20 2.47.2