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

skip kprobe functions outside normal text section #1647

Merged
merged 1 commit into from
Mar 23, 2018
Merged

skip kprobe functions outside normal text section #1647

merged 1 commit into from
Mar 23, 2018

Conversation

yonghong-song
Copy link
Collaborator

Fix issue #1634.

When kernel is about to attach a kprobe, the following functions
are called:

  register_kprobe
    check_kprobe_address_safe
      kernel_text_address
        core_kernel_text

In core_kernel_text, we have:

        if (addr >= (unsigned long)_stext &&
            addr < (unsigned long)_etext)
                return 1;

Basically, any address outside of [_stext, _etext] will
be rejected.

The functions marked as __init are outside [_stext, _etext].
That is why vfs_caches_init_early and vfs_caches_init
are rejected by trace_kprobe.
Given a regex, this patch avoided attaching these functions
if their func addresses are outside [_stext, _etext] range.

Signed-off-by: Yonghong Song [email protected]

@goldshtn
Copy link
Collaborator

goldshtn commented Mar 23, 2018 via email

Fix issue #1634.

When kernel is about to attach a kprobe, the following functions
are called:
  register_kprobe
    check_kprobe_address_safe
      kernel_text_address
        core_kernel_text

In core_kernel_text, we have:
        if (addr >= (unsigned long)_stext &&
            addr < (unsigned long)_etext)
                return 1;

Basically, any address outside of [_stext, _etext] will
be rejected.

The functions marked as __init are outside [_stext, _etext].
That is why vfs_caches_init_early and vfs_caches_init
are rejected by trace_kprobe.
Given a regex, this patch avoided attaching these functions
if their func addresses are outside [_stext, _etext] range.

Signed-off-by: Yonghong Song <[email protected]>
@yonghong-song
Copy link
Collaborator Author

Make sense, let me do one pass by the fact that syymbols in kallsyms are sorted based on address.

@4ast 4ast merged commit 581052a into master Mar 23, 2018
yonghong-song added a commit that referenced this pull request May 10, 2018
Fix issue #1747.

In commit #1647, we excluded all symbols outside [_stext, _etext].
This is incorrect as it excluded module symbols as well.

This patch changed the algorithm to only skip symbols
in init sections [__init_begin, __init_end].

Signed-off-by: Yonghong Song <[email protected]>
banh-gao pushed a commit to banh-gao/bcc that referenced this pull request Jun 21, 2018
Fix issue iovisor#1747.

In commit iovisor#1647, we excluded all symbols outside [_stext, _etext].
This is incorrect as it excluded module symbols as well.

This patch changed the algorithm to only skip symbols
in init sections [__init_begin, __init_end].

Signed-off-by: Yonghong Song <[email protected]>
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
Fix issue iovisor#1747.

In commit iovisor#1647, we excluded all symbols outside [_stext, _etext].
This is incorrect as it excluded module symbols as well.

This patch changed the algorithm to only skip symbols
in init sections [__init_begin, __init_end].

Signed-off-by: Yonghong Song <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants