Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9925311ybi; Wed, 24 Jul 2019 12:26:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4rb30okaKOZe7kVvl5erktcRm8YzugR8kHIWSPi5xankap0KtRoJb+om5YmwuIs0C3qr+ X-Received: by 2002:a65:64c4:: with SMTP id t4mr46524914pgv.298.1563996369595; Wed, 24 Jul 2019 12:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996369; cv=none; d=google.com; s=arc-20160816; b=qPrpTk7dRYggDeBnv8PKnkp5ezuDSh2pCMEGm7/Mi7l+ImGoJf61E2qwyNCOv4U3n+ E7KRINvZBE9EN9RIemRUWchMvUTpQ0yL/GDwrL4x/A05e+HTd1/cdTkmldTyBs2zS8rT LSyQ7mITlQp2oHtrmHTA0KHJWwiIFW7p7wEqFnpfIxBBvAYOCvptrFQoS57HsAeZP3R2 4ZWl4yK1QlGsy6pu82AGWxOzq2zKEMllLcfdv0ZUMC7iWkmayKWwxM/HWO062eH4Ltaz PACn1DClMRMcGhU1m0Bx764vP3lZOOCaq+gCT4hzjs2w52gnGwLyUuS0+uMkmzsm8jpn FC5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=r1Lwo95bqBpHaP05fLy4buBVdc4R2UztiarSDTsVMoM=; b=Dl5P8VaqrJzZ6s0x4uN1a9G7sbcmmFAUcyZ8X9YUfbA3H6ooLIiWHxo3f8JjyL/oyc 6ZSmpKWovh6FE33Iw13Wrurav/wJ9DZ9rXfWNHWvf0dnxxJm96RXUFWTLnD4woZ9Z2td 5JbSXqN8IUtcd/PgoeGNqpCHJN4qFZU610gDX7TNdV9LB2FbeUSUIX/AxT5xuKq5D7Wr Fy5zi3aVD/7gBIHX2PP5dGBurSRRJk2vtIdAz8zYaekgcQRz8N4LNDWfNRlnOsDV1TWu 1SscpAxXAmgqQuQkO+CF4DpE0c24+iSyX5NTxTqFG8gfaKYascZT6QlLMGskz0V4qgqN poHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ex6GxVMQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si15336499pff.221.2019.07.24.12.25.55; Wed, 24 Jul 2019 12:26:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ex6GxVMQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387552AbfGXSpZ (ORCPT + 99 others); Wed, 24 Jul 2019 14:45:25 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:54242 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728720AbfGXSpY (ORCPT ); Wed, 24 Jul 2019 14:45:24 -0400 Received: by mail-pg1-f201.google.com with SMTP id t18so18893810pgu.20 for ; Wed, 24 Jul 2019 11:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=r1Lwo95bqBpHaP05fLy4buBVdc4R2UztiarSDTsVMoM=; b=Ex6GxVMQvR+cx+YRIWfUlH5M2lCX6wTziVMvcS4Eaj7OoYwUDJjJuihOPkKO9TqegM kpvb4I9F1SqW3fjZghdG7z/XLvUsY+wjqQrJXy1px+i9ThldzZbm3hyydwFD2wJDRiQz 1RsZs5+34rNT7TX875PqgjnGo79eB4Uz/rXN5Q2ETBMnyJN+jRiRdRQJR4GXJDMNxDfo 7GGSO80sbebtOtOy3rODVuZpRx8ldyNVltGmV443tofM8GHbgVDTqztYi8hL6f/b5K7K KqU65CyxmXHrNxuFfXBnU/JvhkJK5M32ny+ABRzaKAu0QuVm6fIjdtwUKHMshFzmZIcf RlPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=r1Lwo95bqBpHaP05fLy4buBVdc4R2UztiarSDTsVMoM=; b=tX6HkWwxDudwwULZ9qJ0/HvKd+9dcmHj0sFFjMstCw6TuzGbRz/a8Jsh41DASJ/KQ4 Xe0KfpoWcQcaoDXqkayjz/+Hks0zcui/Ry6h10s5+qBtXGhTKQglxOM5WdSsSiLlX1us /aVW6gvjliPmISIMEiiKuLlFO9NDPA3QOCzRTH0mduMhOeYsN8p5i88YHkMMpUR7N+CT OwIofmPlOptXte9NO364HxizibzhKwxjIHj2s4DfqFY7WI0mmrqoI3O46ucRuDrGbU1C VdZal2yitp4xoaEb9vR3QG7uf4Z9WGSxQUxfIaMgTlJMsmPa9wFHANQy2+buyOjzamEs Mxvg== X-Gm-Message-State: APjAAAUKmUNb3BgrDBA9ch4TjYeGyVtr2bbUf0e3d2YT2fbGTDiABmTy xyM0VYP7TZNVKWXIxkwt6uX9X2c/ X-Received: by 2002:a63:3147:: with SMTP id x68mr18906127pgx.212.1563993923640; Wed, 24 Jul 2019 11:45:23 -0700 (PDT) Date: Wed, 24 Jul 2019 11:45:12 -0700 In-Reply-To: <20190724184512.162887-1-nums@google.com> Message-Id: <20190724184512.162887-4-nums@google.com> Mime-Version: 1.0 References: <20190724184512.162887-1-nums@google.com> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog Subject: [PATCH 3/3] Fix insn.c misaligned address error From: Numfor Mbiziwo-Tiapo To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, songliubraving@fb.com, mbd@fb.com Cc: linux-kernel@vger.kernel.org, irogers@google.com, eranian@google.com, Numfor Mbiziwo-Tiapo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ubsan (undefined behavior sanitizer) version of perf throws an error on the 'x86 instruction decoder - new instructions' function of perf test. To reproduce this run: make -C tools/perf USE_CLANG=1 EXTRA_CFLAGS="-fsanitize=undefined" then run: tools/perf/perf test 62 -v The error occurs in the __get_next macro (line 34) where an int is read from a potentially unaligned address. Using memcpy instead of assignment from an unaligned pointer. Signed-off-by: Numfor Mbiziwo-Tiapo --- tools/perf/util/intel-pt-decoder/insn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/intel-pt-decoder/insn.c b/tools/perf/util/intel-pt-decoder/insn.c index ca983e2bea8b..de1944c60aa9 100644 --- a/tools/perf/util/intel-pt-decoder/insn.c +++ b/tools/perf/util/intel-pt-decoder/insn.c @@ -31,7 +31,8 @@ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) #define __get_next(t, insn) \ - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) + ({ t r; memcpy(&r, insn->next_byte, sizeof(t)); \ + insn->next_byte += sizeof(t); r; }) #define __peek_nbyte_next(t, insn, n) \ ({ t r = *(t*)((insn)->next_byte + n); r; }) -- 2.22.0.657.g960e92d24f-goog