Fallback to /proc/PID/mem when process_vm_readv not in kernel #240
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #238
Describe your changes
I've added an alternative implementation of
ProcessMemoryManager::readChunk
that uses the relevant/proc/PID/mem
file and is fallen back to whenprocess_vm_readv
fails withENOSYS
.Once the
/proc/PID/mem
file is open, subsequent reads are done only from there.Testing performed
On my dev instance where my kernel does have
CONFIG_CROSS_MEMORY_ATTACH
set, I did various tests with small source changes. Such as forcing the fallback implementation to always be used.Details
I also checked what the various errors might look like, say if the file didn't exist
Once I was pretty happy that it wasn't too awful, I spun up a flatcar VM and tested the happy path there.
Details (Probably too many)
Per https://www.flatcar.org/docs/latest/setup/releases/verify-images/
Additional context
I've not written any C++ for about 14 years, so I've probably missed out on some cleverer or prettier ways of doing this.