[all-commits] [llvm/llvm-project] b74f61: [msan] Add 'MappingDesc::ALLOCATOR' type and check...

Thurston Dang via All-commits all-commits at lists.llvm.org
Wed Mar 27 16:04:13 PDT 2024


  Branch: refs/heads/release/18.x
  Home:   https://github.com/llvm/llvm-project
  Commit: b74f6158460c8d65203d8e5218faf584bbbbe096
      https://github.com/llvm/llvm-project/commit/b74f6158460c8d65203d8e5218faf584bbbbe096
  Author: Thurston Dang <thurston at google.com>
  Date:   2024-03-27 (Wed, 27 Mar 2024)

  Changed paths:
    M compiler-rt/lib/msan/msan.h
    M compiler-rt/lib/msan/msan_allocator.cpp
    M compiler-rt/lib/msan/msan_linux.cpp

  Log Message:
  -----------
  [msan] Add 'MappingDesc::ALLOCATOR' type and check it is available (#85153)

MSan divides the virtual address space into APP, INVALID, SHADOW and
ORIGIN memory. The allocator usually just steals a bit of the APP
address space: typically the bottom portion of the PIE binaries section,
which works because the Linux kernel maps from the top of the PIE
binaries section. However, if ASLR is very aggressive, the binary may
end up mapped in the same location where the allocator wants to live;
this results in a segfault.

This patch adds in a MappingDesc::ALLOCATOR type and enforces that the
memory range for the allocator is not occupied by anything else.

Since the allocator range information is not readily available in
msan.h, we duplicate the information from msan_allocator.cpp.

Note: aggressive ASLR can also lead to a different type of failure,
where the PIE binaries/libraries are mapped entirely outside of the
APP/ALLOCATOR sections; that will be addressed in a separate patch
(https://github.com/llvm/llvm-project/pull/85142).

(cherry picked from commit af2bf86a372cacf5f536bae06e2f2d3886eefb7b)


  Commit: c2a57034eff048cd36c563c8e0051db3a70991b3
      https://github.com/llvm/llvm-project/commit/c2a57034eff048cd36c563c8e0051db3a70991b3
  Author: Thurston Dang <thurston at google.com>
  Date:   2024-03-27 (Wed, 27 Mar 2024)

  Changed paths:
    M compiler-rt/lib/msan/msan.cpp
    M compiler-rt/lib/msan/msan.h
    M compiler-rt/lib/msan/msan_linux.cpp

  Log Message:
  -----------
  [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142)

This ports the change from TSan
(https://github.com/llvm/llvm-project/commit/0784b1eefa36d4acbb0dacd2d18796e26313b6c5).

Testing notes: run 'sudo sysctl vm.mmap_rnd_bits=32; ninja check-msan'
before and after this patch.

N.B. aggressive ASLR may also cause the app to overlap with the
allocator region; for MSan, this was fixed in
https://github.com/llvm/llvm-project/commit/af2bf86a372cacf5f536bae06e2f2d3886eefb7b

(cherry picked from commit 58f7251820b14c93168726a24816d8a094599be5)


Compare: https://github.com/llvm/llvm-project/compare/98a15dd2d728...c2a57034eff0

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list