Skip to content

Commit 8bd51a2

Browse files
committed
gcc-plugins: Explicitly document purpose and deprecation schedule
GCC plugins should only exist when some compiler feature needs to be proven but does not exist in either GCC nor Clang. For example, if a desired feature is already in Clang, it should be added to GCC upstream. Document this explicitly. Additionally, mark the plugins with matching upstream GCC features as removable past their respective GCC versions. Cc: Masahiro Yamada <[email protected]> Cc: Michal Marek <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: James Morris <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Reviewed-by: Miguel Ojeda <[email protected]> Acked-by: Nick Desaulniers <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6eb4bd9 commit 8bd51a2

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

Documentation/kbuild/gcc-plugins.rst

+26
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ This infrastructure was ported from grsecurity [6]_ and PaX [7]_.
3232
.. [7] https://pax.grsecurity.net/
3333
3434
35+
Purpose
36+
=======
37+
38+
GCC plugins are designed to provide a place to experiment with potential
39+
compiler features that are neither in GCC nor Clang upstream. Once
40+
their utility is proven, the goal is to upstream the feature into GCC
41+
(and Clang), and then to finally remove them from the kernel once the
42+
feature is available in all supported versions of GCC.
43+
44+
Specifically, new plugins should implement only features that have no
45+
upstream compiler support (in either GCC or Clang).
46+
47+
When a feature exists in Clang but not GCC, effort should be made to
48+
bring the feature to upstream GCC (rather than just as a kernel-specific
49+
GCC plugin), so the entire ecosystem can benefit from it.
50+
51+
Similarly, even if a feature provided by a GCC plugin does *not* exist
52+
in Clang, but the feature is proven to be useful, effort should be spent
53+
to upstream the feature to GCC (and Clang).
54+
55+
After a feature is available in upstream GCC, the plugin will be made
56+
unbuildable for the corresponding GCC version (and later). Once all
57+
kernel-supported versions of GCC provide the feature, the plugin will
58+
be removed from the kernel.
59+
60+
3561
Files
3662
=====
3763

scripts/gcc-plugins/Kconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ config GCC_PLUGIN_CYC_COMPLEXITY
3737

3838
config GCC_PLUGIN_SANCOV
3939
bool
40+
# Plugin can be removed once the kernel only supports GCC 6+
41+
depends on !CC_HAS_SANCOV_TRACE_PC
4042
help
4143
This plugin inserts a __sanitizer_cov_trace_pc() call at the start of
4244
basic blocks. It supports all gcc versions with plugin support (from
@@ -83,8 +85,6 @@ config GCC_PLUGIN_RANDSTRUCT
8385
the existing seed and will be removed by a make mrproper or
8486
make distclean.
8587

86-
Note that the implementation requires gcc 4.7 or newer.
87-
8888
This plugin was ported from grsecurity/PaX. More information at:
8989
* https://grsecurity.net/
9090
* https://pax.grsecurity.net/

security/Kconfig.hardening

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ choice
5656

5757
config GCC_PLUGIN_STRUCTLEAK_USER
5858
bool "zero-init structs marked for userspace (weak)"
59-
depends on GCC_PLUGINS
59+
# Plugin can be removed once the kernel only supports GCC 12+
60+
depends on GCC_PLUGINS && !CC_HAS_AUTO_VAR_INIT_ZERO
6061
select GCC_PLUGIN_STRUCTLEAK
6162
help
6263
Zero-initialize any structures on the stack containing
@@ -67,7 +68,8 @@ choice
6768

6869
config GCC_PLUGIN_STRUCTLEAK_BYREF
6970
bool "zero-init structs passed by reference (strong)"
70-
depends on GCC_PLUGINS
71+
# Plugin can be removed once the kernel only supports GCC 12+
72+
depends on GCC_PLUGINS && !CC_HAS_AUTO_VAR_INIT_ZERO
7173
depends on !(KASAN && KASAN_STACK)
7274
select GCC_PLUGIN_STRUCTLEAK
7375
help
@@ -85,7 +87,8 @@ choice
8587

8688
config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL
8789
bool "zero-init everything passed by reference (very strong)"
88-
depends on GCC_PLUGINS
90+
# Plugin can be removed once the kernel only supports GCC 12+
91+
depends on GCC_PLUGINS && !CC_HAS_AUTO_VAR_INIT_ZERO
8992
depends on !(KASAN && KASAN_STACK)
9093
select GCC_PLUGIN_STRUCTLEAK
9194
help

0 commit comments

Comments
 (0)