Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp486723ybi; Fri, 26 Jul 2019 13:15:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCOKgs+vR6VflpoN8CLzWU54+xg+K4J0lZH+Dl652lZGmycJSL6DylayjwaFaF5/DrcvE3 X-Received: by 2002:a17:90a:de02:: with SMTP id m2mr99534929pjv.18.1564172131677; Fri, 26 Jul 2019 13:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564172131; cv=none; d=google.com; s=arc-20160816; b=jlmb8HgVyDT1YJ4zW9Dq2/6+Z7I+wWniWhzFei8NB6jV3VE90esj5BnMq2ZXoB2EzI 3uxPswKLOBqkLK2AQaPQDarROkVG3t4VRK3KrLSrbYPZXe8jV6K1RWtY3hKbj1S3HE08 buLzEIU96porYk9XnQIDGSf7n+mpB04hoOpCZT99MilD4HevcIgIfnudJRf7IQBoI/G/ pIMDao59yaAW+jSX3L/xq8XcEFaSonbA+DCjqQrqhHEYGsmF3Ns2WnvhwTogqmRzCuBW eOhtniOaPIuZ060V/2vrurj+YDaelABJRrNA9EMW5T+qay7VNHVI0i6At+27gWZqFggu ZQww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=X2lDZIgoy2QitEtYC02cKSjZsrq3PsRON1whrdUGlu4=; b=n5KY5XkUyWDhhKhKsmQpmx6NNjqNZT7WFcY2cfD1Pz+NsV0wJZ0FHysEfvuKT6xtRn Ud5szwl3XmWg3G2yaUEqMFIZ8cyO7Li/2ONoAnf74oTlHzKojLOb2OZcGgiVBDc/L7lS nnaB0+Ag554mP0JPgsl6Z/8qzR5NH1uUGyhLP2Hs+Q7E1yhAL4BU+hanHGDRBvHoMHHT 4k7Vj2C2rsbKsENeDFFOOPhn8FflPqlpIsvXGjKTWTCfMiNAQfszOjlLpuMCJE7DjDKA mr9lOJ1Aow/pyklkCUhqdTGjTDgqloDAFVj6pdxha3Cdmj3wjPYTcNnmpUjaoMaqyFka rfUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sWpQ8Nmj; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si19969045pgj.147.2019.07.26.13.15.08; Fri, 26 Jul 2019 13:15:31 -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=@gmail.com header.s=20161025 header.b=sWpQ8Nmj; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfGZTks (ORCPT + 99 others); Fri, 26 Jul 2019 15:40:48 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46065 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbfGZTks (ORCPT ); Fri, 26 Jul 2019 15:40:48 -0400 Received: by mail-qt1-f193.google.com with SMTP id x22so48834293qtp.12 for ; Fri, 26 Jul 2019 12:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=X2lDZIgoy2QitEtYC02cKSjZsrq3PsRON1whrdUGlu4=; b=sWpQ8NmjcX5CHs7dCM8npofYhw3/Kox1EhshiH13OGYgDMQfuYr5YrSiFWUVIIL7mM PBrP0DWUKgTUn4P2NlyBEFKS36f+LErW7yyuYSISU0yFC9AVu+zyMFs7TYr3dAdZqzJS SJfF3jMFXelcWWrUQojfcuI3vWHt5ET/GVDqdakIaDXBSRHV1k7jZ9Zw2IgHKmNhKVzH SWxcF6aq9OjRI6vxd6+/gX6bszFCLcYUMFGiTKDX7S999CIwzBe6HDjk4y2lCgVs/yUL rKUXtc+3f7jI2rX2+sGbtVSgESvTbhywHreBTgBz7B6wnw3ErkjSph+5Rs88WX4ezwgG +mVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=X2lDZIgoy2QitEtYC02cKSjZsrq3PsRON1whrdUGlu4=; b=qtXCiDBkGTLaa9Pyshp3wb39FbmqpJg+M0o2K960puntPn2k31ISXq4ElnP4x/AWkc 7K59iUbrLG/1vBR25OLUyDfG863V/LZs8h7vBvlhUPMqidQqDqRt4aqr2Tp9eRCRl/Cj X8P89NZEneqJ9Sfm5UMsFrjOD4xFd1hgnR3JcW3lTMI6FAZH3XIxePJvwiriARECNnI4 3TsybOfS70jmHnOVePz/1pl9e2K0BF6+515uQslxKyI6kq+gUXGS/nVIiizSmd7s+tjJ B27OUQLBTcsULB7CwmsN1G3s7rsk7WOEpt+Nw7xXvs2fYJDrJScDSM2/ojFaZI7U+vCD 7gdA== X-Gm-Message-State: APjAAAU1vaizDDG+Z4r41WWi9IijPWRuuA97AtFu8SkpV6GxkqJqE2uX jLMGJ1Cv5qWWaa8XRdMp3Sg= X-Received: by 2002:ac8:7219:: with SMTP id a25mr67841044qtp.234.1564170047095; Fri, 26 Jul 2019 12:40:47 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.35.50]) by smtp.gmail.com with ESMTPSA id j66sm23242496qkf.86.2019.07.26.12.40.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 26 Jul 2019 12:40:46 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 5F14340340; Fri, 26 Jul 2019 16:40:44 -0300 (-03) Date: Fri, 26 Jul 2019 16:40:44 -0300 To: Numfor Mbiziwo-Tiapo Cc: peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, songliubraving@fb.com, mbd@fb.com, linux-kernel@vger.kernel.org, irogers@google.com, eranian@google.com Subject: Re: [PATCH 1/3] Fix backward-ring-buffer.c format-truncation error Message-ID: <20190726194044.GC24867@kernel.org> References: <20190724184512.162887-1-nums@google.com> <20190724184512.162887-2-nums@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190724184512.162887-2-nums@google.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Jul 24, 2019 at 11:45:10AM -0700, Numfor Mbiziwo-Tiapo escreveu: > 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: ‘%d’ directive output > may be truncated writing between 1 and 10 bytes into a region of > size 8 [-Werror=format-truncation=] > 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=1 EXTRA_CFLAGS="-fsanitize=undefined" > > 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/backward-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; > > for (i = 0; i < NR_ITERS; i++) { > - char proc_name[10]; > + char proc_name[15]; > > snprintf(proc_name, sizeof(proc_name), "p:%d\n", i); > prctl(PR_SET_NAME, proc_name); This was fixed already by: commit 11c1ea6f1a9bc97bf857fd12f72eacb6c69794e2 Author: Changbin Du Date: Sat Mar 16 16:05:43 2019 +0800 perf tools: Fix errors under optimization level '-Og' Optimization level '-Og' offers a reasonable level of optimization while maintaining fast compilation and a good debugging experience. This patch tries to make it work. $ make DEBUG=1 EXTRA_CFLAGS='-Og' bench/epoll-ctl.c: In function ‘do_threads’: bench/epoll-ctl.c:274:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized] return ret; ^~~ ... Signed-off-by: Changbin Du Reviewed-by: Jiri Olsa