Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp760237lqa; Sun, 28 Apr 2024 03:09:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbSvL6k6Wp8n2Uz6WNStDkdmr9Hhf7lQ/GKy7OICdJwTf0qmZuTbSi5spQERn2S7cbYbWntw29PMeGyp0cDl/O/r515iClB8AdHxnpHQ== X-Google-Smtp-Source: AGHT+IHIsCoE1M/CTnL6l/oqdrduxEXAkHHoXBTyC6q2uAa7MyOg+vyP/j9snf81qQrBGcdoeJwf X-Received: by 2002:ac2:4652:0:b0:51d:9bb5:3528 with SMTP id s18-20020ac24652000000b0051d9bb53528mr690555lfo.41.1714298943641; Sun, 28 Apr 2024 03:09:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714298943; cv=pass; d=google.com; s=arc-20160816; b=rpNuhJaSEm/EmchuvphELe6ToV+VpTVG9IRIhhsMJMNvDLj6k47WJ7fKB34AKGVrk7 oJ8BGCVnu9y6mH4Oo95WPYwth1X4Po/4MLMrAeHCm7dbUmTgQ7ad1APykER0UjnUbbzb ZBsgzX5hSKx0Ab96DygNnDzWd1wji31Km9yy0UfsRzy7lk5A7BOaPBBQVTz77Z9BNnp7 Q+PdBcLVp1IjTc1IIu4S3pPcZOXrWA9L/hFJs97Y2Svygw51WfZ9N+SzuHkjp04dTSy2 d0ymtf5e1EnAvbkIBEqABT3rYML/pqS+EzsI+oGW/MGmT4rQDeNOuMUpxCuLBZ9XWpi0 oAuA== 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; bh=sFVnM9VjTASA0RyWpFhDGBf3u/TDBOX66EzrmYWGUBI=; fh=wZGzu4d9oQHfpPNL8BlalrftecaQrBB1T6gt+biwRCA=; b=PEEUcHy6dinE7/u/m/mMbCW7RB0uXRkWlagxPX0VXi85l/drdQXHbPemehnsI52yxb qmjA3lGxDxyHw2oNN+sH4Hm+++sy8wQ7eNv9lZQvpe5YTQVTe9FnSBrdAUNmzeQpF1rD FQgXgKdYsPjySFw6zY0vde+qHFPR5YPLS55jqTyLkneYUmr2yLvopriYtlXdGq3t9Fwo H8w9GOdJdQbEFjgEbC9HBmYMV6QTOJYd8mWXHmLMr99vQu7SiuKA+vkfjoEXpIKcezzJ iNkEYXbFqTZsv9Sbhd7TuL3m5/NvoA0e/KL17Dqj/8592b+GgNGzFlViBjTW8/AQSRqM bJwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-161368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161368-linux.lists.archive=gmail.com@vger.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 l22-20020a170906079600b00a54c11dc738si3506679ejc.924.2024.04.28.03.09.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 03:09:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161368-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-161368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161368-linux.lists.archive=gmail.com@vger.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 5BF431F21156 for ; Sun, 28 Apr 2024 10:09:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97ACB56B6A; Sun, 28 Apr 2024 10:08:54 +0000 (UTC) Received: from bmailout2.hostsharing.net (bmailout2.hostsharing.net [83.223.78.240]) (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 66AF654BFC; Sun, 28 Apr 2024 10:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.223.78.240 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714298934; cv=none; b=LQYoZwgULTlFMwu2D1F+HzuQ16RvrEPun1qFMf53lV/DLiua1KY0O5Oh0gVS3oqpOWTWICbOP/x/fDRezSRKkYhP0ZsyXiTmaD843DaFAHl0pcAoJJFeTz9DCdJSZq5KTR0SImKYylSdAZufl3VZHZntfksPiIZsW3Qj8Uf/xSo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714298934; c=relaxed/simple; bh=TTARU/Xd9FlQOME2CIODtyLJRuvfgCO/Q3kMmgLEpAg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qdNQCGYj8L1lYuiMw11TX8nlT8CzQEmggXtZVczU3fWUBHhRN1JxYfTrSvVO36/9vpmPjsHZ8hBzQzfVlnW6GnE+pVb1fmMYM0OUhvfHNBZ643A3BCCgS26waUMkxfFX3WkGzL9XCqYftP0zJfr+YVmgwhb9PSq2xkrL3UrwZ7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=none smtp.mailfrom=h08.hostsharing.net; arc=none smtp.client-ip=83.223.78.240 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id 83873280072AE; Sun, 28 Apr 2024 12:08:43 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 4D1F555998; Sun, 28 Apr 2024 12:08:43 +0200 (CEST) Date: Sun, 28 Apr 2024 12:08:43 +0200 From: Lukas Wunner To: Dan Williams Cc: gregkh@linuxfoundation.org, Pierre-Louis Bossart , Marc Herbert , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-coco@lists.linux.dev, alsa-devel@alsa-project.org Subject: Re: [PATCH 1/3] sysfs: Fix crash on empty group attributes array Message-ID: References: <170863444851.1479840.10249410842428140526.stgit@dwillia2-xfh.jf.intel.com> <170863445442.1479840.1818801787239831650.stgit@dwillia2-xfh.jf.intel.com> <662beb6ad280f_db82d29458@dwillia2-xfh.jf.intel.com.notmuch> <662d2ca522cc6_b6e02942d@dwillia2-mobl3.amr.corp.intel.com.notmuch> <662d6f24528d7_b6e0294d2@dwillia2-mobl3.amr.corp.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=us-ascii Content-Disposition: inline In-Reply-To: <662d6f24528d7_b6e0294d2@dwillia2-mobl3.amr.corp.intel.com.notmuch> On Sat, Apr 27, 2024 at 02:33:24PM -0700, Dan Williams wrote: > Lukas Wunner wrote: > > Perhaps an optional ->is_group_visible() callback in struct attribute_group > > which gets passed only the struct kobject pointer? > > > > At least for PCI device authentication, that would be sufficient. > > I could get from the kobject to the corresponding struct device, > > then determine whether the device supports authentication or not. > > > > Because it's a new, optional callback, there should be no compatibility > > issues. The SYSFS_GROUP_INVISIBLE return code from the ->is_visible() > > call for individual attributes would not be needed then, at least in my > > use case. > > That's where I started with this, but decided it was overkill to > increase the size of that data structure globally for a small number of > use cases. Memory is cheap and memory-constrained devices can set CONFIG_SYSFS=n. There aren't that many struct attribute_groups and this is just 8 additional bytes on a 64-bit machine. (There are way more struct attribute than struct attribute_group.) The contortions necessary to overload individual attribute ->is_visible() callbacks to also govern the group's visibility aren't worth it. Having an ->is_group_visible() callback has the additional benefit that the mode of directories no longer needs to be hardcoded to 0755 in sysfs_create_dir_ns(), but can be set to, say, 0500 or 0700 or 0511, depending on the use case. So more flexibility there as well. Thanks, Lukas