Lines Matching refs:dso

24  * functions. These two functions will be called before visiting other dso's resources. The responsibility is to
25 * calculate the __cfi_check() of the target dso, and call it. So use CFI shadow and shadow value to store the
26 * relationship between dso and its __cfi_check addr while loading a dso. CFI shadow is an array which stores shadow
28 * each dso will be mapped to one or more shadow values in the CFI shadow, this depends on the address range of the
29 * dso.
31 * - invalid(0) : the target addr does not belongs to any loaded dso.
32 * - uncheck(1) : this LIBRARY_ALIGNMENT memory range belongs to a dso but it is no need to do the CFI check.
33 * - valid(2 - 0xFFFF) : this LIBRARY_ALIGNMENT memory range belongs to a dso and need to do the CFI check.
35 * of the dso (The unit is 4096, because the __cfi_check is aligned with 4096).
39 * N : starts at 0, is the index of LIBRARY_ALIGNMENT memory range that belongs to a dso.
42 * Below is a example for calculating shadow values of a dso.
66 * In order for the algorithm to work well, the start addr of each dso should be aligned with LIBRARY_ALIGNMENT. */
88 static struct dso *dso_list_head = NULL;
89 static struct dso *pldso = NULL;
94 * - removing a dso. */
98 * - the DSO enabled CFI Cross-Dso, but this DSO is larger than 16G, for the part of the dso that exceeds 16G,
115 static int add_dso_to_cfi_shadow(struct dso *dso);
118 /* Find the __cfi_check() of target dso and call it */
129 static struct symdef find_cfi_check_sym(struct dso *p)
179 LD_LOGD("[CFI] [%{public}s] cfi_check_func_addr[%{public}p] in dso[%{public}s]\n",
180 __FUNCTION__, cfi_check_func_addr, ((struct dso *)addr2dso((size_t)cfi_check_func_addr))->name);
216 ((struct dso *)addr2dso((size_t)__builtin_return_address(0)))->name,
217 ((struct dso *)addr2dso((size_t)func_ptr))->name,
220 struct dso *dso = NULL;
231 dso = (struct dso *)addr2dso((size_t)__builtin_return_address(0));
232 if (dso == NULL) {
233 LD_LOGE("[CFI] [%{public}s] can not find the dso from address:%{public}p func_ptr:0x%{public}p shadow value:%{public}d call_site_type_id[%{public}p!\n",
239 LD_LOGD("[CFI] [%{public}s] dso name[%{public}s]!\n", __FUNCTION__, dso->name);
241 struct symdef cfi_check_sym = find_cfi_check_sym(dso);
243 LD_LOGE("[CFI] [%{public}s] can not find the __cfi_check in the dso: %{public}s func_ptr:0x%{public}p shadow value:%{public}d call_site_type_id[%{public}p!\n",
245 ((struct dso *)addr2dso((size_t)__builtin_return_address(0)))->name,
250 LADDR(cfi_check_sym.dso, cfi_check_sym.sym->st_value));
251 ((cfi_check_t)LADDR(cfi_check_sym.dso, cfi_check_sym.sym->st_value))(call_site_type_id, func_ptr, diag_data);
263 int init_cfi_shadow(struct dso *dso_list, struct dso *ldso)
272 /* Save the head node of dso list */
279 int map_dso_to_cfi_shadow(struct dso *dso)
283 if (dso == NULL) {
290 /* Find __cfi_check symbol in dso list */
291 for (struct dso *p = dso; p; p = p->next) {
293 LD_LOGD("[CFI] [%{public}s] find __cfi_check function in dso %{public}s!\n", __FUNCTION__, p->name);
307 /* If the cfi shadow exists, map the current dso and its dependents to it. */
309 add_dso_to_cfi_shadow(dso);
316 void unmap_dso_from_cfi_shadow(struct dso *dso)
318 if (dso == NULL) {
323 LD_LOGD("[CFI] [%{public}s] unmap dso %{public}s from shadow!\n", __FUNCTION__, dso->name);
328 if (dso->map == 0 || dso->map_len == 0)
331 if (dso->is_mapped_to_shadow == false)
334 /* Set the dso's shadow value as invalid. */
335 fill_shadow_value_to_shadow(dso->map, dso->map + dso->map_len, 0, sv_invalid);
336 dso->is_mapped_to_shadow = false;
363 static int add_dso_to_cfi_shadow(struct dso *dso)
365 LD_LOGD("[CFI] [%{public}s] start with %{public}s !\n", __FUNCTION__, dso->name);
366 for (struct dso *p = dso; p; p = p->next) {
369 LD_LOGW("[CFI] [%{public}s] the dso has no data! map[%{public}p] map_len[0x%{public}x]\n",
380 /* If the dso doesn't have __cfi_check(), set it's shadow value unchecked. */
384 LD_LOGE("[CFI] [%{public}s] add dso to cfi shadow failed!\n", __FUNCTION__);
387 /* If the dso has __cfi_check(), set it's shadow value valid. */
391 uintptr_t cfi_check = LADDR(cfi_check_sym.dso, cfi_check_sym.sym->st_value);
405 LD_LOGD("[CFI] [%{public}s] %{public}s done.\n", __FUNCTION__, dso->name);
440 /* If the dso has __cfi_check(), calculate valid shadow value */
456 /* If a dso is larger than 16G( = max_shadow_value * shadow_alignment / 1G),
495 LD_LOGD("[CFI] [%{public}s] called from dso[%{public}s] to dso[%{public}s] func_ptr[%{public}p]\n",
497 ((struct dso *)addr2dso((size_t)__builtin_return_address(0)))->name,
498 ((struct dso *)addr2dso((size_t)func_ptr))->name,
507 LD_LOGD("[CFI] [%{public}s] called from dso[%{public}s] to dso[%{public}s] func_ptr[%{public}p]\n",
509 ((struct dso *)addr2dso((size_t)__builtin_return_address(0)))->name,
510 ((struct dso *)addr2dso((size_t)func_ptr))->name,