Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp331843rwb; Tue, 4 Oct 2022 04:51:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4xGRAzywQTaRITDMGdEXqAc/F/9JHu3q7+N45cfkgLlZ7y0rGd6fUHY+ZO7zk/OcUlP4X+ X-Received: by 2002:a17:907:1688:b0:782:5fc0:6477 with SMTP id hc8-20020a170907168800b007825fc06477mr18787533ejc.306.1664884319232; Tue, 04 Oct 2022 04:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664884319; cv=none; d=google.com; s=arc-20160816; b=Rv7Y1939pD4ItBqu1EASHl0DFMGAKmpSaZxJvNfS9cunbco4dX4CAszhtp7j17o417 rI6iFFPh/YSNeOd+fJTnK7P58AJEIxRDvfTJ0I4A8UVILggsfWecW9r5P37iWkmCtCFt +rSaOIB2uJ3VdTNYi5cg5ytBDXRfacjcnoTT6ISdfeSdO8Z0XPlvHUR+LKDByfZcntYG kzuUyMhG2KSV0xj7ZmGqfPff/qp1RWTuL3PcWWCcSe0plp0Hnv2GD0mPzsoHv2BYIAOG 1PEqlktoRnj9zm+fg8euPU/685tcl6YsYsoPOdJ7atCc32+hC/xeP9gl2wkyKC6HJuAa sPuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jTuv470xENNNy7AmQaQ+UBBKxX94bSCI1vErs/s+9iM=; b=DQnjO/7tUXmPziEabX3Ps0yPVsmX0zPSD1uFQ/B1dqQytruBlj0nMFIpxJemftA/Qa NUgXYtfKWuLbq4wgrMipTGKm4iQTAR8IEWz1NvNHXc4w2HOJpHzAR/VHuJ+iv20ekzHd qunPL/tY9RwMGkHuQXv/0CsE216BH0nrJLxW5nnHq7IhvJNUh0nELpLB/6CpbO82NO1G Pg/um8GIlLqIZ3oUw58D5i5Tuf2E+gHz4cfKyhRmf+yDC3qN3VQ8DMDc5iKEe0eUoldZ KtjvLXGrhBgu+xQic2yzPXxeJrzROiziPEsz5BceeqQaYrAbfrK0D8Rd6iHlvfGnHZr0 MCQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RXEVEkFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a056402518700b00457c4773001si12156555edd.131.2022.10.04.04.51.34; Tue, 04 Oct 2022 04:51:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RXEVEkFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbiJDLsb (ORCPT + 99 others); Tue, 4 Oct 2022 07:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiJDLs2 (ORCPT ); Tue, 4 Oct 2022 07:48:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 591674D4D4 for ; Tue, 4 Oct 2022 04:48:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EB266B81A13 for ; Tue, 4 Oct 2022 11:48:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3584CC433C1; Tue, 4 Oct 2022 11:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664884105; bh=jVsr8vDY6btfVtvTcnIpc1i/LL+SGq9Q+ZvamuQM0GM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RXEVEkFNYLkprSJaZMK9wxbK0VreILO1l1TZVyG++VdCjqrVzAMlKIYpm+gudlW46 unMdKy4zgUQ6fgK/ao0bPd/rqHcAOrHr2dgWrFeTEhEg3pz6opH+DbSuiijVyWCP+O fms8tk1Wp36kZmkGfD/rY3Toa55gJpZcojOJ7IuDwJEONdEbQl4LPEiJEb0MGmM3nb t8Be7NWHGM5GiafTFuGibkKqm4Z+HvDJNEHCoZSA0f27++2gQWibJvr33NK08T3hHW TiMCDj40QQWzbQCowJQ51fE1hqtJqlbCNdWvKJNZWY1+1Tzstnb05+Aph9JrU3irjo 8YYALxcJUP4Tg== Date: Tue, 4 Oct 2022 12:48:19 +0100 From: Will Deacon To: xu.panda668@gmail.com Cc: catalin.marinas@arm.com, broonie@kernel.org, maz@kernel.org, kristina.martsenko@arm.com, vladimir.murzin@arm.com, mark.rutland@arm.com, ardb@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, cgel.zte@gmail.com, Xu Panda , Zeal Robot Subject: Re: [PATCH linux-next] arm64/idreg: use strscpy() is more robust and safer Message-ID: <20221004114818.GA23663@willie-the-truck> References: <20220929072905.282639-1-xu.panda668@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929072905.282639-1-xu.panda668@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 07:29:06AM +0000, xu.panda668@gmail.com wrote: > From: Xu Panda > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL terminated strings. > > Reported-by: Zeal Robot > Signed-off-by: Xu Panda > Signed-off-by: Xu Panda > --- > arch/arm64/kernel/idreg-override.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c > index 95133765ed29..61bbec7ef62e 100644 > --- a/arch/arm64/kernel/idreg-override.c > +++ b/arch/arm64/kernel/idreg-override.c > @@ -246,7 +246,7 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases) > return; > > len = min(len, ARRAY_SIZE(buf) - 1); > - strncpy(buf, cmdline, len); > + strscpy(buf, cmdline, len); > buf[len] = 0; Aren't we terminating the buffer explicitly here anyway? Will