[Lldb-commits] [lldb] [lldb][Linux] Mark memory regions used for shadow stacks (PR #117861)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 9 01:43:11 PST 2025


================
@@ -164,12 +164,17 @@ void lldb_private::ParseLinuxSMapRegions(llvm::StringRef linux_smap,
     if (!name.contains(' ')) {
       if (region) {
         if (name == "VmFlags") {
-          if (value.contains("mt"))
-            region->SetMemoryTagged(MemoryRegionInfo::eYes);
-          else
-            region->SetMemoryTagged(MemoryRegionInfo::eNo);
+          region->SetMemoryTagged(MemoryRegionInfo::eNo);
+          region->SetIsShadowStack(MemoryRegionInfo::eNo);
+
+          llvm::SmallVector<llvm::StringRef> flags;
+          value.split(flags, ' ', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+          for (llvm::StringRef flag : flags)
----------------
DavidSpickett wrote:

The line we are parsing looks like:
```
VmFlags: rd ex mr mw me de sd
```
And I wouldn't want to see "amtb" and assume that memory tagging is set. We could do `contains(" mt ")` buy relying on that trailing space being there is risky.

It would be nice to be lazy and only tokenise as much as we need from the string though. I'll see if there's an iterator version I can use.

You made me realise I don't actually have a test case to check we don't match on substrings though, so I will add that.

https://github.com/llvm/llvm-project/pull/117861


More information about the lldb-commits mailing list