Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1443256pxf; Fri, 2 Apr 2021 10:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycZYcC+ZH7U2qLBKbqm4wCD7ypqgPdFNBFbAo3cuwqMsUvR2RAOnTBe4kTTpyS7xqjsava X-Received: by 2002:aa7:d954:: with SMTP id l20mr16474411eds.1.1617384848075; Fri, 02 Apr 2021 10:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617384848; cv=none; d=google.com; s=arc-20160816; b=ZG1KqGQF3sTldnBT2BMmR5ucBm5af6h9UwPWKnTOSjg5hZG386wHvY4GyWHrNnPlPw F/8SBJWBEjQPfzQOgzsC0uABU3CnN9YtdiLYhZ0VWH/XaSLcdsBRf4EClvvtijZsF3YH CkZCau54uwFaOPp9mP1WbEv+FstBwJV7D1TgFbjLMiO5DPRUlfRhknPGql82SlrN9SFb Rk/HoRhNN3NhHlZMOgM+oFSb5CJrT1Ok97F57Ub0D6DtRTx/Dba9tjcI3J05MzIvImpW 1fGFM1tDF6NrWm3ivsdgikMFGZzNgsSNeI7GJCOxxJX5wy3mRtazFC3DFIH1ha8qlVQY WjKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=8nBfmh9yGTJ2vkHlbd2Z0q5OXS3ulkTD4RE8xOFYBN4=; b=W1CBrva2aYx8LiQMYsQI3POqULto7FgZ6UPFF6juuwnnQBncBMr3Bph3hju6LEWKac Y5F6yeCUT7B1LCu9XYQ6yHNnb1zO+GAsynmlNgjiGHhutF3oxAiWUWmSdyLIhMDUAzX/ EZea7swqUnl4mwTnUWfkgKEbTKPuE+gLmI+fOZSqCrEOer3uxwFdZ8mUtp2+2VnnT0dP Hy4Pzcxo3eIZsIoFRkZ3bAk2eZSPCcS2sNldFuyjcD6AcL6TZ9QcoIC9niRXi0Ab+biG V2Qr+frxb63og+8kNWzPwRSkA60a4gpWYs30aK7FtAt6fhwNcsxo1Szl5zr3WOEX7MPS HE8g== 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 a7si6859600edy.54.2021.04.02.10.33.44; Fri, 02 Apr 2021 10:34:08 -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 S235247AbhDBRcs (ORCPT + 99 others); Fri, 2 Apr 2021 13:32:48 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:45965 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236284AbhDBRcl (ORCPT ); Fri, 2 Apr 2021 13:32:41 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FBnF106C9z9v3qR; Fri, 2 Apr 2021 19:32:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id lodEmtGE1XZv; Fri, 2 Apr 2021 19:32:36 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FBnF04lhLz9v3qQ; Fri, 2 Apr 2021 19:32:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C362C8BB77; Fri, 2 Apr 2021 19:32:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Ig-4h8da1m4r; Fri, 2 Apr 2021 19:32:38 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B96388BB6F; Fri, 2 Apr 2021 19:32:37 +0200 (CEST) Subject: Re: [PATCH 3/8] powerpc: convert strcpy to strlcpy in prom_init To: Daniel Walker , Will Deacon , ob Herring , Daniel Gimpelevich , Andrew Morton , x86@kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: xe-linux-external@cisco.com, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org References: <41021d66db2ab427c14255d2a24bb4517c8b58fd.1617126961.git.danielwa@cisco.com> <0c80a08ad4cf788c75043c1615c05bad893f4fde.1617126961.git.danielwa@cisco.com> From: Christophe Leroy Message-ID: Date: Fri, 2 Apr 2021 19:32:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <0c80a08ad4cf788c75043c1615c05bad893f4fde.1617126961.git.danielwa@cisco.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 30/03/2021 à 19:56, Daniel Walker a écrit : > There's only two users of strcpy and one is the command > line handling. The generic command line handling uses strlcpy > and it makes sense to convert this one other user to strlcpy to > keep prom_init size consistent. > > Cc: xe-linux-external@cisco.com > Signed-off-by: Daniel Walker Reviewed-by: Christophe Leroy > --- > arch/powerpc/kernel/prom_init.c | 25 +++++++++++++++---------- > 1 file changed, 15 insertions(+), 10 deletions(-) > > diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c > index ccf77b985c8f..2c2f33155317 100644 > --- a/arch/powerpc/kernel/prom_init.c > +++ b/arch/powerpc/kernel/prom_init.c > @@ -242,15 +242,6 @@ static int __init prom_strcmp(const char *cs, const char *ct) > return 0; > } > > -static char __init *prom_strcpy(char *dest, const char *src) > -{ > - char *tmp = dest; > - > - while ((*dest++ = *src++) != '\0') > - /* nothing */; > - return tmp; > -} > - > static int __init prom_strncmp(const char *cs, const char *ct, size_t count) > { > unsigned char c1, c2; > @@ -276,6 +267,20 @@ static size_t __init prom_strlen(const char *s) > return sc - s; > } > > +static size_t __init prom_strlcpy(char *dest, const char *src, size_t size) > +{ > + size_t ret = prom_strlen(src); > + > + if (size) { > + size_t len = (ret >= size) ? size - 1 : ret; > + > + memcpy(dest, src, len); > + dest[len] = '\0'; > + } > + return ret; > +} > + > + > static int __init prom_memcmp(const void *cs, const void *ct, size_t count) > { > const unsigned char *su1, *su2; > @@ -2702,7 +2707,7 @@ static void __init flatten_device_tree(void) > > /* Add "phandle" in there, we'll need it */ > namep = make_room(&mem_start, &mem_end, 16, 1); > - prom_strcpy(namep, "phandle"); > + prom_strlcpy(namep, "phandle", 8); > mem_start = (unsigned long)namep + prom_strlen(namep) + 1; > > /* Build string array */ >