Skip to contentSkip to conversation

Ptrace hole / Linux 2.2.25

DISCUSSION Ben Pfaff 2 participants 2 messages Mar 17, 2003 – Mar 18, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ben Pfaff

author
#1 lore raw
Quoted 4 lines · Alan Cox

A patch for Linux 2.4.20/Linux 2.4.21pre is attached. The patch also subtly changes the PR_SET_DUMPABLE prctl. We believe this is neccessary and that it will not affect any software. The functionality change is specific to unusual debugging situations.

I am concerned about this change because it will break sandboxing software that I have written, which uses prctl() to turn dumpability back on so that it can open a file, setuid(), and then execve() through the open file via /proc/self/fd/#. Without calling prctl(), the ownership of /proc/self/fd/* becomes root, so the process cannot exec it after it drops privileges. It uses prctl() in other places to get the same effect in /proc, but that's one of the most critical.

Signature · 3 lines
<[email protected]> <[email protected]> <[email protected]> <[email protected]>
  Stanford Ph.D. Student - MSU Alumnus - Debian Maintainer - GNU Developer
                              www.benpfaff.org
#2 lore raw
Quoted 8 lines · Ben Pfaff

I am concerned about this change because it will break sandboxing software that I have written, which uses prctl() to turn dumpability back on so that it can open a file, setuid(), and then execve() through the open file via /proc/self/fd/#. Without calling prctl(), the ownership of /proc/self/fd/* becomes root, so the process cannot exec it after it drops privileges. It uses prctl() in other places to get the same effect in /proc, but that's one of the most critical.

The dumpability is per mm, which means that you have to consider all the cases of a thread being created in parallel to dumpability being enabled.

So consider a three threaded process. Thread one triggers kernel thread creation, thread two turns dumpability back on, thread three ptraces the new kernel thread.

Proving that is safe is non trivial so the current patch chooses not to attempt it. For 2.4.21 proper someone can sit down and do the needed verification if they wish