Messages in this thread | | | From | Kees Cook <> | Date | Wed, 4 Apr 2018 17:20:14 -0700 | Subject | Re: [GIT PULL] x86/build changes for v4.17 |
| |
On Wed, Apr 4, 2018 at 5:05 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote: > On Wed, Apr 4, 2018 at 4:31 PM, Matthias Kaehlcke <mka@chromium.org> wrote: >> >> From some experiments it looks like clang, in difference to gcc, does >> not treat constant values passed as parameters to inline function as >> constants. > > Yeah, I think gcc used to have those semantics a long time ago too. > > Many of our __builtin_constant_p() uses are indeed just in macros, but > certainly not all. > > Other examples are found in our "fortified" string functions. > > There a clang build will likely simply miss some of the build-time > fortification checks, and trigger them at runtime instead. > > Of course, we hopefully don't *have* any build-time failures, because > gcc will have caught them, so you won't care as long as clang is a > secondary compiler, but long-term they'd be good.
Yeah, it's used in inline functions in a lot of places. Some quickly jump out: kmalloc, crypto, bitmaps, networking, uaccess, kvm, etc from doing a dumb grep as:
git grep -B5 __builtin_constant_p | grep -A5 inline
FWIW, I prefer inline functions over macros just to keep type checking a some level of sanity when reading build warnings/errors. ;)
-Kees
-- Kees Cook Pixel Security
| |