Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp97999lqo; Wed, 27 Mar 2024 07:57:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOnUZhgLNsarXif22x9PZm0/yTcqLz823Yb49SUdRG1B+igWBmqrenRO5pbxc+lRfutfvxcddUL72EctMvga7J7cp7bBu3BqLMPBm1hg== X-Google-Smtp-Source: AGHT+IEOalJ9vuolXU5s+Z824dbzqnkH++4MaZSfpdl92EihML3eFJouQxc60GFIFXTvEbALLXXx X-Received: by 2002:a50:8e1d:0:b0:56c:2d52:617a with SMTP id 29-20020a508e1d000000b0056c2d52617amr7751edw.34.1711551450982; Wed, 27 Mar 2024 07:57:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711551450; cv=pass; d=google.com; s=arc-20160816; b=M6xR+i2scI/k+meA7clB5/U3q4B4FDq+vsllOZ1XswMUkGTiPETVYxsRKu/FloSfDx AOeLjz6ZhBvFn9rizrykrqiRWWyDmcjtKqp1BtisFcs9xV2nk7den+Ryw+Vbeuy63+b+ sZ3hBWhOc5rC2UqvoPHH+61KH+znlyKkCeC09ZdK4daqpY9+LiJdlW2cHlNDRuWaCcT8 xjxEEwOiBYEuUiyWrJdhpu3zKF+hwN5MpKFd59zQJoUA5LDM8xgVZGYAJWNOIuiMY0Vc 36O48vIXhfAEcYHdsfmQ+CgZ4333bqmJHOK9i8/kfViOsUy/atRjQcL2t4kHZ9L+h3gq ZRBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=tVLIT5t1INVDtLpZQY5ZygDpBgaF6JQvNghvbszneic=; fh=AXddIJvWqTKKX3H+xghVXkHIROQGzYGuNLhB1R3+plU=; b=XE6wyhXn8uLNcsE5ymZnIzzfTKlSaE8Y1C7BXtvsCGGkgJEYCIpGdh0fi9pcbFN6UH 0gJlRzMEruiITtgfS7dJnOtwKoTSDn2VVv+6jgoUcIciBWaVsfBMXPWnh074n7egOAti ZYbjqGZ0Ja5rhCwNyl2lOdGEkbyTfyIDjw4udx9/I794jYoN99RFu3Ei5A4xg9fn6O/9 nS7LGR2WTdr1m2pgyKzeyoVC0/t/89PZ3WJC9m8rFM/5honGu4o+Xlvj/PjQQV4AFE+h c54Xfr7Ah44i0q3rZ0+UhswGxWrHn9awjQCbRJ4/agRI0+z4lo/drqnXdPgqV61spN4p 9ZGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cwrJOIvV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-121397-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121397-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dj23-20020a05640231b700b005682d10babbsi4771095edb.391.2024.03.27.07.57.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 07:57:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121397-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cwrJOIvV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-121397-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121397-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2B29B1F315E9 for ; Wed, 27 Mar 2024 14:57:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4545130A5E; Wed, 27 Mar 2024 13:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cwrJOIvV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E57985F86B; Wed, 27 Mar 2024 13:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711547955; cv=none; b=QkaQrteERu+kdwKjoaWesqAI0JzYLuIqym2/vp15CLoTgCpGaJGqSmw/E0eGhMFzMlZYDj81EFLHjT8fQKtUfmKDWhjU5+FbEz2wUv72gwKD38YBuGCdSiY/jyvz7bmKPaA0CDFydxxi987X0llwBDgz4rQn1AFw4L7p4airOz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711547955; c=relaxed/simple; bh=y7yN0TthxO4uWT3oRU9hlOqPj8ktWodvttgpdiryghw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sWiZKSrLVOPtzlbkEk0O3LTcWJN7Gs4y/yGuY0podTxNyVgwspMs4OGiN77e0PqX/y66T+MeUlLpaLPAQo2iIQUCDduy0K7JPpWp/6vqD6fE5GMjYSvL3DaA2EDXNguGy1IJaUfoj6f2A6GIvHnFKlIGRMa4MkieLh2ab59QJhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cwrJOIvV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79C8CC433F1; Wed, 27 Mar 2024 13:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711547954; bh=y7yN0TthxO4uWT3oRU9hlOqPj8ktWodvttgpdiryghw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cwrJOIvV5CojMqp/G6F7olo4S1tgohbPYJNr8D18I6Xe8/gCy3YU7162zMWt4QK+f EoW5+SfY+ruoZWnfN5vPydVFr9X7+lGmKw9dVOGGH/jVAzFWMOXzSSVrDSPa9pd4Pi OrRra25o7GrOYEoafJ3m/NcGQoJkGjr3hTbKlS37omZUNaXXC9AvcN8BhWr4Ytchec Ux/3PtYyAg3EhBjwUqGzlK0ct1HO4L/Hgst2+86qz8amhKlFlJUKuA3t8GdqwYFtyz senzZEKL1gsLqPtXdUlxs9ZJBD2bMkWIVqvM7TqM+3lOrbfDg1fEDvyENlciOw+hd0 nOP+Uygii8/pA== Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-5a46b30857bso1692118eaf.1; Wed, 27 Mar 2024 06:59:14 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCU6TjLfFmP6aINZnc0Wy9gPmzUayE6Q9p1V+R7fVlBTBaswr4xQ8zk4A5ZP2LNVMHiVHqJCHg3dIatDxtni+MWVxoNgu5Hm4ZAdygvipYwsiURqEqudpmuSP6xOf8kUy0eJLMQ2e+T1OKF4Wd+glBaWBCbtXxrLPRLOkcwWQH6S3V5f12vAbnQ= X-Gm-Message-State: AOJu0YwSHRFwIFgE9cbJxa0oDXa6cNTDlTM9v+TYWrA8lwb6o4ICUe6l H1IzHiZ/Yc0AoQ1Pys4rIpAoDfG7Kres94dVy2nb8sgxooKAzTDA+eQS+omnP/CBu5raGHFNQeL pntlbUrc7damscNnDWogLyyBDKJU= X-Received: by 2002:a05:6870:d252:b0:229:e747:6f56 with SMTP id h18-20020a056870d25200b00229e7476f56mr12486707oac.3.1711547953856; Wed, 27 Mar 2024 06:59:13 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240318-strncpy-drivers-thermal-intel-int340x_thermal-acpi_thermal_rel-c-v1-1-08839fbf737a@google.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 27 Mar 2024 14:59:02 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] thermal: intel: int340x_thermal: replace deprecated strncpy with strscpy To: srinivas pandruvada , Justin Stitt Cc: Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-pm@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 On Tue, Mar 19, 2024 at 5:20=E2=80=AFPM srinivas pandruvada wrote: > > On Tue, 2024-03-19 at 12:39 +0100, Rafael J. Wysocki wrote: > > On Mon, Mar 18, 2024 at 11:36=E2=80=AFPM 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. > > > > > > psvt->limit.string can only be 8 bytes so let's use the appropriate > > > size > > > macro ACPI_LIMIT_STR_MAX_LEN. > > > > > > Neither psvt->limit.string or psvt_user[i].limit.string requires > > > the > > > NUL-padding behavior that strncpy() provides as they have both been > > > filled with NUL-bytes prior to the string operation. > > > > memset(&psvt->limit, 0, sizeof(u64)); > > > and > > > > psvt_user =3D kzalloc(psvt_len, GFP_KERNEL); > > > > > > Let's use `strscpy` [2] due to the fact that it guarantees > > > NUL-termination on the destination buffer without unnecessarily > > > NUL-padding. > > > > > > Link: > > > https://www.kernel.org/doc/html/latest/process/deprecated.html#strncp= y-on-nul-terminated-strings > > > [1] > > > Link: > > > https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.htm= l > > > [2] > > > Link: https://github.com/KSPP/linux/issues/90 > > > Cc: linux-hardening@vger.kernel.org > > > Signed-off-by: Justin Stitt > > > > Srinivas, any objections? > No > > Reviewed-by: Srinivas Pandruvada Applied as 6.10 material, thanks!