4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
35 #include <sys/modctl.h>
36 #include <sys/types.h>
39 * All Brands supported by this kernel must use BRAND_VER_1.
44 * sub-commands to brandsys.
45 * 1 - 128 are for common commands
46 * 128+ are available for brand-specific commands.
51 #define B_EXEC_NATIVE 4
52 #define B_EXEC_BRAND 5
53 #define B_TRUSS_POINT 6
56 * Structure used by zoneadmd to communicate the name of a brand and the
57 * supporting brand module into the kernel.
60 char ba_brandname
[MAXNAMELEN
];
61 char ba_modname
[MAXPATHLEN
];
64 /* What we call the native brand. */
65 #define NATIVE_BRAND_NAME "native"
67 /* What we call the labeled brand. */
68 #define LABELED_BRAND_NAME "labeled"
71 * Aux vector containing lddata pointer of brand library linkmap.
72 * Used by common {brand}_librtld_db.
74 #define AT_SUN_BRAND_COMMON_LDDATA AT_SUN_BRAND_AUX1
77 * Information needed by the brand library to launch an executable.
79 typedef struct brand_elf_data
{
90 * Common structure used to register a branded processes
92 typedef struct brand_proc_reg
{
93 uint_t sbr_version
; /* version number */
94 caddr_t sbr_handler
; /* base address of handler */
101 struct brand_mach_ops
;
106 void (*b_init_brand_data
)(zone_t
*);
107 void (*b_free_brand_data
)(zone_t
*);
108 int (*b_brandsys
)(int, int64_t *, uintptr_t, uintptr_t, uintptr_t,
109 uintptr_t, uintptr_t, uintptr_t);
110 void (*b_setbrand
)(struct proc
*);
111 int (*b_getattr
)(zone_t
*, int, void *, size_t *);
112 int (*b_setattr
)(zone_t
*, int, void *, size_t);
113 void (*b_copy_procdata
)(struct proc
*, struct proc
*);
114 void (*b_proc_exit
)(struct proc
*, klwp_t
*);
116 void (*b_lwp_setrval
)(klwp_t
*, int, int);
117 int (*b_initlwp
)(klwp_t
*);
118 void (*b_forklwp
)(klwp_t
*, klwp_t
*);
119 void (*b_freelwp
)(klwp_t
*);
120 void (*b_lwpexit
)(klwp_t
*);
121 int (*b_elfexec
)(struct vnode
*vp
, struct execa
*uap
,
122 struct uarg
*args
, struct intpdata
*idata
, int level
,
123 long *execsz
, int setid
, caddr_t exec_file
,
124 struct cred
*cred
, int brand_action
);
125 void (*b_sigset_native_to_brand
)(sigset_t
*);
126 void (*b_sigset_brand_to_native
)(sigset_t
*);
131 * The b_version field must always be the first entry in this struct.
133 typedef struct brand
{
136 struct brand_ops
*b_ops
;
137 struct brand_mach_ops
*b_machops
;
140 extern brand_t native_brand
;
145 #define lwptolwpbrand(l) ((l)->lwp_brand)
146 #define ttolwpbrand(t) (lwptolwpbrand(ttolwp(t)))
147 #define PROC_IS_BRANDED(p) ((p)->p_brand != &native_brand)
148 #define ZONE_IS_BRANDED(z) ((z)->zone_brand != &native_brand)
149 #define BROP(p) ((p)->p_brand->b_ops)
150 #define ZBROP(z) ((z)->zone_brand->b_ops)
151 #define BRMOP(p) ((p)->p_brand->b_machops)
152 #define SIGSET_NATIVE_TO_BRAND(sigset) \
153 if (PROC_IS_BRANDED(curproc) && \
154 BROP(curproc)->b_sigset_native_to_brand) \
155 BROP(curproc)->b_sigset_native_to_brand(sigset)
156 #define SIGSET_BRAND_TO_NATIVE(sigset) \
157 if (PROC_IS_BRANDED(curproc) && \
158 BROP(curproc)->b_sigset_brand_to_native) \
159 BROP(curproc)->b_sigset_brand_to_native(sigset)
161 extern void brand_init();
162 extern int brand_register(brand_t
*);
163 extern int brand_unregister(brand_t
*);
164 extern brand_t
*brand_register_zone(struct brand_attr
*);
165 extern brand_t
*brand_find_name(char *);
166 extern void brand_unregister_zone(brand_t
*);
167 extern int brand_zone_count(brand_t
*);
168 extern void brand_setbrand(proc_t
*);
169 extern void brand_clearbrand(proc_t
*, boolean_t
);
172 * The following functions can be shared among kernel brand modules which
173 * implement Solaris-derived brands, all of which need to do similar tasks to
176 extern int brand_solaris_cmd(int, uintptr_t, uintptr_t, uintptr_t,
177 struct brand
*, int);
178 extern void brand_solaris_copy_procdata(proc_t
*, proc_t
*,
180 extern int brand_solaris_elfexec(vnode_t
*, execa_t
*, uarg_t
*,
181 intpdata_t
*, int, long *, int, caddr_t
, cred_t
*, int,
182 struct brand
*, char *, char *, char *, char *, char *);
183 extern void brand_solaris_exec(struct brand
*);
184 extern int brand_solaris_fini(char **, struct modlinkage
*,
186 extern void brand_solaris_forklwp(klwp_t
*, klwp_t
*, struct brand
*);
187 extern void brand_solaris_freelwp(klwp_t
*, struct brand
*);
188 extern int brand_solaris_initlwp(klwp_t
*, struct brand
*);
189 extern void brand_solaris_lwpexit(klwp_t
*, struct brand
*);
190 extern void brand_solaris_proc_exit(struct proc
*, klwp_t
*,
192 extern void brand_solaris_setbrand(proc_t
*, struct brand
*);
194 #if defined(_SYSCALL32)
195 typedef struct brand_elf_data32
{
201 uint32_t sed_ldentry
;
203 } brand_elf_data32_t
;
205 typedef struct brand_common_reg32
{
206 uint32_t sbr_version
; /* version number */
207 caddr32_t sbr_handler
; /* base address of handler */
208 } brand_common_reg32_t
;
209 #endif /* _SYSCALL32 */
212 * Common information associated with all branded processes
214 typedef struct brand_proc_data
{
215 caddr_t spd_handler
; /* address of user-space handler */
216 brand_elf_data_t spd_elf_data
; /* common ELF data for branded app. */
219 #define BRAND_NATIVE_DIR "/.SUNWnative/"
220 #define BRAND_NATIVE_LINKER32 BRAND_NATIVE_DIR "lib/ld.so.1"
221 #define BRAND_NATIVE_LINKER64 BRAND_NATIVE_DIR "lib/64/ld.so.1"
229 #endif /* _SYS_BRAND_H */