Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7489136ybi; Mon, 8 Jul 2019 23:00:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3eePhoeEyb3qnIT5sh/sznoUxD++FnKWFvKCHKYjCEj5GEwAFRDwSoFLgUXELTcGeKpVt X-Received: by 2002:a17:90a:e38f:: with SMTP id b15mr31150453pjz.85.1562652028773; Mon, 08 Jul 2019 23:00:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562652028; cv=none; d=google.com; s=arc-20160816; b=E6p7tmfOaFJtuG8kb4Bkld+opdhoMNdgrccn2TfNcGraBLofLcOVV03T+dQm0BFz4n G7Q2DSgypUspHJ8hrNBE4Gnyf05tF9AYUglQVpstiGFxUkb8Z2IXU+J560S6TXK2tNun OE+7skcAzTId7EbfgRn82LietQCpQSs7ps5Si9X1lpeTJEJGzS23y8LLnPvuv11tidET eZDLEDeg4QDcHskA4nVxUigPep/s4RvIk1a9gz/agVJsHo+JJmOXsKVx0lPxTygosVnt yXJPNAsjGqLtRmx3O979yvuXS3ag0eBr4ZojuKOn6YtwPws6g8RMkHFLaw/Wpup1EOsy e10Q== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=bv2BxcGDjTEiVluEPghF/ArqYKnEYIIYVWno2FsNGLM=; b=LevmQffSP45PoyXLauHI+TvIlUt9aaHZ8+G3XGsfcCToQzLj9EjLrgr/g9jDexuT5Q iC9HxDvntYz6LgwWwOYxQdtb0iWuFR/3ShHM9OUNdGP+KACPXWtfK8jIFRfyEsQfev9m thbALDqp4ZqsDH1p3ZurHWWHcqGpr6KURy/TovRWDakmHr5A+RuWHQ4uLwWvkI3vGFM/ Z/nSbTvqVdbVF+yhcgP5aZIsB70pytODyO7bkRCW6tL4LTriYpJLynv8JKF3XiAi5Sca oRCWrMLbE2rj0R5PHvtGEbjXqkpRyM/am6+UDgfqIe1wsat6onyQ7jwGjve4rf38EL7F nwag== 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 y5si15050909plk.338.2019.07.08.23.00.13; Mon, 08 Jul 2019 23:00:28 -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 S1726341AbfGIF6B (ORCPT + 99 others); Tue, 9 Jul 2019 01:58:01 -0400 Received: from smtprelay0157.hostedemail.com ([216.40.44.157]:57194 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725818AbfGIF6B (ORCPT ); Tue, 9 Jul 2019 01:58:01 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 8AC98181D3417; Tue, 9 Jul 2019 05:57:59 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1801:2197:2198:2199:2200:2393:2559:2562:2693:2828:2895:3138:3139:3140:3141:3142:3353:3622:3653:3865:3866:3867:3868:3870:3871:3873:3874:4321:4605:5007:6119:7576:7903:8957:10004:10400:10848:11026:11232:11233:11658:11914:12043:12297:12438:12740:12760:12895:13439:14181:14659:14721:21080:21221:21451:21627:30012:30054:30064:30070:30091,0,RBL:23.242.196.136:@perches.com:.lbl8.mailshell.net-62.8.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: month28_7fc9c36087e4a X-Filterd-Recvd-Size: 3399 Received: from XPS-9350.home (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA; Tue, 9 Jul 2019 05:57:58 +0000 (UTC) Message-ID: <5e2fb063f50b0d0d8caac5742117488245c4b052.camel@perches.com> Subject: Re: [PATCH v2] Added warnings in checkpatch.pl script to : From: Joe Perches To: NitinGote , akpm@linux-foundation.org Cc: corbet@lwn.net, apw@canonical.com, keescook@chromium.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Mon, 08 Jul 2019 22:57:56 -0700 In-Reply-To: <20190709054055.21984-1-nitin.r.gote@intel.com> References: <20190709054055.21984-1-nitin.r.gote@intel.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.5-0ubuntu0.18.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-07-09 at 11:10 +0530, NitinGote wrote: > From: Nitin Gote > > 1. Deprecate strcpy() in favor of strscpy(). > 2. Deprecate strlcpy() in favor of strscpy(). > 3. Deprecate strncpy() in favor of strscpy() or strscpy_pad(). > > Updated strncpy() section in Documentation/process/deprecated.rst > to cover strscpy_pad() case. > > Acked-by: Kees Cook Kees, I think the concept is fine, but perhaps your acked-by here isn't great. There are a few clear defects in the checkpatch code that you also might have overlooked. > Change log: > v1->v2 > - For string related apis, created different %deprecated_string_api > and these will get emitted at CHECK Level using command line option > -f/--file to avoid bad patched from novice script users. > [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -605,6 +605,21 @@ foreach my $entry (keys %deprecated_apis) { > } > $deprecated_apis_search = "(?:${deprecated_apis_search})"; > > +our %deprecated_string_apis = ( > + "strcpy" => "strscpy", > + "strlcpy" => "strscpy", > + "strncpy" => "strscpy, strscpy_pad or for non-NUL-terminated strings, > + strncpy() can still be used, but destinations should be marked with the __nonstring", This last strncpy line should not be on multiple lines. checkpatch output is single line. [] > @@ -6446,6 +6461,16 @@ sub process { > "Deprecated use of '$deprecated_api', prefer '$new_api' instead\n" . $herecurr); > } > > +# check for string deprecated apis > + if ($line =~ /\b($deprecated_string_apis_search)\b\s*\(/) { > + my $deprecated_string_api = $1; > + my $new_api = $deprecated_string_apis{$deprecated_string_api}; > + $check = 1; > + CHK("DEPRECATED_API", > + "Deprecated use of '$deprecated_string_api', prefer '$new_api' instead\n" . $herecurr); > + $check = 0; nack. Please use consistent tab indentation and no, do not set and unset $check. Please use the same style as the rest of the script when emitting at different levels for -f uses my $msg_level = \&WARN; $msg_level = \&CHK if ($file); &{$msg_level}("DEPRECATED_API", etc...