Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1384048rdb; Fri, 9 Feb 2024 23:00:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFN+fgCEVQC+4xFg7KToXBO64pOQ1tWlddSfgJ5fr/Q3PSSQ7NAu7GtTz9QjCZ7B5cbjcCUYP3kR5TqqE5sln6T7cinNQgbxL71+2hRg== X-Google-Smtp-Source: AGHT+IEBT3GNLI2x+Q5qUq1ZqlggCZeSDvzLvpwMAVfu8fkF+Ut+s89eFhsWHCgWtioOMVezLM3G X-Received: by 2002:ad4:5aa5:0:b0:68c:cd9c:2fa7 with SMTP id u5-20020ad45aa5000000b0068ccd9c2fa7mr2759869qvg.5.1707548455847; Fri, 09 Feb 2024 23:00:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707548455; cv=pass; d=google.com; s=arc-20160816; b=uMk5YW2WgKMGN1HBMPoZy+o7vWaad7zdHzr/EmLajBr5PNnxukM/CKPZm3XHJWXLZy Wq7nB27fRpFGZ5dwEFFWU9optlwIi7pi5KmUbPrKxBzjlgoofv1tJb1kEFPeSybtdA5o YqWgyxgw8r4bJB9d1qFUGIjGg7Z8ssqO46L+V0PqRCAu78cGBngld8M3suYoVylHBkkS ehVKBaDprhOeVRoX+SBgxTnAAdbu+lFDQeM7+8oGn8w9CcPhp7YLVIPHACHMNqvwkI4y ohgflNpZ/mr18k4tK/AuAWy/KeGwL5DbFHUHCg8X5LeeJ0W3AGSBr/keWN9IeyIdK7fc 386w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VYFXmL9enl8Nqc0X2rjMzIeAy30W1fA7dyQuw3D2AfE=; fh=LtpyCZ34yOVYrv9i096MGr5n31m4Ackqkc8BzGIa8uQ=; b=S+eu+vJz1AQR0bFNbESIEmzfHd2yirvoZJLabfZy270gbsdMyBbNstpPEq/2kI40Pj KMONRCBXzrnHTOI/FDRmifv0dDWcb9uIvLQVEE8T/WPnGYKS1niXi+Ftrk9MVDglOqQo y6rL1IC5cLs5BOaOLodpAoE+i9Mhj64bAMDh9InkK//qQu87c+qcJp1+Vl1W2rzrhoTH epAKKxyog6GHYMOqtM1ESkNZ0aNllyJ1dhp1Klg+vzjJUNkvsSXx6cTfzEs89W0xUpve Z9yLIucx3iW7Y0cnqn9eRRSZ/NpuaPXBVaiOJ59WzJ7HuDS+dgaaCb7oFmD+F/imW/cW 2csA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZgZZGxVe; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60299-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCU1iLs+WxlWl1NO/7H0j6cdxYC19NaDC1hGvJTkTjEIVBQ3Kh9b6MxYfhdrgtnF3ZiABSMch3RT6PIpCclTystGW362c0+C2ACFSWP60A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v10-20020a05620a440a00b007858b6dd450si1289207qkp.460.2024.02.09.23.00.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:00:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60299-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZgZZGxVe; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60299-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 975D71C21023 for ; Sat, 10 Feb 2024 07:00:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D5FB53B8; Sat, 10 Feb 2024 07:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZgZZGxVe" Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 633D81A27C for ; Sat, 10 Feb 2024 07:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707548444; cv=none; b=b9KOFOAZlC+6n3HUT56fZuHfN2+yU0icrKg8USRcV8JGLMsVSv8DsTf+Oo6E4rXXUg5RCL19XccCPPtTyLCSueJeAyZr8jmBLkaI1C8NZtICczMxwkzkNoM/VeTCrZTwYmjXjAQXhnBIKrRQ8sYHLtJFPXgtQ5b6DWdeB+MleBw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707548444; c=relaxed/simple; bh=ZtjqAt2Yq4OUXIaX7R+nn8REMEEMKAok1ITHIzfkHpU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KF8VTX3eDo179yjWw/zj2LiC7n4OaMxij8hnJrb+yGeAMQP0xes84W6pH495LRkCp8xlzP6gp72drT5jSFJlYafgFkWtCeopgAt/nMvMiEIEeeByELt+awXCYoGy7yIS/mUc5Ej/ethS7DXS0u+/EsIn7/zNLsQO8oLkZfr+wEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ZgZZGxVe; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e08dd0fa0bso903191b3a.1 for ; Fri, 09 Feb 2024 23:00:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707548442; x=1708153242; 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=VYFXmL9enl8Nqc0X2rjMzIeAy30W1fA7dyQuw3D2AfE=; b=ZgZZGxVegADBa/vJ0QvpaaGIKdt6HvbthQ6iWa6PC511lD4lHJZRcT88WMG/C9Z14S XTf/1qnNfVAmkUpgRTq1qYfXnz1lyHuJN4zzLcmvOCiD+wZfrG8d7cM7MDpYaPaMaJQ7 uefJqtXusSUi603xRQRpnfIYCgOTgtvkRIhWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707548442; x=1708153242; 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=VYFXmL9enl8Nqc0X2rjMzIeAy30W1fA7dyQuw3D2AfE=; b=XrUHXiDn4DXxZYaCqqlL5edy2hUA1zFXYMzJU9/btE4ys4RB2ZFBu5YvtM9dL6FUQZ 4IPYjDMxUBscbIjKwUKhkO5CNtBOMgdAHZh4u9t8s48lObO9myeF7j/o7ctiSOd0dDXj ON5dsNfhu8l2H0nLPYEJkeXrW18mpWz4UDnlX3k6cvbx+H7pzt9PluXsXcgPNWn7LmkB Uy/MepmQd20q44ihC6xYspIxoJqbSxCn84Ztrd3Exeo9/8FbOr1//nczqENbUllzYncU unM+XQKPw0XLL8M8iiIwFaBD/SJY26kzXN9eZYNhJwNoWDsOwF5kccG0jM+GXi7phw8Z nrrQ== X-Gm-Message-State: AOJu0Yy8o9MQn4QoUHr7eMcF2+ecdsQ3M9KnobSLMd8lpaR0uV4cmooL 2KUlbRleXQpWJkjK0m7Y9aBaJq3JCIqSmwO5cqQj9qwVrehDf8EDVosTm1X8NUxoyIBHUpGRJx0 = X-Received: by 2002:a05:6a00:2ea4:b0:6e0:8a23:65c with SMTP id fd36-20020a056a002ea400b006e08a23065cmr4124497pfb.13.1707548442518; Fri, 09 Feb 2024 23:00:42 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWWp608kYFRN7GxPqnpTu3do8ixzLsypK9rb2cOgy8DretbLXf6U9LgS3fl4J6YFvzuT3urfnxFQM70mfsT7H2XGTBlZS/2lb/xg+3eJze6TBJMWeZANtt90ZGBLo/0dcCB7Blj8YBzn43NmSP6Y96IdbNljxZ+BM4AJ/lalD3ehAblvHy+kuBKAJw9Kcb00fQoJwoPKqRWoxgHT/Ivfu4XFWXCDyg/O/evDRu9SyhWmU6Mvi1VgkBFUj4nTxnX00UrmmUSe04p8Blk Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id ls53-20020a056a00743500b006e0967170bcsm1610335pfb.158.2024.02.09.23.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 23:00:42 -0800 (PST) Date: Fri, 9 Feb 2024 23:00:41 -0800 From: Kees Cook To: Lee Jones Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , "PMC-Sierra, Inc" , linux-scsi@vger.kernel.org Subject: Re: [PATCH 04/10] scsi: aacraid: linit: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Message-ID: <202402092300.926169D618@keescook> References: <20240208084512.3803250-1-lee@kernel.org> <20240208084512.3803250-5-lee@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240208084512.3803250-5-lee@kernel.org> On Thu, Feb 08, 2024 at 08:44:16AM +0000, Lee Jones wrote: > Since snprintf() has the documented, but still rather strange trait of > returning the length of the data that *would have been* written to the > array if space were available, rather than the arguably more useful > length of data *actually* written, it is usually considered wise to use > something else instead in order to avoid confusion. > > In the case of sysfs call-backs, new wrappers exist that do just that. > > Link: https://lwn.net/Articles/69419/ > Link: https://github.com/KSPP/linux/issues/105 > Signed-off-by: Lee Jones Yeah, better to use sysfs_emit(). Reviewed-by: Kees Cook -- Kees Cook