Re: [PATCH v7 04/43] fscrypt: conditionally don't wipe mk secret until the last active user is done

Eric Biggers <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs,org.kernel.vger.linux-block,org.kernel.vger.linux-fscrypt,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Wed, Aug 19, 2026 at 04:22:23PM +0200, Daniel Vacek wrote:
> > > +     /* We can't wipe the master key secret until the last activeref is
> > > +      * dropped on the master key with per-extent encryption since the key
> > > +      * derivation continues to happen as long as there are active refs.
> > > +      * Wipe it here now that we're done using it.
> > > +      */
> > > +     if (sb->s_cop->has_per_extent_encryption)
> > > +             wipe_master_key_secret(&mk->mk_secret);
> >
> > wipe_master_key_secret() is idempotent, so we might as well just do it
> > unconditionally here.
> 
> While this is true, it also (kind of) documents that the secret should
> already be wiped out by now in case of !extent encryption.
> 
> But I can wipe the secret unconditionally here if you insist.

So leave a comment that mentions that it's not always needed.  Just like
how fscrypt_free_master_key() does kfree_sensitive(), because why not.

- Eric
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.