Page MenuHomeFreeBSD

kernel: Enable -fstack-protector-strong
ClosedPublic

Authored by markj on May 7 2026, 4:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 20, 3:53 PM
Unknown Object (File)
Tue, Jun 16, 9:13 PM
Unknown Object (File)
Tue, Jun 16, 11:29 AM
Unknown Object (File)
Thu, Jun 4, 10:15 PM
Unknown Object (File)
Sat, May 30, 2:33 PM
Unknown Object (File)
May 21 2026, 10:45 PM
Unknown Object (File)
May 21 2026, 1:14 PM
Unknown Object (File)
May 20 2026, 11:18 PM

Details

Summary

This extends stack canary use to all functions which perform operations
on arrays, not just those which operate on byte buffers.

Test Plan

I ran will-it-scale on a 16-core ryzen 7950X3D (hyperthreading enabled, will disable it if I do another run): https://people.freebsd.org/~markj/stack-protector-strong/will-it-scale2.html

The results aren't very conclusive. (will-it-scale also isn't a great test for this, but it's convenient and I have some scripts for it.) The stack-protector option changes the kernel's .text layout and I suspect that the small differences observed in the benchmark are a result of that rather than direct overhead of the option itself. In particular:

   text    data     bss     dec     hex filename
21042932        1756749 8728192 31527873        1e113c1 /boot/kernel.no-stack-protector/kernel
21142484        1756749 8728192 31627425        1e298a1 /boot/kernel.stack-protector/kernel
21485116        1756749 8728192 31970057        1e7d309 /boot/kernel.stack-protector-strong/kernel

and across the benchmarks there's no consistent "winner". I wouldn't expect the kernel to matter at all for the malloc 1KB benchmarks for instance, as there are no system calls happening.

With -fstack-protector-strong something like ~9000 functions in the kernel are covered, versus ~1500 by default. (This isn't counting kernel modules.)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.May 7 2026, 4:32 PM
olivier added a subscriber: olivier.

No performance impact (CPU usage increase) for our use case

This revision is now accepted and ready to land.May 12 2026, 9:02 PM
olce added a subscriber: olce.

Great!