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)
Wed, May 1, 2:57 AM
Unknown Object (File)
Tue, Apr 30, 6:04 PM
Unknown Object (File)
Tue, Apr 30, 6:04 PM
Unknown Object (File)
Tue, Apr 30, 6:04 PM
Unknown Object (File)
Tue, Apr 30, 5:53 PM
Unknown Object (File)
Tue, Apr 30, 5:53 PM
Unknown Object (File)
Tue, Apr 30, 2:04 PM
Unknown Object (File)
Sun, Apr 28, 11:42 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