|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * Copyright (c) 1992 NeXT Computer, Inc. ! 24: * ! 25: * Selector value conversion/validation. ! 26: * ! 27: * HISTORY ! 28: * ! 29: * 19 June 1992 ? at NeXT ! 30: * Created. ! 31: */ ! 32: ! 33: #if 0 ! 34: #import <machdep/i386/table_inline.h> ! 35: #endif ! 36: ! 37: ! 38: static inline ! 39: unsigned int ! 40: sel_to_selector( ! 41: sel_t sel ! 42: ) ! 43: { ! 44: union { ! 45: sel_t sel; ! 46: unsigned short selector; ! 47: } tconv; ! 48: ! 49: tconv.sel = sel; ! 50: ! 51: return (tconv.selector); ! 52: } ! 53: ! 54: static inline ! 55: sel_t ! 56: selector_to_sel( ! 57: unsigned int selector ! 58: ) ! 59: { ! 60: union { ! 61: unsigned short selector; ! 62: sel_t sel; ! 63: } tconv; ! 64: ! 65: tconv.selector = selector; ! 66: ! 67: return (tconv.sel); ! 68: } ! 69: ! 70: #if 0 ! 71: static inline ! 72: boolean_t ! 73: valid_user_data_selector( ! 74: unsigned int selector ! 75: ) ! 76: { ! 77: sel_t sel = selector_to_sel(selector); ! 78: ! 79: if (selector == 0) ! 80: return (TRUE); ! 81: ! 82: if (sel.ti == SEL_LDT) ! 83: return (TRUE); ! 84: else if (sel.index < GDTSZ) { ! 85: data_desc_t *desc = (data_desc_t *)sel_to_gdt_entry(sel); ! 86: ! 87: if (desc->dpl == USER_PRIV) ! 88: return (TRUE); ! 89: } ! 90: ! 91: return (FALSE); ! 92: } ! 93: ! 94: static inline ! 95: boolean_t ! 96: valid_user_code_selector( ! 97: unsigned int selector ! 98: ) ! 99: { ! 100: sel_t sel = selector_to_sel(selector); ! 101: ! 102: if (selector == 0) ! 103: return (FALSE); ! 104: ! 105: if (sel.ti == SEL_LDT) { ! 106: if (sel.rpl == USER_PRIV) ! 107: return (TRUE); ! 108: } ! 109: else if (sel.index < GDTSZ && sel.rpl == USER_PRIV) { ! 110: code_desc_t *desc = (code_desc_t *)sel_to_gdt_entry(sel); ! 111: ! 112: if (desc->dpl == USER_PRIV) ! 113: return (TRUE); ! 114: } ! 115: ! 116: return (FALSE); ! 117: } ! 118: ! 119: static inline ! 120: boolean_t ! 121: valid_user_stack_selector( ! 122: unsigned int selector ! 123: ) ! 124: { ! 125: sel_t sel = selector_to_sel(selector); ! 126: ! 127: if (selector == 0) ! 128: return (FALSE); ! 129: ! 130: if (sel.ti == SEL_LDT) { ! 131: if (sel.rpl == USER_PRIV) ! 132: return (TRUE); ! 133: } ! 134: else if (sel.index < GDTSZ && sel.rpl == USER_PRIV) { ! 135: data_desc_t *desc = (data_desc_t *)sel_to_gdt_entry(sel); ! 136: ! 137: if (desc->dpl == USER_PRIV) ! 138: return (TRUE); ! 139: } ! 140: ! 141: return (FALSE); ! 142: } ! 143: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.