Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3055375ybi; Tue, 2 Jul 2019 01:15:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqybXfGfJP7+9IjUw64a5TDmKfJEL2bTl6w0+TgbGjDEG72L03nePj/iBxosa3oD4ZNLvrQf X-Received: by 2002:a63:5b52:: with SMTP id l18mr1220462pgm.21.1562055315972; Tue, 02 Jul 2019 01:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055315; cv=none; d=google.com; s=arc-20160816; b=iETEiCBCniZzIzwIMLjQJ2tzs4E4xK1EU2E6GRfnMmAcKoDkUvPUZfShzS+qFp0ax3 os8UZ23Vy3lEV8+beXgVNnRQrf1TMpTpaPt/uJWZ8FTTgxQKmoQH2ocgtyBQthzzlUE0 T8eSjM1OFXVtY6rvU8nIgeJu535DQqKjChO2Z8ruxSbD2YgGwePOCUZdh3T7/7uI3+4B aLnNjLz5zY5RAaLfHw2mrFev2qnUSJojT3dLo5PtEUMqiiAKNEULxYOIO+dICrNgEv4s g2HKrrMcdtvACxrbvbf92V1NZWaC8CYICkg3EaK4fpZnSNS5ySgrWrojiWEBHQGReOJP FGoQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=99k+Iva/6QCpybtzYMlM4iLwUSEUEcpx8efPZt7i914=; b=UIKWi0u8mLD9MjIEztQCJEow+ir3oMO0SON2Cbnav3sgux/4MepsKzFMVtvQRTxmyj PFWPMcFEEooiNH/ZwekUvz0JAcCwsk3KpcG7VI1c8G6IEY/JYqCGEFIVT05bvcXzrshA WkFzYr039YDTS1cMOZvkEiCqA8PGykqZtyFfRkDcby7x+RwZJ5kQFPPFtSFofQCLnIpE M2vGZejkMPvOPDmw9N13gD24cAQMJkMYMcgQT1sUUL6Qqvapv6RToq5erLnkhmUTKJx6 CVTuqA1S2ss3rT2beZ+zK8JbmwWZJ+QJG7t1oluEctVshR/iJIlmlzofxAdohA0wQYBl 63qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KKYll/S7"; 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 cx20si1659249pjb.97.2019.07.02.01.15.01; Tue, 02 Jul 2019 01:15:15 -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=@kernel.org header.s=default header.b="KKYll/S7"; 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 S1727520AbfGBIFq (ORCPT + 99 others); Tue, 2 Jul 2019 04:05:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:51892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727983AbfGBIFk (ORCPT ); Tue, 2 Jul 2019 04:05:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01C2821479; Tue, 2 Jul 2019 08:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054739; bh=P4gngWAm/oQwGpJFLyM9AT+69qGMzIOeTXRMv4eSdiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KKYll/S7r+fsScD7YV8nwdSgZhfLBkng67FNQVjAqu77OjsFLSMYRS+F4vgUpGbuy TUgwZpDh0jR2MZDPUeipuXtakRDzOeQhgJ0dBUuEZ1lhNYWt62Ts1qgiFAKGuKX7hh +g897K/4wfF2ly6IBmpRq0vI2rANi+rgA+Ld8YYA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 4.19 03/72] perf header: Fix unchecked usage of strncpy() Date: Tue, 2 Jul 2019 10:01:04 +0200 Message-Id: <20190702080124.744956462@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo commit 5192bde7d98c99f2cd80225649e3c2e7493722f7 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/header.c: In function 'perf_event__synthesize_event_update_name': util/header.c:3625:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] strncpy(ev->data, evsel->name, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ util/header.c:3618:15: note: length computed here size_t len = strlen(evsel->name); ^~~~~~~~~~~~~~~~~~~ Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Fixes: a6e5281780d1 ("perf tools: Add event_update event unit type") Link: https://lkml.kernel.org/n/tip-wycz66iy8dl2z3yifgqf894p@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3562,7 +3562,7 @@ perf_event__synthesize_event_update_name if (ev == NULL) return -ENOMEM; - strncpy(ev->data, evsel->name, len); + strlcpy(ev->data, evsel->name, len + 1); err = process(tool, (union perf_event*) ev, NULL, NULL); free(ev); return err;