From patchwork Fri Dec 27 13:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13921893 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 F29191F37A3; Fri, 27 Dec 2024 13:23:37 +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=1735305821; cv=none; b=j+QryEPE/C4Gx7XdMbj0LG/7d37JdZ/mqbmvwuFFZTUEly3dU4ZljGrPOUU3SHNpqJNTfi2ZpuUcHBfhCa0rM1rAGRDvm7CteSZugF14aKcIKTJ6B95FyuKurxTsxYZCKQWyRC0Obz+W1ATiaGTWua+MX15eVq9f5TaV8hUub8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735305821; c=relaxed/simple; bh=kPbX9vewD0+nconYwUSoLoEMScFyNi2Lagyw6lolf6c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QIywl/r6gUoNzkkijqPBYpzpSo820/t2nLpB49iO7IpXCV/KgC7qUtPfugl5TQfVVZqygZOIjs4tz7Al8CTZ4X1P3JF6oOlhioeM6SXyNdAA+Dq947chOjgHI2z9ztUWFx+OIvTGSGZZZtdl6qFqk01cUIFTpu1zEGGEKrnI/To= 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=OYRwV1Lx; 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="OYRwV1Lx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735305810; bh=kPbX9vewD0+nconYwUSoLoEMScFyNi2Lagyw6lolf6c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OYRwV1LxutLunu6Ity59v+8g3fJJTh2eCeyXIbJLWNQhtOIwVDx7jMMREsBOrK0ut QFyVgbxm5dElWbM1sMlJV+mSXup29YM9YlLZzvwhb7DwV0ArV8r3l/weoRLZ5P2ztE 0OnGyLMZvoasYZTsOUplofTi21yJ6W/tTkoWJZso= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 27 Dec 2024 14:23:20 +0100 Subject: [PATCH v2 1/6] module: sysfs: Drop member 'module_sect_attrs::nsections' Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241227-sysfs-const-bin_attr-module-v2-1-e267275f0f37@weissschuh.net> References: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> To: Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Kees Cook , "Gustavo A. R. Silva" Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735305809; l=1863; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=kPbX9vewD0+nconYwUSoLoEMScFyNi2Lagyw6lolf6c=; b=RcpP+ZL9Id2+eYyAu7kl1Eoqaek5pf5vxL1BluAJXsgmHJQGK2KcJE47Jc7GQ0N0uSoTJ4M/C 8j6i32V/JPPCAA+kVSK8Td027jC/v9CULXCmZswvQDcjtCpnyxaDThu X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The member is only used to iterate over all attributes in free_sect_attrs(). However the attribute group can already be used for that. Use the group and drop 'nsections'. Signed-off-by: Thomas Weißschuh --- kernel/module/sysfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c index 456358e1fdc43e6b5b24f383bbefa37812971174..b7841f76a933114e6dbd0fc2d32a60b66b7966b6 100644 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@ -26,7 +26,6 @@ struct module_sect_attr { struct module_sect_attrs { struct attribute_group grp; - unsigned int nsections; struct module_sect_attr attrs[]; }; @@ -62,10 +61,10 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj, static void free_sect_attrs(struct module_sect_attrs *sect_attrs) { - unsigned int section; + struct bin_attribute **bin_attr; - for (section = 0; section < sect_attrs->nsections; section++) - kfree(sect_attrs->attrs[section].battr.attr.name); + for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++) + kfree((*bin_attr)->attr.name); kfree(sect_attrs); } @@ -92,7 +91,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) sect_attrs->grp.name = "sections"; sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0]; - sect_attrs->nsections = 0; sattr = §_attrs->attrs[0]; gattr = §_attrs->grp.bin_attrs[0]; for (i = 0; i < info->hdr->e_shnum; i++) { @@ -108,7 +106,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) ret = -ENOMEM; goto out; } - sect_attrs->nsections++; sattr->battr.read = module_sect_read; sattr->battr.size = MODULE_SECT_READ_SIZE; sattr->battr.attr.mode = 0400; From patchwork Fri Dec 27 13:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13921895 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 F28BC1F2C56; Fri, 27 Dec 2024 13:23:37 +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=1735305821; cv=none; b=epLt0DDSFRERcU4gb4S3asN3zft+O3ZUr/h9+fkKr+K4N+tQkSX77x8ga5CkR77XzoqUxLpxAqv2LHlPFfPNCqJbGPPohnQwQ30pQ3hy2OeeE3O+olPA5OZGjgt7Rr0p63LNom6U33/0UAHcNmmGY3gak6tkozDjwYxvvHUlbeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735305821; c=relaxed/simple; bh=NyHZ3hkjhrnYderQwPxSsaZMIcwAhrt2JhACazI/sTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R3CqeJs8etwQbWCSosE6kFKA/aoB47VJdr979sNpxje6220fBYKKmU1ixx8VTIxMiXJQZ7X+jgyYUgTFEiYugQyQt4Vv+RSxVa4adE2gwMjooxvFDL46VNc5J46uueM45i4m9xtdygM1i7yQOZj/oArnsDq0g9V/Q3gGUIExqBU= 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=pooX4bma; 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="pooX4bma" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735305810; bh=NyHZ3hkjhrnYderQwPxSsaZMIcwAhrt2JhACazI/sTg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pooX4bma7jAaRAWYjllADvOAvPpwInQfV7wIyNjk9Na0P/qFKr5jT77K1WXfyiO8L z9Wi8zvig7q6xHiyWPkYsgFc2SY8qXf1xlvdOda98JUrHNModmr/Zs/caFowflrUk5 k4dK2jG/gIcYjkzcWH0OiyJJxNajn357jqgrMgfk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 27 Dec 2024 14:23:21 +0100 Subject: [PATCH v2 2/6] module: sysfs: Drop member 'module_sect_attr::address' Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241227-sysfs-const-bin_attr-module-v2-2-e267275f0f37@weissschuh.net> References: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> To: Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Kees Cook , "Gustavo A. R. Silva" Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735305809; l=2030; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=NyHZ3hkjhrnYderQwPxSsaZMIcwAhrt2JhACazI/sTg=; b=qorr1OiOp9Q218uSJEB+xwCv3OxULp3uoZXXNx+skBODc2tr9b+7YqaekUGi0Ky6uD7ntxi0p n0ZAHDJTOvvA+AROQEn1wa0l2vUPZhO0YWP9BSu0Gv5uQTkDbwFGWdY X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 'struct bin_attribute' already contains the member 'private' to pass custom data to the attribute handlers. Use that instead of the custom 'address' member. Signed-off-by: Thomas Weißschuh --- kernel/module/sysfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c index b7841f76a933114e6dbd0fc2d32a60b66b7966b6..8955b3da1b499881256670418d41c5d52d9e5a5e 100644 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@ -21,7 +21,6 @@ #ifdef CONFIG_KALLSYMS struct module_sect_attr { struct bin_attribute battr; - unsigned long address; }; struct module_sect_attrs { @@ -34,8 +33,6 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj, struct bin_attribute *battr, char *buf, loff_t pos, size_t count) { - struct module_sect_attr *sattr = - container_of(battr, struct module_sect_attr, battr); char bounce[MODULE_SECT_READ_SIZE + 1]; size_t wrote; @@ -52,7 +49,7 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj, */ wrote = scnprintf(bounce, sizeof(bounce), "0x%px\n", kallsyms_show_value(file->f_cred) - ? (void *)sattr->address : NULL); + ? battr->private : NULL); count = min(count, wrote); memcpy(buf, bounce, count); @@ -99,7 +96,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) if (sect_empty(sec)) continue; sysfs_bin_attr_init(&sattr->battr); - sattr->address = sec->sh_addr; sattr->battr.attr.name = kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL); if (!sattr->battr.attr.name) { @@ -107,6 +103,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) goto out; } sattr->battr.read = module_sect_read; + sattr->battr.private = (void *)sec->sh_addr; sattr->battr.size = MODULE_SECT_READ_SIZE; sattr->battr.attr.mode = 0400; *(gattr++) = &(sattr++)->battr; From patchwork Fri Dec 27 13:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13921899 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 B78611F4288; Fri, 27 Dec 2024 13:23:42 +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=1735305824; cv=none; b=l9beJq1IZjqM/s+rnXewddxzeTLzyl0gizps3VbC7ikH9GxICYGXwMbJTUPCmtXLNELgsLtZVWsT+8c2bW9/VI389zQpS/q5YA59Hn0+YNPLHgYdwg5yRc9qHc9AXR8MpugXndtu45b2eYqoo6QMZDQmmwk1EJxAUWQu67TYUNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735305824; c=relaxed/simple; bh=FhZcpa+oH0AuaI//x4ZCk0kWcoGzPTmlzuGyc897LEI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cQFg2xloxcfJUsdjttg6EmDDp4OWU0cWa95LOooRLcjI67uOFBW9JkXwGwYsn77kIuEtd/5FxnnHFLSYy1ET/UR5wlrCeeycSsYN/5Qnimd/AJL8wAVgfHO3uM91SPJaUQ4uO7LR9IdDtKbqQTwddlymbnGHNArfQvvDyV5Jd0s= 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=tvnGtSfe; 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="tvnGtSfe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735305810; bh=FhZcpa+oH0AuaI//x4ZCk0kWcoGzPTmlzuGyc897LEI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tvnGtSfePS7SbtytS/Caiv2qPt+/8KzLete/W1WoHxfOLXkeS2cgegg680xcEtsJy 0FfQAUY8da68c1UR4weIpx1DwjDe3LSba74o150reC+zDGirDwKMf7PHd1gi3Ab8hJ 9VRvKGLZ9Veb+EuK/ePCvOKHwWVbdg9jiw/P7ps0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 27 Dec 2024 14:23:22 +0100 Subject: [PATCH v2 3/6] module: sysfs: Drop 'struct module_sect_attr' Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241227-sysfs-const-bin_attr-module-v2-3-e267275f0f37@weissschuh.net> References: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> To: Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Kees Cook , "Gustavo A. R. Silva" Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735305809; l=2536; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FhZcpa+oH0AuaI//x4ZCk0kWcoGzPTmlzuGyc897LEI=; b=u0qKz3BMtEpVGZXUui3SoMB/EwETgeN08i19n73QAIeK4X/aiflTBqEyt4MDXvG7NGaEOmPsS 6L5hReKxg6tCSIhs3ntGT8bWm7LnzZF8Aend7nQMZtcRYudgyQWCyTk X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This is now an otherwise empty wrapper around a 'struct bin_attribute', not providing any functionality. Remove it. Signed-off-by: Thomas Weißschuh --- kernel/module/sysfs.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c index 8955b3da1b499881256670418d41c5d52d9e5a5e..3d507005d7111b8328c04d35476a73193f73db1c 100644 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@ -19,13 +19,9 @@ * J. Corbet */ #ifdef CONFIG_KALLSYMS -struct module_sect_attr { - struct bin_attribute battr; -}; - struct module_sect_attrs { struct attribute_group grp; - struct module_sect_attr attrs[]; + struct bin_attribute attrs[]; }; #define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4)) @@ -69,8 +65,8 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) { unsigned int nloaded = 0, i, size[2]; struct module_sect_attrs *sect_attrs; - struct module_sect_attr *sattr; struct bin_attribute **gattr; + struct bin_attribute *sattr; int ret; /* Count loaded sections and allocate structures */ @@ -95,18 +91,18 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) if (sect_empty(sec)) continue; - sysfs_bin_attr_init(&sattr->battr); - sattr->battr.attr.name = + sysfs_bin_attr_init(sattr); + sattr->attr.name = kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL); - if (!sattr->battr.attr.name) { + if (!sattr->attr.name) { ret = -ENOMEM; goto out; } - sattr->battr.read = module_sect_read; - sattr->battr.private = (void *)sec->sh_addr; - sattr->battr.size = MODULE_SECT_READ_SIZE; - sattr->battr.attr.mode = 0400; - *(gattr++) = &(sattr++)->battr; + sattr->read = module_sect_read; + sattr->private = (void *)sec->sh_addr; + sattr->size = MODULE_SECT_READ_SIZE; + sattr->attr.mode = 0400; + *(gattr++) = sattr++; } *gattr = NULL; @@ -186,7 +182,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info) continue; if (info->sechdrs[i].sh_type == SHT_NOTE) { sysfs_bin_attr_init(nattr); - nattr->attr.name = mod->sect_attrs->attrs[loaded].battr.attr.name; + nattr->attr.name = mod->sect_attrs->attrs[loaded].attr.name; nattr->attr.mode = 0444; nattr->size = info->sechdrs[i].sh_size; nattr->private = (void *)info->sechdrs[i].sh_addr; From patchwork Fri Dec 27 13:23:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13921897 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 79A251F37B3; Fri, 27 Dec 2024 13:23:38 +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=1735305822; cv=none; b=VUJeEP4T+khOzGLK9Fgb7Q6P70ClKT47fRMdJRMn2lsF1tQEdp7C3vMfmZ4iNgO5u7g8ezbEu16thpabXwxtgUCZnk8ExbOcVpRtc9WCI+4RLkR6blURFWNtNF8ocf+La6qEiwxElqd1SfDFX4dRPeL7GFiIptvnn65wB8MAtAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735305822; c=relaxed/simple; bh=TeyRT5JwHtydwOLRe+G9myQi3F2An6hZMnH1NE1+//Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nDSq0IQ1D1D3yzqyo7O1kU1cPbnmVoMTV7OzOb1yDId/HvBVtXunICLkvhLovoRqOj+LrBm3Jz9kHnl1GvS8cDLQo9XcJdvM3zYf9Iuh/Thf3w3RNgakUtO4P1eQJorgc0F2azVejfeTy0SmeL2K5J8jtFPW5nwTpcS5FDBIP74= 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=ErO0Eyfw; 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="ErO0Eyfw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735305810; bh=TeyRT5JwHtydwOLRe+G9myQi3F2An6hZMnH1NE1+//Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ErO0EyfwpJv4YcgA0xEAQyMyAgyvTaIIA9SN8RxjyvTHd23Z7Fw0tQYnCge5xyrKY JyCaK6uuSvJYNRncgqIrU4I94559WBt5PsywXa02X3KUE9SsGoXw7JrT3MgKYKK0nu zOAuCZ1gedhxx7B9ZmIIdNKIm6CkKmPb7lFCTZxc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 27 Dec 2024 14:23:23 +0100 Subject: [PATCH v2 4/6] module: sysfs: Simplify section attribute allocation Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241227-sysfs-const-bin_attr-module-v2-4-e267275f0f37@weissschuh.net> References: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> To: Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Kees Cook , "Gustavo A. R. Silva" Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735305809; l=2389; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=TeyRT5JwHtydwOLRe+G9myQi3F2An6hZMnH1NE1+//Q=; b=4onz1NiJHT4zTS9zmwM5XcRg3R14uRSF1rP8uasu1EbRr0ytOJcRLvLiR5EDV9baUxCGpbov2 Z/KhXztuL2EB+5vuB9/MsVc+NZJMc5p+wINsKzT5ijldDCarvCaP6X6 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The existing allocation logic manually stuffs two allocations into one. This is hard to understand and of limited value, given that all the section names are allocated on their own anyways. Une one allocation per datastructure. Signed-off-by: Thomas Weißschuh --- kernel/module/sysfs.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c index 3d507005d7111b8328c04d35476a73193f73db1c..4b1a963b712b609cde1c4375e789a6ee7f359c7a 100644 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@ -58,34 +58,37 @@ static void free_sect_attrs(struct module_sect_attrs *sect_attrs) for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++) kfree((*bin_attr)->attr.name); + kfree(sect_attrs->grp.bin_attrs); kfree(sect_attrs); } static int add_sect_attrs(struct module *mod, const struct load_info *info) { - unsigned int nloaded = 0, i, size[2]; struct module_sect_attrs *sect_attrs; struct bin_attribute **gattr; struct bin_attribute *sattr; + unsigned int nloaded = 0, i; int ret; /* Count loaded sections and allocate structures */ for (i = 0; i < info->hdr->e_shnum; i++) if (!sect_empty(&info->sechdrs[i])) nloaded++; - size[0] = ALIGN(struct_size(sect_attrs, attrs, nloaded), - sizeof(sect_attrs->grp.bin_attrs[0])); - size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.bin_attrs[0]); - sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL); + sect_attrs = kzalloc(struct_size(sect_attrs, attrs, nloaded), GFP_KERNEL); if (!sect_attrs) return -ENOMEM; + gattr = kcalloc(nloaded + 1, sizeof(*gattr), GFP_KERNEL); + if (!gattr) { + kfree(sect_attrs); + return -ENOMEM; + } + /* Setup section attributes. */ sect_attrs->grp.name = "sections"; - sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0]; + sect_attrs->grp.bin_attrs = gattr; sattr = §_attrs->attrs[0]; - gattr = §_attrs->grp.bin_attrs[0]; for (i = 0; i < info->hdr->e_shnum; i++) { Elf_Shdr *sec = &info->sechdrs[i]; @@ -104,7 +107,6 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) sattr->attr.mode = 0400; *(gattr++) = sattr++; } - *gattr = NULL; ret = sysfs_create_group(&mod->mkobj.kobj, §_attrs->grp); if (ret) From patchwork Fri Dec 27 13:23:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13921896 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 7995E1F37AD; Fri, 27 Dec 2024 13:23:38 +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=1735305821; cv=none; b=qttBwbinkKr919ugDxpxTPo6o8Od6cBiRcXfPiEWjdbb1hCIKbqiir95fnkPp3MJDMaSMvmTtR/OXvzUFmswqe3u3hZSdRUMDWYt3BYrS4Cdo7SVkzKx8MZnSeUvCAbPwlnC++9XrSn/iEohS/MM2JObC7TrJkdhBsymbxfcggI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735305821; c=relaxed/simple; bh=K02KJuxHoyR3doDRIJgCmzfosr6MYLp9M2UJxLzc+pw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bCbDdrq4lwlH7knbuqst0nia63bz92q2yaWo2Or5DNc6Au3caSutO8gbnytUtt8f8b+rDunDQovN5DbpF9K25RSt3Qv9jKhTZwkPSKUJQ1dZ8DpNCW9PWh6khbxscwEpwmtM0y1MvDnM74la12v6YK6kjbpvw3yqpzI0sI9HSYM= 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=WxAzzrvX; 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="WxAzzrvX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735305810; bh=K02KJuxHoyR3doDRIJgCmzfosr6MYLp9M2UJxLzc+pw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WxAzzrvX6I9x+DRGo4tI5HllXQSsE23PnCt+7cUWcxn4ZXOwOAP4lZbEhH5zJhary uTHlRtjf5A4ZVWteDBW7zU80a1E9mmvyRX4sC8UnWSZLlpZ/iJeo8+8OVaVE1irCvC 8u/nwk5Kwerx6bJwLcX0hUKjdxVg1gN0OYM7cFvw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 27 Dec 2024 14:23:24 +0100 Subject: [PATCH v2 5/6] module: sysfs: Add notes attributes through attribute_group Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241227-sysfs-const-bin_attr-module-v2-5-e267275f0f37@weissschuh.net> References: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> To: Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Kees Cook , "Gustavo A. R. Silva" Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735305809; l=3549; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=K02KJuxHoyR3doDRIJgCmzfosr6MYLp9M2UJxLzc+pw=; b=7xBBtyCfmRqKo+9VgUdWzdBI8PeiiNgD0iy3kGRotz2l4vcAuDwJWpicTJfUsFaVZOZi4T4uv F8PZPjR29StCHtT72pSrMPC781lI64QHJSDMlfYbKDXfcZyGHjyYKci X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= A kobject is meant to manage the lifecycle of some resource. However the module sysfs code only creates a kobject to get a "notes" subdirectory in sysfs. This can be achieved easier and cheaper by using a sysfs group. Switch the notes attribute code to such a group, similar to how the section allocation in the same file already works. Signed-off-by: Thomas Weißschuh --- kernel/module/sysfs.c | 54 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c index 4b1a963b712b609cde1c4375e789a6ee7f359c7a..d04cb12eac7be63dd0bb65bd55e97280e7875e4e 100644 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@ -138,20 +138,13 @@ static void remove_sect_attrs(struct module *mod) */ struct module_notes_attrs { - struct kobject *dir; - unsigned int notes; - struct bin_attribute attrs[] __counted_by(notes); + struct attribute_group grp; + struct bin_attribute attrs[]; }; -static void free_notes_attrs(struct module_notes_attrs *notes_attrs, - unsigned int i) +static void free_notes_attrs(struct module_notes_attrs *notes_attrs) { - if (notes_attrs->dir) { - while (i-- > 0) - sysfs_remove_bin_file(notes_attrs->dir, - ¬es_attrs->attrs[i]); - kobject_put(notes_attrs->dir); - } + kfree(notes_attrs->grp.bin_attrs); kfree(notes_attrs); } @@ -159,6 +152,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info) { unsigned int notes, loaded, i; struct module_notes_attrs *notes_attrs; + struct bin_attribute **gattr; struct bin_attribute *nattr; int ret; @@ -177,7 +171,15 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info) if (!notes_attrs) return -ENOMEM; - notes_attrs->notes = notes; + gattr = kcalloc(notes + 1, sizeof(*gattr), GFP_KERNEL); + if (!gattr) { + kfree(notes_attrs); + return -ENOMEM; + } + + notes_attrs->grp.name = "notes"; + notes_attrs->grp.bin_attrs = gattr; + nattr = ¬es_attrs->attrs[0]; for (loaded = i = 0; i < info->hdr->e_shnum; ++i) { if (sect_empty(&info->sechdrs[i])) @@ -189,35 +191,35 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info) nattr->size = info->sechdrs[i].sh_size; nattr->private = (void *)info->sechdrs[i].sh_addr; nattr->read = sysfs_bin_attr_simple_read; - ++nattr; + *(gattr++) = nattr++; } ++loaded; } - notes_attrs->dir = kobject_create_and_add("notes", &mod->mkobj.kobj); - if (!notes_attrs->dir) { - ret = -ENOMEM; + ret = sysfs_create_group(&mod->mkobj.kobj, ¬es_attrs->grp); + if (ret) goto out; - } - - for (i = 0; i < notes; ++i) { - ret = sysfs_create_bin_file(notes_attrs->dir, ¬es_attrs->attrs[i]); - if (ret) - goto out; - } mod->notes_attrs = notes_attrs; return 0; out: - free_notes_attrs(notes_attrs, i); + free_notes_attrs(notes_attrs); return ret; } static void remove_notes_attrs(struct module *mod) { - if (mod->notes_attrs) - free_notes_attrs(mod->notes_attrs, mod->notes_attrs->notes); + if (mod->notes_attrs) { + sysfs_remove_group(&mod->mkobj.kobj, + &mod->notes_attrs->grp); + /* + * We are positive that no one is using any notes attrs + * at this point. Deallocate immediately. + */ + free_notes_attrs(mod->notes_attrs); + mod->notes_attrs = NULL; + } } #else /* !CONFIG_KALLSYMS */ From patchwork Fri Dec 27 13:23:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13921894 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 799D11F37AE; Fri, 27 Dec 2024 13:23:38 +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=1735305821; cv=none; b=AnRQMHordknCfObVwPsYfRs0rhxfwzEqs4gcWdf969mRMKP0rAv5JO4R52u/V7AkIGVO434wAjqR+XED6pqszJFBRimHSsD86RmfQJm5MGJ1P3cssKCvQ8vX+FFe+8vWP9rnVRs+f6Jy/lYOr+NrI7TihjLE9d97A112tdPM3SY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735305821; c=relaxed/simple; bh=QoqqZMdscJifL85sSU4W8OY4Djn0uzs7qpMPaw0acy0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=raYTK0SE0WP/163n7PqtYXErCIFx79RyS9rsOHSyylZxtpLYEP5TEyW4kx/0XiK3YcReCcTEAydIwaarrx/zeXypANP/m6/VGjoEoDU2ogZcFGg2Zgi54Pr1gzmB7ltDFfArIL8Le+JBnXNn5EZoY83xy2HcGTB/h06JugoHhQ0= 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=IZweKvep; 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="IZweKvep" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1735305810; bh=QoqqZMdscJifL85sSU4W8OY4Djn0uzs7qpMPaw0acy0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IZweKvepjmNrroQf7LtKcfatQkN+yorL/6R2ymJD7ZCmmEI792MIwp1sXzBlT1C5O 3hMJiXYij7GpMFTGDmdiv82vSLgrisgIAP0PxVCxLS+pHNmswNhLsOBxfbmwPBC0/n 7/932UB1IfmN76G5BULIDU0Ms16jHDdS67GpC/mQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 27 Dec 2024 14:23:25 +0100 Subject: [PATCH v2 6/6] module: sysfs: Use const 'struct bin_attribute' Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241227-sysfs-const-bin_attr-module-v2-6-e267275f0f37@weissschuh.net> References: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> In-Reply-To: <20241227-sysfs-const-bin_attr-module-v2-0-e267275f0f37@weissschuh.net> To: Luis Chamberlain , Petr Pavlu , Sami Tolvanen , Daniel Gomez , Kees Cook , "Gustavo A. R. Silva" Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735305809; l=3169; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=QoqqZMdscJifL85sSU4W8OY4Djn0uzs7qpMPaw0acy0=; b=GuaY64bsgH40d08xbPdonBvAes0cdWVElxunF+rL4jI1VlFfWopEe02t5GzNyq1ZVbNcu+jj/ TxfzRl6frftArjL8DhH1HxBUujw56qi592q0GzRInSqBG+odDVfhKHW X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The sysfs core is switching to 'const struct bin_attribute's. Prepare for that. Signed-off-by: Thomas Weißschuh --- kernel/module/sysfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/module/sysfs.c b/kernel/module/sysfs.c index d04cb12eac7be63dd0bb65bd55e97280e7875e4e..853745e353381204161541c6f29bf97c42ec6df3 100644 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@ -26,7 +26,7 @@ struct module_sect_attrs { #define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4)) static ssize_t module_sect_read(struct file *file, struct kobject *kobj, - struct bin_attribute *battr, + const struct bin_attribute *battr, char *buf, loff_t pos, size_t count) { char bounce[MODULE_SECT_READ_SIZE + 1]; @@ -54,18 +54,18 @@ static ssize_t module_sect_read(struct file *file, struct kobject *kobj, static void free_sect_attrs(struct module_sect_attrs *sect_attrs) { - struct bin_attribute **bin_attr; + const struct bin_attribute *const *bin_attr; - for (bin_attr = sect_attrs->grp.bin_attrs; *bin_attr; bin_attr++) + for (bin_attr = sect_attrs->grp.bin_attrs_new; *bin_attr; bin_attr++) kfree((*bin_attr)->attr.name); - kfree(sect_attrs->grp.bin_attrs); + kfree(sect_attrs->grp.bin_attrs_new); kfree(sect_attrs); } static int add_sect_attrs(struct module *mod, const struct load_info *info) { struct module_sect_attrs *sect_attrs; - struct bin_attribute **gattr; + const struct bin_attribute **gattr; struct bin_attribute *sattr; unsigned int nloaded = 0, i; int ret; @@ -86,7 +86,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) /* Setup section attributes. */ sect_attrs->grp.name = "sections"; - sect_attrs->grp.bin_attrs = gattr; + sect_attrs->grp.bin_attrs_new = gattr; sattr = §_attrs->attrs[0]; for (i = 0; i < info->hdr->e_shnum; i++) { @@ -101,7 +101,7 @@ static int add_sect_attrs(struct module *mod, const struct load_info *info) ret = -ENOMEM; goto out; } - sattr->read = module_sect_read; + sattr->read_new = module_sect_read; sattr->private = (void *)sec->sh_addr; sattr->size = MODULE_SECT_READ_SIZE; sattr->attr.mode = 0400; @@ -144,7 +144,7 @@ struct module_notes_attrs { static void free_notes_attrs(struct module_notes_attrs *notes_attrs) { - kfree(notes_attrs->grp.bin_attrs); + kfree(notes_attrs->grp.bin_attrs_new); kfree(notes_attrs); } @@ -152,7 +152,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info) { unsigned int notes, loaded, i; struct module_notes_attrs *notes_attrs; - struct bin_attribute **gattr; + const struct bin_attribute **gattr; struct bin_attribute *nattr; int ret; @@ -178,7 +178,7 @@ static int add_notes_attrs(struct module *mod, const struct load_info *info) } notes_attrs->grp.name = "notes"; - notes_attrs->grp.bin_attrs = gattr; + notes_attrs->grp.bin_attrs_new = gattr; nattr = ¬es_attrs->attrs[0]; for (loaded = i = 0; i < info->hdr->e_shnum; ++i) {