Repository navigation
Linux: keep file-backed VMAs whose inode fails validation - #2095
Closed
ricardojrdez wants to merge 1 commit into
Closed
ricardojrdez wants to merge 1 commit into
ricardojrdez wants to merge 1 commit into
Conversation
vm_area_struct.is_valid() dereferenced the result of get_inode() without a None check. get_inode() returns None when inode.is_valid() rejects the inode, which happens for the first System V shared-memory segment: its inode number is the shmid, 0. One such mapping aborted linux.proc.Maps, linux.elfs, linux.library_list and linux.malware.malfind runs. Skip only the page-offset size check in that case.
Contributor
|
Is this similar to #2083? |
Contributor
Author
|
Superseded by #2096 (same commit, opened from the reverseame organization fork). |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Guard the file-backed VMA page-offset/size check when
struct_file.get_inode()returnsNone.A valid System V shared-memory segment can have inode number 0: Linux sets the shm file's inode number to its segment identifier, and the first segment in an IPC namespace has identifier 0. The inode smear heuristic rejects that inode, after which
vm_area_struct.is_valid()currently dereferencesNoneand aborts every plugin using VMA iteration.The change keeps a VMA that has passed the existing address-range, page-alignment, and protection checks, and skips only the inode-size/page-offset check when no validated inode is available. The size check is unchanged for validated inodes. Returning
Falsein this case would avoid the exception but would also drop a known-valid shared-memory mapping.Affected plugins observed in the reproduction image:
linux.proc.Mapslinux.elfs.Elfslinux.library_list.LibraryListlinux.malware.malfind.MalfindTesting
Added
test/test_linux_vma.py, which exercises a structurally valid file-backed VMA whose inode cannot be resolved. It verifies that validation succeeds and that the page-offset calculation is not attempted without an inode.Commands:
Results:
Integration check on a Linux 6.18.59 x86-64 memory image containing an attached SysV segment with
shmid=0:linux.proc.Mapslinux.elfs.Elfs --pid <pid>linux.library_list.LibraryListlinux.malware.malfind.MalfindScope
The shm VMA path still renders as
<invalid dentry inode> 0x...; this PR intentionally does not relaxinode.is_valid()globally. That is a separate cosmetic issue and changing it would affect the smear heuristic for every inode consumer.Fixes #2094.