Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2515143pxb; Sun, 28 Feb 2021 03:58:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHNx73n7JMfvaj8EPYKj3W8a6Gx42WDgGuCahp7V0y72OnkpB7sh0TYPuypZdqdnCo+kMh X-Received: by 2002:aa7:da97:: with SMTP id q23mr4960178eds.180.1614513498987; Sun, 28 Feb 2021 03:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614513498; cv=none; d=google.com; s=arc-20160816; b=ohFscqtf1DjDZ2z6WlaeqhpHtSg9q1kkj01PdNoduSiAP28+7HMotKNFa1dJBtnWZu dbAlYZUaT5DtMq21SJign3h+TrV5CthHRfOwBb6Fjm6NfRcCvcvtvpc4z6TToLngkYXI Gm0HRcyW7x+txv7F2Pzfuw5TPLg1MvXR1jqeB7oWq6Boyq0GGpanOrtV5j1kaGJARwjK cm4VtIlnwCwnISMMJTCEaQ0bFnBQx4ZGbRfaeDPapvm3cQ+sJbmaRezo0rPwZ3+Gktby mRdqdeQ1sKG8m05W2T4PIgI1fesT7fZwDB7h5TbETVQtk4Kp6Bjyku5Os4HUTdem9XOV 7zMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=6DTs4MzzcSAWJJ6hmGMzvW7ZNgWRC14qJc7+4/QG1hE=; b=pJWF3xGFOrXtJlZcAtcbXgxx66QPvOGenwWI1cA9hiYkVUuRmtcNU1ulpwdiYabDK5 Elivg/N0yntlsV3sWBN9WgKh/eJo9Tur4RFkksjq4Q4124eIxdS5VRzK+leGIT1CRTp2 9HWfB1JSPbiYy+x77RMMFJCXcHHy0vc4JDW1f9AO7r6mEwnhvEDzwT2iCA+HPJNZf/yp mFWnkA1DUlK7vcPRTy0fenaq4c93iLtuEwf5i+m4OxvwTSAH5WfYz7pTUxLUySZqAAdl 1dsrm9vq7Ylzs09YLewsjSbbkeKM3R56iZxBtEovetMFNoBSlNyUwOYPmtdfxX+16acq Q1JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kl13si9302166ejc.507.2021.02.28.03.57.38; Sun, 28 Feb 2021 03:58:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbhB1Lv2 (ORCPT + 99 others); Sun, 28 Feb 2021 06:51:28 -0500 Received: from smtprelay0196.hostedemail.com ([216.40.44.196]:49726 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230049AbhB1Lv2 (ORCPT ); Sun, 28 Feb 2021 06:51:28 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id A34D0837F24D; Sun, 28 Feb 2021 11:50:46 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:800:960:967:973:982:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2561:2564:2682:2685:2693:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:5007:7514:7652:7903:9025:10004:10400:10848:11232:11658:11914:12043:12048:12297:12438:12555:12740:12760:12895:13069:13255:13311:13357:13439:14181:14659:14721:14764:21080:21433:21451:21611:21627:21990:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: lake55_4500ff4276ab X-Filterd-Recvd-Size: 2254 Received: from [192.168.1.159] (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf15.hostedemail.com (Postfix) with ESMTPA; Sun, 28 Feb 2021 11:50:45 +0000 (UTC) Message-ID: <1bf09d848148311a952870113401077dfc956bbd.camel@perches.com> Subject: Re: [PATCH 11/20] hwmon: Manual replacement of the deprecated strlcpy() with return values From: Joe Perches To: Guenter Roeck , Romain Perier , Kees Cook , kernel-hardening@lists.openwall.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 28 Feb 2021 03:50:44 -0800 In-Reply-To: <3b8dd556-8c09-9686-dec6-9d523a9762a8@roeck-us.net> References: <20210222151231.22572-1-romain.perier@gmail.com> <20210222151231.22572-12-romain.perier@gmail.com> <3b8dd556-8c09-9686-dec6-9d523a9762a8@roeck-us.net> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-02-22 at 07:46 -0800, Guenter Roeck wrote: > On 2/22/21 7:12 AM, Romain Perier wrote: > > The strlcpy() reads the entire source buffer first, it is dangerous if > > the source buffer lenght is unbounded or possibility non NULL-terminated. > > length > > > It can lead to linear read overflows, crashes, etc... > > > Not here. This description is misleading. > > > As recommended in the deprecated interfaces [1], it should be replaced > > by strscpy. > > > > This commit replaces all calls to strlcpy that handle the return values > > by the corresponding strscpy calls with new handling of the return > > values (as it is quite different between the two functions). > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > > > > Signed-off-by: Romain Perier > > This patch just adds pain to injury, as the source 'buffers' are all fixed > strings and their length will never exceed the maximum buffer length. > I really don't see the point of using strscpy() in this situation. Might as well just use strcpy (I'd still prefer stracpy) https://lore.kernel.org/lkml/24bb53c57767c1c2a8f266c305a670f7@sk2.org/T/