mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@kernel.org>
To: Kyle Zeng <kylebot@openai.com>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, davem@davemloft.net,
	kuba@kernel.org, pabeni@redhat.com,
	outbounddisclosures@openai.com
Subject: Re: [PATCH net] netlink: avoid hashing the network namespace pointer
Date: Wed, 7 Oct 2026 07:42:44 +0200	[thread overview]
Message-ID: <40018dc8-0452-4dfa-95eb-2c401e117c39@kernel.org> (raw)
In-Reply-To: <20261006224149.50498-1-kylebot@openai.com>



On 10/7/26 00:41, Kyle Zeng wrote:
> The netlink rhashtable key includes a raw struct net pointer and a
> user-controlled port ID.  Both /proc/net/netlink and socket diagnostics
> expose the table's bucket order.  By binding and rebinding chosen
> NETLINK_USERSOCK port IDs, an unprivileged reader can distinguish equal
> buckets and recover the low bits of the Jenkins hash.  Its 32-bit seed
> and the limited set of kernel-image slides can then be searched offline
> to recover the address of init_net.
> 
> Use the namespace's unique, non-address ID in the comparison key
> instead.  This ID is assigned before the per-net initializers run and
> remains unchanged for the namespace's lifetime.  The lookup key and
> object hash are still built by netlink_compare_arg_init(), keeping
> lookup, insertion, removal and rehashing consistent while preserving
> namespace separation.  Neither public table walker needs to change.
> 

Please use net->net_cookie instead.

It has the same value in current trees (net->net_cookie = 
ns_tree_gen_id(net)),
but ns.ns_id only appeared in 6.18, while your Fixes: tag points to
a 2015 commit.

net_cookie is set at the top of setup_net() in stable kernels >= 5.15,
so backports would be trivial.

 >  struct netlink_compare_arg
 >  {
 > -       possible_net_t pnet;
 > +       u64 netns_id;

'netns_id' is confusing, we already have NETNSA_NSID and net->netns_ids.

 > -              !net_eq(sock_net(&nlk->sk), read_pnet(&x->pnet));
 > +              sock_net(&nlk->sk)->ns.ns_id != x->netns_id;

We now dereference sock_net() from netlink_compare(), under RCU,
possibly for a socket of a dismantling netns.

I think this is fine (sockets are freed after call_rcu(), and
cleanup_net() has an rcu_barrier() before freeing the netns),
but please mention it in the changelog.

Thanks.

      parent reply	other threads:[~2026-10-07  5:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 22:41 Kyle Zeng
2026-10-06 22:49 ` netdev-bot+sinfo
2026-10-07  5:24   ` Kyle Zeng
2026-10-07  5:42 ` Eric Dumazet [this message]

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=40018dc8-0452-4dfa-95eb-2c401e117c39@kernel.org \
    --to=edumazet@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kylebot@openai.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=outbounddisclosures@openai.com \
    --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

all inboxes | Powered by JetHome®