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

PTU causes process to exit prematurely #8

Open
charmoniumQ opened this issue Jul 4, 2024 · 0 comments
Open

PTU causes process to exit prematurely #8

charmoniumQ opened this issue Jul 4, 2024 · 0 comments

Comments

@charmoniumQ
Copy link

charmoniumQ commented Jul 4, 2024

This issue can be reproduced in a Docker container running Ubuntu 22.04 (e.g., docker run -it --rm ubuntu:22.04). Run the following script (or copy/paste each step):

set -ex

apt update
apt install -y curl git time proftpd gcc cmake make nano proftpd proftpd-mod-vroot

# Build provenance-to-use
git clone --recursive https://github.com/depaul-dice/provenance-to-use.git
cd provenance-to-use
# This patch is needed to compile provenance-to-use!
curl https://patch-diff.githubusercontent.com/raw/depaul-dice/provenance-to-use/pull/4.patch | patch --strip=1
./run.sh -r
export PATH=$PWD:$PATH
cd ..

# Set up Profptd srv directory
mkdir --parents proftpd/srv
echo Hello World > proftpd/srv/test

# Write Proftpd config file
USER=$(id --user --name)
GROUP=$(id --group --name)
echo $USER $GROUP
cat <<EOF > proftpd/conf
DefaultAddress   0.0.0.0
Port             54123
User             $USER
Group            $GROUP
DelayTable       "$PWD/proftpd/delay"
ScoreboardFile   "$PWD/proftpd/scoreboard"
PidFile          "$PWD/proftpd/proftpd.pid"
TransferLog      "$PWD/proftpd/xferlog"
DefaultRoot      "$PWD/proftpd/srv"
LoadFile         "/lib/proftpd/mod_vroot.so"
LoadModule       mod_vroot.c
VRootEngine       on
WtmpLog           off
RequireValidShell off
<Anonymous $PWD/proftpd/srv/>
    User $USER
    Group $GROUP
    UserAlias anonymous $USER
    <Directory *>
        AllowAll
    </Directory>
</Anonymous>
EOF

Make sure the script completes successfully. Then we will test the behavior of a script with and without PTU. The script is

proftpd --nodaemon --config $PWD/proftpd/conf &
pid=$! 
sleep 5
kill $pid
wait $pid

The script starts ProFTPD in the background, records its PID, waits for 5 seconds, kills ProFTPD, and waits for it to finish shutting down In a realistic setting, sleep 5 would be replaced with some FTP client activity (e.g., a load test). This script should take a little more than five seconds of "real" time, which should be shown on the third field of the last line. Indeed it is when we run natively (no PTU):

root@af7254134e60:/# cd PROBE/benchmark
root@af7254134e60:/PROBE/benchmark# \time sh -c 'proftpd --nodaemon --config $PWD/proftpd/conf & pid=$! && sleep 5 && kill $pid && wait $pid'
2024-07-04 22:06:24,378 af7254134e60 proftpd[22159] 0.0.0.0: ProFTPD 1.3.8 (stable) (built Tue Jan 1 1980 00:00:00 UTC) standalone mode STARTUP
2024-07-04 22:06:29,776 af7254134e60 proftpd[22159] 0.0.0.0: ProFTPD killed (signal 15)
2024-07-04 22:06:29,776 af7254134e60 proftpd[22159] 0.0.0.0: ProFTPD 1.3.8 standalone mode SHUTDOWN
0.00user 0.00system 0:05.40elapsed 0%CPU (0avgtext+0avgdata 3200maxresident)k
0inputs+144outputs (0major+640minor)pagefaults 0swaps
root@af7254134e60:/PROBE/benchmark#

The nix shell <pkgs>... --command <cmd>... simply runs <cmd>... in a reproducible environment containing <pkgs>....

However if we do the same script with ptu, the script does not wait 5 seconds. The whole script completes in a fraction of a second. This means that the client load, represented by sleep 5 would not get a chance to connect to the FTP server.

root@af7254134e60:/PROBE/benchmark# \time ptu sh -c 'proftpd --nodaemon --config $PWD/proftpd/conf & pid=$! && sleep 5 && kill $pid && wait $pid'
Provenance log file: /PROBE/benchmark/cde-package/provenance.cde-root.5.log
Command terminated by signal 11
0.00user 0.01system 0:00.07elapsed 17%CPU (0avgtext+0avgdata 2688maxresident)k
0inputs+1416outputs (0major+523minor)pagefaults 0swaps
root@af7254134e60:/PROBE/benchmark# 2024-07-04 22:09:33,001 af7254134e60 proftpd[22204] 0.0.0.0: ProFTPD 1.3.8 (stable) (built Tue Jan 1 1980 00:00:00 UTC) standalone mode STARTUP
root@af7254134e60:/PROBE/benchmark# 
root@af7254134e60:/PROBE/benchmark# 
root@af7254134e60:/PROBE/benchmark# 2024-07-04 22:09:38,337 af7254134e60 proftpd[22204] 0.0.0.0: ProFTPD killed (signal 15)
2024-07-04 22:09:38,338 af7254134e60 proftpd[22204] 0.0.0.0: ProFTPD 1.3.8 standalone mode SHUTDOWN
root@af7254134e60:/PROBE/benchmark# 

Note that the prompt returns to the user as soon as the output of time is finished (line beginning with 0inputs), at which point, I pressed <enter> to get new blank prompts. It seems that the tracee process (sh -c '...') continues to execute, since we see its output but perhaps gets orphaned by the ptu process, which already terminated.

@charmoniumQ charmoniumQ changed the title PTU causes program process to exit prematurely PTU causes process to exit prematurely Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant