2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-03 07:45:50 +00:00

make longpath a default test

This commit is contained in:
John Johansen
2008-03-08 04:17:40 +00:00
parent 7e69d3c91c
commit ed4e639d7e
2 changed files with 40 additions and 13 deletions

View File

@@ -142,10 +142,11 @@ TESTS=access \
syscall \ syscall \
unix_fd_server \ unix_fd_server \
unlink\ unlink\
xattrs xattrs\
longpath
# Tests that can crash the kernel should be placed here # Tests that can crash the kernel should be placed here
RISKY_TESTS=longpath RISKY_TESTS=
all: $(EXEC) changehat.h all: $(EXEC) changehat.h

View File

@@ -13,6 +13,13 @@
# Verify handling of long pathnames. # Verify handling of long pathnames.
#=END #=END
pwd=`dirname $0`
pwd=`cd $pwd ; /bin/pwd`
bin=$pwd
. $bin/prologue.inc
genrandname() genrandname()
{ {
_goal=$1 _goal=$1
@@ -28,16 +35,27 @@ genrandname()
echo $_s echo $_s
} }
pwd=`dirname $0`
pwd=`cd $pwd ; /bin/pwd`
bin=$pwd
. $bin/prologue.inc
name_max=255 #NAME_MAX name_max=255 #NAME_MAX
direlem_max=235 #Length for intermediate dirs, slightly less than name_max direlem_max=235 #Length for intermediate dirs, slightly less than name_max
buf_max=4096 #PAGE #if [ -f /sys/module/apparmor/parameters/path_max ] ; then
# buf_max=`cat /sys/module/apparmor/parameters/path_max`
#else
# buf_max=4096 #standard x86 page size
#fi
#sigh this isn't right but bash's cd/getcwd limit path to a pagesize
buf_max=4096 #standard x86 page size
# change apparmor's path buffer to something less than buf_max so we can
# actually test overflowing apparmor's max buffer
if [ -f /sys/module/apparmor/parameters/path_max ] ; then
buf_max=2048 #standard x86 page size/2
old_max=`cat /sys/module/apparmor/parameters/path_max`
echo $buf_max > /sys/module/apparmor/parameters/path_max
else
echo "WARNING: This version of AppArmor does not support changing buffer size."
fi
# generate 255 character filename # generate 255 character filename
file=`genrandname $name_max` file=`genrandname $name_max`
@@ -54,13 +72,15 @@ file_expected_fail=0
link_expected_fail=0 link_expected_fail=0
iter=1 iter=1
_dpwd=`pwd`
while true while true
do do
direlem=`genrandname $direlem_max` direlem=`genrandname $direlem_max`
#echo "loop ${iter}: ${#_dpwd} ${#direlem}"
_dpath=`pwd`/$direlem _dpath=${_dpwd}/$direlem
if [ ${#_dpath} -lt 4096 ] if [ ${#_dpath} -lt ${buf_max} ]
then then
dstatus=pass dstatus=pass
else else
@@ -77,6 +97,7 @@ do
then then
#echo "mkdir ($iter) passed at length ${#_dpath}" #echo "mkdir ($iter) passed at length ${#_dpath}"
cd $direlem cd $direlem
_dpwd="${_dpwd}/${direlem}"
else else
echo "FAIL: $direlem ($_iter) was not created" >&2 echo "FAIL: $direlem ($_iter) was not created" >&2
fi fi
@@ -91,8 +112,8 @@ do
: :
fi fi
_fpath=`pwd`/$file _fpath=${_dpath}/$file
if [ ${#_fpath} -lt 4096 ] if [ ${#_fpath} -lt ${buf_max} ]
then then
fstatus=pass fstatus=pass
else else
@@ -167,3 +188,8 @@ do
: $((iter++)) : $((iter++))
done done
#restore buffer_max if present
if [ -f /sys/module/apparmor/parameters/path_max ] ; then
echo $old_max > /sys/module/apparmor/parameters/path_max
fi