[libc-commits] [libc] [libc] fix segfault in stack_chk_guard_test on arm (PR #75962)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Dec 19 11:12:48 PST 2023


https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/75962

Use a size smaller than the smallest supported page size so that we don't
clobber over any guard pages, which may result in a segfault before
__stack_chk_fail can be called.


>From 1e1e9cbd367a76e14059e8b0c1003bb2f409060f Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 19 Dec 2023 11:11:20 -0800
Subject: [PATCH] [libc] fix segfault in stack_chk_guard_test on arm

Use a size smaller than the smallest supported page size so that we don't
clobber over any guard pages, which may result in a segfault before
__stack_chk_fail can be called.
---
 libc/test/src/compiler/stack_chk_guard_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/test/src/compiler/stack_chk_guard_test.cpp b/libc/test/src/compiler/stack_chk_guard_test.cpp
index 1de2d1b7357f70..df15962acd9678 100644
--- a/libc/test/src/compiler/stack_chk_guard_test.cpp
+++ b/libc/test/src/compiler/stack_chk_guard_test.cpp
@@ -20,7 +20,7 @@ TEST(LlvmLibcStackChkFail, Smash) {
   EXPECT_DEATH(
       [] {
         int arr[20];
-        LIBC_NAMESPACE::memset(arr, 0xAA, 9001);
+        LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
       },
       WITH_SIGNAL(SIGABRT));
 }



More information about the libc-commits mailing list