Received: by 10.213.65.68 with SMTP id h4csp2490762imn; Mon, 2 Apr 2018 08:29:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/q3cjeYjEP/oyq9gDbIiCsblqVFxd2SnbDj0FGvTDVf4/OQG3W50AAOxAdZEdb6rf4R0Zt X-Received: by 10.99.2.202 with SMTP id 193mr6683269pgc.117.1522682971442; Mon, 02 Apr 2018 08:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522682971; cv=none; d=google.com; s=arc-20160816; b=NZgccRpIF66DKhbwY2dRDPpQ/YVGZx6WMa7lccFBATbRipDXPZI6V/LCyzVDs429QQ qKfz0nz/nFQ+KjRk1iVdcqGGcsKtdQ5aL9WFBzyCsSYTwmNUYSRrnvh+p1+Jptke94/7 MQ0rYPqbw9ZbN0Fa2cohmGW+6kF4hFQZ024FiuiFaOl8xUSOULoXJO78U0F05AtYPHxT SziwPSGZp42cophZ1lBI0wkYfSfVltGLBtm1qGjlq1Hwo+yO5EIfWY4I5p0499kZpseS qaeElsIZcaZLU9ytpHuAP16jKzBL0txofDz2lMrGW41VW5XreiLnS1oiQXM+EgoicE2T BYGA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=D3K1agNiEn34jRyQFmBGacP1nBF4e09GCtdWH4EMf5U=; b=ix7rxofGufM6r+jqeoDjV97duefxfrXj7mpoxI1bn6u3IGFyCxKrd56NCC7lxnBqJT gc0Q2yBWUtaRmUdr0+Hzy8hKhqCcYiKfyKoQ0ezfsMnoB9N6CDbYnoYmMvfynoeKmJK+ snWOcmkTqOO6QXT1q/gLaBPtl/ZsFukkKvxfCbgsWYhK0lmgAoaLLSf9U85ZMdtzg0Y/ tPsSelS7IRzSj9FchugZvtovgiL4rkqwts2xN0fTflya1aggQbtNyvTuuebZDCvJn8Qs tG0vffgkRlt/4zhqQ8re2Rdeb4E9lU6yG46/rR/iRsXcbjByQCIoabJ5oUzJKVu8dejX CAxA== 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 p19-v6si531570plo.708.2018.04.02.08.29.17; Mon, 02 Apr 2018 08:29: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; 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 S1752197AbeDBP2G (ORCPT + 99 others); Mon, 2 Apr 2018 11:28:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751315AbeDBP2F (ORCPT ); Mon, 2 Apr 2018 11:28:05 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (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 84D1C206B2; Mon, 2 Apr 2018 15:28:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84D1C206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Mon, 2 Apr 2018 11:28:03 -0400 From: Steven Rostedt To: Arnd Bergmann Cc: Ingo Molnar , Tom Zanussi , Rajvi Jingar , linux-kernel@vger.kernel.org Subject: Re: [PATCH] tracing: avoid string overflow Message-ID: <20180402112803.0f1498c2@gandalf.local.home> In-Reply-To: <20180328140920.2842153-1-arnd@arndb.de> References: <20180328140920.2842153-1-arnd@arndb.de> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Mar 2018 16:09:10 +0200 Arnd Bergmann wrote: > 'err' is used as a NUL-terminated string, but using strncpy() with the length > equal to the buffer size may result in lack of the termination: > > kernel/trace/trace_events_hist.c: In function 'hist_err_event': > kernel/trace/trace_events_hist.c:396:3: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] > strncpy(err, var, MAX_FILTER_STR_VAL); > > This changes it to use the safer strscpy() instead. > > Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers") > Signed-off-by: Arnd Bergmann Thanks! I pulled this in and will push it to git after testing has succeeded. -- Steve > --- > kernel/trace/trace_events_hist.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c > index 4f027642ceef..8357f36d7a1e 100644 > --- a/kernel/trace/trace_events_hist.c > +++ b/kernel/trace/trace_events_hist.c > @@ -393,7 +393,7 @@ static void hist_err_event(char *str, char *system, char *event, char *var) > else if (system) > snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event); > else > - strncpy(err, var, MAX_FILTER_STR_VAL); > + strscpy(err, var, MAX_FILTER_STR_VAL); > > hist_err(str, err); > }