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: <20150322211241.GA7925@gondor.apana.org.au>
Date:	Mon, 23 Mar 2015 08:12:41 +1100
From:	Herbert Xu <herbert@...dor.apana.org.au>
To:	Thomas Graf <tgraf@...g.ch>
Cc:	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <eric.dumazet@...il.com>,
	Patrick McHardy <kaber@...sh.net>,
	Josh Triplett <josh@...htriplett.org>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	netdev@...r.kernel.org
Subject: Re: [v2 PATCH 3/10] rhashtable: Allow hashfn to be unset

On Sun, Mar 22, 2015 at 12:32:57PM +0000, Thomas Graf wrote:
> On 03/22/15 at 11:04pm, Herbert Xu wrote:
> > On Sun, Mar 22, 2015 at 11:55:05AM +0000, Thomas Graf wrote:
> > > On 03/22/15 at 07:04pm, Herbert Xu wrote:
> > > > @@ -134,6 +136,7 @@ struct rhashtable {
> > > >  	struct bucket_table __rcu	*tbl;
> > > >  	atomic_t			nelems;
> > > >  	bool                            being_destroyed;
> > > > +	unsigned int			key_len;
> > > 
> > > Why is this needed? It looks like you're always initializing this
> > > with ht->p.key_len
> > 
> > It's ht->p.key_len/4 if we use jhash2.
> 
> Sure but why not just store key_len/4 in ht->p.key_len then if you
> opt in to jhash2() in rhashtable_init()?

Because that breaks rhashtable_compare/memcmp.

> 
> > > > +	if (!__builtin_constant_p(params.key_len))
> > > > +		hash = ht->p.hashfn(key, ht->key_len, tbl->hash_rnd);
> > > 
> > > I don't understand this. It looks like you only consider
> > > params->key_len if it's constant.
> > 
> > If params->key_len is not constant, then params == ht->p.
> 
> I must be missing something obvious. Who guarantees that? I can see
> that's true for the current callers but what prevents anybody from
> using rhashtable_lookup_fast() with a key length not known at compile
> time and pass it as rhashtable_params?

They shouldn't be doing that.  The whole point of this function
is to have it inlined so all external callers of it should be
supplying a constant parameter.  We could add a __ variant that
is only called by rhashtable if you like so we can enforce this
in rhashtable_lookup_fast.

> I still don't get this. Why do we fall back to jhash2() if
> params.key_len is set but not if only ht->p.key_len is set?

Because if params.key_len is not set then we have no idea whether
we should use jhash or jhash2 because ht->p.key_len cannot be
known at compile time.  This is only used by netfilter currently
as it has a key-length set at run-time.

Cheers,
-- 
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ