From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752584AbcAFL26 (ORCPT ); Wed, 6 Jan 2016 06:28:58 -0500 Received: from mga14.intel.com ([192.55.52.115]:2189 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752157AbcAFL24 (ORCPT ); Wed, 6 Jan 2016 06:28:56 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,528,1444719600"; d="scan'208";a="628849058" Date: Wed, 6 Jan 2016 19:28:54 +0800 From: Fengguang Wu To: Steven Rostedt Cc: Colin King , Li Bin , Russell King , Will Deacon , linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH] scripts: recordmcount: fix incorrect use of sprintf Message-ID: <20160106112854.GA20574@wfg-t540p.sh.intel.com> References: <1451516801-16951-1-git-send-email-colin.king@canonical.com> <20160104104246.636bc47a@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160104104246.636bc47a@gandalf.local.home> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, On Mon, Jan 04, 2016 at 10:42:46AM -0500, Steven Rostedt wrote: > On Wed, 30 Dec 2015 23:06:41 +0000 > Colin King wrote: > > > From: Colin Ian King > > > > Fix build warning: > > > > scripts/recordmcount.c:589:4: warning: format not a string > > literal and no format arguments [-Wformat-security] > > sprintf("%s: failed\n", file); > > > > Fixes: a50bd43935586 ("ftrace/scripts: Have recordmcount copy the object file") > > Signed-off-by: Colin Ian King > > --- > > scripts/recordmcount.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c > > index 301d70b..e1675927 100644 > > --- a/scripts/recordmcount.c > > +++ b/scripts/recordmcount.c > > @@ -586,7 +586,7 @@ main(int argc, char *argv[]) > > do_file(file); > > break; > > case SJ_FAIL: /* error in do_file or below */ > > - sprintf("%s: failed\n", file); > > + fprintf(stderr, "%s: failed\n", file); > > Paper bag bug. I'm not sure how this passed my tests? My tests check > for warnings. And I even got a "BUILD SUCCESS" from Fengguang Wu's > kbuild test robot. Because the error will only show up on "gcc -Wformat-security". It tend to raise false positives, so Kees setup a dedicated tree which enables -Wformat-security as well as quieting the common false positives. In that way Kees can catch such problems from time to time, however the limitation is, only upstreamed code can be tested in Kees' tree. > I'll apply it, test it, and push it out soon. Thanks, Fengguang