Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9925681ybi; Wed, 24 Jul 2019 12:26:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8wGCv4k+uLilsy9G1Fh/ILlWpSZjmlLTvS4M95zUK0BwLDkyF/zA8Ok0tm2Qs/zLFb48+ X-Received: by 2002:aa7:8202:: with SMTP id k2mr13096658pfi.31.1563996399620; Wed, 24 Jul 2019 12:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563996399; cv=none; d=google.com; s=arc-20160816; b=hyVFJ1H0e6Ckjy9PxLrEpNDvroLjF9KAt4+Tc2nVWRVqI9B5oOr33sM6Bq1K1ZIwMS yJeFuK4eMoYBGOpHjmLmqRSuAJhU45b3StlP941p8VmhOm3HHWYC2b7DDywJsYZ4xeqx JoWrPnlpxX2HrPzqZmJn0psZ2P0Degxwztud/3aOCkHqAM+y2YctMKcxlac9zLNlkCan FzjrtoPxMrR9VIo+sWR8K2QZFwUSKIoo+hIGTYfftvPaMp2wVJvTycj9lGBoawcwXbF8 lxZrO6RqJsfo1xGbQ4X62IIm3/v0gH4NqpC7vEUZqCBnX6ttMQRfVe4ON17nvfiIV2fx nn+Q== 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=bK/jHJchVPHPYOwMi778tukKzlyA3mqpp5GJOr1wzvk=; b=rElF524Fwjx3FdjW6bBaZzp+aCLSMoqm9FeL5/7sOoyRRvJyaCuBzux8d0GKuHNVVZ FmdMaKp2AQm0vf5aq46OTKlkHPuWPtVGlITmA6Pcc2KJrmfxxHuAJAWAD35pB3ssIXHp 26U/GLh4e3A/x4aVUJWccpZYRJWknob6NENp+l/TC1slxAjTFjcGJ4sw7XUqpCzN3vOR WmZHfKs9wXSfNlL5eFuAeZACq/HGo4rXAQfwrajOrWfj6+41xnpqyPkfk/3Oq0++GOUo /7H1rVjavZ9cCZqivwMaVlmqrjDdJWt41ZS/SELNNomHxBfrwHDkbOFFcuv7EXn3UdRG ViQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AqlCOzRe; 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 g17si13523302plo.406.2019.07.24.12.26.25; Wed, 24 Jul 2019 12:26:39 -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=AqlCOzRe; 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 S1728707AbfGXSpV (ORCPT + 99 others); Wed, 24 Jul 2019 14:45:21 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:53279 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbfGXSpT (ORCPT ); Wed, 24 Jul 2019 14:45:19 -0400 Received: by mail-pf1-f202.google.com with SMTP id 191so29106514pfy.20 for ; Wed, 24 Jul 2019 11:45:19 -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=bK/jHJchVPHPYOwMi778tukKzlyA3mqpp5GJOr1wzvk=; b=AqlCOzRejDvJtBa3V73BDsWfcruVREk/7GiGhGV4KN1M+qUiNd8ClgtjTQz30/eXsH L5xOXl/XawTO4pj0s1v3wWbGxSd3WahyFeb1GxaPL0frjHZdz+ZCIy6r5wHOY4GHdoPP /+nJtfQq/kmODVc/hf10FJ4fp3W3VO/1R50GQrLKUF7MhA2Enk9w/AaQR8EJlOSG/RB3 Yq9sFSMfw0LPEKDl/8icpqjXtdH0BGiK+mwCCTNVuVQkFd/Gs4EWK3HWmQdW+pjUU3u5 zWTJVdSgY0ZedM/V3Yv7ThAC9eWTPaLcLoy9CWa9dNKx0kGvXh8ADypTotBxiBLky1qh sKNA== 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=bK/jHJchVPHPYOwMi778tukKzlyA3mqpp5GJOr1wzvk=; b=qbIN+sj74nuQggcHGEw6RNBe9N5sSPTi9IfMgp/skZviX7jgZ0wBwTg4xFWAcZYgWz PhD7imjw0RqtpDplfXgjnjW4Rlol6mr2hSv4TMeRfGae/T+c0SMapLVBVwtqdHoVZZ6w 9DMeLqHST6vxtKg8XwPBwBw+2ZzEDguitWIzBr+sYfhCphPV334XwaKlKEEPhkIdro9Q 0vIZkr8ofF6anXsOz41QmrgTKLAM3aljdvd7gC+ANzVlTVO4oPAPreO6t7jY9zRD01z2 7pWYniJc5PRGSgzO27NTMXoUaQr8PUYm7T6OckTsuhD8HUL2OGf6FEN83YBDvLhMJ3Su lt/A== X-Gm-Message-State: APjAAAVwAf/0u8qEQFg9jPrWEoBlx2FzxbiD3lBj/C2dmFUxmr9xz4lO vu3JhJ17ePU2LuhM5srMTL3awfnj X-Received: by 2002:a63:1749:: with SMTP id 9mr30154039pgx.0.1563993918702; Wed, 24 Jul 2019 11:45:18 -0700 (PDT) Date: Wed, 24 Jul 2019 11:45:10 -0700 In-Reply-To: <20190724184512.162887-1-nums@google.com> Message-Id: <20190724184512.162887-2-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 1/3] Fix backward-ring-buffer.c format-truncation 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: tests/backward-ring-buffer.c:23:45: error: =E2=80=98%d=E2=80=99 directive o= utput may be truncated writing between 1 and 10 bytes into a region of size 8 [-Werror=3Dformat-truncation=3D] snprintf(proc_name, sizeof(proc_name), "p:%d\n", i); This can be reproduced by running (from the tip directory): make -C tools/perf USE_CLANG=3D1 EXTRA_CFLAGS=3D"-fsanitize=3Dundefined" Th error occurs because they are writing to the 10 byte buffer - the index 'i' of the for loop and the 2 byte hardcoded string. If somehow 'i' was greater than 8 bytes (10 - 2), then the snprintf function would truncate the string. Increasing the size of the buffer fixes the error. Signed-off-by: Numfor Mbiziwo-Tiapo --- tools/perf/tests/backward-ring-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/bac= kward-ring-buffer.c index 6d598cc071ae..1a9c3becf5ff 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c @@ -18,7 +18,7 @@ static void testcase(void) int i; =20 for (i =3D 0; i < NR_ITERS; i++) { - char proc_name[10]; + char proc_name[15]; =20 snprintf(proc_name, sizeof(proc_name), "p:%d\n", i); prctl(PR_SET_NAME, proc_name); --=20 2.22.0.657.g960e92d24f-goog