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

Add helper to check if ftrace is enabled #94

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

grantseltzer
Copy link
Contributor

Signed-off-by: grantseltzer grantseltzer@gmail.com

rafaeldtinoco
rafaeldtinoco previously approved these changes Nov 22, 2021
Copy link
Contributor

@rafaeldtinoco rafaeldtinoco left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mtcherni95 mtcherni95 left a comment

Choose a reason for hiding this comment

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

why not just use TrimSpace and compare it? don't we also want to report the error instead of just a boolean?

@rafaeldtinoco rafaeldtinoco self-requested a review November 22, 2021 17:15
@rafaeldtinoco
Copy link
Contributor

why not just use TrimSpace and compare it? don't we also want to report the error instead of just a boolean?

I thought you had agreed already on this helper (when I saw your other PR). Whatever you both prefer I'm good, its a simple change.

@mtcherni95
Copy link
Contributor

in the other pr I implemented what I suggested above - we can use return both bool and error IMO.

@rafaeldtinoco
Copy link
Contributor

in the other pr I implemented what I suggested above - we can use return both bool and error IMO.

@mtcherni95 and @yanivagman , I dont recall what we've agreed in last weeks discussion. Was it to be placed in libbpfgo or tracee ? I recall it could have been agreed to be added to tracee because libbpf did not have that check, but I could be wrong.

@mtcherni95
Copy link
Contributor

in the other pr I implemented what I suggested above - we can use return both bool and error IMO.

@mtcherni95 and @yanivagman , I dont recall what we've agreed in last weeks discussion. Was it to be placed in libbpfgo or tracee ? I recall it could have been agreed to be added to tracee because libbpf did not have that check, but I could be wrong.

You are right - we agreed it would have been in tracee. However, after some further thinking it is better to have it in libbpgo and tracee will use the new API of FtraceEnabled

@grantseltzer
Copy link
Contributor Author

why not just use TrimSpace and compare it? don't we also want to report the error instead of just a boolean?

Agreed, changed accordingly

Copy link
Contributor

@rafaeldtinoco rafaeldtinoco left a comment

Choose a reason for hiding this comment

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

would you mind squashing the changes into a single commit and addressing issue from my comment ? this way we can move on and merge this. thanks!

helpers/osinfo.go Outdated Show resolved Hide resolved
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
Copy link
Contributor

@rafaeldtinoco rafaeldtinoco left a comment

Choose a reason for hiding this comment

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

LGTM:

$ echo 0 | sudo tee /proc/sys/kernel/ftrace_enabled
0
$ go run temp.go
false <nil>
$ echo 1 | sudo tee /proc/sys/kernel/ftrace_enabled
1
$ go run temp.go
true <nil>

and simulating an error

$ go run temp.go
false could not read from ftrace_enabled file: open /proc/sys/kernel/ftrace_enabled: no such file or directory

@grantseltzer grantseltzer merged commit 911d504 into aquasecurity:main Nov 23, 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.

3 participants