Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2627036rdh; Wed, 27 Sep 2023 08:06:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTNhUS/1bK4S5oHh4K+iYsGMfDDIFoSw6WphnNHRyuREXjxIEjSjyPSZEcOyClHLgwPdJL X-Received: by 2002:a05:6a21:1f07:b0:13f:5234:24ce with SMTP id ry7-20020a056a211f0700b0013f523424cemr1899663pzb.28.1695827210681; Wed, 27 Sep 2023 08:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695827210; cv=none; d=google.com; s=arc-20160816; b=lrBH/hciCQQvY3ChCyWj7+UZvxX2EHUlVolMLRxauU6ZjJuW8x1kxEaTcBoRk1vyHh C27xqXYnmxSd+n/o9vWZ4ghaph7C7XKaAw+QvVDbvbALLP5OoU8J6EKET3JDuAHPHA7A +Ltqz0TLjBG21nJZWjPNPZZtsCZOYt4J7Dvk8cC3xJBmrZ4gClPHYNx75ptOyoLDbUxQ mj1WS49q4WwNnJ4HbeSgJ2nMki7Y/uTNtAExhW/J7qMolQOGICH1uVaPPMXYds7KVcfr 33YiuJvbn+W042ucWYyUfoqpmd6ZVlYhDXnJSkss4hvAUcj9/CmUzCWy2K9w2h0lC/90 Hr2g== 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=+hHvUR0n4EwEOMV5of1rEk3gEaF0cxdFPl6HtMVDF9g=; fh=dWSEr81agcp0PheKiQkwbn/kHZyAYrQ7Hy7rELEIi4o=; b=Efsip0bMaM2QmduNBKZ2UqbXcL/752OpsAbT5Y+S1zS21znmtqBG2juyrl1XXAB8Fa NIw6IrnSiDR6i6Y2dinuskir5zq8r7SRfDT/jVTiXy43Xm7tUn5ypKuf3y+I3jVXFgSH UO4pms0cPMEQChTKKXFbiq4pXIuOzRxcdozfgv5mpQ+oGhhbbQ1Aa8FU7J2o4Ls/QBY8 c3Y2LbXyzDZZr3cTUZA1NL0j+TdTnZwSh4oSn7AtvT7+oTqgOwHzZp5x2DrdLdX4lCTi Kz2gy5Gf/oFQ+CeVXb+JarTbCV9FayZ8lAq77RD3lQK75qkKLQEXubhaId3RnDpqoe64 edhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rQsXaI80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t12-20020a6549cc000000b00577f7b6e7b4si15447327pgs.624.2023.09.27.08.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 08:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rQsXaI80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 01B4A81EA5F8; Wed, 27 Sep 2023 07:05:32 -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 S232048AbjI0OFZ (ORCPT + 99 others); Wed, 27 Sep 2023 10:05:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232083AbjI0OFX (ORCPT ); Wed, 27 Sep 2023 10:05:23 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9A9C126 for ; Wed, 27 Sep 2023 07:05:20 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2bffa8578feso190204581fa.2 for ; Wed, 27 Sep 2023 07:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695823519; x=1696428319; 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=+hHvUR0n4EwEOMV5of1rEk3gEaF0cxdFPl6HtMVDF9g=; b=rQsXaI80jmvpHELs2QWa9e93J11gYc1okeYxSekqEWMb5T70OzZL8eDWoGXfdObXOO VPtViHGo/dALr5X8eH8XJBRN04UjDdX7Bewfunpk/1Y7z8s5UyhUjv56S7dDz2Tz42r/ mtDEDISBVSbA7Zu5yjNalYqYEn5GZpnYMpVat8P1yPUqFWfFmntVifiZw6vSkIKWLRET bGAvNyNaBVkqu+hi3STPSRGd7XLOfjTpQ0LXfHlAzLQaDUzrGW4LH0NurPXZEe5y4hUK Rw4NiPZXO8mQZ01XJEO2BYZgUZNZ+ZDgkgpQQRKVatMMHggEgTbVDoBZ+GBErSYK5PjY lsYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695823519; x=1696428319; 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=+hHvUR0n4EwEOMV5of1rEk3gEaF0cxdFPl6HtMVDF9g=; b=PFSF5QX6HUfSVI2gNEMD2IbPTeCy0P/AHqFzqbTiIVoPe0vOS2rtc3u+XOETkQ4+l4 9xV4CuYvFFXjkboPI8CV71h/cxNy2UpSVPsCf3rE6Fxs9FGAZKOQ5UAbeIHnyfvxDbTU JjiS7wV6Z/u0pyadhOOHwKd93PetV59OmQ0oLeKGZsofj7z9znxw70FCuwRbdxirG60E WkSf9x2ZtzwQEfe0ulvQqPELl7sXH1xilGohzgUHq8Fe4pc1+6GCs7OdxdA59c2FTk1z l2F0ZdfgAtTUcDK72a1CVTJxBISUXIisYf0V0uHKPpU93JKzfn5M3kttorRz8us1n+z2 INWA== X-Gm-Message-State: AOJu0YxGB439wHbmrGi2J1IO6suc2cp+dGiwyfYroe8kNFs/xJrI5J5P mdDjKMLZtTmC9YHOMFmRPzC8ReFv+dbF3OONowqv3A== X-Received: by 2002:a2e:92d7:0:b0:2bc:c4af:36b7 with SMTP id k23-20020a2e92d7000000b002bcc4af36b7mr2178440ljh.39.1695823518581; Wed, 27 Sep 2023 07:05:18 -0700 (PDT) MIME-Version: 1.0 References: <20230921-strncpy-drivers-hwmon-acpi_power_meter-c-v3-1-307552c6ec3f@google.com> <9837d8dd-d802-4d5d-bca7-6e029658ba76@roeck-us.net> In-Reply-To: <9837d8dd-d802-4d5d-bca7-6e029658ba76@roeck-us.net> From: Justin Stitt Date: Wed, 27 Sep 2023 23:05:07 +0900 Message-ID: Subject: Re: [PATCH v3] hwmon: refactor deprecated strncpy To: Guenter Roeck Cc: Jean Delvare , linux-hwmon@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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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]); Wed, 27 Sep 2023 07:05:32 -0700 (PDT) On Wed, Sep 27, 2023 at 9:49=E2=80=AFPM Guenter Roeck = wrote: > > On Thu, Sep 21, 2023 at 05:41:46AM +0000, Justin Stitt wrote: > > `strncpy` is deprecated for use on NUL-terminated destination strings [= 1]. > > > > Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which ha= s > > more obvious behavior and is less error prone. > > > > To avoid truncating the last byte supply `...length + 1` to > > kmemdup_nul() as `element->string.length` does not account for the > > trailing null as made obvious from it's definition (and associated > > comment): > > | u32 length; /* # of bytes in string, excluding trailing null = */ > > > > ... this is precisely what the original kcalloc invocation did as well. > > > > 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 have multiple patches with the hwmon: prefix but no driver, > like this one, suggesting the change is in the hwmon core, > when in reality it is in some hwmon driver. > I am not going to apply any of those, and I am not even going to > look into them. Whoops, I was using some tooling to auto-fetch prefixes and the style of "xyz: (stuff in paren)" isn't always caught. I will resend with a fixed subject line matching the appropriate driver. > > Guenter Thanks Justin