Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4489987rdb; Fri, 15 Sep 2023 04:04:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMynbgjULols0zEcf1Lw+tjUqrDojP/5cCYIMzy5mr7EhwRGFtruFhihTaK4uazg8HlT55 X-Received: by 2002:a05:6a20:3d83:b0:13d:bf07:7444 with SMTP id s3-20020a056a203d8300b0013dbf077444mr1452349pzi.0.1694775887617; Fri, 15 Sep 2023 04:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694775887; cv=none; d=google.com; s=arc-20160816; b=nXt+AQzX5zHkw3tASWBDEWWVpkbucZ5GGM2Ryqnjfa71HUUU28w8gvinpEw5bjWrU6 KdLExahsD/W5275Dp09IlVJZo8YzZk70ithhsbt0gnIrjWua1uRzDPzgh2zYYyz7m4gB CzanGVHe9fmH0niLIlpMPyg2G88/OpX3suTgxbf7vTgcB7Z7b/GpaRNV4f3IkHvtf8Vt gcyHckHPbtUEbhV4CfARwUudRtwQ2hE8f3ip6hA/aib3gmLL+5PcyCS96A4o3n+Mjv2V Qb9SQXAmlUIWudefYkaP/vN6O65mDmt80eUFJl61xwxF3xTmC+IY/J1azKHAXzX/dfkW EUwg== 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=TIubZOhXnC08Ym5gC3EaH+E8b/9Z9IetgzoFovfcROQ=; fh=BtQCiDI2i8xmvJWTNcve6iezOW62Z+73C4ZPcgVYGDU=; b=ZflzCBUqdpC6Mwp96P8xdXRqAqO/HsFdtqqGZVFnER/7Lkg2zyNicJQNTIAvpwDp5a fjgWTe++LNgMbIGPyyMmJ4FZou5yFW3CuDEqIAiexCrZU8p9yrljKGK7/lagJjP7TT4b 2V6aG9N0ceQr0nM59Cqj9d0PC3iIIWdkwnBvhl19QDYh45hwv7EN9aNvKsjkjfMdDv1d D+yL062DGiT+CTTbzON755q3otdiZyWtOqDcCbTmNB6O8bG12GwmXCAp7VisjdG2vwWQ jQHQqUzUdYl7JEE8ftBzTOiwfgv7egrW+Z6KYxoQ9ZTjgqhkm6/icmMsn4pL4Y4qatD3 VE4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="hwG/VQhc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i9-20020a17090332c900b001bdc664cd65si3404396plr.165.2023.09.15.04.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:04:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="hwG/VQhc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 78D7E818FBC8; Thu, 14 Sep 2023 20:37:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjIODhU (ORCPT + 99 others); Thu, 14 Sep 2023 23:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231337AbjIODhS (ORCPT ); Thu, 14 Sep 2023 23:37:18 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF6F1BF4 for ; Thu, 14 Sep 2023 20:37:14 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-770ef0f51ccso112743285a.1 for ; Thu, 14 Sep 2023 20:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694749034; x=1695353834; 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=TIubZOhXnC08Ym5gC3EaH+E8b/9Z9IetgzoFovfcROQ=; b=hwG/VQhcFQEMzWhn5tv3Eg48tS092BPFcXsMmKbzySblC9Xl3brLHcED0PmNHfoHzw FyZw2C0pN0kcEIfEla++mG3MrkM3swRylt+gap3gmvHcDm2baoQtsa2+YI4dw6Yobpzg FfVx8fieSGW07jjyHYnV4snYlYBNQLRphbpco= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694749034; x=1695353834; 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=TIubZOhXnC08Ym5gC3EaH+E8b/9Z9IetgzoFovfcROQ=; b=U84Xp1b/kPND3ZfOdicAAPCm55Egv5KhTIa75AKcDkEs39tsGFwsf5N9KZjiJ0TH0F ri8gJSavKOcG1PkLi3oHmIHa31IND6XMX5qlec6mkE8HGcUvAwy20EfZXyPfsyxlKps6 4YvlvqrxmpStAikzvxrkC8jtvoVbJHC37jpS8jx1BfIExg/p0ZM3k1LYln12VkwR5MCj OV+jbeqIaDkbEH0SV588EwByHsT1idYktdfiuHC9OlRfLs+OhCXItgBsLfeNjr2MmNeF +dvVT/OWHfO9pfIL79E9z0N4Jzt7L2Xp7GGGan6dEJHeZjx51Z7SR0qXFhbGCjWI7E03 Mxug== X-Gm-Message-State: AOJu0YyMr5sNeYnvoJLaREl2QJUc4ZY6I4Pi2qqjdQr4CtSYbJf5JVAc Z2aGUz79/rXU05ih+9CSZD7KsQ== X-Received: by 2002:a05:620a:29d3:b0:76f:1eac:e72d with SMTP id s19-20020a05620a29d300b0076f1eace72dmr477359qkp.38.1694749033852; Thu, 14 Sep 2023 20:37:13 -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 ff16-20020a056a002f5000b0068fedfe01fesm2011980pfb.161.2023.09.14.20.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 20:37:13 -0700 (PDT) Date: Thu, 14 Sep 2023 20:37:13 -0700 From: Kees Cook To: Justin Stitt Cc: "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] cpufreq: refactor deprecated strncpy Message-ID: <202309142037.DAF02CD00@keescook> References: <20230913-strncpy-drivers-cpufreq-cpufreq-c-v1-1-f1608bfeff63@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230913-strncpy-drivers-cpufreq-cpufreq-c-v1-1-f1608bfeff63@google.com> 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 (pete.vger.email [0.0.0.0]); Thu, 14 Sep 2023 20:37:22 -0700 (PDT) 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 pete.vger.email On Wed, Sep 13, 2023 at 12:07:21AM +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. > > Both `policy->last_governor` and `default_governor` are expected to be > NUL-terminated which is shown by their heavy usage with other string > apis like `strcmp`. > > A suitable replacement is `strscpy` [2] due to the fact that it guarantees > NUL-termination on the destination buffer. > > 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 All looks sensible to me. Reviewed-by: Kees Cook -- Kees Cook