1*2922Sdp /* 2*2922Sdp * CDDL HEADER START 3*2922Sdp * 4*2922Sdp * The contents of this file are subject to the terms of the 5*2922Sdp * Common Development and Distribution License (the "License"). 6*2922Sdp * You may not use this file except in compliance with the License. 7*2922Sdp * 8*2922Sdp * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*2922Sdp * or http://www.opensolaris.org/os/licensing. 10*2922Sdp * See the License for the specific language governing permissions 11*2922Sdp * and limitations under the License. 12*2922Sdp * 13*2922Sdp * When distributing Covered Code, include this CDDL HEADER in each 14*2922Sdp * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*2922Sdp * If applicable, add the following below this CDDL HEADER, with the 16*2922Sdp * fields enclosed by brackets "[]" replaced with your own identifying 17*2922Sdp * information: Portions Copyright [yyyy] [name of copyright owner] 18*2922Sdp * 19*2922Sdp * CDDL HEADER END 20*2922Sdp */ 21*2922Sdp 22*2922Sdp /* 23*2922Sdp * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*2922Sdp * Use is subject to license terms. 25*2922Sdp */ 26*2922Sdp 27*2922Sdp #pragma ident "%Z%%M% %I% %E% SMI" 28*2922Sdp 29*2922Sdp /* 30*2922Sdp * Test that there is no value of 'size' which can be passed to copyin 31*2922Sdp * to cause mischief. The somewhat odd order of operations ensures 32*2922Sdp * that we test both size = 0 and size = 0xfff...fff 33*2922Sdp */ 34*2922Sdp #include <sys/types.h> 35*2922Sdp 36*2922Sdp 37*2922Sdp #if defined(_LP64) 38*2922Sdp #define MAX_BITS 63 39*2922Sdp size_t size; 40*2922Sdp #else 41*2922Sdp #define MAX_BITS 31 42*2922Sdp size_t size; 43*2922Sdp #endif 44*2922Sdp 45*2922Sdp syscall::: 46*2922Sdp /pid == $pid/ 47*2922Sdp { 48*2922Sdp printf("size = 0x%lx\n", (ulong_t)size); 49*2922Sdp } 50*2922Sdp 51*2922Sdp syscall::: 52*2922Sdp /pid == $pid/ 53*2922Sdp { 54*2922Sdp tracemem(copyin(curthread->t_procp->p_user.u_envp, size), 10); 55*2922Sdp } 56*2922Sdp 57*2922Sdp syscall::: 58*2922Sdp /pid == $pid && size > (1 << MAX_BITS)/ 59*2922Sdp { 60*2922Sdp exit(0); 61*2922Sdp } 62*2922Sdp 63*2922Sdp syscall::: 64*2922Sdp /pid == $pid/ 65*2922Sdp { 66*2922Sdp size = (size << 1ULL) | 1ULL; 67*2922Sdp } 68