Page MenuHomeFreeBSD

fix users of cn_flags for 64 bits
AcceptedPublic

Authored by sigsys_gmail.com on Apr 4 2020, 4:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 17, 5:26 AM
Unknown Object (File)
Fri, Nov 15, 5:41 PM
Unknown Object (File)
Thu, Nov 14, 4:07 PM
Unknown Object (File)
Thu, Nov 14, 11:30 AM
Unknown Object (File)
Thu, Nov 14, 7:34 AM
Unknown Object (File)
Mon, Nov 11, 7:49 PM
Unknown Object (File)
Mon, Nov 11, 2:36 PM
Unknown Object (File)
Sun, Nov 10, 12:33 AM
Subscribers

Details

Reviewers
kib
markj
Summary

namei's componentname struct has a cn_flags field that was changed to 64 bits at some point to allow for more flags, but some users of this field still treat it as an int (or sometimes long).

This patch fixes all of those that I could find.

I added the ULL suffix to the individual flag macro literals to make masking operations just work.

I changed some variables to bool but I was careful to do so in a way that would still work if bool is typedef'd to int.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Updated to use uint64_t instead of u_int64_t. No other changes.

kib added inline comments.
sys/sys/namei.h
193

Does the op arg need to be long ?

This revision is now accepted and ready to land.Apr 4 2020, 2:36 PM
markj added inline comments.
sys/fs/fuse/fuse_vnops.c
984โ€“986

I would make wantparent and islastcn into bools as well:

bool wantparent = (flags & (LOCKPARENT | WANTPARENT)) != 0;
bool islastcn = (flags & ISLASTCN) != 0;

just to explicitly avoid narrowing.

sys/fs/smbfs/smbfs_vnops.c
1199

Same as above regarding the use of a bool.

sys/fs/fuse/fuse_vnops.c
984โ€“986

Oops missed those ones. I'll update the diff.

sys/sys/namei.h
193

I can't see any reason it would need to be. It gets saved in int variables too sometimes.

But I just noticed an assert in vfs_lookup.c that checks if cn_nameiop gets "contaminated" with flags, so if the op is larger it allows to detect more errors like this.

Change some ints to bools in fuse_vnops.c. No other changes.

This revision now requires review to proceed.Apr 4 2020, 6:25 PM

Change some more variables to bool in smbfs_vnops.

sys/fs/smbfs/smbfs_vnops.c
1199

The two other variables could be changed to bool too. It seemed a bit silly not to do it since they're declared together.

This revision is now accepted and ready to land.Apr 4 2020, 7:55 PM