Re: [PATCH v2 61/63] struct mount: relocate MNT_WRITE_HOLD bit

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

 



On Thu, Aug 28, 2025 at 04:31:56PM -0700, Linus Torvalds wrote:

> Same largely goes for that
> 
> > -       struct mount **mnt_pprev_for_sb;/* except that LSB of pprev will be stolen */
> > +       unsigned long mnt_pprev_for_sb; /* except that LSB of pprev is stolen */
> 
> change, but at least there it's now a 'unsigned long', so it will
> *always* complain if a cast is missing in either direction. That's
> better, but still horrendously ugly.
> 
> If you want to use an opaque type, then please make it be truly
> opaque. Not 'unsigned long'. And certainly not 'void *'. Make it be
> something that is still type-safe - you can make up a pointer to
> struct name that is never actually declared, so that it's basically a
> unique type (or two separate types for mnt_pprev_for_sb and
> 
> I'm not even clear on why you did this change, but if you want to have
> specific types for some reason, make them *really* specific. Don't
> make them 'void *', and 'unsigned long'.

What I want to avoid is compiler seeing something like
	(unsigned long)READ_ONCE(m->mnt_pprev_for_sb) & 1
and going "that thing is a pointer to struct mount *, either the address
is even or it's an undefined behaviour and I can do whatever I want
anyway; optimize it to 0".

unsigned long is a brute-force way to avoid that - it avoids UB (OK, avoids
it as long as no struct mount instance has an odd address), so compiler can't
start playing silly buggers.

If you have a prettier approach, I'd like to hear it - I obviously do not
enjoy the way this one looks.




[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