From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0394EC8757 for ; Thu, 7 Sep 2023 17:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245615AbjIGRsK (ORCPT ); Thu, 7 Sep 2023 13:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245480AbjIGRrr (ORCPT ); Thu, 7 Sep 2023 13:47:47 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6D8B1BF7; Thu, 7 Sep 2023 10:47:30 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92B46C43395; Thu, 7 Sep 2023 17:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694108214; bh=Eiz6SK/GqpmCoXTlpi6rkM1vG/IzusgKaLu2J8ONxZc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=lNmwdK0igINXgKTUlE2M5AL8aAcwBLGL82xBc092o9SE8QeG66ueU70gN9x3wzaWj 7QVF1N2SAwkrvnPeRjiN/Ncs2oFKV80LqfhPi6waSgUaY7jwDNBNnMkaNrCCupKWJG iOB+mAGaBLEzOTXygDVuQSHWP9afZu1ESP6FCwCUaGHliCdPjd5rDlnTdOnQ2ynmkg xNE8UwfSkfxl0wlcSP138wN7JOF/wudkT1n2VeQw1WMAspSFxi/2so0nXUepTJD5CA Dj5Zky56qn34Zk2YnuKmBvj+RviuXBnU35mOTeAasBvKGzpPPom4cosPC+EMDbAE6Q LMc5umqDShYoA== Message-ID: Date: Thu, 7 Sep 2023 19:36:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4] arm64/sysreg: refactor deprecated strncpy Content-Language: en-US To: Justin Stitt , Catalin Marinas , Will Deacon , Mostafa Saleh Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kees Cook , linux-hardening@vger.kernel.org References: <20230905-strncpy-arch-arm64-v4-1-bc4b14ddfaef@google.com> From: Konrad Dybcio In-Reply-To: <20230905-strncpy-arch-arm64-v4-1-bc4b14ddfaef@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Konrad [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=d232606773a0b09ec7f1ffc25f63abe801d011fd