Received: by 10.213.65.68 with SMTP id h4csp477460imn; Wed, 28 Mar 2018 07:11:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx48jg9yPCysKUcoeG+CJ1RC2QC869IMRxpXT7oTZ6g3ljKqoZ3mps8cfm3ApTbtm+5t/cGd3 X-Received: by 10.99.95.5 with SMTP id t5mr2674300pgb.295.1522246294805; Wed, 28 Mar 2018 07:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522246294; cv=none; d=google.com; s=arc-20160816; b=UslWFf/3I2X7NzSyfQ34raTcuJHP5wcZm7YDCleHXRXx0SyEsGf8TJLXQCJdF6PTLD SGZ6zwErReHjDRgG5a8nXI3KmNobUPc8CCtZwSK8ANiKHEfY5Zzhzx0R6zw7vk/92Ahf KPU5KsoDSj9wntO8jM8QQW1+ODTnFil1H7FBhyNHQi+mVIfPVPgDBQIoDQL4m8SBFQwM BjOeDsf8wjftzVyyqjVg4MJmyErVJ9Q+Bz+c9EQe6FCO8tZkthMPpgjKNSnS4TiDYkm3 oiYBZjmQk2HkibtHvMfanRUR03/2D/a336zKk/SyQC+NzMUcTfUYPv5A9WSRNBuGYxkw IGsQ== 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 s20-v6si3477574plp.340.2018.03.28.07.11.17; Wed, 28 Mar 2018 07:11:34 -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 S1753481AbeC1OJl (ORCPT + 99 others); Wed, 28 Mar 2018 10:09:41 -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-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:q6WMWnbtXTvRuKklsylCCybv53yK04Nv170eUp4JJqZR066zstl 6wAkHd8Fm//XqlEZBgHJAfaaK3orKoiHGpm/loziCQaVrKI2U1algS5VdTzeoo2CaiFtvv0 s6gUyVkWRrp01i9G282cO+PEVqmDpYjpW/nMWwkLvs4SeJVwDb0zbK0B2aFq2LBRZsMB48v A9zwlv4v2YYjrD/51oyHg== X-UI-Out-Filterresults: notjunk:1;V01:K0:gPP4Bn5ChHw=:RLnRScZYxECAleqv7wDUAb tQJMKdRsVb0NEfP7BYAoflSJWTxvNtakZjAxiMhLgEWoZ8tM3fWkd3HikzQvn5xmc0rXD/NE1 l0RmDm3WvXJyc7qs5z+eBhTGsvJ3H61EpZ1sPWpFtKzw2UGwgOVB0ghWkafCd5dCBJgliJ6zO hNi0P9I3hFmHpDHlviWtHASX73fftQ5MXFGfqe4f6PboGK+5nG2PJlD+f1jNUshypwbdZC1aT 6QRlilr0SbRrHiwU8VT0nYxn8RCr/uAJyZvpgOdRrpO85TRJ4l2k+4VQo76lpnx7wrAwvt9hB S2PofzD19GxqjW34Ar6SCwyAzJyyKTfHDd0fVHkJFOmphfSCnszNFm08F8JnE6B7/Fe/LIMZx RGvq3L35gVGgdkKmbMbcS0OCtCWRqHK42F5fY6/SrwOBBd63UDWeJhn2LsVgdvJfHOGMsRZe7 cbqVNQUxX9DjD4QPHO3eBKkSTRed/dE6zRCjLLpyOjyKYhULpcyTicDOPJvrgJvE9Akym3S+4 BkfbJG0ZtyYXQlLdOkANLU0uop/Yy72OJMcEblKmRPYLDzD80evS1SwTAm66Pzi0NvrICeleO ms5BM+PE+K0rFr8SXdb4S5od3Mv5sAI96aMX99yFtM6mT0+yS1H/arWksg4tU+vk5Jg9G+7Ap wfjYr2yT2f/Vq4Xhz3s7HRYfzvYWwo29fSaOmsVGh8+1oWwMgx3CMbNVK7OTo19HUmHlZ0fvj AI+FWCfCbezx9MNoDbUcf7jMWuyu2yf9bf3Nlw== 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(-) 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); } -- 2.9.0