Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3570477rdh; Thu, 28 Sep 2023 16:19:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZyXdPmDaOI37RcuvXhmsoPu/0cXjfoCzC62vfbwS9FttDOBCO4o3ipgBHHy1ORWd59NhP X-Received: by 2002:a05:6a20:3d87:b0:13f:b028:789c with SMTP id s7-20020a056a203d8700b0013fb028789cmr2848650pzi.5.1695943147048; Thu, 28 Sep 2023 16:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695943147; cv=none; d=google.com; s=arc-20160816; b=MxLyDk8+LgvBFez/oVSheefuaD0IhYmH8wDL1nlPWJ/bMR3kpUhBS7SGwHv4WiRKbP Pmamgwxvr/m1hMw5zB4rgXF2TOKYm83xUhPQknmSLlYqyhr+MvWIYBCB3QdGMFn+yKgZ MI+R7rwdcLy3d/bcSvuEocDF5y+2TGJbzFYLohXjDxtvZBLDv3Gjhop3GKRR0jWgKIpx vy9YxA/iecO9ecNPhAMo+hY1coALviH97+K/sw5GbAQ0gJjioJMi0ZiQbw84zku5vMUC dP6BmExOYdYewm9T1raM9vmDuW52/2ohjMLALozrzx/wKAqEEtMcxOXcnKNBf6ymp8BZ u6+Q== 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=d53VmuoWKktNI02x/f4SVOnb4OpZ9AYZl6S7M2mENOQ=; fh=eUfhcHxFE9P/fHkFk30W064T43PxpdVbVyb9wm6S2Zo=; b=chsezEGarG9BmT3Hc+17y64lbJToe7scIrAtLCofnvybb/LdUoHKvxJDjaIPsUTfX+ KAfJXNqpyY2dMusbBWVWsTj7ylxBcU9gqW/eC+8ZZrYMUk02AwvK6GFEfiSTzSBbshO3 1qnkjDt+xmywFhzm6SG06BvHTOMNGxeTdRnE++wOm+mYCble0XdWd55KtrRuF16iXuGw 03YEY7M1sEMjpX4HNWmcG+JXYy09lAD7BYujY4Xbm8UK5hGEE8BegLv2QTXJ1zVIfZjV ycgULm0IBQj83gaQe52+on+D17iaJ81Xyzvgyo3f+bgryE8i1jk+B7DvBcxjtPMvxsXg tHnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nzty1U2p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id le11-20020a170902fb0b00b001b9f55d28a2si18152694plb.205.2023.09.28.16.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 16:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nzty1U2p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 03DB6823CC41; Thu, 28 Sep 2023 14:45:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232327AbjI1VpI (ORCPT + 99 others); Thu, 28 Sep 2023 17:45:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjI1VpH (ORCPT ); Thu, 28 Sep 2023 17:45:07 -0400 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD61219D for ; Thu, 28 Sep 2023 14:45:05 -0700 (PDT) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-59f1dff5298so156961747b3.3 for ; Thu, 28 Sep 2023 14:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695937505; x=1696542305; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=d53VmuoWKktNI02x/f4SVOnb4OpZ9AYZl6S7M2mENOQ=; b=nzty1U2pWLvDqcpqJ94rU6HFEx3DmdPGnkI/X/B6+uoyETWQgoH7gxY4dLSiQ6D3qv JXvoVUz/PkK8s601b7l6pG8fGZ0CYYPO3oet9Xycc8voX15G8ay6eh4f8WMRzxSGm/Vj /InXsaVuxKp/ND3f4oxcHNTrw7okKArHQ/vsr+nmsvWc1EzZE4fdM1u8AeNtR8CvlR8J udfTBaP3g9x7xgVfFe6al9fVs4XqCQPBj7iLuevmdt2IkO2TURezw6W24HHYlTHfqlUI jhCIc+rSDKRxtaakqqic3q4Q+ZIYa0EIvbxonMWQf/dOSMjvyI9LCEzPJy8FcrpoPsam 6Oww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695937505; x=1696542305; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d53VmuoWKktNI02x/f4SVOnb4OpZ9AYZl6S7M2mENOQ=; b=Gr4IALSOerTmSRwYo6IPIW75Rr3ieOnhfKVXSQu7OeZrnEizj/tnjc/EPLy0Pgw8hg Z5JjCFB0FR8pZLmWFeY9btAhrpsHTTNJ65a9IayrAvvlWlqWOx6IVtWMcdycL64/z50G uynZ/Rd+uXcBLR896fHRGAywfej2GlK6gRXuOHKrXO7iqIG5M1qdsi0Jlj9PTZCwwPbw iK27SJS3me+EA4yFuwe2M5zdaQugD0oFOKqCBUa6q9CyqlwaxOaEPDqG/qggja6KnmbR QZ0jXGkQndetG9uBD7CJJMQv3DvsC5sZ+PGzg7LJRgDpAOednxXC9QcwPqwjzmvINubz KyGg== X-Gm-Message-State: AOJu0YwpShsNkYa4RNVbLo79uf/DThSNUjs+y4uC3rXbOmKfz+vO6N3G YzKA2tsjh/Ld5B1BYJcA6GihOfD0BwrjP9UzegKqOw== X-Received: by 2002:a81:72c5:0:b0:59b:2458:f612 with SMTP id n188-20020a8172c5000000b0059b2458f612mr2417694ywc.28.1695937505000; Thu, 28 Sep 2023 14:45:05 -0700 (PDT) MIME-Version: 1.0 References: <20230927-strncpy-drivers-mfd-db8500-prcmu-c-v1-1-db9693f92a68@google.com> In-Reply-To: <20230927-strncpy-drivers-mfd-db8500-prcmu-c-v1-1-db9693f92a68@google.com> From: Linus Walleij Date: Thu, 28 Sep 2023 23:44:53 +0200 Message-ID: Subject: Re: [PATCH] mfd: db8500-prcmu: replace deprecated strncpy with strscpy To: Justin Stitt Cc: Lee Jones , linux-arm-kernel@lists.infradead.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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Thu, 28 Sep 2023 14:45:12 -0700 (PDT) Hi Justin, thanks for your patch! On Wed, Sep 27, 2023 at 7:10=E2=80=AFAM Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > We expect project_name to be NUL-terminated based on its use with > pr_info: > | pr_info("PRCMU firmware: %s(%d), version %d.%d.%d\n", > | fw_info.version.project_name, > | fw_info.version.project, > | fw_info.version.api_version, > | fw_info.version.func_version, > | fw_info.version.errata); > > Moreover, NUL-padding does not seem to be needed. > > Considering the above, a suitable replacement is `strscpy` [2] due to > the fact that it guarantees NUL-termination on the destination buffer > without unnecessarily NUL-padding. > > Let's also change `PRCMU_FW_PROJECT_NAME_LEN` to just > sizeof(fw_info.version.project_name) as this is more idiomatic strscpy > usage. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strn= cpy-on-nul-terminated-strings [1] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.h= tml [2] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt Well analyzed, well patched, what can I say! Hats off. Reviewed-by: Linus Walleij Yours, Linus Walleij