Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1853922pxy; Mon, 2 Aug 2021 11:58:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyoCZHSVKPRn3HVsWcnmbaALEBsegeqiU4EDGSbldwMCnUw89W1dmXjzrJfCuiOERiJI1W X-Received: by 2002:a05:6e02:1b88:: with SMTP id h8mr822153ili.48.1627930724012; Mon, 02 Aug 2021 11:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627930724; cv=none; d=google.com; s=arc-20160816; b=dV4R3GErKAXKNVW73gtZv6ZS0H/a0bvD9+TGdpMp8w31ZIT8x6LSgdiq3nx6nrUYPZ uOjPqacKH1EQP+ROYV+4SPz3KwyQUGWPcmviqgfJzA+nXk4w+w6cTbQd/9ZT/uHgiTHX jCk1SOFccQBcVi4DYLDI/1Qqu3kKI7Nqw6rBXKB80tbgHpU77qWeQr70CLxL6hAGoDWL Mh9spW8Ubfxt2+4or+9fR1Ufx5+hh/x9WjmDieDc5NdXkMRrCg/AwzFjukSRztmL89T0 Gp9Xw8ooCKr+ItW1MczX4bs29vGI2wv3faSy46nUm9nKR9DsAlmEUX4dinlqHaUzO1YR VtoQ== 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=9mft/8iGqVlr1bSA5A5H+IOU2q5DkCXYJLm22Ud5JKk=; b=WHI1LWsHuuwIH2ZXK8K4FkDaHY12iivkR46PIHdrJJIs9tu5uo4ydSfViy+icOyKqS mnhJTwonQgR91c1U42oEEyFHi9at1hEjx8M+CC4lbGiWOaC6R0fqCBh7dfjsUYOoGcA+ gpBnDucuGHkmGUOxG3p5uMQhTAFOQZWEG/YUPq8Ef/BNtXofqiO9ZcCdRjd/0EI/BZ1J 2ox1Jh0ARSgOn3etezeD0QqQTY8ETi0GjQ7Q6o5zCscskQtjMFdB9QMau2CACpX/fo46 tdTX01P3jSvqWe28RoaFfGrZmVrgiwVbo5xk5ELO4HNyIygN1aVi1uXd+v3Av5Tbp1qQ KAVw== 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 q1si13676375ile.21.2021.08.02.11.58.30; Mon, 02 Aug 2021 11:58:43 -0700 (PDT) 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 S229677AbhHBS5y (ORCPT + 99 others); Mon, 2 Aug 2021 14:57:54 -0400 Received: from smtprelay0169.hostedemail.com ([216.40.44.169]:35556 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229537AbhHBS5x (ORCPT ); Mon, 2 Aug 2021 14:57:53 -0400 Received: from omf17.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 354C4100E7B4F; Mon, 2 Aug 2021 18:57:43 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf17.hostedemail.com (Postfix) with ESMTPA id D5FED27DD11; Mon, 2 Aug 2021 18:57:41 +0000 (UTC) Message-ID: <30984a540fb8e340c12e52054cdf7d6478b8b960.camel@perches.com> Subject: Re: [PATCH] drivers/input: Remove all strcpy() uses in favor of strscpy() From: Joe Perches To: Kees Cook Cc: "Russell King (Oracle)" , Len Baker , Dmitry Torokhov , Lee Jones , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , linux-hardening@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 02 Aug 2021 11:57:40 -0700 In-Reply-To: <202108020912.3807510B4B@keescook> References: <20210801144316.12841-1-len.baker@gmx.com> <20210801145959.GI22278@shell.armlinux.org.uk> <922b0d99b6397adc44761abaed12c019dc0b9e88.camel@perches.com> <4962ac72a94bc5826960dab855b5e2f47a4d1b9a.camel@perches.com> <202108020912.3807510B4B@keescook> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.60 X-Stat-Signature: ighkxrxg33quaz6kqpd9gm8ujq9abaoq X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: D5FED27DD11 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+MGQoRjSeQ40Zmc0KA7pV/cp/fRUrdq5c= X-HE-Tag: 1627930661-732664 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-08-02 at 09:13 -0700, Kees Cook wrote: > I'm wondering, instead, if we could convert strcpy() into this instead > of adding another API? I.e. convert all the places that warn (if this > were strcpy), and then land the conversion. Perhaps not as strcpy is a builtin. It might be easier as a cocci script. Something like: @@ char [] dest; constant char [] src; @@ * strcpy(dest, src) There are some additional test that needs to be added so that only length(src) > length(dest) is reported.