Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9925338ybi; Wed, 24 Jul 2019 12:26:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGi+1p4V5m4iFmOuuCRlXtC3NqvzHmlDsU4Xcas4A0JQ5RYGkeb8bGr77jaV+tFNgOv4eR X-Received: by 2002:a63:6888:: with SMTP id d130mr11142877pgc.197.1563996371846; Wed, 24 Jul 2019 12:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996371; cv=none; d=google.com; s=arc-20160816; b=F+KoD0avYwoqNIxYzIOcFwl5VbGS0aIqE+nZs+hSdISqDbNrlxCpJLNN8ia/4L+7Vc Zi/rrBSL273H2BDbceogwFza5OkvAfm3S4QljStY4Yv0T0+tKgRakdKjRVxpJr1hpJL1 Pl/enVcSz866e1/VXldIQANAoh92+Z2FlHqINpJhcHny5rba0LKlCScmDpLFHMn+y1Na qsqVZ3VIwE8sm8VVogpfTzrKXvfB0wlIC9M7AbrArfNoHmh9CmRwBhhD9gNCzJofTRh4 XE4EcjsXRo+w5sExeM+yYKfGF2r6DYNgCbO1MhqUMXHK3NV2r+arDbtkuFMqpt49cc3S xRww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:from :subject:references:mime-version:message-id:in-reply-to:date :dkim-signature; bh=BjWNWCDen5V1rKWn+IHS9XDd/FHSwkWnF0k7e0VBT3Y=; b=fQeoeqsAWCiyVFLV5dbvq+6n/aY9Mq8uAdkgJL9kaXdq6sc990Z21Pk4iq1qX9yIhL aj5vbiyXQp0zlWvSTgqm+dALNnkjdiw2OvKMtPrAeZsPaplJfrnl+gel0oEvg6zALDKY nZMOyKXL7tzaKSG47/Ht06X1QgZTUbAWAVU2m2AwRQhnhxnA3PnPWLo0ZpBSOVft5e3s FOtVQkMlgRSJeIE8SupyocXY+kiih0jNtSbs6tsur2jpTNQYtXE9tE53eWAA6L4oxuat NfT4Yf6rXh6O+RIxMCix5W17+rOjd8NgxCtwRzFjBWjLbuPVDLkZgNwagcj3pcwxBDNq 75jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L3VCDyNh; 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 k129si6228585pgk.42.2019.07.24.12.25.56; Wed, 24 Jul 2019 12:26:11 -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=L3VCDyNh; 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 S2387432AbfGXSpZ (ORCPT + 99 others); Wed, 24 Jul 2019 14:45:25 -0400 Received: from mail-vs1-f74.google.com ([209.85.217.74]:52066 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbfGXSpW (ORCPT ); Wed, 24 Jul 2019 14:45:22 -0400 Received: by mail-vs1-f74.google.com with SMTP id b7so12715547vsr.18 for ; Wed, 24 Jul 2019 11:45:22 -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:content-transfer-encoding; bh=BjWNWCDen5V1rKWn+IHS9XDd/FHSwkWnF0k7e0VBT3Y=; b=L3VCDyNh6Wyj2VLaIJBKXSI/rngNMWnuv4xkxRlSK+6K/OhCbI+VGsbNycNwB7Pls7 QviD0x5CvHDVD1T1CONj4E9EbqBKjI6/lTBptdTGhLsqTKxJW8gWc8iLKCrFALVqsHiI LA3OEt21TnGOyewXtTeZDtbXEktYsO5aak6sErMlARNCczzH3QElLWKjhdCE/ChmmnIf lmCkY8JElyCdBel9Tutcc4uQy7gOo1tBbQ7PutM7OFxJ+K8//2OXRUYW1Xx1zEwb4/7H zCwzZsS5NySC46A4j+t1SdzltawktcT0bQFjLKZor5U1+YOPA5CUr+desdcvL81GEn91 MrfQ== 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:content-transfer-encoding; bh=BjWNWCDen5V1rKWn+IHS9XDd/FHSwkWnF0k7e0VBT3Y=; b=adv3K7lWXS+4TPDtggCiKMFDTQr47Gbmhc1F0iacdj0AJBEUSEAgrxYaqOYSQhug7n CAwFGvY6iHVyRxNUEoR7TPsPm3sZk0R8UlA30ibo5jAwGRvsEBSIeloZyBkiTS06eyvk liNPas+182zABzLxwXe25pFSdxLe10lRmNuO53zuaoVpgq7R/QBkORKQNcC/DeVT9Ush GCQxbu2F8h/rsMby4ZKUBvPBCUt6UBn8kn3cK0VmvnGKDWvTw1H2wAXJdIjjrTPe+jH3 SI+1TkBn44th843m71PqgkHK4l+ImI8mXD8JbF4QSfVz/NxRN3LlcKj6Kyq/8bXJQXNc C6Eg== X-Gm-Message-State: APjAAAWJ1SoWSY5tLwa70JGunMSUVdhl/7OS6fiwJQQriWLIZST3tJ0b BngSpPImXqk8xmaQnl+RUVmpJxQb X-Received: by 2002:a67:6bc1:: with SMTP id g184mr3704438vsc.70.1563993921248; Wed, 24 Jul 2019 11:45:21 -0700 (PDT) Date: Wed, 24 Jul 2019 11:45:11 -0700 In-Reply-To: <20190724184512.162887-1-nums@google.com> Message-Id: <20190724184512.162887-3-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 2/3] Fix ordered-events.c array-bounds 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" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Perf does not build with the ubsan (undefined behavior sanitizer) and there is an error that says: tools/perf/util/debug.h:38:2: error: array subscript is above array bounds [-Werror=3Darray-bounds] eprintf_time(n, var, t, fmt, ##__VA_ARGS__) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tools/perf/util/debug.h:40:34: note: in expansion of macro =E2=80=98pr_time_N=E2=80=99 #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) util/ordered-events.c:329:2: note: in expansion of macro =E2=80=98pr_oe_tim= e=E2=80=99 pr_oe_time(oe->next_flush, "next_flush - ordered_events__flush POST %s, nr_events %u\n", This can be reproduced by running (from the tip directory): make -C tools/perf USE_CLANG=3D1 EXTRA_CFLAGS=3D"-fsanitize=3Dundefined" The error stems from the 'str' array in the __ordered_events__flush function in tools/perf/util/ordered-events.c. On line 319 of this file, they use values of the variable 'how' (which has the type enum oeflush - defined in ordered-events.h) as indices for the 'str' array. Since 'how' has 5 values and the 'str' array only has 3, when the 4th and 5th values of 'how' (OE_FLUSH__TOP and OE_FLUSH__TIME) are used as indices, this will go out of the bounds of the 'str' array. Adding the matching strings from the enum values into the 'str' array fixes this. Signed-off-by: Numfor Mbiziwo-Tiapo --- tools/perf/util/ordered-events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-eve= nts.c index 897589507d97..c092b0c39d2b 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -270,6 +270,8 @@ static int __ordered_events__flush(struct ordered_event= s *oe, enum oe_flush how, "FINAL", "ROUND", "HALF ", + "TOP", + "TIME", }; int err; bool show_progress =3D false; --=20 2.22.0.657.g960e92d24f-goog