Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4767485rdb; Fri, 15 Sep 2023 11:33:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/KC41E0FkOh7S9nAUjYcDhQ3eA5y+PgwzYqpvq27c5QpjyA/3zgO74WRgOWreGSxde0c0 X-Received: by 2002:a05:6a20:3d83:b0:154:a579:b0ff with SMTP id s3-20020a056a203d8300b00154a579b0ffmr3082001pzi.19.1694802819609; Fri, 15 Sep 2023 11:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694802819; cv=none; d=google.com; s=arc-20160816; b=je1MJvtulSiCEO8VCvRIalkPSJayJI+tvn6wbvtPaf+5IELcCrwqFJUrVs8rTjWByk YhV3YZESWOpb+Bv0ZlDvaNQfwsBWGIZgAa4hwHdJ0QhzmMPQRzAHDrYFQORz1ngtIwkK UEiPIR5qQgvh92z6qNLSrC/2jvbWcHIM0Rjm9DKjfkRHN9kFaIzHNX/vkQcI7TR9XQG3 LVm1T+JexEowWTtvwpxz+/H7jvBOWPpxNd+BoggN4YUej5ibynIT+tIPmeG5VayN/VZL 9HEbDI9799PNWhq3UnWWVgceQZ9TY/fgVQbxAk76loPgXvg1NggM46M8yK8rwBhJN04i 9gaw== 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=Z4avXvzursC+45bqw32CiKah19BSXYGGSK9tL8yLNEc=; fh=zGQdO0x6BFFeJbUYn/rQAV4nDR1T1yJNtSq5/QEHAWQ=; b=oNx93tpaQ+mI4l7m5Uh3y0YmjQ/1Yg1Uqgu8O+N8x2m4HfrdrIplIwHYmZPTMwUu/+ +nVZOyBMrUnQ9wYvY8w3oicEVl9aGY5xlLl1TZIx4dF6mtw9Uf68UzpI7h+R3rNL00uj oYXWz8edoX1oWrFqiDCo73WgEqcwxzLYw5YYAhyztc3oRbpdW66/0LOZbLMmODutG/FP fVUhVvWggK5IdD6hhsLAO4klWjghieqYL9ReoAvr2hRNkyCIMFo+tdKuiIC6k7GdAjVC iA3pVLDdAmGIqDfO51dHSB6YYosHqE0XB1VsQ3eVBF/AURU0m/Jl+r5pH2HpwWRpRMKL A/yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Pwaqgrls; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s11-20020a056a00194b00b0068e26b4cd71si3864543pfk.179.2023.09.15.11.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 11:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Pwaqgrls; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 8708883EC663; Thu, 14 Sep 2023 22:18:26 -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 S232109AbjIOFSU (ORCPT + 99 others); Fri, 15 Sep 2023 01:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232095AbjIOFST (ORCPT ); Fri, 15 Sep 2023 01:18:19 -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 C06A52D48 for ; Thu, 14 Sep 2023 22:18:06 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fc1bbc94eso1472125b3a.3 for ; Thu, 14 Sep 2023 22:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694755086; x=1695359886; 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=Z4avXvzursC+45bqw32CiKah19BSXYGGSK9tL8yLNEc=; b=PwaqgrlsEMxq+k/+X5gjVldHqbDjToMtesJUqILPx/co+97vthVRTL+dqjs45tcBI/ QzhmJMTr7CJTxQ8SPODAc0YyIFr5eaNS9cw9bwyeRLBsFK6xvMHBVF+1LEz9evzqybzK TNcNQGEpYFF5DMNAwXj1skrn7rDfSvHxYMQtE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694755086; x=1695359886; 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=Z4avXvzursC+45bqw32CiKah19BSXYGGSK9tL8yLNEc=; b=v8i9lF0bR90DqOipd+HW9RmbmCbKGecNWMWkr7OIQGoyrFW79UhrWA67PP99JUDE9D u68STrz4CbGc/RPMmwGFiRLk+T+10xALDZM18pg3GrEPSHCTQXEhZ3oq+tic59LXuAUP JdjgQq2kVwhTNBw1T/p/x36crCfpQC0CqR4tsKxhXPaLAFWLxm0VP10jri8sGMgcxX6E 2kZZMYJdcf3rnbBonKzlR7Rrex2scJ+/k8p8Ze00EEAF+cRYuW8zRMkF7JFVid/2zci7 oXLKkp5J/ATg3DQte0hX5cL8pCS7bjvlumxvV/De3mUmau7GS2a/2qhcH+w5Vb96LigB 5nPg== X-Gm-Message-State: AOJu0YytznYknWQfdz4O06ycUsL6l4SsNsbf5o9lmuOWe/E2NU+msczC jo4++FTMrOdSaNCAAZgqfBcx+Q== X-Received: by 2002:a05:6a21:4849:b0:14c:ca56:69f7 with SMTP id au9-20020a056a21484900b0014cca5669f7mr797797pzc.28.1694755086219; Thu, 14 Sep 2023 22:18:06 -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 x53-20020a056a000bf500b0069029a2206bsm2147947pfu.47.2023.09.14.22.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 22:18:05 -0700 (PDT) Date: Thu, 14 Sep 2023 22:18:05 -0700 From: Kees Cook To: Justin Stitt Cc: Ed Brindley , Denis Pauk , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] hwmon: (asus_wmi_sensors) refactor deprecated strncpy Message-ID: <202309142217.52EEAEA1@keescook> References: <20230914-strncpy-drivers-hwmon-asus_wmi_sensors-c-v1-1-e1703cf91693@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230914-strncpy-drivers-hwmon-asus_wmi_sensors-c-v1-1-e1703cf91693@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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 14 Sep 2023 22:18:26 -0700 (PDT) On Thu, Sep 14, 2023 at 11:10:34PM +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 without > unnecessarily NUL-padding. If, for any reason, NUL-padding is needed > 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 A classic replacement. :) Reviewed-by: Kees Cook -- Kees Cook