Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp792589rdd; Tue, 9 Jan 2024 22:39:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXczGDfPVgxmVnqflPfXI2b77huHr0/E6Is+StrqcJrlXPHUwT9hB10TEVA2JSWekGOyBn X-Received: by 2002:a05:6a20:6b9e:b0:199:c09d:3717 with SMTP id bu30-20020a056a206b9e00b00199c09d3717mr403914pzb.125.1704868754680; Tue, 09 Jan 2024 22:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704868754; cv=none; d=google.com; s=arc-20160816; b=QTXK2JX2I+ScqM6vqlQyf9pTira7o6gANd+Ytz3L0smKNFw20yGwN2vx8KrEtrvtkw BswSHtgjgTXbGUOy0kQyHWKKpNGsMzPdD9y6/H812k8+n3QPPRvD4XeKEFT11cKgdTmG yKC5G27eT3LKPSLFBWOWH4lqeP+KJMKnxuEuBs00zd6WdSEDtOY3lWeJBiEE48zJsB3M xNgAQ4HwdzkmsWp697qsxmhwKdJ5BxQu+HX9mdQPoyTAApJVDuOFR5AUXb67x3T4ujSX LdjRkF8XSXTgwZVYIErrhxQvWXWVEeYqyauJXUjBb9syWrJNP1jS1e5N5srw2rWybKam z/ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=e5m5n4+0uQw+AX6UaFbPCJ2FmiqUuQSJEp23siT5ShU=; fh=1bB/ILqY14e9Zvogs0T/fpnkWPZjpwszBQJ9FTY895w=; b=f9szlXPGU4KqJpswynLWTeB+6MHGIlXrThHTFA8kvf1ZcwIk7j3XRke752T28YuFB2 bYZo2tarzDS4PWk5T3e5aVqdlLUMXrWyBS/FaESElXqlCz8YcPCHJqJJKekZP3FcOviD QhMUWH+2N4RrB8Zbo++CwNK61ul4RvnfzcQeZ3n2Yrm499N1aqUdGzVXv1EbV7SUaXIf P2i4MFmVBwsUi27wrUbhZTTlrESFoLKc38t137k6wTZMbsuuV8upJyHXtk7oc22+9ggX D1jplU/yzUscOfircwOApbfRzA0VCrPR6ana2hVlk703AsjrFmXJWzaxzAJc/CLnESSp 0iow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21752-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t18-20020a17090ad51200b0028868509509si739725pju.108.2024.01.09.22.39.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 22:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21752-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21752-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CC8052898C8 for ; Wed, 10 Jan 2024 06:39:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D8DB364B4; Wed, 10 Jan 2024 06:39:05 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11426ECE; Wed, 10 Jan 2024 06:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id F13091C0004; Wed, 10 Jan 2024 06:38:48 +0000 (UTC) Message-ID: <4e0da12a-62ed-47fa-9f75-a7de10bd8dc0@ghiti.fr> Date: Wed, 10 Jan 2024 07:38:48 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] riscv: Fix an off-by-one in get_early_cmdline() Content-Language: en-US To: Christophe JAILLET , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Palmer Dabbelt , linux-riscv@lists.infradead.org References: <9f66d2b58c8052d4055e90b8477ee55d9a0914f9.1698564026.git.christophe.jaillet@wanadoo.fr> From: Alexandre Ghiti In-Reply-To: <9f66d2b58c8052d4055e90b8477ee55d9a0914f9.1698564026.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi Christophe, On 29/10/2023 08:20, Christophe JAILLET wrote: > The ending NULL is not taken into account by strncat(), so switch to > strlcat() to correctly compute the size of the available memory when > appending CONFIG_CMDLINE to 'early_cmdline'. > > Fixes: 26e7aacb83df ("riscv: Allow to downgrade paging mode from the command line") > Signed-off-by: Christophe JAILLET > --- > arch/riscv/kernel/pi/cmdline_early.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/riscv/kernel/pi/cmdline_early.c b/arch/riscv/kernel/pi/cmdline_early.c > index 68e786c84c94..f6d4dedffb84 100644 > --- a/arch/riscv/kernel/pi/cmdline_early.c > +++ b/arch/riscv/kernel/pi/cmdline_early.c > @@ -38,8 +38,7 @@ static char *get_early_cmdline(uintptr_t dtb_pa) > if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || > IS_ENABLED(CONFIG_CMDLINE_FORCE) || > fdt_cmdline_size == 0 /* CONFIG_CMDLINE_FALLBACK */) { > - strncat(early_cmdline, CONFIG_CMDLINE, > - COMMAND_LINE_SIZE - fdt_cmdline_size); > + strlcat(early_cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE); > } > > return early_cmdline; This looks good to me, you can add: Reviewed-by: Alexandre Ghiti Thanks, Alex