Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2101719rdh; Sun, 29 Oct 2023 00:21:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAu48Md2s8BtGwxEVIG/7BCXB312lZZYK536bXZBzXaTQaNg6sf/PtHo23Mpxa3F6A65Lz X-Received: by 2002:a05:6602:340f:b0:7a9:96aa:e01b with SMTP id n15-20020a056602340f00b007a996aae01bmr9637157ioz.20.1698564067947; Sun, 29 Oct 2023 00:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698564067; cv=none; d=google.com; s=arc-20160816; b=tsBmRLpbowZolaXgxP6d9x11Hb738YLKnnIQMSEr1jMYvxsz2LA6uZpmthu/Aywjqr hRKX8wQ36JXWq2Oiox83bCEdWj7lmlhTJp3lD/evC1eMLIZg0zkKOz3GYTUAGaE3TeTz dA3/N4nLJh89hXBTXsnXmjGABopNxKOnczxm9loBNLb/QGBgOQOGNbTee974xQwU5pjs zz3+2vh2nPrIJSNnxfZqxT33Soy6qKUtQjyu+ppOJoqSzunWx2x30cysC/vn3+WYrvtb /xHuYTf/s2dvd2IFkSZKn7CH2N/pdFy3QVZ2ki2nlHIiTp+SN8el2TlUhSzMgFy+noNc gmMw== 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 Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g20-20020a635654000000b005b8f181b729si3419380pgm.360.2023.10.29.00.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 00:21:07 -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 9748C80569B9; Sun, 29 Oct 2023 00:21:05 -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 S230019AbjJ2HUx (ORCPT + 99 others); Sun, 29 Oct 2023 03:20:53 -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 ); 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 ; 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 To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Palmer Dabbelt , 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: 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:05 -0700 (PDT) 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; -- 2.34.1