sandbox-build-if-glibc-2.34-dynamic-stack-size-is-en.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 28ac6a15411d01301e171b8a8b0019abd57589b9 Mon Sep 17 00:00:00 2001
  2. From: Stephan Hartmann <stha09@googlemail.com>
  3. Date: Mon, 7 Feb 2022 20:09:57 +0000
  4. Subject: [PATCH] sandbox: build if glibc 2.34+ dynamic stack size is enabled
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Compilation of sandbox fails when using dynamic stack size in glibc
  9. 2.34 or newer. This is because the value is not a literal anymore but
  10. obtained through sysconf.
  11. To avoid this, use memset to put zeros in the buffer.
  12. Change-Id: Ia479e0f799b77a10a00197aaaa0500e62546f458
  13. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3436947
  14. Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
  15. Commit-Queue: José Dapena Paz <jdapena@igalia.com>
  16. Cr-Commit-Position: refs/heads/main@{#967943}
  17. ---
  18. sandbox/linux/services/credentials.cc | 5 ++++-
  19. 1 file changed, 4 insertions(+), 1 deletion(-)
  20. diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
  21. index ca6b5954798..c933eafd163 100644
  22. --- a/sandbox/linux/services/credentials.cc
  23. +++ b/sandbox/linux/services/credentials.cc
  24. @@ -100,7 +100,10 @@ bool ChrootToSafeEmptyDir() {
  25. // TODO(crbug.com/1247458) Broken in MSan builds after LLVM f1bb30a4956f.
  26. clone_flags |= CLONE_VM | CLONE_VFORK | CLONE_SETTLS;
  27. - char tls_buf[PTHREAD_STACK_MIN] = {0};
  28. + // PTHREAD_STACK_MIN can be dynamic in glibc2.34+, so it is not possible to
  29. + // zeroify tls_buf assigning { 0 }
  30. + char tls_buf[PTHREAD_STACK_MIN];
  31. + memset(tls_buf, 0, PTHREAD_STACK_MIN);
  32. tls = tls_buf;
  33. #endif