tst.badcopyoutstr.d revision 259065
1158979Snetchild/*
2166322Sjoel * CDDL HEADER START
3166322Sjoel *
4166322Sjoel * The contents of this file are subject to the terms of the
5158979Snetchild * Common Development and Distribution License (the "License").
6166322Sjoel * You may not use this file except in compliance with the License.
7166322Sjoel *
8166322Sjoel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9166322Sjoel * or http://www.opensolaris.org/os/licensing.
10166322Sjoel * See the License for the specific language governing permissions
11166322Sjoel * and limitations under the License.
12166322Sjoel *
13166322Sjoel * When distributing Covered Code, include this CDDL HEADER in each
14166322Sjoel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15166322Sjoel * If applicable, add the following below this CDDL HEADER, with the
16166322Sjoel * fields enclosed by brackets "[]" replaced with your own identifying
17166322Sjoel * information: Portions Copyright [yyyy] [name of copyright owner]
18166322Sjoel *
19166322Sjoel * CDDL HEADER END
20166322Sjoel */
21166322Sjoel
22158979Snetchild/*
23158979Snetchild * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24158979Snetchild * Use is subject to license terms.
25158979Snetchild */
26158979Snetchild
27158979Snetchild#pragma ident	"%Z%%M%	%I%	%E% SMI"
28158979Snetchild
29158979Snetchild/*
30158979Snetchild * ASSERTION:
31158979Snetchild *	On IA/32, there is a single 32-bit address space that is partitioned
32158979Snetchild *	between user-level and kernel-level.  copyin()/copyinstr() and
33158979Snetchild *	copyout()/copyoutstr() must check that addresses specified as
34166971Snetchild *	user-level addresses are actually at user-level.  This test attempts
35158979Snetchild *	to perform an illegal copyoutstr() to a kernel address.  It asserts
36166971Snetchild *	that the fault type is DTRACEFLT_BADADDR and that the bad address is
37166971Snetchild *	set to the kernel address to which the copyoutstr() was attempted.
38166971Snetchild *
39166971Snetchild * SECTION: Actions and Subroutines/copyoutstr()
40166971Snetchild *
41158979Snetchild */
42
43#pragma D option destructive
44
45BEGIN
46{
47	this->str = alloca(10);
48	bcopy("kablammo!", this->str, 10);
49	copyoutstr(this->str, (uintptr_t)&`clock, 10);
50	exit(1);
51}
52
53ERROR
54{
55	exit(arg4 == DTRACEFLT_BADADDR && arg5 == (uint64_t)&`clock ? 0 : 1);
56}
57