From patchwork Fri Jul 6 01:06:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 141238 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2540729ljj; Thu, 5 Jul 2018 18:07:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfYc2ymNu/s5dQXi8XH+Dg9xzgI9XfGhayfpzUDsYTlOpykq+WLE9+rTYEU1+1ZEaV/DnDG X-Received: by 2002:a17:902:1005:: with SMTP id b5-v6mr8361986pla.207.1530839230685; Thu, 05 Jul 2018 18:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530839230; cv=none; d=google.com; s=arc-20160816; b=LPD8QthwdYAr73xw4zLQXa6S/w++X8n2pLTUOXrw7ud90btaxK+k3PKVItGsjDk2Jv 80Jk4uXufGfoemAPCg1mYWth/7zUY72ea9VyeQ46U3dnLn2JOz5pB9yuafWXvRIp6K5S CNLT3vrMPVt81OC1p5AcXbTOieVBtJlirncG6lAPCNOdSulkdeVdecVVUCqOtH/54p2F Ku4jip2q01W+2stdOKcIyaMnRsX4ZGoaXLyR5mn81AAl//eixMpTwH/foFuDS2Am3uQR Pv8Kxk1P1X1DJisVQS7shrzhXjZbT0xk/sERTMdhoOMdOxSivRBMsi/X7mvsrfQ5RcF/ PnYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:subject:cc:to:from:date :user-agent:message-id:arc-authentication-results; bh=g67yd+6kjLV7MGC3H4+FJWgSBM6fZ74E4Evqjz5SjJM=; b=ijhwU1kOq9jpNhv/ZHZa6ruU55dDaI2Fiqg6SUsnEt0FgvgCxwrFsDL2GXSYGAh4Am VTFwbJ6/QoSnTn4Ao2rI+ISQukZo8SoY5JyMWe1cDMvao1VTLEoTuYfPEp39KtnI9B8i 2SR4bfUDQoAFa5sq1wYeV987A4rojTsTuT8Hpczm5YU6kYwpHGSBZfImVmnu5D1fXqhM wvLHxJjO5R/P35F6NYm3EvxHNabRn07Bq0BMCN22ixaXAhHzdHKUJ0nh47aqCOpNsNYH vfWdOUG0XRf/PY0ylr6T1C8vYK5HCUFMt5kIWr+JQaGlkQc1Tykrk1tHg8qB27SoYI9w gOoA== 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 l11-v6si6449600pgq.174.2018.07.05.18.07.10; Thu, 05 Jul 2018 18:07:10 -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 S932537AbeGFBGp (ORCPT + 30 others); Thu, 5 Jul 2018 21:06:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:44870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932360AbeGFBGj (ORCPT ); Thu, 5 Jul 2018 21:06:39 -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 1E41724017; Fri, 6 Jul 2018 01:06:39 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.91) (envelope-from ) id 1fbFCo-0007Hj-6i; Thu, 05 Jul 2018 21:06:38 -0400 Message-Id: <20180706010638.104814314@goodmis.org> User-Agent: quilt/0.65 Date: Thu, 05 Jul 2018 21:06:05 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Ingo Molnar , Andrew Morton , stable@vger.kernel.org, Tom Zanussi , Arnd Bergmann Subject: [PATCH 1/6] tracing: Avoid string overflow MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann '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. Link: http://lkml.kernel.org/r/20180328140920.2842153-1-arnd@arndb.de Cc: stable@vger.kernel.org Fixes: f404da6e1d46 ("tracing: Add 'last error' error facility for hist triggers") Acked-by: Tom Zanussi Signed-off-by: Arnd Bergmann Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 046c716a6536..aae18af94c94 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); }