Messages in this thread | | | From | Nick Desaulniers <> | Date | Thu, 3 Feb 2022 12:37:41 -0800 | Subject | Re: [PATCH v6 4/4] fortify: Add Clang support |
| |
On Thu, Feb 3, 2022 at 9:33 AM Kees Cook <keescook@chromium.org> wrote: > > Enable FORTIFY_SOURCE support for Clang: > > Use the new __pass_object_size and __overloadable attributes so > that Clang will have appropriate visibility into argument sizes such > that __builtin_object_size(p, 1) will behave correctly. Additional > details here: > https://github.com/llvm/llvm-project/issues/53516 > https://github.com/ClangBuiltLinux/linux/issues/1401 > > When available, use the new __diagnose_as attribute to make sure no > compile-time diagnostic warnings are lost due to the effectively renamed > string functions.
Consider adding something along the lines of the following to the above paragraph: Without diagnose_as, compile time error messages won't be as precise as they could be, but at least users of older toolchains will have fortified routines. That is more valuable, but certainly a tradeoff.
> > Redefine strlen() as a macro that tests for being a constant expression > so that strlen() can still be used in static initializers, which was > lost when adding __pass_object_size and __overloadable.
I'd like to see `const` changes explicit in 4/4; I suspect that's _why_ __overloadable is even needed? If so, then a comment here about that wouldn't hurt.
Having const be more explicit in the signature will make it more obvious why the definition cannot modify the parameter.
-- Thanks, ~Nick Desaulniers
| |