Last active
December 15, 2019 03:11
-
-
Save iAklis/ea544a147f2d3a75ebce3ddf05b03b3e to your computer and use it in GitHub Desktop.
Proof of concept of dying cgroup and dirty slab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
old_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}') | |
free -m | |
slabtop -o | head | |
echo "now the number of memory cgroup is $old_memcg_num" | |
echo "begin to create cgroups" | |
prefix=/sys/fs/cgroup/memory/aklis | |
for i in {1..1000}; | |
do | |
mkdir $prefix-$i; | |
bash -c "echo \$\$ > $prefix-$i/tasks; mkdir /tmp/$i; echo 'fubao'>/tmp/$i/pandada8;" | |
done | |
created_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}') | |
free -m | |
slabtop -o | head | |
echo "now the number of memory cgroup is $created_memcg_num" | |
echo "begin to del cgroups that created by Poc, pddka!" | |
for i in {1..1000}; | |
do | |
rmdir $prefix-$i; | |
done | |
free -m | |
slabtop -o | head | |
deleted_memcg_num=$(cat /proc/cgroups | awk '/memory/ {print $3}') | |
echo "now the number of memory cgroup is $deleted_memcg_num" | |
echo "P.S. remember to clear the tmp file (/tmp)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment