netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kovalev@altlinux.org
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, jiri@resnulli.us, jacob.e.keller@intel.com,
	johannes@sipsolutions.net, idosch@nvidia.com,
	kovalev@altlinux.org
Subject: [PATCH] genetlink: fix potencial use-after-free and null-ptr-deref in genl_dumpit()
Date: Thu, 15 Feb 2024 23:23:09 +0300	[thread overview]
Message-ID: <20240215202309.29723-1-kovalev@altlinux.org> (raw)

From: Vasiliy Kovalev <kovalev@altlinux.org>

The pernet operations structure for the subsystem must be registered
before registering the generic netlink family.

Fixes: 134e63756d5f ("genetlink: make netns aware")
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
 net/netlink/genetlink.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 8c7af02f845400..3bd628675a569f 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -1879,14 +1879,16 @@ static int __init genl_init(void)
 {
 	int err;
 
-	err = genl_register_family(&genl_ctrl);
-	if (err < 0)
-		goto problem;
-
 	err = register_pernet_subsys(&genl_pernet_ops);
 	if (err)
 		goto problem;
 
+	err = genl_register_family(&genl_ctrl);
+	if (err < 0) {
+		unregister_pernet_subsys(&genl_pernet_ops);
+		goto problem;
+	}
+
 	return 0;
 
 problem:
-- 
2.33.8


             reply	other threads:[~2024-02-15 20:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 20:23 kovalev [this message]
2024-02-19 11:32 ` [PATCH] genetlink: fix potencial use-after-free and null-ptr-deref in genl_dumpit() Simon Horman
2024-02-19 12:15   ` kovalev
2024-02-20 13:02     ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240215202309.29723-1-kovalev@altlinux.org \
    --to=kovalev@altlinux.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@resnulli.us \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).