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: <20260123072700.GN5910@frogsfrogsfrogs>
Date: Thu, 22 Jan 2026 23:27:00 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: Christoph Hellwig <hch@....de>
Cc: Eric Biggers <ebiggers@...nel.org>, Al Viro <viro@...iv.linux.org.uk>,
	Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
	David Sterba <dsterba@...e.com>, Theodore Ts'o <tytso@....edu>,
	Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>,
	Andrey Albershteyn <aalbersh@...hat.com>,
	"Matthew Wilcox (Oracle)" <willy@...radead.org>,
	linux-fsdevel@...r.kernel.org, linux-btrfs@...r.kernel.org,
	linux-ext4@...r.kernel.org, linux-f2fs-devel@...ts.sourceforge.net,
	fsverity@...ts.linux.dev
Subject: Re: [PATCH 11/11] fsverity: use a hashtable to find the fsverity_info

On Fri, Jan 23, 2026 at 06:27:23AM +0100, Christoph Hellwig wrote:
> On Thu, Jan 22, 2026 at 02:04:20PM -0800, Darrick J. Wong wrote:
> > On Thu, Jan 22, 2026 at 09:22:07AM +0100, Christoph Hellwig wrote:
> > > Use the kernel's resizable hash table to find the fsverity_info.  This
> > 
> > Oh is that what the 'r' stands for?  I thought it was rcu.  Maybe it's
> > both. :P
> 
> From the lib/rhashtable.c:
> 
>  * Resizable, Scalable, Concurrent Hash Table
> 
> > > Because insertation into the hash table now happens before S_VERITY is
> > > set, fsverity just becomes a barrier and a flag check and doesn't have
> > > to look up the fsverity_info at all, so there is only one two two
> > 
> > "one two two" <confused>?
> 
> one or two, sorry.  The cover letter actually explains this in more
> detail, which this should be updated to.
> 
> > > +static const struct rhashtable_params fsverity_info_hash_params = {
> > > +	.key_len		= sizeof(struct inode *),
> > 
> > 	.key_len		= sizeof_field(struct fsverity_info, inode),
> > 
> > Perhaps?
> 
> That should work, yes.
> 
> > > -	kfree(vi->tree_params.hashstate);
> > > -	kvfree(vi->hash_block_verified);
> > > -	kmem_cache_free(fsverity_info_cachep, vi);
> > > +	return rhashtable_lookup_fast(&fsverity_info_hash, &inode,
> > > +			fsverity_info_hash_params);
> > 
> > Hrm.  The rhashtable stores a pointer to the rhash_head, but now we're
> > returning that as if it were a fsverity_info pointer.  Can I be pedantic
> > and ask for a proper container_of() to avoid leaving a landmine if the
> > struct layout ever changes?
> 
> rhashtable_lookup_fast returns the struct containing the rhash_head.
> The paramters store the rhead_offset for that purpose.  See rht_obj
> as used by rhashtable_lookup.

Ahah.  That's right, but (imo) a weird quirk of the rhashtable
interface.  Though I only say that because *I* keep tripping over that;
maybe everyone else is ok.

> > > @@ -323,9 +323,9 @@ fsverity_init_verification_context(struct fsverity_verification_context *ctx,
> > >  				   struct fsverity_info *vi)
> > >  {
> > >  	ctx->inode = inode;
> > > -	ctx->vi = vi;
> > 
> > Can this function drop its @vi argument?
> 
> No..
> 
> > 
> > > +	ctx->vi = fsverity_get_info(inode);
> 
> ... but this extra lookup should have been removed and got messed up by a
> rebase, causing a pointless extra lookup.  (Which still is completely
> in the noise in my runs).

Ah ok, I was mildly confused by all this.

--D

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ