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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <677d27cc5d9b_25382b294fd@willemb.c.googlers.com.notmuch>
Date: Tue, 07 Jan 2025 08:10:36 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Jakub Kicinski <kuba@...nel.org>, 
 davem@...emloft.net
Cc: netdev@...r.kernel.org, 
 edumazet@...gle.com, 
 pabeni@...hat.com, 
 Jakub Kicinski <kuba@...nel.org>, 
 stable@...r.kernel.org, 
 jdamato@...tly.com, 
 almasrymina@...gle.com, 
 amritha.nambiar@...el.com, 
 sridhar.samudrala@...el.com
Subject: Re: [PATCH net] netdev: prevent accessing NAPI instances from another
 namespace

Jakub Kicinski wrote:
> The NAPI IDs were not fully exposed to user space prior to the netlink
> API, so they were never namespaced. The netlink API must ensure that
> at the very least NAPI instance belongs to the same netns as the owner
> of the genl sock.
> 
> napi_by_id() can become static now, but it needs to move because of
> dev_get_by_napi_id().
> 
> Cc: stable@...r.kernel.org
> Fixes: 1287c1ae0fc2 ("netdev-genl: Support setting per-NAPI config values")
> Fixes: 27f91aaf49b3 ("netdev-genl: Add netlink framework functions for napi")
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> Splitting this into fix per-version is a bit tricky, because we need
> to replace the napi_by_id() helper with a better one. I'll send the
> stable versions manually.
> 
> CC: jdamato@...tly.com
> CC: almasrymina@...gle.com
> CC: amritha.nambiar@...el.com
> CC: sridhar.samudrala@...el.com
> ---
>  net/core/dev.c         | 43 +++++++++++++++++++++++++++++-------------
>  net/core/dev.h         |  3 ++-
>  net/core/netdev-genl.c |  6 ++----
>  3 files changed, 34 insertions(+), 18 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 7c63d97b13c1..e001df4cb486 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -753,6 +753,36 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
>  }
>  EXPORT_SYMBOL_GPL(dev_fill_forward_path);
>  
> +/* must be called under rcu_read_lock(), as we dont take a reference */
> +static struct napi_struct *napi_by_id(unsigned int napi_id)
> +{
> +	unsigned int hash = napi_id % HASH_SIZE(napi_hash);
> +	struct napi_struct *napi;
> +
> +	hlist_for_each_entry_rcu(napi, &napi_hash[hash], napi_hash_node)
> +		if (napi->napi_id == napi_id)
> +			return napi;
> +
> +	return NULL;
> +}
> +
> +/* must be called under rcu_read_lock(), as we dont take a reference */

Instead of function comments, invariant checks in code?

Like in dev_get_by_napi_id:

        WARN_ON_ONCE(!rcu_read_lock_held());

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ