lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250912195339.20635-5-yana2bsh@gmail.com>
Date: Fri, 12 Sep 2025 22:53:27 +0300
From: Yana Bashlykova <yana2bsh@...il.com>
To: "David S. Miller" <davem@...emloft.net>
Cc: Yana Bashlykova <yana2bsh@...il.com>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	linux-kernel@...r.kernel.org,
	netdev@...r.kernel.org,
	lvc-project@...uxtesting.org
Subject: [PATCH 6.1 04/15] genetlink: add test case for duplicate genl family registration

Add incorrect_genl_family struct with duplicate name to test
error handling when registering families with conflicting names.

Signed-off-by: Yana Bashlykova <yana2bsh@...il.com>
---
 .../net-pf-16-proto-16-family-PARALLEL_GENL.c | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c b/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
index 17f869ece2d6..1db5d15a6f2c 100644
--- a/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
+++ b/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
@@ -1077,6 +1077,18 @@ static struct genl_family my_genl_family_parallel = {
 	.n_mcgrps = ARRAY_SIZE(genl_many_mcgrps_two),
 };
 
+// genl_family struct with incorrect name
+static struct genl_family incorrect_genl_family = {
+	.hdrsize = 0,
+	.name = MY_GENL_FAMILY_NAME,   // such family already exists
+	.version = MY_GENL_VERSION,
+	.maxattr = MY_GENL_ATTR_MAX,
+	.netnsok = true,
+	.ops = my_genl_ops,
+	.n_ops = ARRAY_SIZE(my_genl_ops),
+	.policy = my_genl_policy,
+};
+
 static int __init init_netlink(void)
 {
 	int rc;
@@ -1104,6 +1116,25 @@ static int __init init_netlink(void)
 	return rc;
 }
 
+static int __init incorrect_init_netlink(void)
+{
+	int rc;
+
+	pr_info("%s: My module. Initializing incorrect Netlink\n", __func__);
+
+	rc = genl_register_family(&incorrect_genl_family);
+	if (rc) {
+		pr_err("%s: Failed to register incorrect Generic Netlink family\n", __func__);
+		goto failure;
+	}
+
+	return 0;
+
+failure:
+	pr_info("%s: Error was handled correctly\n", __func__);
+	return -EINVAL;
+}
+
 static int __init init_sysfs_third_genl(void)
 {
 	int ret;
@@ -1215,6 +1246,10 @@ static int __init module_netlink_init(void)
 		goto err_sysfs;
 	pr_info("%s: New families are registered\n", __func__);
 
+	ret = incorrect_init_netlink();
+	if (ret)
+		pr_err("%s: Incorrect Generic Netlink family wasn't registered\n", __func__);
+
 	return 0;
 
 err_sysfs:
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ