Skip to content

[PW_SID:1099248] riscv: cfi: reduce shadow stack size limit from 2GB to 512MB#1995

Closed
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1099248
Closed

[PW_SID:1099248] riscv: cfi: reduce shadow stack size limit from 2GB to 512MB#1995
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1099248

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1099248 applied to workflow__riscv__fixes

Name: riscv: cfi: reduce shadow stack size limit from 2GB to 512MB
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1099248
Version: 1

Linux RISC-V bot and others added 2 commits May 22, 2026 06:39
Change the shadow stack size calculation from RLIMIT_STACK/2 (capped at
2GB) to RLIMIT_STACK/8 (capped at 512MB), following David Laight's
analysis and recommendation.

Rationale:

David Laight pointed out that the focus should be on the ratio between
shadow stack size and the normal stack size, rather than just the
absolute upper limit. His analysis showed that while there are many
functions with small stack frames, the majority have stack deltas of
over 64 bytes due to saved registers and local variables.

Shadow stacks only store return addresses (8 bytes per entry on 64-bit
systems), whereas normal stack frames typically consume 64+ bytes. This
8:64 byte ratio means that programs using a lot of stack space are
dominated by large buffer allocations and local variables, not extreme
recursion depths with minimal local data.

For example, with the default RLIMIT_STACK of 8MB:
- RLIMIT_STACK/2 gives a 4MB shadow stack supporting 512K nested calls
- RLIMIT_STACK/8 gives a 1MB shadow stack supporting 128K nested calls

Given typical stack frame sizes of 64+ bytes, RLIMIT_STACK/8 is still
conservative and provides adequate depth for practical applications.
David noted that this could even be safely halved again.

This reduction also better accommodates memory-constrained platforms.
On systems with limited physical memory, allocating large shadow stacks
can cause virtual memory allocation failures when overcommit mode is set
to OVERCOMMIT_GUESS or OVERCOMMIT_NEVER.

Suggested-by: David Laight <david.laight.linux@gmail.com>
Link: https://lore.kernel.org/all/20260518105725.7afe7a4c@pumpkin/
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 114.43 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1017.40 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1368.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.51 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 20.71 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.60 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 76.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
kdoc
Desc: Detects for kdoc errors
Duration: 0.71 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
module-param
Desc: Detect module_param changes
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: cfi: reduce shadow stack size limit from 2GB to 512MB"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot force-pushed the workflow__riscv__fixes branch from a1231b7 to c03cdce Compare May 23, 2026 03:29
@linux-riscv-bot linux-riscv-bot deleted the pw1099248 branch May 30, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants