Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4860846rdb; Fri, 15 Sep 2023 14:55:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTuz5BqLQ0/5y9r+680SA3IVxY4mDIKPORjQhx48pBzmUerfpyHqebvUfAlEYR9UxQ+aED X-Received: by 2002:a05:6a21:7784:b0:14c:6404:7c5e with SMTP id bd4-20020a056a21778400b0014c64047c5emr3436726pzc.24.1694814901607; Fri, 15 Sep 2023 14:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694814901; cv=none; d=google.com; s=arc-20160816; b=BpyfKXNe1Fbg1OefCd962Q/GQLwhVPu/riF24hc8LSkEAYhfGNeX2O74hXi84UQEl7 X/4E9Lw1eLJ1Z7fg8RhrKw5Q6rwBsxOKj5JuGKzTfbcH11EU7/r/0rwvmAM0r0js8T9A fCQUwHCg7YZ/xr7PZ6SUJlPKetZqeiyiRIciK50mY3S+hUHl8cf9kq6+mpCGyVynazgK dGX4MEJyGEDV20Y3/S9wM0v4kr59zkkCA+XNIcTfUCmHINr2VOo5kO2rsvnpnGYV86Br wljfxT4knTmsSo6xw/fuiedL4YZwARmvdjgpe6FZzNfFEU0J6LIK36cxluPmVy/zUlTB qolQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fRHJ/RTdkjV1T7VQMz3Gh8DiS1ERKAhw13PCyOr4quI=; fh=o64lMsTH2r5NoMuytzsJyDWq2lsGQbK8QSftaYwES54=; b=UJ2dABF8a5LGPWZT/AcfvEsJ5GFT6SMDAfq5km0B/efGQq72a5NZmyIZZ3M6GVlmlg c/FpjiSGuOQ5hCBjy15GITDZLfRuhWTIceEpj8SX+Bln2mxTwhVmxTNZZxFTbgTdQOyb UfUCnspvp7tzVI9ENt4Z9BaE/uWKegxjMlZesSZNmBNH+mRl5BbbyZUZoY4DvbskrEpq r51pshpGo4qcB8YP/zd3SS2l9gFUDacAVS6T5Epzo4cA1OcWfsl0iR7qIIWjKjv95ls7 Xq/ktt/fdnuLGSjDCi634TDY4T4EPMNVBtfcL+VQlfpJfLWueUyeYXOuJ9BnxMSC/FnK Nu9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="d/BpGzO4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id s128-20020a637786000000b0057828b85afdsi1325302pgc.795.2023.09.15.14.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 14:55:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="d/BpGzO4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 07A6682EA157; Fri, 15 Sep 2023 10:14:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235290AbjIOROM (ORCPT + 99 others); Fri, 15 Sep 2023 13:14:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235406AbjIORNk (ORCPT ); Fri, 15 Sep 2023 13:13:40 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EED24E7F for ; Fri, 15 Sep 2023 10:13:34 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fc081cd46so2283011b3a.0 for ; Fri, 15 Sep 2023 10:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694798014; x=1695402814; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fRHJ/RTdkjV1T7VQMz3Gh8DiS1ERKAhw13PCyOr4quI=; b=d/BpGzO4zmNEoey5wzbS5IJHtoYqCwjle7N4blNvGqGh84uci5bxH0GnllApNKPD4n 0NjFVClcVCLCNgigXho/sFdE3zOGCm7Bc0SuAL14ImPszCtaSMX6vZVLIw9Pk4e/yood pzSXn/fgHkaEc1ccSzgxO0c/ZXDIEvyVB7OeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694798014; x=1695402814; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fRHJ/RTdkjV1T7VQMz3Gh8DiS1ERKAhw13PCyOr4quI=; b=AeiFPGqC1KlmKU6o9SnsgdGhRLvYXkb5CEzaAwBzp1L5nR9iuFoJ67ipWG6KMVHh27 KFrjCfzNKhKtjTyKF/ZLp1vSFRzVPLz3S0Sf9fQt3DkTlH19DRIQR2kLsYfCeaPCWTcG OhDV6IGxPHp3olX/yJjA4VL/K8Lwchxmn7JC+PYrimCIH6xPezx+02c8+Cdf6Mp8FqAL zXnaDzBY+fJLL0fK/3r5iDoS0KbSFLEtAKVbqT7TBwoWlJdjD0NsPuS78v2tFZt5hEDm 9bVA4IIEmaVIPpWKSIMu9U256/CIuvBCWQC5GSi2QbPpG0OptKTOh2uYNbUGS5QGTqKr UeDg== X-Gm-Message-State: AOJu0YytHTpyDNFhnq0EMBeX5dqLUHp9X7AcsG1Nan2DVSTUkTLCCyYc wyOfsM6WaxJ6AAedHCeISmthIA== X-Received: by 2002:a05:6a20:8f0c:b0:159:e0b9:bd02 with SMTP id b12-20020a056a208f0c00b00159e0b9bd02mr3278129pzk.40.1694798014413; Fri, 15 Sep 2023 10:13:34 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id j15-20020a633c0f000000b00565009a97f0sm2965476pga.17.2023.09.15.10.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:13:33 -0700 (PDT) Date: Fri, 15 Sep 2023 10:13:32 -0700 From: Kees Cook To: Nishanth Menon Cc: Justin Stitt , Tero Kristo , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] firmware: ti_sci: refactor deprecated strncpy Message-ID: <202309151012.446CC82E2@keescook> References: <20230913-strncpy-drivers-firmware-ti_sci-c-v1-1-740db471110d@google.com> <202309142103.6DFFDEB@keescook> <20230915124038.vmj3gzthboypzp3v@parsnip> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230915124038.vmj3gzthboypzp3v@parsnip> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 10:14:46 -0700 (PDT) On Fri, Sep 15, 2023 at 07:40:38AM -0500, Nishanth Menon wrote: > On 21:03-20230914, Kees Cook wrote: > > On Wed, Sep 13, 2023 at 08:23:02PM +0000, Justin Stitt wrote: > > > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > > > > > We should prefer more robust and less ambiguous string interfaces. > > > > > > A suitable replacement is `strscpy` [2] due to the fact that it guarantees > > > NUL-termination on the destination buffer. > > > > > > It does not seem like `ver->firmware_description` requires NUL-padding > > > (which is a behavior that strncpy provides) but if it does let's opt for > > > `strscpy_pad()`. > > > > > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > > > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] > > > Link: https://github.com/KSPP/linux/issues/90 > > > Cc: linux-hardening@vger.kernel.org > > > Signed-off-by: Justin Stitt > > > > Looks right to me. > > > > Reviewed-by: Kees Cook > > Does this belong to stable as well? If so, please add appropriate stable > process. No need. This is a refactoring only. :) -- Kees Cook