Bug 1210966 - Some tests fails when Yama policy disallows PTRACE_ATTACH
Summary: Some tests fails when Yama policy disallows PTRACE_ATTACH
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: elfutils
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mark Wielaard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-11 15:00 UTC by Ludovic Courtès
Modified: 2015-04-13 07:28 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-04-13 07:28:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Proposed patch (1.91 KB, text/plain)
2015-04-11 15:00 UTC, Ludovic Courtès
no flags Details

Description Ludovic Courtès 2015-04-11 15:00:14 UTC
Created attachment 1013474 [details]
Proposed patch

Description of problem:

The 'run-deleted.sh' and 'vdsosyms' tests fail when the Yama policy disallows uses of PTRACE_ATTACH for non-CAP_SYS_PTRACE processes, as is the case by default in recent Linux kernels (such as 3.19.3.)

Version-Release number of selected component (if applicable):

0.161

How reproducible:

100%

Steps to Reproduce:
1. Pick a Linux 3.19ish system.
2. echo 1 > /proc/sys/kernel/yama/ptrace_scope (as root)
3. Run "make check".


Actual results:

run-deleted.sh and vdosyms fail.

Expected results:

These tests should be skipped in this case.

Additional info:

Patch attached (this patch is currently used in GNU Guix.)

Comment 1 Mark Wielaard 2015-04-11 17:00:07 UTC
(In reply to Ludovic Courtès from comment #0)
> The 'run-deleted.sh' and 'vdsosyms' tests fail when the Yama policy
> disallows uses of PTRACE_ATTACH for non-CAP_SYS_PTRACE processes, as is the
> case by default in recent Linux kernels (such as 3.19.3.)
> [...]
> Steps to Reproduce:
> 1. Pick a Linux 3.19ish system.
> 2. echo 1 > /proc/sys/kernel/yama/ptrace_scope (as root)

So do not do that! :)

Really, that policy is not very helpful.
It disallows users to inspect their own processes.

> Patch attached (this patch is currently used in GNU Guix.)

I think there is an upstream patch that is better for working around such crippled systems:

https://git.fedorahosted.org/cgit/elfutils.git/commit/?id=cc74c21c0de87cc3c7b293234808b3118c4d85db

commit cc74c21c0de87cc3c7b293234808b3118c4d85db
Author: Mark Wielaard <mjw>
Date:   Thu Jan 15 13:39:06 2015 +0100

    tests: Make deleted and vdsosyms testcases work with "restricted ptrace".
    
    Some systems might have "restricted ptrace" that doesn't allow process
    inspection of arbitrary processes. Change the deleted testcase to
    explicitly allow any other process to inspect it using the PR_SET_PTRACER
    prctl set to PR_SET_PTRACER_ANY. Change the vdsosyms testcase to inspect
    the process itself which should always be allowed.
    
    Reported-by: Anatol Pomozov <anatol.pomozov>
    Signed-off-by: Mark Wielaard <mjw>

Could you try the above?

Comment 2 Ludovic Courtès 2015-04-11 19:42:04 UTC
(In reply to Mark Wielaard from comment #1)
> (In reply to Ludovic Courtès from comment #0)
> > The 'run-deleted.sh' and 'vdsosyms' tests fail when the Yama policy
> > disallows uses of PTRACE_ATTACH for non-CAP_SYS_PTRACE processes, as is the
> > case by default in recent Linux kernels (such as 3.19.3.)
> > [...]
> > Steps to Reproduce:
> > 1. Pick a Linux 3.19ish system.
> > 2. echo 1 > /proc/sys/kernel/yama/ptrace_scope (as root)
> 
> So do not do that! :)
> 
> Really, that policy is not very helpful.

Yeah agreed.  It just turns out to be the upstream default.  :-/

> I think there is an upstream patch that is better for working around such
> crippled systems:
> 
> https://git.fedorahosted.org/cgit/elfutils.git/commit/
> ?id=cc74c21c0de87cc3c7b293234808b3118c4d85db
> 
> commit cc74c21c0de87cc3c7b293234808b3118c4d85db
> Author: Mark Wielaard <mjw>
> Date:   Thu Jan 15 13:39:06 2015 +0100
> 
>     tests: Make deleted and vdsosyms testcases work with "restricted ptrace".
>     
>     Some systems might have "restricted ptrace" that doesn't allow process
>     inspection of arbitrary processes. Change the deleted testcase to
>     explicitly allow any other process to inspect it using the PR_SET_PTRACER
>     prctl set to PR_SET_PTRACER_ANY. Change the vdsosyms testcase to inspect
>     the process itself which should always be allowed.
>     
>     Reported-by: Anatol Pomozov <anatol.pomozov>
>     Signed-off-by: Mark Wielaard <mjw>

Better, indeed.

Thanks!

Ludo'.


Note You need to log in before you can comment on or make changes to this bug.