tst.badcopyout.d revision 178476
182498Sroberto/*
254359Sroberto * CDDL HEADER START
382498Sroberto *
482498Sroberto * The contents of this file are subject to the terms of the
554359Sroberto * Common Development and Distribution License (the "License").
654359Sroberto * You may not use this file except in compliance with the License.
754359Sroberto *
854359Sroberto * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
954359Sroberto * or http://www.opensolaris.org/os/licensing.
1054359Sroberto * See the License for the specific language governing permissions
1154359Sroberto * and limitations under the License.
1254359Sroberto *
1354359Sroberto * When distributing Covered Code, include this CDDL HEADER in each
1454359Sroberto * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1554359Sroberto * If applicable, add the following below this CDDL HEADER, with the
1654359Sroberto * fields enclosed by brackets "[]" replaced with your own identifying
1754359Sroberto * information: Portions Copyright [yyyy] [name of copyright owner]
1854359Sroberto *
1954359Sroberto * CDDL HEADER END
2054359Sroberto */
2154359Sroberto
2254359Sroberto/*
2354359Sroberto * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2454359Sroberto * Use is subject to license terms.
2554359Sroberto */
2654359Sroberto
2754359Sroberto#pragma ident	"%Z%%M%	%I%	%E% SMI"
2854359Sroberto
2954359Sroberto/*
3054359Sroberto * ASSERTION:
3154359Sroberto *	On IA/32, there is a single 32-bit address space that is partitioned
3254359Sroberto *	between user-level and kernel-level.  copyin()/copyinstr() and
3354359Sroberto *	copyout()/copyoutstr() must check that addresses specified as
3454359Sroberto *	user-level addresses are actually at user-level.  This test attempts
3554359Sroberto *	to perform an illegal copyout() to a kernel address.  It asserts that
3654359Sroberto *	the fault type is DTRACEFLT_BADADDR and that the bad address is set to
3754359Sroberto *	the kernel address to which the copyout() was attempted.
3854359Sroberto *
3954359Sroberto * SECTION: Actions and Subroutines/copyout()
4054359Sroberto *
4154359Sroberto */
4254359Sroberto
4354359Sroberto#pragma D option destructive
4454359Sroberto
4554359SrobertoBEGIN
4654359Sroberto{
4754359Sroberto	this->a = (uint32_t *)alloca(4);
4854359Sroberto	*this->a = -1;
4954359Sroberto	copyout(this->a, (uintptr_t)&`clock, 4);
5082498Sroberto	exit(1);
5154359Sroberto}
5254359Sroberto
5354359SrobertoERROR
5454359Sroberto{
5554359Sroberto	exit(arg4 == DTRACEFLT_BADADDR && arg5 == (uint64_t)&`clock ? 0 : 1);
5654359Sroberto}
5754359Sroberto