This removes mac_label_copyin32() as mac_label_copyin() can now handle
both native and 32-bit struct mac objects.
Obtained from: CheriBSD
Sponsored by: AFRL, DARPA
Differential D53755
MAC: Use the current thread's user ABI to determine the layout of struct mac Authored by jhb on Fri, Nov 14, 2:55 PM. Tags None Referenced Files
Details
Diff Detail
Event Timeline
Comment Actions Well, this isn't a generated stub so using void * could be ok, OTOH, it is now always passed something like wcred->cr_label in which case it is typed (though user_setcred intentionally discards that type) and it might be nice to keep what type checking you do get there (so that for internal APIs a compat user pointer is always treated as the native user pointer). Most places where we deal with user pointers though they are just one type and not polymorphic as in this case. Globally changing all user pointers would definitely be a net negative, but using void * here is probably fine. Comment Actions user_setcred() passes mac_label_copyin() wcred->cr_label, yes, but the latter is only used as a temporary pointer storage until after mac_label_copyin(), and thus one cannot assume that wcred->sc_label is of type struct mac * before mac_label_copyin(). I re-used wcred->sc_label for semantics (grouping information in a single struct setcred), at the expense of making the code not really "type clean" before mac_label_copyin(). That could be changed if you think it would be clearer in the 32-bit case to copy the label pointer in umac directly and have wcred->sc_label filled only by mac_label_copyin(). In any case, the umac argument to mac_label_copyin() really can be a pointer to struct mac or struct mac32, so a type of struct mac * is deceptive (it's an input parameter, not an output one, and I don't see a reason to temporarily derogate to the type here, contrary to what is described in the previous paragraph). Having a pointer to union here would probably be overkill, but would be the exact expression of what umac really is. void * is already a compromise, with the benefit that you can't dereference umac by error.
I'd probably have a slightly different take here, but that doesn't matter much anyway since I think we can have the best of both worlds (keep the real type, but enforce the pointer is not dereferenced), which I'll try to hack as soon as I have more time. It certainly can wait though if you think this is going to interfere badly with Cheri upstreaming. Comment Actions Please don't add Linux-style __user annotations. Every single one will be a conflict in CheriBSD because in hybrid C mode (not being upstreamed to FreeBSD) we add a qualifier to the *pointer* saying that it is a capability. __user annotations apply to the thing being pointed to, not the pointer itself so we can not use them as they are in the wrong position. Comment Actions Please add Effort: CHERI upstreaming to the commit message so we count this as part of that effort. Comment Actions Admittedly I haven't played with attributes recently. I think the quite cumbersome GCC documentation on Attribute Syntax is nonetheless clear about the fact that an attribute placed before the semi-colon applies to the object being declared, so would apply to the pointer itself, by contrast with putting an attribute in the specifiers/qualifiers list of a declaration. Does your experience suggest otherwise? A couple of other points:
| ||||||||||||||||||||||||||||||||||||||||||||||||||