From patchwork Wed Mar 28 14:09:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 132527 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp522604ljb; Wed, 28 Mar 2018 07:09:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+apNjfAW8y8ntEFnfMUJi3DSRnhd/gs2yuVZkQBQL4I5w+yama6O+VLT60y0RG3xDQDfan X-Received: by 2002:a17:902:4d45:: with SMTP id o5-v6mr4140416plh.84.1522246187168; Wed, 28 Mar 2018 07:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522246187; cv=none; d=google.com; s=arc-20160816; b=KZDMevNECIjvllTPAc5kPdjHHoXvUId2T+ITDfvNAgqwSHaykev1Hs0AL7avYARKqy hmq3PkvMWIMEjqpk8VSB0msGjZZoVGpkUpDrTnsAG1V/jafKJ6vJK8qoCY4MqYWP1uVW sE8imLJkbrIeqnvHibSsUV5qoNhOm1rsu713cz8wi0u3mpkgln6EhhZ9LMREz7TnQFbu WZNbvePXyiqq1toBdBSDvLi1hMaPqVqhrD2Jxtwu/P73GaSFm6Lhh9WchWg6SEumGsxz 9rYO193tvLZdfBho0wi4AHoQ1Sed5CxeBD1h8+3bqHBfou1jSzGLZIyorrOnWaNfdBxi GtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/8OO/gSTVKwKfNRf6Icg1PHWfS3ePIZs4f6I2RihNTU=; b=XlK/VBBCSCAWjfKvhtSedN/4sT1o4nIMAGSrgjAmqE4UH7WXML0cha0gkI1M8U+2Js 2QaeXsrgpsHkNLP8FB7oBjB4/xXVIEmSDknaIj5qKfOE6HrQjr5Ou/smRxYfx/NMzZBh /AwaVOky3rs23Ui5Uo2lXdpyfbjKbeLGO2E40No1jkFmIYHUh/Y4vl8V5A39fVGeffPz 9TDKV4JobKguhmD1I5KCenSt3ZgIABnynGjvH81BQzHLSqu9KdBNNtvDz09JP1hTqvCx oQrTTICWnZNqk2gzatTO2fG0AMdSOpGdX13SnjaXn/8A+Scvx/G/Hxz+eWyiCFEHfxKO QmQg== 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 n11-v6si3702744plg.565.2018.03.28.07.09.46; Wed, 28 Mar 2018 07:09:47 -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 S1753484AbeC1OJm (ORCPT + 28 others); Wed, 28 Mar 2018 10:09:42 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:46307 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752725AbeC1OJk (ORCPT ); Wed, 28 Mar 2018 10:09:40 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0LcP1q-1eJZYZ3oWs-00juoB; Wed, 28 Mar 2018 16:09:26 +0200 From: Arnd Bergmann To: Steven Rostedt , Ingo Molnar Cc: Arnd Bergmann , Tom Zanussi , Rajvi Jingar , linux-kernel@vger.kernel.org Subject: [PATCH] tracing: avoid string overflow Date: Wed, 28 Mar 2018 16:09:10 +0200 Message-Id: <20180328140920.2842153-1-arnd@arndb.de> X-Mail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bf3Nlw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '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 --- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 Acked-by: Tom Zanussi 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); }