Skip to contentSkip to conversation

ptrace permissions

DISCUSSION Russell Coker 2 participants 2 messages Aug 13, 2002 – Aug 19, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw
root@test:/usr/src/test/woody# ps axf --context
  PID    SID CONTEXT                                  COMMAND
31819    432 root:user_r:user_t                       -bash
31944    432 root:user_r:user_t                        \_ ps axf --context
27769    432 root:user_r:user_t                       -bash
23336    432 root:user_r:user_t                       -bash
25574    511 root:user_r:chtest_super_t                \_ ./entry
31943    512 root:user_r:chtest_t                     /sbin/syslogd
29358    512 root:user_r:chtest_t                     /usr/sbin/sshd
31789    512 root:user_r:chtest_t                      \_ /usr/sbin/sshd
31790    512 root:user_r:chtest_t                          \_ -bash
root@test:/usr/src/test/woody# id
uid=0(root) gid=0(root) groups=0(root) context=root:user_r:user_t sid=432
root@test:/usr/src/test/woody# strace -p 31943
select(1, [], NULL, NULL, NULL <unfinished ...>
root@test:/usr/src/test/woody# strace -p 29358
select(7, [4], NULL, NULL, NULL <unfinished ...>
root@test:/usr/src/test/woody# strace -p 31790
attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
root@test:/usr/src/test/woody# strace -p 31789
attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
root@test:/usr/src/test/woody# id
uid=0(root) gid=0(root) groups=0(root) context=root:user_r:user_t sid=432
root@test:/usr/src/test/woody#

I am trying to strace programs in my chroot environment. I can trace a syslogd, a sshd, but the child sshd and a bash login shell it spawned are untracable. Here's the AVC message:

avc: denied { sys_ptrace } for pid=31984 comm=strace capability=19 scontext=root:user_r:user_t tcontext=root:user_r:user_t tclass=capability

I'm using the latest SE Linux from the latest LSM kernel patch.

The bash process is UID!=0, but the sshd is UID==0.

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 10 lines · Russell Coker

I am trying to strace programs in my chroot environment. I can trace a syslogd, a sshd, but the child sshd and a bash login shell it spawned are untracable. Here's the AVC message:

avc: denied { sys_ptrace } for pid=31984 comm=strace capability=19 scontext=root:user_r:user_t tcontext=root:user_r:user_t tclass=capability

I'm using the latest SE Linux from the latest LSM kernel patch.

The bash process is UID!=0, but the sshd is UID==0.

SELinux performs a sys_ptrace permission check whenever the kernel checks the CAP_SYS_PTRACE capability. The kernel checks this capability on ptrace_attach if:
1) There is a mismatch between the current process' real uid and any of the target process' uids (real, effective, or saved), or
2) There is a mismatch between the current process' real gid and any of the target process' gids, or
3) The target process is no longer dumpable, e.g. due to a prior change in uid or gid or lack of read access to the executable.

On a successful ptrace_attach, the kernel will also check this capability and save the result in the ptrace flags (PT_PTRACE_CAP if granted) of the target task. This result is subsequently used in the
kernel must_not_trace_exec check to guard against tracing across set[ug]id program execution unless the tracer had the capability.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.