Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp315233lqa; Sat, 27 Apr 2024 03:47:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXV5Trblwtjcu9pVstQSRmtXJiS8UX/U7HwVNNsrTV2B9DnJber1zfKbMy2/jj7qQ2GhOMSUTx7Oz4jnfueZ/x+j8Ir/6Xgxd2vedhjsg== X-Google-Smtp-Source: AGHT+IEdzt18c99UMpZsBvLP0sEIayBlk7Eo/X1N3yqUrVhpndJWESWuXD40ON8Wbhqpim/kfTFT X-Received: by 2002:a17:902:d883:b0:1e6:3577:1912 with SMTP id b3-20020a170902d88300b001e635771912mr6033107plz.25.1714214851125; Sat, 27 Apr 2024 03:47:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714214851; cv=pass; d=google.com; s=arc-20160816; b=pqce3lHAjMIvhcWzJ6F1y+CPiI9QLfCh2jVbEFoJLkTrIlEZ0ENDjljcKeOigfiyIQ ePLUNHvJyoR9FokmW1tcYh+w0ny2PCnxiMxj0eegS9/x2V6voKMTaWK9LSuHKqQOtDza vRrH1mjF7CrMkQgnwF8Wl7SFh37BqdkrMNnifEoio7DvDADOyFrIDE9GAhi+atTggDVb xZRZJi0u7RpauImfjIKpLBNo/V45pf2FStB29es+gFL0cmhmG0IA+e4zamq/E7SnzHsU qcISQ0LWZD8playWdYam0qTjpS8/YpwBIEtyogoD7DF7I181KRKbrLojCuboMtHZEI/P B1rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DTMOl6DkR80haOxeX0aHeHMbrPNbDpI6jKkL+E8KJOs=; fh=KgB/+zEuIKGTKBybnQkbvGp9VM14AaBimK+cuOr9LV8=; b=R5NcyTCM9CVz4pZL5pNwW8d8AyYcoixD7l+WdnQAbMC4e5vWTAWfwF7a0e2F7ROvqe 66Xwx2+y2tUAl8zdISkzm+6FXD6kHKoCL3dfIFQrnwatzFcV3SKc2U6onT4SmwQsq0lF uErmj2Q8OC5o9oBy9A8tOq5XQ1zGIFERzUKoaOtI/NuYFAzSEQIFPL19h5032zEOWXJ2 is/xGg9ZpymehVDO/FI9x8Q0mlHokYucZOyiX8Q+BDhP06OC+Lj9d/IvXVqbRwyksKIl 8bHTWNHARVy13r6K2WGEbeiDJnw2EmzjHFKa5Cu6Z3OT+Xtp91DF92OBqXyCsA9tmOJx UVLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rNeuQu1P; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-161001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a3-20020a170902900300b001e27f807a8esi16219193plp.343.2024.04.27.03.47.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 03:47:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rNeuQu1P; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-161001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F0132B21BCA for ; Sat, 27 Apr 2024 10:47:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73ADF43176; Sat, 27 Apr 2024 10:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rNeuQu1P" 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 905C5482C3 for ; Sat, 27 Apr 2024 10:47:17 +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=1714214837; cv=none; b=SUQsiCRjVn9vBvv9i59t1H4ChNQPYZsMCIpoGrbTKKJq1DwHq14kiuVHqNJqlcJGuojTRkppc6p1hUVoFPwitTbDnhWZ1b9am4x8ddNKUCHbu7NOIY7/9Clz/cxSoKzylLYcG+EbV7kj0UYtSCWjyEeTmKu8opQXFpbxRk8cj9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714214837; c=relaxed/simple; bh=V/KsT2l1lLKaNucqtbUkHPoat4/H53QLyxsOCUw6n2A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hbo1eirkI/xymmuCoD1toGjQl6DWQGqDG9b0iNwaAh5TzZEpQBN9ow3fOXejVhkoDG3dsAyPTfPeevBLyT/Il8mEsuKAF+RhTetzSL1aPartCDklqz3oeIToT1QXwsJx7gQIhv8xg8iFtbdG+6WBWQw3Pf7LXlIUW/zpjX6KlNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rNeuQu1P; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DB6FC113CE; Sat, 27 Apr 2024 10:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714214837; bh=V/KsT2l1lLKaNucqtbUkHPoat4/H53QLyxsOCUw6n2A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rNeuQu1PPnk7Z3rctJZ9paFPkHUt/8b4Y/QyMA1uFsGpFEj6A32E4wmPtYUF5cwNK gKlAwHWAzTFpj4Vjc7MWcRNsA3YQACT2bTfVXHoHc6YdAckvraj4r2h7s8NeA0Q3ir e74MkBaeCTDheAUGjt9NKJyqeoy/Mtbv/a4akiNs= Date: Sat, 27 Apr 2024 12:47:11 +0200 From: Greg Kroah-Hartman To: Lukas Wunner Cc: Dan Williams , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Alan Stern , Jonathan Cameron Subject: Re: [PATCH] sysfs: Allow bin_attributes to be added to groups Message-ID: <2024042736-radiance-unaired-c69c@gregkh> References: <662be72549aaf_db82d294c7@dwillia2-xfh.jf.intel.com.notmuch> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Apr 26, 2024 at 08:59:51PM +0200, Lukas Wunner wrote: > On Fri, Apr 26, 2024 at 10:40:53AM -0700, Dan Williams wrote: > > Lukas Wunner wrote: > > > Commit dfa87c824a9a ("sysfs: allow attributes to be added to groups") > > > introduced dynamic addition of sysfs attributes to groups. > > > > > > Allow the same for bin_attributes, in support of a forthcoming commit > > > which adds various bin_attributes every time a PCI device is > > > authenticated. > > > > > > Addition of bin_attributes to groups differs from regular attributes in > > > that different kernfs_ops are selected by sysfs_add_bin_file_mode_ns() > > > vis-?-vis sysfs_add_file_mode_ns(). > > > > > > So call either of those two functions from sysfs_add_file_to_group() > > > based on an additional boolean parameter and add two wrapper functions, > > > one for bin_attributes and another for regular attributes. > > > > > > Removal of bin_attributes from groups does not require a differentiation > > > for bin_attributes and can use the same code path as regular attributes. > > > > > > Signed-off-by: Lukas Wunner > > > Cc: Alan Stern > > > --- > > > Submitting this ahead of my PCI device authentication v2 patches. > > > Not sure if the patch is acceptable without an accompanying user, > > > but even if it's not, perhaps someone has early review feedback > > > or wants to provide an Acked-by? Thank you! > > > > On the one hand it makes sense from a symmetry perspective, on the other > > hand the expectation and the infrastructure for dynamic sysfs visibilty > > has increased since 2007. > > > > That is why I would like to see the use case to understand why a > > dynamically added a bin_attribute is needed compared with a statically > > defined attribute with dynamic visibility. > > I assume "would like to see" means "on the mailing list", which would > (or will) be as part of the PCI device authentication v2 patches. > > But in case you're curious, the use case is the log of signatures > presented by the device. Each signature is exposed as a bin_attribute > in a signatures/ directory below a PCI device's sysfs directory, > for verification by a remote attester (or user space in general). > > Here's the code: > > https://github.com/l1k/linux/commit/ca420b22af05 > > The signature's bin_attribute is accompanied by several other > bin_attributes containing ancillary data, such as nonces > (to allow user space to ascertain that a fresh nonce has been used). > > The signatures/ directory is an empty attribute group to which the > signatures received from the device are dynamically added using > sysfs_add_bin_file_to_group() (introduced by the present patch). > > All of that was done to address an objection raised by James Bottomley > at Plumbers that it is "not good enough" if the kernel keeps the > challenge-response received from the device to itself and doesn't > allow a remote attester to verify it. > > Here is the recording, in his own words: > > https://www.youtube.com/watch?v=ZqMIlZ5lPAw&t=2345s > > A static attribute with dynamic visibility doesn't cut it in this case: > > Each signature needs a unique filename and the number of signatures > that can be generated is essentially unlimited. (Though older ones > are likely uninteresting and can be culled.) If you want to expose, > say, up to 1000 signatures per device, you'd have to allocate an array > of 1000 signatures (for each device!), even though the actual number > of signatures received might be much lower. It would be a waste of > memory. It is much more economical to add signature attributes > dynamically on demand. > > It has the additional benefit that it allows user space to dynamically > adjust the maximum number of signatures retained in the log. > That's more difficult to implement with static attributes, as you'd > have to reallocate the attributes array and adjust all the pointers > pointing to it. Thanks for the details, that makes sense. And overall, the patch also looks good, so just include it in the patch series that uses it and I'll be glad to ack it then. thanks, greg k-h