10000 checking /proc/sys/kernel/ftrace_enabled by mtcherni95 · Pull Request #1152 · aquasecurity/tracee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

checking /proc/sys/kernel/ftrace_enabled #1152

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

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

mtcherni95
Copy link
Contributor
@mtcherni95 mtcherni95 commented Nov 21, 2021

Resolves: #1150

@mtcherni95 mtcherni95 force-pushed the handling-ftrace-enabled branch from 8506db8 to 892e892 Compare November 22, 2021 09:08
@itaysk
Copy link
Collaborator
itaysk commented Nov 22, 2021

Resolves: #1150

this goes in the PR body, not title :)

@itaysk itaysk changed the title checking /proc/sys/kernel/ftrace_enabled - Resolves: #1150 checking /proc/sys/kernel/ftrace_enabled Nov 22, 2021
@itaysk
Copy link
Collaborator
itaysk commented Nov 22, 2021

In the linked issue you say you will add the check to libbpfgo, what changed?

@rafaeldtinoco
Copy link
Contributor

Yes, @mtcherni95 , please check:

aquasecurity/libbpfgo#94

@mtcherni95
Copy link
Contributor Author

I will update PR by using helper in libbpfgo - this will require update of go mod version of libbpgo

@grantseltzer grantseltzer added this to the v0.6.5 milestone Nov 29, 2021
@grantseltzer
Copy link
Contributor

@mtcherni95 Now that we've upgraded the libbpfgo dependency to the latest release (which includes this helper function) you can update this PR.

@mtcherni95 mtcherni95 force-pushed the handling-ftrace-enabled branch from 892e892 to 6114c91 Compare November 30, 2021 20:45
@mtcherni95
Copy link
Contributor Author
mtcherni95 commented Nov 30, 2021

@mtcherni95 Now that we've upgraded the libbpfgo dependency to the latest release (which includes this helper function) you can update this PR.

great, thanks a lot!

@mtcherni95 mtcherni95 closed this Nov 30, 2021
@mtcherni95 mtcherni95 reopened this Nov 30, 2021
@mtcherni95 mtcherni95 force-pushed the handling-ftrace-enabled branch from 6114c91 to 005d4cd Compare November 30, 2021 20:48
if err != nil {
return err
}
if !enabled {
fmt.Fprintf(os.Stderr, "ftrace_enabled: warning: ftrace is not enabled - kprobes won't be inserted\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

To a user, I don't know if having "kprobes won't be inserted" is very useful. Is it possible to list events that won't be traced? Are we sure that ftrace is absolutely required for all kprobes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so yeah. @yanivagman ?

Copy link
Contributor
@rafaeldtinoco rafaeldtinoco Nov 30, 2021

Choose a reason for hiding this comment

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

Ftrace is needed for kprobes as they're built on top of ftrace base architecture (https://www.kernel.org/doc/Documentation/trace/ftrace-design.txt & https://www.kernel.org/doc/Documentation/trace/kprobetrace.txt), like an extension to it. I don't think we should expand to much here, but I do think the message could be clearer for an average user that might not know what kprobes and ftrace are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually think that if a user is using Tracee then most likely he will have some technical background (and kprobes knowledge as well). I suggest something like "ftrace_enabled: warning: ftrace is not enabled - some events may not be caught (kprobes not enabled)".

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe no events, at all, will be caught, if ftrace is disabled.

And I disagree that users of tracee will know what a kprobe (or ftrace) is.

I do agree that a warning like that could be helpful as long as it is rephrased to something like:

ftrace_enabled: warning: ftrace is not enabled, kernel events won't be caught, make sure to enable it by executing echo 1 | sudo tee /proc/sys/kernel/ftrace_enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You do get events coming from tracepoints.

Let's go with your message then :)

10000 Copy link
Contributor

Choose a reason for hiding this comment

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

You do get events coming from tracepoints.

I see what you mean. But our ebpf logic might be broken as there are maps manipulated by different eBPF programs (with different probe methods) in different times, I believe.

I agree that if we consider tracee purely as an introspection tool, final user might know what we're talking about... but we're trying to shift that mindset as well (thus the explicit message about how to get it enabled).

Cool, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if this is the case should we just error out if ftrace is disabled? Is there any point in running tracee?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So if this is the case should we just error out if ftrace is disabled? Is there any point in running tracee?

I don't think so - tracepoint will still work, which means that all the syscalls + some other events will still work (> 95% of the events are not kprobes) - so I think we should just warn

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright then, works for me.

@mtcherni95 mtcherni95 force-pushed the handling-ftrace-enabled branch from 005d4cd to 2eda2b3 Compare December 1, 2021 14:30
Copy link
Contributor
@grantseltzer grantseltzer 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 060b554 into aquasecurity:main Dec 1, 2021
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.

tracee-ebpf should check that /proc/sys/kernel/ftrace_enabled is '1' (enabled)
5 participants
0