Skip to contentSkip to conversation

feature_test_macros.7: document -D_FORTIFY_SOURCE=3

PATCH In review Sam James 2 participants 2 messages Oct 13, 2022 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

Sam James

author
#0 lore raw

PATCH v2 1/1 feature_test_macros.7: document -D_FORTIFY_SOURCE=3

Reference: https://developers.redhat.com/blog/2021/04/16/broadening-compiler-checks-for-buffer-overflows-in-_fortify_source
Reference: https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level

---
 man7/feature_test_macros.7 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
man7/feature_test_macros.7 +14 -0
index cdd962f7f..f057c1c87 100644
@@ -634,9 +634,23 @@ and result in compiler warnings;
 other checks take place at run time,
 and result in a run-time error if the check fails.
 .IP
+With
+.B _FORTIFY_SOURCE
+set to 3, additional checking is added to intercept some function
+calls used with an argument of variable size where the compiler can
+deduce an upper bound for its value.
+For example, a program where malloc's size argument is variable
+can now be fortified.
+.IP
 Use of this macro requires compiler support, available with
 .BR gcc (1)
 since version 4.0.
+.IP
+For use of
+.B _FORTIFY_SOURCE
+set to 3, then
+.BR gcc (1)
+version 12.0 or later is required.
 .SS Default definitions, implicit definitions, and combining definitions
 If no feature test macros are explicitly defined,
 then the following feature test macros are defined by default:
Signature · 1 line
2.38.0
#1 lore raw

Hi Sam,

Quoted 3 lines · Sam James

Reference: https://developers.redhat.com/blog/2021/04/16/broadening-compiler-checks-for-buffer-overflows-in-_fortify_source
Reference: https://developers.redhat.com/articles/2022/09/17/gccs-new-fortification-level

Patch applied.

Cheers,

Alex

Quoted 9 lines
---
  man7/feature_test_macros.7 | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
man7/feature_test_macros.7 +0 -0
index cdd962f7f..f057c1c87 100644

man7/feature_test_macros.7 and result in compiler warnings; · line 643

Quoted 10 lines
man7/feature_test_macros.7 +7 -0
@@ -634,9 +634,23 @@ and result in compiler warnings;
  other checks take place at run time,
  and result in a run-time error if the check fails.
  .IP
+With
+.B _FORTIFY_SOURCE
+set to 3, additional checking is added to intercept some function
+calls used with an argument of variable size where the compiler can
+deduce an upper bound for its value.
+For example, a program where malloc's size argument is variable
+can now be fortified.

I reflowed this text a little bit (rationale: semantic newlines), and also formatted malloc(3).

The mention to malloc(3) was useful, IMO :)

man7/feature_test_macros.7 and result in compiler warnings; · line 653

Quoted 10 lines
man7/feature_test_macros.7 +7 -0
+.IP
  Use of this macro requires compiler support, available with
  .BR gcc (1)
  since version 4.0.
+.IP
+For use of
+.B _FORTIFY_SOURCE
+set to 3, then
+.BR gcc (1)
+version 12.0 or later is required.

And reworded this a bit.

Quoted 3 lines
man7/feature_test_macros.7 +0 -0
  .SS Default definitions, implicit definitions, and combining definitions
  If no feature test macros are explicitly defined,
  then the following feature test macros are defined by default:
Signature · 1 line
<http://www.alejandro-colomar.es/>