Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1410333yba; Tue, 2 Apr 2019 08:21:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQHswGQ8vZRX6VIJALoBVGA0VisT8pBm2GToA9hKkIS6XCKU4IEB32C5qjN08TjLQlfzPr X-Received: by 2002:a17:902:7b96:: with SMTP id w22mr36537676pll.28.1554218514359; Tue, 02 Apr 2019 08:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554218514; cv=none; d=google.com; s=arc-20160816; b=veTu3gptA03IwUEO6j1533QGwmIv4Z03cYjAdV9N1pFMb8kIHZA/mpiT0LfoFCkWqW TtGidCkb542DBbDyfDQ7I9u3Ki+7UImoYoh6Ydlk2OT0Ql7x2to2FlumDuP1IfGXOOGX ygqsL7Ohn8OfO3zQ0O0nE1XMyfaydxq3HwbB6fpN26DJsWUDAmjaHJTkCrT/c40aCAsJ 4QKwifBEkn+aFhc62Sa0+6ul9ZMmz+G07uRrrlE4DGgn8WSGtfMGm9kAbp3A59j2VcKE lfq8XEUyjtYHEsl2OY1HfK7sESQ1sjnsxvQT7py9aNDq4kDzFUYmNr9R2Gutbhg0Q+jr torg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=1FtaQAq4ABz5hgZdWbwaziGzAUQ3Zf7ScfYkfBtwl3c=; b=f2VS4KebkWLCJLifQE5kWORZx/dxRBms48cGJeiBW94NAfPvbCFYkXMGquEneGRn47 pMNYhMdc9w+ABdl3okZCP6hyWChUR4buFO9+vt61ZfDN0x3i3gXY7/ULJgb/QV8JdTk6 tiIHY9it2A3uxCrfQ35+77esboPLgupp8T7k/Vc0i0b4Pxnh6kFO0v6rWkiR71GdOpGn ALai7v9rhOL37qITUeAker/DdieysrPTbP0TtzlKDLAtkGhFAYEWrAiXZjvuEKj08Rrw c6vorOULdwzN02dJty6V0gXSN4Miz9gabitSg71p0mq1CoSHUP6ZxGzyLJuklTslo1BT SPyQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d62si11886916pfc.104.2019.04.02.08.21.34; Tue, 02 Apr 2019 08:21:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731594AbfDBNkS (ORCPT + 99 others); Tue, 2 Apr 2019 09:40:18 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43152 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731427AbfDBNkF (ORCPT ); Tue, 2 Apr 2019 09:40:05 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdx-0002oX-09; Tue, 02 Apr 2019 14:40:01 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdw-0004tp-Ae; Tue, 02 Apr 2019 14:40:00 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Namhyung Kim" , "Arnaldo Carvalho de Melo" , "Jiri Olsa" , "Adrian Hunter" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 42/99] perf parse-events: Fix unchecked usage of strncpy() In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo commit bd8d57fb7e25e9fcf67a9eef5fa13aabe2016e07 upstream. The strncpy() function may leave the destination string buffer unterminated, better use strlcpy() that we have a __weak fallback implementation for systems without it. This fixes this warning on an Alpine Linux Edge system with gcc 8.2: util/parse-events.c: In function 'print_symbol_events': util/parse-events.c:2465:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation] strncpy(name, syms->symbol, MAX_NAME_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'print_symbol_events.constprop', inlined from 'print_events' at util/parse-events.c:2508:2: util/parse-events.c:2465:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation] strncpy(name, syms->symbol, MAX_NAME_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'print_symbol_events.constprop', inlined from 'print_events' at util/parse-events.c:2511:2: util/parse-events.c:2465:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation] strncpy(name, syms->symbol, MAX_NAME_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Fixes: 947b4ad1d198 ("perf list: Fix max event string size") Link: https://lkml.kernel.org/n/tip-b663e33bm6x8hrkie4uxh7u2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Ben Hutchings --- tools/perf/util/parse-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1217,7 +1217,7 @@ static void print_symbol_events(const ch if (strlen(syms->alias)) snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); else - strncpy(name, syms->symbol, MAX_NAME_LEN); + strlcpy(name, syms->symbol, MAX_NAME_LEN); printf(" %-50s [%s]\n", name, event_type_descriptors[type]);