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

feature: add notpm command & keep tpm devices in private-dev #6390

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

qdii
Copy link
Contributor

@qdii qdii commented Jun 22, 2024

An ssh private key may be stored in a Trusted Platform Module (TPM)
device and private-dev in ssh.profile currently breaks this use-case,
as it does not keep tpm devices (see #6379).

So add a new notpm command and keep tpm devices in /dev by default
with private-dev unless notpm is used.

Tested locally with:

❯ /usr/local/bin/firejail --private-dev --noprofile stat /dev/tpm0
firejail version 0.9.73

Parent pid 34059, child pid 34060
Base filesystem installed in 0.03 ms
Child process initialized in 13.23 ms
  File: /dev/tpm0
  Size: 0         	Blocks: 0          IO Block: 4096   character special file
Device: 0,6	Inode: 150         Links: 1     Device type: 10,224
Access: (0600/crw-------)  Uid: (  973/     tss)   Gid: (  973/     tss)
Access: 2024-06-22 11:20:44.017230197 +0200
Modify: 2024-06-22 11:20:44.017230197 +0200
Change: 2024-06-22 11:20:44.017230197 +0200
 Birth: 2024-06-22 11:20:10.406666659 +0200

Parent is shutting down, bye...

Fixes #6379.

Copy link
Collaborator

@rusty-snake rusty-snake left a comment

Choose a reason for hiding this comment

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

LGTM

There has to be an follow-up PR that adds notpm to all profiles with private-dev.

@qdii
Copy link
Contributor Author

qdii commented Jun 22, 2024

@rusty-snake Added a commit that adds notpm statement to all the profiles which contain private-dev.

Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

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

LGTM

@qdii
Copy link
Contributor Author

qdii commented Jun 23, 2024

After this is committed, we should also update the Wiki: https://github.com/netblue30/firejail/wiki/Comparison-of-firejail-and-systemd's-hardening-options

src/man/firejail.1.in Outdated Show resolved Hide resolved
Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

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

LGTM. Some ordering nitpicks...

@qdii
Copy link
Contributor Author

qdii commented Jun 23, 2024

Amended and force-pushed with alphabetical ordering.

Copy link
Collaborator

@kmk3 kmk3 left a comment

Choose a reason for hiding this comment

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

Sorting.

src/fbuilder/build_profile.c Outdated Show resolved Hide resolved
src/firejail/firejail.h Outdated Show resolved Hide resolved
src/firejail/fs_dev.c Outdated Show resolved Hide resolved
src/firejail/fs_dev.c Outdated Show resolved Hide resolved
src/firejail/fs_dev.c Outdated Show resolved Hide resolved
src/firejail/fs_dev.c Outdated Show resolved Hide resolved
src/firejail/main.c Outdated Show resolved Hide resolved
src/firejail/main.c Outdated Show resolved Hide resolved
src/firejail/sandbox.c Outdated Show resolved Hide resolved
src/firejail/usage.c Outdated Show resolved Hide resolved
@kmk3
Copy link
Collaborator

kmk3 commented Jun 23, 2024

There are some other missing changes:

  • Add notpm to profile.c
  • Add notpm to firejail-profile.5.in
  • Add #notpm to default.profile (keep it commented like #nou2f for
    consistency)
  • Run make syntax and commit the resulting changes

See commit 760f50f ("landlock: move commands into profile and add
landlock.enforce", 2023-11-17) / PR #6125 for a recent example of a new
command.

@kmk3 kmk3 changed the title Add TPM devices to private-dev feature: add notpm command & keep tpm devices in private-dev Jun 23, 2024
@qdii qdii force-pushed the master branch 3 times, most recently from 0a57213 to 6d50555 Compare June 24, 2024 21:09
@qdii
Copy link
Contributor Author

qdii commented Jun 24, 2024

It looks like force-pushing is making other updates obsolete.
I'm not used to working on github just yet, sorry.

Copy link
Collaborator

@kmk3 kmk3 left a comment

Choose a reason for hiding this comment

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

This PR already makes substantial changes by adding the new command; leave the
profile changes (other than the ones for default.profile and profile.template)
for after this PR to make reviewing easier.

In the parts of the code that are mostly alphabetically sorted (such as in the
man pages), it makes sense to put notpm before notv.

But in some parts of the code, for whatever reason the multimedia-related
options (nosound, noautopulse, no3d, notv, nodvd) are sorted
together, so for consistency put notpḿ before nou2f, as was suggested in
the previous review.

That is:

  • notv, nou2f -> notpm, notv, nou2f
  • nodvd, nou2f -> nodvd, notpm, nou2f

Also, avoid sorting things in this PR (especially in the same commit).

After this PR I might try to make these parts more consistent.

Copy link
Collaborator

@kmk3 kmk3 left a comment

Choose a reason for hiding this comment

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

Misc

src/firejail/fs_dev.c Outdated Show resolved Hide resolved
src/man/firejail-profile.5.in Outdated Show resolved Hide resolved
src/man/firejail-profile.5.in Outdated Show resolved Hide resolved
src/man/firejail.1.in Outdated Show resolved Hide resolved
@qdii
Copy link
Contributor Author

qdii commented Jul 3, 2024

This PR already makes substantial changes by adding the new command; leave the profile changes (other than the ones for default.profile and profile.template) for after this PR to make reviewing easier.

OK, reverted the long list of profile changes. I stored it in another branch to propose later.

In the parts of the code that are mostly alphabetically sorted (such as in the man pages), it makes sense to put notpm before notv.

But in some parts of the code, for whatever reason the multimedia-related options (nosound, noautopulse, no3d, notv, nodvd) are sorted together, so for consistency put notpḿ before nou2f, as was suggested in the previous review.

That is:

  • notv, nou2f -> notpm, notv, nou2f
  • nodvd, nou2f -> nodvd, notpm, nou2f

OK, I see.

Also, avoid sorting things in this PR (especially in the same commit).

This sentence confuses me, because I interpreted the two previous paragraphs as a ask to actually sort these options in a certain way.

Or do you want to merge this PR, and do the sorting in a different one? I'm happy either way.

After this PR I might try to make these parts more consistent.

@kmk3 kmk3 force-pushed the master branch 2 times, most recently from 4da75ef to 1d80642 Compare July 4, 2024 07:10
@kmk3
Copy link
Collaborator

kmk3 commented Jul 4, 2024

Also, avoid sorting things in this PR (especially in the same commit).

This sentence confuses me, because I interpreted the two previous paragraphs
as a ask to actually sort these options in a certain way.

Sorry, I meant avoid sorting/moving existing lines while adding new lines at
the same time, such as in these cases:

In general it seems better to avoid refactoring in PRs that just add a new
thing, as they will mostly contain hunks that add new lines, which are easier
to review. Hunks that sort lines might be wrong/inconsistent with how the
sorting is done elsewhere (this applies to the first link above).

Or do you want to merge this PR, and do the sorting in a different one? I'm
happy either way.

I fixed the sorting, squashed the commits, edited the commit message and
force-pushed.

Let me know if there are any issues.

An ssh private key may be stored in a Trusted Platform Module (TPM)
device and `private-dev` in ssh.profile currently breaks this use-case,
as it does not keep tpm devices (see netblue30#6379).

So add a new `notpm` command and keep tpm devices in /dev by default
with `private-dev` unless `notpm` is used.
@kmk3 kmk3 merged commit 0013202 into netblue30:master Jul 9, 2024
14 checks passed
kmk3 added a commit that referenced this pull request Jul 9, 2024
@kmk3 kmk3 added the enhancement New feature request label Jul 9, 2024
kmk3 added a commit to kmk3/firejail that referenced this pull request Jul 9, 2024
This command is deprecated and may be confused for a hardening option.

This amends commit 5a61202 ("rename noautopulse to keep-config-pulse",
2021-05-13) / PR netblue30#4278.

This is a follow-up to netblue30#6390.
kmk3 added a commit that referenced this pull request Jul 11, 2024
This command is deprecated and may be confused for a hardening option.

This amends commit 5a61202 ("rename noautopulse to keep-config-pulse",
2021-05-13) / PR #4278.

This is a follow-up to #6390.
kmk3 added a commit that referenced this pull request Jul 15, 2024
Remove the newer #6390 item as it is already on the list, remove the
older #6307 item (modif) and sort the new #6307 item (bugfix).

This amends commit 9ebecd0 ("readme/relnotes update", 2024-07-13).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request
Projects
Status: Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

ssh: cannot access private key stored in TPM (private-dev)
4 participants