Skip to content

Commit ccce0bf

Browse files
committed
Zero-initialize stat structures before fstat calls.
This is upstreaming a fix from Google. MSan reports use-of-uninitialized-value in google_breakpad::MemoryMappedFile::Map because it cannot track memory initialized via syscalls like sys_fstat. Reintroducing zero-initialization using __builtin_memset to avoid introducing a dependency on the standard library in this low-level context. Bug: 504133260 Change-Id: Ic9fd0a0173e74e0308f2f4c8f3e96fc039b846a2 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/7780286 Reviewed-by: Joshua Peraza <jperaza@chromium.org>
1 parent 8be0e31 commit ccce0bf

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/common/linux/memory_mapped_file.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ bool MemoryMappedFile::Map(const char* path, size_t offset) {
7575
(defined(__riscv) && __riscv_xlen == 64)
7676

7777
struct kernel_stat st;
78+
__builtin_memset(&st, 0, sizeof(st));
7879
if (sys_fstat(fd, &st) == -1 || st.st_size < 0) {
7980
#else
8081
struct kernel_stat64 st;
82+
__builtin_memset(&st, 0, sizeof(st));
8183
if (sys_fstat64(fd, &st) == -1 || st.st_size < 0) {
8284
#endif
8385
sys_close(fd);

0 commit comments

Comments
 (0)