Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4396317rdb; Fri, 15 Sep 2023 00:15:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgsYd1d1UUSTWDXfXvWLcRMfg+cghd9QCm+liXl9DU9DxqH1NqPgnKkM+5Ao28F3Rmt1xg X-Received: by 2002:a05:6a00:2d90:b0:68f:c7c5:a73a with SMTP id fb16-20020a056a002d9000b0068fc7c5a73amr915321pfb.16.1694762152267; Fri, 15 Sep 2023 00:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694762152; cv=none; d=google.com; s=arc-20160816; b=fiogDM7Vris8sZLj0kj2FUHVkN23lfpzXLNyCI4basgJTdOMpQzFD6fN55nDritTir cF77v9U3b+nq67wZEcJ6yop5rPEwjjRVw5tipbfPOEItSI+d9FEawo/ys2IDDWcwq0sf t1Rk0Zu6qYww2OxcbvwOqUGdrKcY9mt6KpkaoL/N10k+iPvibQFN39CAVGtfXJvzU6Y/ ViZuEmUYpyfBB1gb5/4fufrcssE2K5gjBHwI2Ofm0/tRTkjD85kEU6RWjROcln3WKMea XsF7cDxsqUtmuJRQK/XHvROUjUxNu248VevE0sEt9XjbgiBz95FiQvxZyaDsL5sn+uMB ZuPA== 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=bdckIkCIpFym7NUpRG7gX2O8Kgm1I4+FpTJ9+N9Nf8w=; fh=CdVnfXzba96AChd/wjNSDHj9wkMMY65Aoc5ptEuc628=; b=u3/+QgYHc41eZ6yI60UFdtpSR4TLNup30dDtjoE8l4EtGnxIW447LkUlFdvx9TK+QW fDv1GFRGt65XBrAt7Wl89TGc8B93LqAGVp/AfSRE15ULPKom3MaHvtIYhT5u+LGpHihm IAa1HXRxLGenXb6uVlzJTDc+jOBy/dpuo+vJYzSGnbEqI/aZslKP7Kv1p5UFBA8GoVYM 4ywcPFagk0rIeWxKCOd+m/BFog7q++uf1Jld+q9koEXgZp1rPbV9k2+vaFn7JqzT8ekz Oebrb1SZy4o3bdM5SC0nUDyilP4nK7MpRaOXEpUw2TZ8IlRTIiD/9u8cfK5NK1zzAz0C W8Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=esQwlkVD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id x190-20020a6363c7000000b0056f81e7418fsi2799925pgb.551.2023.09.15.00.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 00:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=esQwlkVD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id DDB9E8363C6D; Thu, 14 Sep 2023 21:03:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjIOEDg (ORCPT + 99 others); Fri, 15 Sep 2023 00:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjIOEDf (ORCPT ); Fri, 15 Sep 2023 00:03:35 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EAA7270C for ; Thu, 14 Sep 2023 21:03:30 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so1362173a12.1 for ; Thu, 14 Sep 2023 21:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694750610; x=1695355410; 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=bdckIkCIpFym7NUpRG7gX2O8Kgm1I4+FpTJ9+N9Nf8w=; b=esQwlkVDCg0AEMMAu81jaIgDB7TJXZTvEYj+Lw0TbrqWJ4jCs5JfMw1ULHWt3w+0uV 9i5eYpW39cdLGlAfLhH8ZbEruBai0g4AuMR372XYpbwmHAhJksMsvmSUbIgyPwlkVOZP 6UOkm5iEQCBM/flEgnKHqAtkDZtCMBG06f2jA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694750610; x=1695355410; 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=bdckIkCIpFym7NUpRG7gX2O8Kgm1I4+FpTJ9+N9Nf8w=; b=DBJH9YP+f6FSG59+s3R4f8iZbB8W1VvhDqaRN5fV9kxna9+ipwwnODj4bJDMKytCBS uMcPoMJ1dq6E08mnBq+6xhK7Vh0gdV7uLK+6nvg3ZqGjCwaYBXgdBUS8osoT7G6xEQpc S7mydliLHcNLyKLW/njS3VUOMiFNizYd7TczU/Jb5ck7wfJFjj3dk1N806+V8jxNZCTO ilzkHg4Sl7XVqSwI8fucVLiaAehFaJfhHjDsD/z96zBZcCLu2UiXqAGuDdo0KZ0PcPUo qHk5Y+kS4S3eywC4fYupy6JuwveZwryg3liEAgGF7zRy8qbYzyU03URbms634v+g4UAz vtKw== X-Gm-Message-State: AOJu0YzSUnI15ip4vZ/LauR6lfngQ1SxfzI+kKQQ+C0beIKDlOlw2tG9 AfNLYD3IjOkyrXaHFnNIHojKuw== X-Received: by 2002:a05:6a20:3ca1:b0:14d:a97c:911 with SMTP id b33-20020a056a203ca100b0014da97c0911mr866067pzj.5.1694750609891; Thu, 14 Sep 2023 21:03:29 -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 a9-20020a170902ee8900b001bf095dfb76sm2336357pld.237.2023.09.14.21.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 21:03:29 -0700 (PDT) Date: Thu, 14 Sep 2023 21:03:29 -0700 From: Kees Cook To: Justin Stitt Cc: Nishanth Menon , 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: <202309142103.6DFFDEB@keescook> References: <20230913-strncpy-drivers-firmware-ti_sci-c-v1-1-740db471110d@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230913-strncpy-drivers-firmware-ti_sci-c-v1-1-740db471110d@google.com> 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 21:03:47 -0700 (PDT) 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 -- Kees Cook