18e648814SRui Paulo#! /usr/bin/ksh 28e648814SRui Paulo# 38e648814SRui Paulo# 48e648814SRui Paulo# This file and its contents are supplied under the terms of the 58e648814SRui Paulo# Common Development and Distribution License ("CDDL"), version 1.0. 68e648814SRui Paulo# You may only use this file in accordance with the terms of version 78e648814SRui Paulo# 1.0 of the CDDL. 88e648814SRui Paulo# 98e648814SRui Paulo# A full copy of the text of the CDDL should have accompanied this 108e648814SRui Paulo# source. A copy of the CDDL is also available via the Internet at 118e648814SRui Paulo# http://www.illumos.org/license/CDDL. 128e648814SRui Paulo# 138e648814SRui Paulo 148e648814SRui Paulo# 158e648814SRui Paulo# Copyright (c) 2013 Joyent, Inc. All rights reserved. 168e648814SRui Paulo# 178e648814SRui Paulo 188e648814SRui Paulo# 198e648814SRui Paulo# This test is purposefully using a 64-bit DTrace and thus 64-bit types 208e648814SRui Paulo# when compared with a 32-bit process. This test uses the userland 218e648814SRui Paulo# keyword and so the implicit copyin should access illegal memory and 228e648814SRui Paulo# thus exit. 238e648814SRui Paulo# 248e648814SRui Paulo 258e648814SRui Pauloif [ $# != 1 ]; then 268e648814SRui Paulo echo expected one argument: '<'dtrace-path'>' 278e648814SRui Paulo exit 2 288e648814SRui Paulofi 298e648814SRui Paulo 308e648814SRui Paulodtrace=$1 318e648814SRui Paulot="zelda_info_t" 328e648814SRui Pauloexe="tst.chasestrings.exe" 338e648814SRui Paulo 34*a5ddd965SMark Johnstonelfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' 358e648814SRui Pauloif [[ $? -ne 0 ]]; then 368e648814SRui Paulo echo "CTF does not exist in $exe, that's a bug" >&2 378e648814SRui Paulo exit 1 388e648814SRui Paulofi 398e648814SRui Paulo 408e648814SRui Paulo./$exe & 418e648814SRui Paulopid=$! 428e648814SRui Paulo 438e648814SRui Paulo$dtrace -64 -qs /dev/stdin <<EOF 448e648814SRui Paulotypedef struct info { 458e648814SRui Paulo char *zi_gamename; 468e648814SRui Paulo int zi_ndungeons; 478e648814SRui Paulo char *zi_villain; 488e648814SRui Paulo int zi_haszelda; 498e648814SRui Paulo} info_t; 508e648814SRui Paulo 518e648814SRui Paulopid$pid::has_princess:entry 528e648814SRui Paulo/next == 0/ 538e648814SRui Paulo{ 548e648814SRui Paulo this->t = (userland info_t *)arg0; 558e648814SRui Paulo printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 568e648814SRui Paulo stringof(this->t->zi_gamename), this->t->zi_ndungeons, 578e648814SRui Paulo stringof(this->t->zi_villain), this->t->zi_haszelda); 588e648814SRui Paulo next = 1; 598e648814SRui Paulo} 608e648814SRui Paulo 618e648814SRui Paulopid$pid::has_dungeons:entry 628e648814SRui Paulo/next == 1/ 638e648814SRui Paulo{ 648e648814SRui Paulo this->t = (userland info_t *)arg0; 658e648814SRui Paulo printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 668e648814SRui Paulo stringof(this->t->zi_gamename), this->t->zi_ndungeons, 678e648814SRui Paulo stringof(this->t->zi_villain), this->t->zi_haszelda); 688e648814SRui Paulo next = 2; 698e648814SRui Paulo} 708e648814SRui Paulo 718e648814SRui Paulopid$pid::has_villain:entry 728e648814SRui Paulo/next == 2/ 738e648814SRui Paulo{ 748e648814SRui Paulo this->t = (userland info_t *)arg0; 758e648814SRui Paulo printf("game: %s, dungeon: %d, villain: %s, zelda: %d\n", 768e648814SRui Paulo stringof(this->t->zi_gamename), this->t->zi_ndungeons, 778e648814SRui Paulo stringof(this->t->zi_villain), this->t->zi_haszelda); 788e648814SRui Paulo exit(0); 798e648814SRui Paulo} 808e648814SRui Paulo 818e648814SRui PauloERROR 828e648814SRui Paulo{ 838e648814SRui Paulo exit(1); 848e648814SRui Paulo} 858e648814SRui PauloEOF 868e648814SRui Paulorc=$? 878e648814SRui Paulo 888e648814SRui Paulokill -9 $pid 898e648814SRui Paulo 908e648814SRui Pauloexit $rc 91