Message ID | 9f66d2b58c8052d4055e90b8477ee55d9a0914f9.1698564026.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1562053vqb; Sun, 29 Oct 2023 00:21:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOJuHJB8tXmq917WxqiNK8S80YmR1gWaPR19BXTpBZ7g3OJQ7c0ElV0nbsxVOJQsm3MEWV X-Received: by 2002:a81:9b0c:0:b0:5a8:7cb2:15d1 with SMTP id s12-20020a819b0c000000b005a87cb215d1mr7211903ywg.24.1698564077924; Sun, 29 Oct 2023 00:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698564077; cv=none; d=google.com; s=arc-20160816; b=GF888aFojD/XQ1xIUjsfIGEQuG0g7jUiLfgWFE+S7get5cCPWtn/jkoVP3DzCKB4Z6 m94SMogV/BZAQvsmrSXmZl00+gxi2wR8+aPtPDUNVC3QksxKMNSG/LtzHUtRCGPIYh16 lYZKQFhVKAnLrqqi+kgxF7cZdXwH2ws/RIliBa84aPI3W1h+hLrQGbRjVp00j9MwXSQq gbYMiXwHCUqHN1hy+tmmDBjC519FQld5ID3DLa35J4bJWPQcRttr9HBzqdrZi0x7wMXa vvJrGC77MXpTYNm+cdeYYOjUwkvQu/H99mscMFMSoyolNF8TLeinaWOqenFSMwKeCq56 2LhA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MDsDuhCr9olbw0nTq2ub5nqlO4/+Skgqu55qCR4cVX0=; fh=y5g2U0sPq7qGpmY4C5mEX+eUq/cM5fq+NwWxEusqJL8=; b=ps747r8NgQrIDLZ7xW72fPeYt+FMaVlU6ifw115o4pwM1F3vpDOfDKR3Koa0w9t3rd BKXSbHN/mncor3nLF8v53rq4xzjqWyrNg21oNSjah8ftcT6LA52mMpr4TTSOezWYhfRy ELRC7oIFH4LtW5cRpKfJAAC1sm2PBCOWRo/BDFmo5eY/LTLNM9Cznxm5qjo19ZuQ0cKk IgXBb4SHjrEfSBzAbd0lhHFaj5/qbB6RdjdHlNmRUQSGfkWTA+UyX5Dvba0NeAvL1bkr 340i/unmqvpbJEC3/dBaOWTxaQzP3R9G3JzWGVL/pK56jk3y3H3a/4UhBTh62w70/6di ONzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=t3VEn56I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b00578bd92e502si3341813pgb.558.2023.10.29.00.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 00:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=t3VEn56I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id F25D180568E7; Sun, 29 Oct 2023 00:21:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjJ2HUy (ORCPT <rfc822;fengqi706@gmail.com> + 30 others); Sun, 29 Oct 2023 03:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjJ2HUw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 29 Oct 2023 03:20:52 -0400 Received: from smtp.smtpout.orange.fr (smtp-20.smtpout.orange.fr [80.12.242.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D377D6 for <linux-kernel@vger.kernel.org>; Sun, 29 Oct 2023 00:20:48 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id x06DqqqBCvx99x06Dqyxs3; Sun, 29 Oct 2023 08:20:46 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698564046; bh=MDsDuhCr9olbw0nTq2ub5nqlO4/+Skgqu55qCR4cVX0=; h=From:To:Cc:Subject:Date; b=t3VEn56IA1ozmNuyAqXus1ROpaXMxRPzyaxwLbtPDKkv1rCqfILUjVpGwY5GimzS+ semo9phsAuSxLBztVY1VPDi+iRtmwM+VSBCqXn3Z0O4eyA8k//AMqKexA5uvtMGszG VtVjtZTvQrjcb9W6KDxwn4aZ+xdjXwlIjPJijmhXYwr+PoFcLLohHJonM6JG6OVFmd jCU009uZPxDSWkgnGLA8QJAlhbEw6ELCo/bgLkAgorOtMOFT5csSclgdPGFQTmUwEq audeq/OkxTsFvQkCLer/LqyznHYzAWWfMVPJUWCa8MEen4vNoGXKJ79nZIBNKQXvqz 3DltTAecjWGeA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 29 Oct 2023 08:20:46 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Alexandre Ghiti <alexghiti@rivosinc.com>, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@rivosinc.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, Palmer Dabbelt <palmer@rivosinc.com>, linux-riscv@lists.infradead.org Subject: [PATCH] riscv: Fix an off-by-one in get_early_cmdline() Date: Sun, 29 Oct 2023 08:20:40 +0100 Message-Id: <9f66d2b58c8052d4055e90b8477ee55d9a0914f9.1698564026.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 29 Oct 2023 00:21:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781073526528584179 X-GMAIL-MSGID: 1781073526528584179 |
Series |
riscv: Fix an off-by-one in get_early_cmdline()
|
|
Commit Message
Christophe JAILLET
Oct. 29, 2023, 7:20 a.m. UTC
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 <christophe.jaillet@wanadoo.fr>
---
arch/riscv/kernel/pi/cmdline_early.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
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 <christophe.jaillet@wanadoo.fr> > --- > 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 <alexghiti@rivosinc.com> Thanks, Alex
Hello: This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <palmer@rivosinc.com>: On Sun, 29 Oct 2023 08:20:40 +0100 you 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 <christophe.jaillet@wanadoo.fr> > > [...] Here is the summary with links: - riscv: Fix an off-by-one in get_early_cmdline() https://git.kernel.org/riscv/c/adb1f95d388a You are awesome, thank you!
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;