Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebpf: fix mem_prot_alert anonymous file info #3225

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

AlonZivony
Copy link
Collaborator

1. Explain what the PR does

Anonymous files in mmap triggering mem_prot_alert got an incorrect file info, because it was not checked.
Fix it so there won't be file info in this case.

fix #3217

2. Explain how to test it

Ran it using the following script:

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

int main() {
    size_t size = 4096; // Size of memory to allocate (in bytes)
    void* addr = NULL;  // Address at which to create the mapping

    // Allocate anonymous memory with write and execute permissions
    void* ptr = mmap(addr, size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    if (ptr == MAP_FAILED) {
        perror("mmap");
        exit(1);
    }

    if (munmap(ptr, size) == -1) {
        perror("munmap");
        exit(1);
    }

    return 0;
}
```c

Anonymous files in `mmap` triggering `mem_prot_alert` got an incorrect
file info, because it was not checked.
Fix it so there won't be file info in this case.
Copy link
Collaborator

@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yanivagman yanivagman merged commit d01ceca into aquasecurity:main Jun 12, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mem_prot_alert return incorrect file info for anonymous memory
2 participants