Re: [RFC] a possible way of reducing the PITA of ->d_name audits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 10 Sep 2025, Al Viro wrote:
> On Wed, Sep 10, 2025 at 12:45:41PM +1000, NeilBrown wrote:
> 
> >    - dentry is negative and a shared lock is held on parent inode.
> >      This is guaranteed for dentries passed to ->atomic_open when create
> >      is NOT set.
> 
> Umm...  The same goes for tmpfile dentry while it's still negative (nobody
> else could make it positive - it's only reachable via the parent's list
> of children and those who traverse such will ignore anything negative unhashed
> they find there.
> 
> > One thing I don't like is the name "unwrap_dentry()".  It says what is
> > done rather than what it means or what the purpose is.
> > Maybe "access_dentry()" (a bit like rcu_access_pointer()).
> > Maybe "dentry_of()" - then we would want to call stable dentries
> > "stable_foo" or similar.  So:
> > 
> >  static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> >                       struct stable_dentry stable_child, const char *content)
> 
> That has too much of over-the-top hungarian notation feel for my taste, TBH...
> 
> Note that these unwrap_dentry() are very likely to move into helpers - if some
> function is always called with unwrapped_dentry(something) as an argument,
> great, that's probably a candidate for struct stable_dentry.
> 
> I'll hold onto the current variant for now...
> 

Another idea - maybe we don't need "unwrap_dentry()" at all.
Just have
  struct stable_dentry {
       struct dentry *dentry;
  };

and code can use child.dentry.

There is no concern about people misusing unwrap_dentry() so there is no
need to be able to grep for it.  So we don't need it.

It is only uses of claim_stability() and of ->d_name and ->d_parent that we
might want to monitor.  So I imagine that one day all accesses to
->d_name and ->d_parent will be centralised either dentry_name() and
dentry_parent() or in fs/*.c code - and then we can rename them to
->_private_d_name and ->_private_d_parent or whatever to discourage
unwrapped access.

But accessing the dentry in a stable_dentry is safe and uninteresting so
there is no need to wrap it.

NeilBrown





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux