fortify: Explicitly check bounds are compile-time constants
authorKees Cook <keescook@chromium.org>
Mon, 19 Sep 2022 23:33:33 +0000 (16:33 -0700)
committerKees Cook <keescook@chromium.org>
Mon, 26 Sep 2022 18:01:32 +0000 (11:01 -0700)
commitfa35198f39571bbdae53c5b321020021eaad6bd2
tree93875fff4a34cec43dfa48cea3ac90fca53ac0d3
parent3e1730842f142add55dc658929221521a9ea62b6
fortify: Explicitly check bounds are compile-time constants

In preparation for replacing __builtin_object_size() with
__builtin_dynamic_object_size(), all the compile-time size checks
need to check that the bounds comparisons are, in fact, known at
compile-time. Enforce what was guaranteed with __bos(). In other words,
since all uses of __bos() were constant expressions, it was not required
to test for this. When these change to __bdos(), they _may_ be constant
expressions, and the checks are only valid when the prior condition
holds. This results in no binary differences.

Cc: linux-hardening@vger.kernel.org
Link: https://lore.kernel.org/lkml/20220920192202.190793-3-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
include/linux/fortify-string.h