Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp522535rdb; Fri, 8 Sep 2023 07:57:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAl6H2D4rXgs1UJv5RYWUgwwGZJRPGiJf+hAWoqXr8WpUTNplKam4d6hFJ8Ba0PQ37yJTZ X-Received: by 2002:a05:6a20:4287:b0:133:7a67:b477 with SMTP id o7-20020a056a20428700b001337a67b477mr3023244pzj.1.1694185079377; Fri, 08 Sep 2023 07:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694185079; cv=none; d=google.com; s=arc-20160816; b=Eev/kq/Knz/pOj47V2HZgaGr5zOOiQ5iQpa2Pp65rbH+OwYvaVFgple7cctM8FPJJ9 tRMYiu0Np3Ev0oZm+EjEKvRC/06WI35K6MdA+3fypjXVBK8e4TnHPLw0Jd+RwhaGh2ed jJA+HAJgse5Gd+vQaoxEuGV+ASB++e5rSzVxCD/UP6C3lksWDm6RlcFbKFahaF+96+gC kVhTupWVSXKpiRSTpDYKhpvygab3zjnd1BOKO79/61F4GXuhCU+sFHCyVMpKTFKVw9jA FQrKUmcxnNc0v1bJa5aEwMm4FujVra6A8LIrHiEQqXJcUhIXvWoJeDkIBScvM+t3L8sb PWJA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Sd1HZHVYwP2OjZy0CC0fnA+GK52SgjPvk2QOEZpJ8UA=; fh=LoHbHL5ExjFiyA1+JMFdb4PvQsD5y2IOMCBJPoShQtg=; b=WVCjLQPpj8+o+VKCwkbQcG9ZXG3RPwRmUO93nUCZ81G2zhjUCNJTp+qnUShSnzWkTN CI3HQ7v4HpX51cwUIucyWU4aYtu5Nf/HMjiZEw/hel5MNyrH0A0QTMZvsLSYz4GysKq+ 1WZYlo4HklmWYglCqWRMCDPTIOUKZCrx27j06SJYNQ3PsAb29vr4XOsH8zLh6CLlzRjG MiV/xzhDPzpLmEJIg9/8V8IMHesRlRXCpTAUcBTbht10Pof/RLeNaL88daOeUvIs5VUS BTOdbh+rgvKY0LarLvre5m9yjjXfWyfc5TCBJxHF/o8lyVsWXRjeek8Cva/Jydqxps+n MqlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PtpRW/1t"; 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 r24-20020a635158000000b0056f8fdb4430si1558502pgl.893.2023.09.08.07.57.45; Fri, 08 Sep 2023 07:57: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="PtpRW/1t"; 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 S243103AbjIHK3F (ORCPT + 99 others); Fri, 8 Sep 2023 06:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241013AbjIHK26 (ORCPT ); Fri, 8 Sep 2023 06:28:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A602123; Fri, 8 Sep 2023 03:28:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ECC8C433CD; Fri, 8 Sep 2023 10:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694168317; bh=7ppBGSYE/D1DEoQwtHJNYsJokjRP5do2Yy52Rv5Uyxo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PtpRW/1t8nNfLPqbo8IsCfPOJ0tpjyhRkcrwyjGZc1qXUr7kx+xBgWnf4qnDaq77F ukvUPCQmK7go5SvzVPY9r4Lx0yyK5QoY3Fg+B7UhjyTV6JC1WeOGCIQzyRlW8iO1i0 leYHJP3eNUq9z+n8Ei3tikxScTyzXQuHcNomq8QtyWul2ZarX0T7Ho6WjLblQa36Qk hMZxVKMkr/G1XEnGV4HHLYggegV+eqcVCz2Th4PJXzTsPv6RHXp2//ur9ztXIv3qDv NUYLjzfG0afA3ziCgVdjO08R3Rsgop/ZCNgZiomsBZC1b4+aGbnkpY78ckK5c7tfM+ eVYu9zOdxc4Yw== Date: Fri, 8 Sep 2023 11:18:32 +0100 From: Will Deacon To: Justin Stitt Cc: Konrad Dybcio , Catalin Marinas , Mostafa Saleh , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kees Cook , linux-hardening@vger.kernel.org Subject: Re: [PATCH v4] arm64/sysreg: refactor deprecated strncpy Message-ID: <20230908101831.GA6849@willie-the-truck> References: <20230905-strncpy-arch-arm64-v4-1-bc4b14ddfaef@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 07, 2023 at 11:17:08AM -0700, Justin Stitt wrote: > On Thu, Sep 7, 2023 at 10:37 AM Konrad Dybcio wrote: > > > > > > > > On 5.09.2023 22:10, Justin Stitt wrote: > > > strncpy is deprecated [1] and should not be used if the src string is > > > not NUL-terminated. > > > > > > When dealing with `cmdline` we are counting the number of characters > > > until a space then copying these over into `buf`. Let's not use any of > > > the str*() functions since the src string is not necessarily NUL-terminated. > > > > > > Prefer `memcpy()` alongside a forced NUL-termination as it more > > > accurately describes what is going on within this function, i.e: copying > > > from non NUL-terminated buffer into a NUL-terminated buffer. > > > > > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > > > Link: https://github.com/KSPP/linux/issues/90 > > > Cc: linux-hardening@vger.kernel.org > > > Suggested-by: Kees Cook > > > Signed-off-by: Justin Stitt > > > --- > > Hi, > > > > some form of this patch [1] went into -next and it broke booting > > on at least the Qualcomm SC8280XP-based Lenovo Thinkpad X13S. > > > > Thanks for the heads up! The previous versions of the patch (including > the one that was applied) had some errors. This patch should be good > and Will is looking to apply it to arm64 fixes tree. Yes, it should be fixed in linux-next 20230908. Cheers, Will