From patchwork Thu Sep 29 07:29:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xu.panda668@gmail.com X-Patchwork-Id: 12993637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19CDBC04A95 for ; Thu, 29 Sep 2022 07:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3L/7pqkiVChCoeVLa4elyvW1i0e/VEMIAeweaoJolLw=; b=mfjN6vhwPp7dma WYnP0rYNS/bT3kuHDVyNHSVWMdfuO5Hs8R6B+JHfjUKezgwuacB1ouGjO72GXKsP5gjqgF+R0Sqci aV7hFIiNMRbCLXvNehluJk5y+6tx3UBPuBuBrw5eXVkT3QF7BMGMQ9pOmal/i34lIs/4ya3xKY8Hn iEWdbEiYoA6Wp+J0HcYdpmYfsIciS6HO9/96LZktnn5ZWljFkHroyxtrStdg9xd+GVIleQ7cUPgbz RSw6Tu8lWeNSokivYCpFICfqD1QW48l6MWsRccQQKNPGV1gaJwgRNo8ptewafRK3vFftIcx9gPFN/ ddKAbs+pOSEvH965yePQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odnzG-001Zfo-Ks; Thu, 29 Sep 2022 07:29:38 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odnzD-001Zf8-K3 for linux-arm-kernel@lists.infradead.org; Thu, 29 Sep 2022 07:29:36 +0000 Received: by mail-pg1-x544.google.com with SMTP id c7so700002pgt.11 for ; Thu, 29 Sep 2022 00:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=/tZNUqIuW2LgU2Y9VqaDgSpmLoQ9J9brfNhqe2zcUd4=; b=TbtdNNzpWV35S/fp7qRYAa/xZ0A9UAnyY/vJ09WVw5b64FS8Kqscx6qcR56xV0MHc0 WNyigkhyYcUO8kHFJw7/MWS6iRdYDebD2nN5FV9095BtgrOsQQSEnNRxJq8YdU/+D0m2 L8rDOrhcfWRj2lbv5uKcP8wRgOk6WJ1j0AV+C4l9Mg1pt1bZdNI85sEKLPhIr1PZcQLx ace/RLjSmrW2eBlPWIvjtxpNL7E5TSbLaiLZeb6i9qwC0iFbtCr5FDG5AAjITJx0DrtC XSSN0mnajnXEY/g86XEnDiTbDON/bIz9WLoOGthqMdgONsC4v3d14lPhc1Jny/OcaG8A ILuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=/tZNUqIuW2LgU2Y9VqaDgSpmLoQ9J9brfNhqe2zcUd4=; b=t5KiCKqBY091CEri+OJkSbAG9szu0bwSZh2y+vwz7u4dUtN6VAWrVEqMg/I7TnEIVC fteiawAkDgxepcZGzNzwDnkm1YhGqsREymDlCsOYj3wPilIzuITBh2tnrjzjlnx57hlF wOTezHBQneUp1Gqqu9drN3sIPWqm98pFmRyQSuiZMywF6LsG9tcB71BhYxMCzSmuGLto PtlJRRtrMyIuPTAo34KG/a5VTpbwdJpkvS6HJILjHCDhSBWX2HJP0KocZE6WX5+gH46Y TzJ4h2IbOyAh77GtbDonTzfkKWx4UXC9j1OK1y/te+efLgxGo2d0jf4heRECJd1Pzgsn Be0Q== X-Gm-Message-State: ACrzQf12UQ3J3AVh8iYP21xxFnamr+RxJrLmNFAu7yiTi1IwPlEOOqR8 gYvOnZz2usuLnISooQDYWhs= X-Google-Smtp-Source: AMsMyM6PDL1TFKiLzj869qO2hFoH0crHj9TTJXQQ1kQG1tFQrRVwd54oMzyOsq8V0HfgM5LPGooVwg== X-Received: by 2002:a05:6a00:cd6:b0:546:d03:3dd7 with SMTP id b22-20020a056a000cd600b005460d033dd7mr2182591pfv.19.1664436571966; Thu, 29 Sep 2022 00:29:31 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id q4-20020a634304000000b0042b5095b7b4sm4861948pga.5.2022.09.29.00.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 00:29:31 -0700 (PDT) From: xu.panda668@gmail.com To: catalin.marinas@arm.com Cc: will@kernel.org, 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 , Xu Panda Subject: [PATCH linux-next] arm64/idreg: use strscpy() is more robust and safer Date: Thu, 29 Sep 2022 07:29:06 +0000 Message-Id: <20220929072905.282639-1-xu.panda668@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220929_002935_686462_945AF08B X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; if (strcmp(buf, "--") == 0)