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

Ensure we are running under root #1992

Merged
merged 1 commit into from
Sep 7, 2023
Merged

Ensure we are running under root #1992

merged 1 commit into from
Sep 7, 2023

Conversation

javierhonduco
Copy link
Contributor

This was previously discussed in
#719.

While ideally we could check for the individual capabilities this is fraught with issues: different kernel revisions might require different capabilities, over time we are adding new features that might require or drop the needed capabilities, and in general, capabilities don't seem to be a feature that many users are intimately familiar with.

Checking for the superuser is a reasonable thing to do as it will ensure we can run, and it's how every single deployment that we know of executes this software.

We can always re-evaluate this in the future, but in the meantime let's ensure that running the Agent does not result in surprises (#1979, but we've seen this happening multiple times).

As there were concerns regarding this check being to broad, I've added a escape hatch, which is disabled by default
(--allow-running-as-non-root).

Test Plan

no root w/ escape hatch

$ dist/parca-agent --allow-running-as-non-root
level=error name=parca-agent ts=2023-09-07T08:39:27.529651017Z caller=main.go:345 err="bpf check: perf event program type not supported: errno 0\nstack trace map type not supported: errno 0\nhash map type not supported: errno 0"

no root

$ dist/parca-agent
level=error name=parca-agent ts=2023-09-07T08:39:34.003842932Z caller=main.go:345 err="superuser (root) is required to run Parca Agent to load and manipulate BPF programs"

root

$ sudo dist/parca-agent

It works fine

This was previously discussed in
#719.

While ideally we could check for the individual capabilities this is
fraught with issues: different kernel revisions might require different
capabilities, over time we are adding new features that might require or
drop the needed capabilities, and in general, capabilities don't seem to
be a feature that many users are intimately familiar with.

Checking for the superuser is a reasonable thing to do as it will ensure
we can run, and it's how every single deployment that we know of
executes this software.

We can always re-evaluate this in the future, but in the meantime let's
ensure that running the Agent does not result in surprises
(#1979, but we've seen
this happening multiple times).

As there were concerns regarding this check being to broad, I've added a
escape hatch, which is disabled by default
(`--allow-running-as-non-root`).

Test Plan
========

**no root w/ escape hatch**
```
$ dist/parca-agent --allow-running-as-non-root
level=error name=parca-agent ts=2023-09-07T08:39:27.529651017Z caller=main.go:345 err="bpf check: perf event program type not supported: errno 0\nstack trace map type not supported: errno 0\nhash map type not supported: errno 0"
```

**no root**
```
$ dist/parca-agent
level=error name=parca-agent ts=2023-09-07T08:39:34.003842932Z caller=main.go:345 err="superuser (root) is required to run Parca Agent to load and manipulate BPF programs"
```

**root**

```
$ sudo dist/parca-agent
```

It works fine
@javierhonduco javierhonduco requested a review from a team as a code owner September 7, 2023 08:44
Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

LGTM

@javierhonduco javierhonduco merged commit 403a421 into main Sep 7, 2023
22 checks passed
@javierhonduco javierhonduco deleted the ensure-root-is-used branch September 7, 2023 09:17
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.

None yet

3 participants