Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2218330rdh; Tue, 26 Sep 2023 17:02:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzzgvlnmL1pT4+M/R3Ggi50JSW0HWfn6uPaqdHldykB6abWTrMQNhRWPJ5gKfAfH5OzpOX X-Received: by 2002:a05:6358:9206:b0:135:4003:7851 with SMTP id d6-20020a056358920600b0013540037851mr717105rwb.19.1695772961680; Tue, 26 Sep 2023 17:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695772961; cv=none; d=google.com; s=arc-20160816; b=VyKUU2GtEYl4IH2D6amGBnsKaFcOB4C/me6cJLyWbzRTHEIPlrTZDO1nzFIjuPMC+X vxEP9gyiadq/3qsUBmP65LZpDkBqJBYAbEUNMxVIBjKIKkTWuJq2hP7USEs9VmUOCX4Q S6ksH/P7aMHbV/hrvM7mQzj3UP9P/Af1fzFvliUCWr43IC1J3tI0yrvzhN026tDVU5zd RImunqC5ykePIESWcEX/EB6Pv1m0rmG8y9jLJvJQu5YzirOTB+5GaFQWvaz58rs7a+sS LDBXGgKnlx+RefjFDbM33wPZCr/RZ1QWnB7J4ZWsutfkAoVwscqAHnJo8n2dE2YuwKsO bWcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NF//GGw6I1DlmTMzxbBLzTKb51so7w8I+tfjxAX6pAs=; fh=S63or3nH783S/rry/9kG24F61K1S0brPOR/qD4aaRAg=; b=omzgu7XL8cbejHDulm60TA9g+Pd0Jitj5rwi5/KhY78xA6S/5R/UG2dGMMNAZlEo+G ZW2tWmx4FY1bL0wIUngurd9co4JNvIjMBpLbk0mHGfP8748xKWNT0bIUoGVEXmWmXKxO K/aZ+MInhZp77ZJnZJEDcezX97fCOT0XoUh5meJAqIArqRP9sdJew9gZAmA6KjV9CBgt PdF7ZxkUKmbuiQJzwz41FpOKLc85nvaHb/1fqNE9QxKLXP2LWTHZ4Un5VrPW3uoJF9tB VS9GQ0p+XBdlP8wIKu+KIwmMm7NsJCzYbU2gd2PF8/JEjonAFgQNelVT4dxET8ICAKzq mrYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T67r0BI8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bz14-20020a056a02060e00b00578b8016c3csi16192347pgb.24.2023.09.26.17.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 17:02:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T67r0BI8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 438708283A37; Tue, 26 Sep 2023 17:02:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbjI0ACd (ORCPT + 99 others); Tue, 26 Sep 2023 20:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbjI0AAL (ORCPT ); Tue, 26 Sep 2023 20:00:11 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 469DEAD10; Tue, 26 Sep 2023 16:17:20 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF245C433C8; Tue, 26 Sep 2023 23:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695770239; bh=Hx5q0X6p+d0LIi6fY+AaluSPneQQ4+sDt0fmIZmmu50=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=T67r0BI8aRoDL8IwCXP7IJmDQXV4D32Lv1WpwdIhVxHaa404HJBSZIbvGjT9nBE+L 0++VqThkAltnkmVUESk768kFI3Aq1aHyxqLjAe1aowyUYeLpQSU6qDH/qn0Uo+Pyof fsdyQ8pZTv61xuhjqfyjbRQU+VUyWcf4b4UTG+vlQKC8H/nToETYK3s9tUGvA+wdf9 RT/l+8OnHerziunqeWYU8GW12Du/PZS4egXsmHPzvlDVwJzuGM3yi0BANb1fzGDdm+ TGmMMWpaE0yFuqkMwIDUNyTERxKoxOupVnayFAI3iuRm9MU5QE7ytb3JLbZGHNaXqD s9o3cXg5lYJTQ== Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5041335fb9cso15874785e87.0; Tue, 26 Sep 2023 16:17:19 -0700 (PDT) X-Gm-Message-State: AOJu0Yy2DkglQWI+imszMx+5rcksD5shG+h/Rqxky3ZwbFPdPPi7DtGs nAVJLrZhwq7iizPffc8jzIQYz/NUtrdtbuz2yjw= X-Received: by 2002:a05:6512:12c3:b0:503:314f:affe with SMTP id p3-20020a05651212c300b00503314faffemr157768lfg.17.1695770238000; Tue, 26 Sep 2023 16:17:18 -0700 (PDT) MIME-Version: 1.0 References: <20230925-strncpy-drivers-md-md-c-v1-1-2b0093b89c2b@google.com> <202309251122.6E3E678140@keescook> In-Reply-To: <202309251122.6E3E678140@keescook> From: Song Liu Date: Tue, 26 Sep 2023 16:17:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] md: replace deprecated strncpy with memcpy To: Kees Cook Cc: Justin Stitt , linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 17:02:38 -0700 (PDT) On Mon, Sep 25, 2023 at 11:22=E2=80=AFAM Kees Cook = wrote: > [...] > > > > So really, all these instances have precisely calculated lengths and > > purposeful NUL-termination so we can just use memcpy to remove ambiguit= y > > surrounding strncpy. > > > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#st= rncpy-on-nul-terminated-strings [1] > > Link: https://github.com/KSPP/linux/issues/90 > > Cc: linux-hardening@vger.kernel.org > > Signed-off-by: Justin Stitt > > I agree on the analysis of the replacements. Thanks for all the detail! > > Reviewed-by: Kees Cook Applied to md-next. Thanks! Song