Skip to content

Commit

Permalink
Allow attaching to non-child processes by default
Browse files Browse the repository at this point in the history
The inability to run strace or gdb is the kind of
developer-unfriendliness that we're used to from OS X, let's not do it
on NixOS.

This restriction can be re-enabled by setting

  boot.kernel.sysctl."kernel.yama.ptrace_scope" = 1;

It might be nice to have a NixOS module for enabling hardened defaults.

Xref #14392.

Thanks @abbradar.
  • Loading branch information
edolstra committed Mar 21, 2017
1 parent 78bb734 commit 86721a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 0 additions & 9 deletions nixos/doc/manual/release-notes/rl-1703.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ following incompatible changes:</para>
</para>
</listitem>

<listitem>
<para>
The Yama LSM is now enabled by default in the kernel,
which prevents ptracing non-child processes.
This means you will not be able to attach gdb to an existing process,
but will need to start that process from gdb (so it is a child).
</para>
</listitem>

<listitem>
<para>
The <literal>stripHash</literal> bash function in <literal>stdenv</literal>
Expand Down
4 changes: 4 additions & 0 deletions nixos/modules/config/sysctl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@ in
# Removed under grsecurity.
boot.kernel.sysctl."kernel.kptr_restrict" =
if (config.boot.kernelPackages.kernel.features.grsecurity or false) then null else 1;

# Disable YAMA by default to allow easy debugging.
boot.kernel.sysctl."kernel.yama.ptrace_scope" = mkDefault 0;

};
}

2 comments on commit 86721a5

@aneeshusa
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add this change to the release notes, since this re-opens a previously closed hole?

Personally I only started with/learned about strace and gdb on OSes with Yama enabled and have always invoked invoked other programs from them, but I can understand how this can be more friendly.

@vcunat
Copy link
Member

@vcunat vcunat commented on 86721a5 Mar 22, 2017

Choose a reason for hiding this comment

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

Well, we haven't that in any release yet, and this got picked to (future) 17.03, including removal from the changelog.

Please sign in to comment.