From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 DD85835974 for ; Sat, 28 Dec 2024 14:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735397829; cv=none; b=WT0dIDuJd0dXFYwRJraCegA+zRyYJSZDDP1RTHSe5NIDxwB+jU7+CnRd0ckh3DjqupsMVEhTrhJ534SvPPdx6K0333tsB8kIvhatEzkgyW6rXiBApkKK4ZpnJ7EqAQAf2fRVKQM/ygKpPBOvYW31wvKYzXEEvBkAdiTC/J6Kbf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735397829; c=relaxed/simple; bh=jC6uMctBnVepfIzJOTEHWpQzATLoJCA97xp6deJUoBo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K3QTlbPnYDvHxQG2ZjHNEol47A3ZFXm/CvFD6EBRgImGiFXE586wgYP1OskXtEr7lhKUzPWzx0RvJ/o0Hl+gG0dnwt7/nAWS1FhSGwQSV65OFx4LvdHWmiMBZewZ9/avTbW/zRJr223a1ilSEF4QlqlP3WBS0y90LIoTDd2QROc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=UyZ8HH2s; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="UyZ8HH2s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735397818; bh=jC6uMctBnVepfIzJOTEHWpQzATLoJCA97xp6deJUoBo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UyZ8HH2sV/dGICWwjC8Yy8ILb8ouwkguGiLgbdOKtEpyXCjg7arVsVs3Q/FnnWCaU /BkqZkV2JuihDfgF8HHGBZlx6P1QEAt4EDFbhzRbfy+Hjbso1FmYfRX3M4LRD2XZsX 9G5usd1RiBWqmqZ0KNYibcNRdjGOzLID7cn5gMwg= Date: Sat, 28 Dec 2024 15:56:53 +0100 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Masahiro Yamada Cc: "Joel Fernandes (Google)" , Greg Kroah-Hartman , Kees Cook , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] kheaders: Simplify attribute through __BIN_ATTR_SIMPLE_RO() Message-ID: References: <20241221-sysfs-const-bin_attr-kheaders-v2-1-8205538aa012@weissschuh.net> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi Masahiro, On 2024-12-28 23:52:13+0900, Masahiro Yamada wrote: > On Sat, Dec 21, 2024 at 11:09 PM Thomas Weißschuh wrote: > > > > The utility macro from the sysfs core is sufficient to implement this > > attribute. Make use of it. > > > > Signed-off-by: Thomas Weißschuh > > > Applied to linux-kbuild. Thanks. Thanks, but FYI it is also already applied to the driver-core tree. Unfortunately Greg's confirmation mails don't go to the list. IMO having an explicit maintainer for this file could avoid this issue in the future. > > --- > > Changes in v2: > > - Use __BIN_ATTR_SIMPLE_RO() (Thanks Masahiro) > > - Link to v1: https://lore.kernel.org/r/20241215-sysfs-const-bin_attr-kheaders-v1-1-319bbd50e224@weissschuh.net > > --- > > __BIN_ATTR() is used over the normal struct initializer because it is > > shorter and can also handle the transition to const struct bin_attr > > callbacks. > > If you prefer, I can switch that back, but it will introduce a trivial > > conflict with [0]. > > > > Note: There is no formal maintainer for that source file. > > > > [0] https://lore.kernel.org/lkml/20241205-sysfs-const-bin_attr-simple-v1-0-4a4e4ced71e3@weissschuh.net/ > > --- > > kernel/kheaders.c | 19 +++---------------- > > 1 file changed, 3 insertions(+), 16 deletions(-) > > > > diff --git a/kernel/kheaders.c b/kernel/kheaders.c > > index 42163c9e94e557c5043e2ac7987b567f23087ee2..378088b07f46d643736c04b9075f631e0dc2a53d 100644 > > --- a/kernel/kheaders.c > > +++ b/kernel/kheaders.c > > @@ -29,25 +29,12 @@ asm ( > > extern char kernel_headers_data[]; > > extern char kernel_headers_data_end[]; > > > > -static ssize_t > > -ikheaders_read(struct file *file, struct kobject *kobj, > > - struct bin_attribute *bin_attr, > > - char *buf, loff_t off, size_t len) > > -{ > > - memcpy(buf, &kernel_headers_data[off], len); > > - return len; > > -} > > - > > -static struct bin_attribute kheaders_attr __ro_after_init = { > > - .attr = { > > - .name = "kheaders.tar.xz", > > - .mode = 0444, > > - }, > > - .read = &ikheaders_read, > > -}; > > +static struct bin_attribute kheaders_attr __ro_after_init = > > + __BIN_ATTR_SIMPLE_RO(kheaders.tar.xz, 0444); > > > > static int __init ikheaders_init(void) > > { > > + kheaders_attr.private = kernel_headers_data; > > kheaders_attr.size = (kernel_headers_data_end - > > kernel_headers_data); > > return sysfs_create_bin_file(kernel_kobj, &kheaders_attr); > > > > --- > > base-commit: 499551201b5f4fd3c0618a3e95e3d0d15ea18f31 > > change-id: 20241215-sysfs-const-bin_attr-kheaders-440887f23892 > > > > Best regards, > > -- > > Thomas Weißschuh > > > > > -- > Best Regards > Masahiro Yamada