1*d2a70789SRichard Lowe#! /usr/bin/ksh 2*d2a70789SRichard Lowe# 3*d2a70789SRichard Lowe# 4*d2a70789SRichard Lowe# This file and its contents are supplied under the terms of the 5*d2a70789SRichard Lowe# Common Development and Distribution License ("CDDL"), version 1.0. 6*d2a70789SRichard Lowe# You may only use this file in accordance with the terms of version 7*d2a70789SRichard Lowe# 1.0 of the CDDL. 8*d2a70789SRichard Lowe# 9*d2a70789SRichard Lowe# A full copy of the text of the CDDL should have accompanied this 10*d2a70789SRichard Lowe# source. A copy of the CDDL is also available via the Internet at 11*d2a70789SRichard Lowe# http://www.illumos.org/license/CDDL. 12*d2a70789SRichard Lowe# 13*d2a70789SRichard Lowe 14*d2a70789SRichard Lowe# Copyright 2015, Richard Lowe. 15*d2a70789SRichard Lowe 16*d2a70789SRichard Lowe# Verify that aslr messes things up, by comparing the mappings of 2 identical 17*d2a70789SRichard Lowe# processes 18*d2a70789SRichard Lowe 19*d2a70789SRichard LoweLC_ALL=C # Collation is important 20*d2a70789SRichard Lowe 21*d2a70789SRichard Lowe/usr/bin/psecflags -s aslr $$ 22*d2a70789SRichard Lowe 23*d2a70789SRichard Lowetmpdir=/tmp/test.$$ 24*d2a70789SRichard Lowe 25*d2a70789SRichard Lowemkdir $tmpdir 26*d2a70789SRichard Lowecd $tmpdir 27*d2a70789SRichard Lowe 28*d2a70789SRichard Lowecleanup() { 29*d2a70789SRichard Lowe cd / 30*d2a70789SRichard Lowe rm -fr $tmpdir 31*d2a70789SRichard Lowe} 32*d2a70789SRichard Lowe 33*d2a70789SRichard Lowetrap 'cleanup' EXIT 34*d2a70789SRichard Lowe 35*d2a70789SRichard Lowecheck() { 36*d2a70789SRichard Lowe typeset name=$1 37*d2a70789SRichard Lowe typeset command=$2 38*d2a70789SRichard Lowe 39*d2a70789SRichard Lowe for (( i=0; i < 1000; i++ )); do 40*d2a70789SRichard Lowe $command > out.$i 41*d2a70789SRichard Lowe done 42*d2a70789SRichard Lowe 43*d2a70789SRichard Lowe cat out.* | sort | uniq -c | sort -nk 1 | nawk ' 44*d2a70789SRichard Lowe BEGIN { 45*d2a70789SRichard Lowe tot = 0 46*d2a70789SRichard Lowe colls = 0 47*d2a70789SRichard Lowe } 48*d2a70789SRichard Lowe 49*d2a70789SRichard Lowe $2 != "text:" { 50*d2a70789SRichard Lowe tot += $1 51*d2a70789SRichard Lowe if ($1 > 1) { 52*d2a70789SRichard Lowe colls += $1 53*d2a70789SRichard Lowe } 54*d2a70789SRichard Lowe } 55*d2a70789SRichard Lowe 56*d2a70789SRichard Lowe END { 57*d2a70789SRichard Lowe prc = (colls / tot) * 100 58*d2a70789SRichard Lowe printf "'$name' Collisions: %d/%d (%g%%)\n", colls, tot, prc 59*d2a70789SRichard Lowe exit prc 60*d2a70789SRichard Lowe } 61*d2a70789SRichard Lowe' 62*d2a70789SRichard Lowe return $? 63*d2a70789SRichard Lowe} 64*d2a70789SRichard Lowe 65*d2a70789SRichard Lowe# Somewhat arbitrary 66*d2a70789SRichard LoweACCEPTABLE=70 67*d2a70789SRichard Lowe 68*d2a70789SRichard Loweret=0 69*d2a70789SRichard Lowecheck 32bit /opt/os-tests/tests/secflags/addrs-32 70*d2a70789SRichard Lowe(( $? > $ACCEPTABLE )) && ret=1 71*d2a70789SRichard Lowecheck 64bit /opt/os-tests/tests/secflags/addrs-64 72*d2a70789SRichard Lowe(( $? > $ACCEPTABLE )) && ret=1 73*d2a70789SRichard Lowe 74*d2a70789SRichard Loweexit $ret 75