-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If a page is not mapped in a process, `bpf_probe_read_user` will not be able to read it (even if the page is resident, so reading would have only caused a minor fault). In this case, instead of giving up, we can ask the agent to fault it into the process by reading /proc/<pid>/mem at the specified offset. To test, compile the following program with `-O0` and attempt to profile it: #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> void x(uint64_t orig_page) { uint64_t this_page = ((uint64_t)(&orig_page) >> 12); if (this_page != orig_page) { pid_t pid = fork(); if (pid) printf("Forked child pid: %d\n", pid); else for (;;) ; } else x(orig_page); } int main(int argc, char *argv[]) { x((uint64_t)(&argc) >> 12); } This program does the following: 1. Recurses until the stack crosses a page boundary 2. Forks -- the new process will initially not have any pages mapped in its address space 3. Loops forever -- thus it will never go back to the old stack frame and read it. This program consistently produces 100% `PreviousRipZero` errors before this commit, but with this commit, it eventually starts bieng profiled successfully.
- Loading branch information
Showing
6 changed files
with
150 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.