Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4741979ybi; Tue, 30 Jul 2019 07:22:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmgOdH3WDgIUjpDisruVqqbvYGXUxoYXT1XXe09kQGxPcomiv4ozzN/TzcrsNWTZ2vQYgt X-Received: by 2002:a17:902:a413:: with SMTP id p19mr116365447plq.134.1564496537019; Tue, 30 Jul 2019 07:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564496537; cv=none; d=google.com; s=arc-20160816; b=kHqYKku1Db8ORLbg8KrSXIewHEZ+XOFX8W/qJNLDQOry/K54jvtSbR8kZrn/eQnBlY 6zlSaP64gmWJceUiOIVbdwwoLH3aYsXqsNPag9ghhhEZ3z6XigP0gDxzgjCV0RCxP45M ptcw+US2fD4JMDgmDshJBOCyerqcwEAtbJJtL7B6jJP9PV0tdByXS5VNL8uwXolyJBz4 ycr/OcXDTg5SEihJaG4wuDTbjOgXwx0WOevTsCWSuljeRhH5Weq8m7eBz80/JYRayB0u Xyk02ftoPuygioU9tmIXq+YVcJQ+Ex3QgzTusay7e+ssaTeqif1BXlE92p2P/17uTLrt tdGA== 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=FXckzr757JzZLDXSA8aS1f5l1dElkmTTa1ZRri987sQ=; b=t2GUrgV9/tKo8Y4Fxb5d6fsAjA5RcfFi2KUOcHt9i1XVtNvIVQcE8m1HABScvtkm49 l1k+KdrhdWCBZtC+GBgGE2KEb27TPkqacslTlO//mRQ9z42Zjc1+Gn9PoCI6ncQ+a7lC 7elxWtdBA59UastFICQ6/u9yC+XJ1xwCeQijna+0j5kKuvecW0XgTzhO42jkx97cp+iu QwTFP8CHRNQQ7Uo4tnTGPJD/0A6ScsmuG9vyt4arBv80DX4DLs6eQu/cKMmiN3AOowih tsg4pCXxXAXDu25MsK3r773o7BM/gtc64X/OZy0gFhrO0SUt+BMwl3HFWCtA4o9RV5bY fGOA== 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 l191si29620173pge.94.2019.07.30.07.22.01; Tue, 30 Jul 2019 07:22:16 -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 S1729458AbfG3HDd (ORCPT + 99 others); Tue, 30 Jul 2019 03:03:33 -0400 Received: from smtprelay0043.hostedemail.com ([216.40.44.43]:35977 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728470AbfG3HDc (ORCPT ); Tue, 30 Jul 2019 03:03:32 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 586E983777EE; Tue, 30 Jul 2019 07:03:31 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,3,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::,RULES_HIT:41:152:355:379:599:800:960:967:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2553:2559:2563:2682:2685:2691:2827:2859:2893:2898:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3834:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4830:5007:6119:7858:7903:8531:9025:9040:10004:10400:10450:10455:10848:11026:11232:11658:11783:11914:12043:12294:12297:12438:12555:12663:12740:12895:13069:13311:13357:13845:13894:14096:14097:14181:14659:14721:19904:19999:21080:21324:21433:21627:21740:30054:30070:30090:30091,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: anger88_1e83daf9ea507 X-Filterd-Recvd-Size: 2841 Received: from XPS-9350.home (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Tue, 30 Jul 2019 07:03:29 +0000 (UTC) Message-ID: <80fbaf63ddbe66cbbf3391256402295af1a3336f.camel@perches.com> Subject: Re: [PATCH 01/12] rdmacg: Replace strncmp with str_has_prefix From: Joe Perches To: Chuhong Yuan , Kees Cook Cc: Tejun Heo , Li Zefan , Johannes Weiner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Laura Abbott , Michael Ellerman , Steven Rostedt Date: Tue, 30 Jul 2019 00:03:28 -0700 In-Reply-To: References: <20190729151346.9280-1-hslester96@gmail.com> <201907292117.DA40CA7D@keescook> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-0ubuntu0.18.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-07-30 at 14:39 +0800, Chuhong Yuan wrote: > Kees Cook 于2019年7月30日周二 下午12:26写道: > > On Mon, Jul 29, 2019 at 11:13:46PM +0800, Chuhong Yuan wrote: > > > strncmp(str, const, len) is error-prone. > > > We had better use newly introduced > > > str_has_prefix() instead of it. > > > > Wait, stop. :) After Laura called my attention to your conversion series, > > mpe pointed out that str_has_prefix() is almost redundant to strstarts() > > (from 2009), and the latter has many more users. Let's fix strstarts() > > match str_has_prefix()'s return behavior (all the existing callers are > > doing boolean tests, so the change in return value won't matter), and > > then we can continue with this replacement. (And add some documentation > > to Documenation/process/deprecated.rst along with a checkpatch.pl test > > maybe too?) > > > > Thanks for your advice! > Does that mean replacing strstarts()'s implementation with > str_has_prefix()'s and then use strstarts() to substitute > strncmp? > > I am not very clear about how to add the test into checkpatch.pl. > Should I write a check for this pattern or directly add strncmp into > deprecated_apis? After Nitin's patch gets applied: (which btw wasn't cc'd to lkml) (sorry about the bad link, something about it hits some spam filter) open wall . com/lists/kernel-hardening/2019/07/28/1 Add it to deprecated_string_apis And we've had this sort of discussion before: https://lore.kernel.org/patchwork/patch/1026598/ I believe I'm still in favor of global conversion of strstarts to str_has_prefix.