| 1 | /* |
| 2 | * Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * Daniel Kopecek <[email protected]> |
| 21 | */ |
| 22 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 23 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 24 | #endif |
| 25 | |
| 26 | #include <pthread.h> |
| 27 | #include <stddef.h> |
| 28 | #include <sexp.h>cxx . . $ `<file>/src/OVAL/probes/SEAP/public/sexp.h`/ |
| 29 | #include <errno.h> |
| 30 | #include <string.h> |
| 31 | #include <inttypes.h> |
| 32 | #include <stdlib.h> |
| 33 | |
| 34 | #if defined(OS_FREEBSD) |
| 35 | #include <pthread_np.h> |
| 36 | #endif |
| 37 | |
| 38 | #include "../SEAP/generic/rbt/rbt.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/generic/rbt/rbt.h`/ |
| 39 | #include "probe-api.h"cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 40 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 41 | #include "common/memusage.h"cxx . . $ `<file>/src/common/memusage.h`/ |
| 42 | #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/ |
| 43 | |
| 44 | #include "probe.h"cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/ |
| 45 | #include "icache.h"cxx . . $ `<file>/src/OVAL/probes/probe/icache.h`/ |
| 46 | #include "_sexp-ID.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_sexp-ID.h`/ |
| 47 | |
| 48 | static volatile uint32_tcxx . . $ uint32_t# next_IDcxx . . $ next_ID. = 0; |
| 49 | |
| 50 | #if !defined(HAVE_ATOMIC_FUNCTIONS) |
| 51 | pthread_mutex_tcxx . . $ pthread_mutex_t# next_ID_mutexcxx . . $ next_ID_mutex. = PTHREAD_MUTEX_INITIALIZERcxx . . $ `<external>/14712363683955484316/pthread.h:90:9`!; |
| 52 | #endif |
| 53 | |
| 54 | static void probe_icache_item_setIDcxx . . $ probe_icache_item_setID(4f986c622adc599b).(SEXP_tcxx . . $ SEXP_t# *item, SEXP_ID_tcxx . . $ SEXP_ID_t# item_ID) |
| 55 | { |
| 56 | SEXP_tcxx . . $ SEXP_t# *name_ref, *prev_id; |
| 57 | SEXP_tcxx . . $ SEXP_t# uniq_id; |
| 58 | uint32_tcxx . . $ uint32_t# local_id; |
| 59 | |
| 60 | /* ((foo_item :id "<int>") ... ) */ |
| 61 | |
| 62 | if (item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 63 | return; |
| 64 | } |
| 65 | if (!SEXP_listpcxx . . $ SEXP_listp(85f078d1f48ac431).(item)) { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | #if defined(HAVE_ATOMIC_FUNCTIONS) |
| 70 | local_id = __sync_fetch_and_add(&next_ID, 1); |
| 71 | #else |
| 72 | if (pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&next_ID_mutexcxx . . $ next_ID_mutex.) != 0) { |
| 73 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't lock the next_ID_mutex: %u, %s", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 74 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 75 | } |
| 76 | |
| 77 | local_id = ++next_IDcxx . . $ next_ID.; |
| 78 | |
| 79 | if (pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&next_ID_mutexcxx . . $ next_ID_mutex.) != 0) { |
| 80 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't unlock the next_ID_mutex: %u, %s", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 81 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 82 | } |
| 83 | #endif |
| 84 | SEXP_string_newf_rcxx . . $ SEXP_string_newf_r(f7254ae56fe447d7).(&uniq_id, "1%05u%u", getpidcxx . . $ getpid(b126dc7c1de90089).(), local_id); |
| 85 | |
| 86 | name_ref = SEXP_listref_firstcxx . . $ SEXP_listref_first(478b347fcbbad3c5).(item); |
| 87 | prev_id = SEXP_list_replacecxx . . $ SEXP_list_replace(e5ee5adb82430ce5).(name_ref, 3, &uniq_id); |
| 88 | |
| 89 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(prev_id); |
| 90 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&uniq_id); |
| 91 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ref); |
| 92 | |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | static int icache_lookupcxx . . $ icache_lookup(4cb2a9090e1d280d).(rbt_tcxx . . $ rbt_t# *tree, int64_tcxx . . $ int64_t# item_id, probe_iqpair_tcxx . . $ probe_iqpair_t# *pair) { |
| 97 | |
| 98 | probe_citem_tcxx . . $ probe_citem_t# *cached = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 99 | |
| 100 | if (rbt_i64_getcxx . . $ rbt_i64_get(ad6c390963f26e29).(tree, item_id, (void**)&cached) != 0) { |
| 101 | return -1; |
| 102 | } |
| 103 | |
| 104 | /* |
| 105 | * Maybe a cache HIT |
| 106 | */ |
| 107 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("cache HIT #1"); |
| 108 | |
| 109 | register uint16_tcxx . . $ uint16_t# i; |
| 110 | for (i = 0; i < cached->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count.; ++i) { |
| 111 | SEXP_tcxx . . $ SEXP_t# rest1; |
| 112 | SEXP_tcxx . . $ SEXP_t#* rest_r1 = SEXP_list_rest_rcxx . . $ SEXP_list_rest_r(35a066576d9f6ea6).(&rest1, pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item.); |
| 113 | |
| 114 | SEXP_tcxx . . $ SEXP_t# rest2; |
| 115 | SEXP_tcxx . . $ SEXP_t#* rest_r2 = SEXP_list_rest_rcxx . . $ SEXP_list_rest_r(35a066576d9f6ea6).(&rest2, cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.[i]); |
| 116 | |
| 117 | if (SEXP_deepcmpcxx . . $ SEXP_deepcmp(24018bafaaa94db3).(rest_r1, rest_r2)) { |
| 118 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&rest1); |
| 119 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&rest2); |
| 120 | break; |
| 121 | } |
| 122 | |
| 123 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&rest1); |
| 124 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&rest2); |
| 125 | } |
| 126 | |
| 127 | if (i == cached->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count.) { |
| 128 | /* |
| 129 | * Cache MISS |
| 130 | */ |
| 131 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("cache MISS"); |
| 132 | |
| 133 | void *new_item = realloccxx . . $ realloc(417ab160f6baadc6).(cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item., sizeof(SEXP_tcxx . . $ SEXP_t# *) * (cached->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count. + 1)); |
| 134 | if (new_item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 135 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Unable to re-allocate memory for cache"); |
| 136 | return -1; |
| 137 | } |
| 138 | cached->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count.++; |
| 139 | cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item. = new_item; |
| 140 | cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.[cached->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count. - 1] = pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item.; |
| 141 | |
| 142 | /* Assign an unique item ID */ |
| 143 | probe_icache_item_setIDcxx . . $ probe_icache_item_setID(4f986c622adc599b).(pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item., item_id); |
| 144 | } else { |
| 145 | /* |
| 146 | * Cache HIT |
| 147 | */ |
| 148 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("cache HIT #2 -> real HIT"); |
| 149 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item.); |
| 150 | pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item. = cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.[i]; |
| 151 | } |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | static void icache_add_to_treecxx . . $ icache_add_to_tree(1f62d0dd0cd58c19).(rbt_tcxx . . $ rbt_t# *tree, int64_tcxx . . $ int64_t# item_id, probe_iqpair_tcxx . . $ probe_iqpair_t# *pair) { |
| 156 | |
| 157 | probe_citem_tcxx . . $ probe_citem_t# *cached = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(probe_citem_tcxx . . $ probe_citem_t#)); |
| 158 | cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(SEXP_tcxx . . $ SEXP_t# *)); |
| 159 | cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.[0] = pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item.; |
| 160 | cached->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count. = 1; |
| 161 | |
| 162 | /* Assign an unique item ID */ |
| 163 | probe_icache_item_setIDcxx . . $ probe_icache_item_setID(4f986c622adc599b).(pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item., item_id); |
| 164 | |
| 165 | if (rbt_i64_addcxx . . $ rbt_i64_add(6611c7b51f165bf2).(tree, (int64_tcxx . . $ int64_t#)item_id, (void **)cached, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 166 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't add item (k=%"PRIi64cxx . . $ `<external>/15933738808807975373/inttypes.h:73:10`!" to the cache (%p)", item_id, tree); |
| 167 | |
| 168 | freecxx . . $ free(5d22bdacc48458e8).(cached->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.); |
| 169 | freecxx . . $ free(5d22bdacc48458e8).(cached); |
| 170 | |
| 171 | /* now what? */ |
| 172 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | static void *probe_icache_workercxx . . $ probe_icache_worker(9f162e79bfc6c74).(void *arg) |
| 177 | { |
| 178 | probe_icache_tcxx . . $ probe_icache_t# *cache = (probe_icache_tcxx . . $ probe_icache_t# *)(arg); |
| 179 | probe_iqpair_tcxx . . $ probe_iqpair_t# *pair, pair_mem; |
| 180 | SEXP_ID_tcxx . . $ SEXP_ID_t# item_ID; |
| 181 | |
| 182 | if (cache == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 183 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 184 | } |
| 185 | |
| 186 | #if defined(HAVE_PTHREAD_SETNAME_NPcxx . . $ `build/config.h:53:9`!) |
| 187 | const char* thread_name = "icache_worker"; |
| 188 | # if defined(OS_APPLE) |
| 189 | pthread_setname_np(thread_name); |
| 190 | # else |
| 191 | pthread_setname_npcxx . . $ pthread_setname_np(bee54c13bee684da).(pthread_selfcxx . . $ pthread_self(f708dce9a8856c70).(), thread_name); |
| 192 | # endif |
| 193 | #endif |
| 194 | |
| 195 | if (pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 196 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while locking the queue mutex: %u, %s", |
| 197 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 198 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 199 | } |
| 200 | |
| 201 | pair = &pair_mem; |
| 202 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("icache worker ready"); |
| 203 | |
| 204 | switch (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = pthread_barrier_waitcxx . . $ pthread_barrier_wait(6183b0e2072457c0).(cache->th_barriercxx . . $ $anonymous_type_e14da216e1c852e7_2#th_barrier.)) |
| 205 | { |
| 206 | case 0: |
| 207 | case PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!: |
| 208 | break; |
| 209 | default: |
| 210 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("pthread_barrier_wait: %d, %s.", |
| 211 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 212 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 213 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 214 | } |
| 215 | |
| 216 | while(pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&cache->queue_notemptycxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notempty., &cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) == 0) { |
| 217 | if (cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt. <= 0) { |
| 218 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 219 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 220 | } |
| 221 | do { |
| 222 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Extracting item from the cache queue: cnt=%"PRIu16cxx . . $ `<external>/15933738808807975373/inttypes.h:103:10`!", beg=%"PRIu16cxx . . $ `<external>/15933738808807975373/inttypes.h:103:10`!"", cache->queue_cnt, cache->queue_beg); |
| 223 | /* |
| 224 | * Extract an item from the queue and update queue beg, end & cnt |
| 225 | */ |
| 226 | pair_mem = cache->queuecxx . . $ $anonymous_type_e14da216e1c852e7_2#queue.[cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg.]; |
| 227 | #ifndef NDEBUGcxx . . $ `<built-in>:425:9`! |
| 228 | memset(cache->queue + cache->queue_beg, 0, sizeof(probe_iqpair_t)); |
| 229 | #endif |
| 230 | --cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt.; |
| 231 | ++cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg.; |
| 232 | |
| 233 | if (cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg. == cache->queue_maxcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_max.) |
| 234 | cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg. = 0; |
| 235 | |
| 236 | if (cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt. == 0 ? |
| 237 | cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end. != cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg. : |
| 238 | cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end. == cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg.) { |
| 239 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 240 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Signaling `notfull'"); |
| 245 | |
| 246 | if (pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&cache->queue_notfullcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notfull.) != 0) { |
| 247 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while signaling the `notfull' condition: %u, %s", |
| 248 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 249 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 250 | } |
| 251 | /* |
| 252 | * Release the mutex |
| 253 | */ |
| 254 | if (pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 255 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while unlocking the queue mutex: %u, %s", |
| 256 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 257 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 258 | } |
| 259 | |
| 260 | if (pair->cobjcxx . . $ $anonymous_type_e14da216e1c852e7_0#cobj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 261 | /* |
| 262 | * Handle NOP case (synchronization) |
| 263 | */ |
| 264 | if (pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..condcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#cond. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 265 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 266 | } |
| 267 | |
| 268 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Handling NOP"); |
| 269 | |
| 270 | if (pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..condcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#cond.) != 0) { |
| 271 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while signaling NOP condition: %u, %s", |
| 272 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 273 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 274 | } |
| 275 | } else { |
| 276 | |
| 277 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Handling cache request"); |
| 278 | |
| 279 | /* |
| 280 | * Compute item ID |
| 281 | */ |
| 282 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("pair address: %"PRIu64cxx . . $ `<external>/15933738808807975373/inttypes.h:105:10`!, (uint64_t) pair); |
| 283 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("item address: %"PRIu64cxx . . $ `<external>/15933738808807975373/inttypes.h:105:10`!, (uint64_t) pair->p.item); |
| 284 | item_ID = SEXP_ID_vcxx . . $ SEXP_ID_v(7b7039adf1662ab5).(pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item.); |
| 285 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("item ID=%"PRIu64cxx . . $ `<external>/15933738808807975373/inttypes.h:105:10`!"", item_ID); |
| 286 | |
| 287 | if (icache_lookupcxx . . $ icache_lookup(4cb2a9090e1d280d).(cache->treecxx . . $ $anonymous_type_e14da216e1c852e7_2#tree., item_ID, pair) != 0) { |
| 288 | /* |
| 289 | * Cache MISS |
| 290 | */ |
| 291 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("cache MISS"); |
| 292 | icache_add_to_treecxx . . $ icache_add_to_tree(1f62d0dd0cd58c19).(cache->treecxx . . $ $anonymous_type_e14da216e1c852e7_2#tree., item_ID, pair); |
| 293 | } |
| 294 | |
| 295 | if (probe_cobj_add_itemcxx . . $ probe_cobj_add_item(ef7ee42b5817e0be).(pair->cobjcxx . . $ $anonymous_type_e14da216e1c852e7_0#cobj., pair->pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item.) != 0) { |
| 296 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("An error ocured while adding the item to the collected object"); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | if (pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 301 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while re-locking the queue mutex: %u, %s", |
| 302 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 303 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 304 | } |
| 305 | |
| 306 | } while (cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt. > 0); |
| 307 | } |
| 308 | |
| 309 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 310 | } |
| 311 | |
| 312 | probe_icache_tcxx . . $ probe_icache_t# *probe_icache_newcxx . . $ probe_icache_new(863b34798c379835).(pthread_barrier_tcxx . . $ pthread_barrier_t# *th_barrier) |
| 313 | { |
| 314 | probe_icache_tcxx . . $ probe_icache_t# *cache = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(probe_icache_tcxx . . $ probe_icache_t#)); |
| 315 | cache->treecxx . . $ $anonymous_type_e14da216e1c852e7_2#tree. = rbt_i64_newcxx . . $ rbt_i64_new(557e4aca7c153cb).(); |
| 316 | |
| 317 | if (pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 318 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't initialize icache mutex: %u, %s", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 319 | goto fail; |
| 320 | } |
| 321 | |
| 322 | cache->queue_begcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_beg. = 0; |
| 323 | cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end. = 0; |
| 324 | cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt. = 0; |
| 325 | cache->queue_maxcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_max. = PROBE_IQUEUE_CAPACITYcxx . . $ `src/OVAL/probes/probe/icache.h:31:9`!; |
| 326 | cache->th_barriercxx . . $ $anonymous_type_e14da216e1c852e7_2#th_barrier. = th_barrier; |
| 327 | |
| 328 | if (pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc).(&cache->queue_notemptycxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notempty., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 329 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't initialize icache queue condition variable (notempty): %u, %s", |
| 330 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 331 | goto fail; |
| 332 | } |
| 333 | |
| 334 | if (pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc).(&cache->queue_notfullcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notfull., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 335 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't initialize icache queue condition variable (notfull): %u, %s", |
| 336 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 337 | goto fail; |
| 338 | } |
| 339 | |
| 340 | if (pthread_createcxx . . $ pthread_create(2141a84bcac899e5).(&cache->thidcxx . . $ $anonymous_type_e14da216e1c852e7_2#thid., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 341 | probe_icache_workercxx . . $ probe_icache_worker(9f162e79bfc6c74)., (void *)cache) != 0) |
| 342 | { |
| 343 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't start the icache worker: %u, %s", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 344 | goto fail; |
| 345 | } |
| 346 | |
| 347 | return (cache); |
| 348 | fail: |
| 349 | if (cache->treecxx . . $ $anonymous_type_e14da216e1c852e7_2#tree. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 350 | rbt_i64_freecxx . . $ rbt_i64_free(c2e6369c3901716e).(cache->treecxx . . $ $anonymous_type_e14da216e1c852e7_2#tree.); |
| 351 | |
| 352 | pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 353 | pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d).(&cache->queue_notemptycxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notempty.); |
| 354 | freecxx . . $ free(5d22bdacc48458e8).(cache); |
| 355 | |
| 356 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 357 | } |
| 358 | |
| 359 | static int __probe_icache_add_nolockcxx . . $ __probe_icache_add_nolock(bab030a7ff87791b).(probe_icache_tcxx . . $ probe_icache_t# *cache, SEXP_tcxx . . $ SEXP_t# *cobj, SEXP_tcxx . . $ SEXP_t# *item, pthread_cond_tcxx . . $ pthread_cond_t# *cond) |
| 360 | { |
| 361 | if (!((cond == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ^ (item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) { |
| 362 | return -1; |
| 363 | } |
| 364 | retry: |
| 365 | if (cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt. < cache->queue_maxcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_max.) { |
| 366 | cache->queuecxx . . $ $anonymous_type_e14da216e1c852e7_2#queue.[cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end.].cobjcxx . . $ $anonymous_type_e14da216e1c852e7_0#cobj. = cobj; |
| 367 | |
| 368 | if (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 369 | if (cobj == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 370 | return -1; |
| 371 | } |
| 372 | cache->queuecxx . . $ $anonymous_type_e14da216e1c852e7_2#queue.[cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end.].pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..itemcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#item. = item; |
| 373 | } else { |
| 374 | if (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || cobj != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 375 | return -1; |
| 376 | } |
| 377 | cache->queuecxx . . $ $anonymous_type_e14da216e1c852e7_2#queue.[cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end.].pcxx . . $ $anonymous_type_e14da216e1c852e7_0#p..condcxx . . $ $anonymous_type_e14da216e1c852e7_0#$anonymous_type_1#cond. = cond; |
| 378 | } |
| 379 | |
| 380 | ++cache->queue_cntcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_cnt.; |
| 381 | ++cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end.; |
| 382 | |
| 383 | if (cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end. == cache->queue_maxcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_max.) |
| 384 | cache->queue_endcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_end. = 0; |
| 385 | } else { |
| 386 | /* |
| 387 | * The queue is full, we have to wait |
| 388 | */ |
| 389 | if (pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&cache->queue_notfullcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notfull., &cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) == 0) |
| 390 | goto retry; |
| 391 | else { |
| 392 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while waiting for the `notfull' queue condition: %u, %s", |
| 393 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 394 | return (-1); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | return (0); |
| 399 | } |
| 400 | |
| 401 | int probe_icache_addcxx . . $ probe_icache_add(5a71e861ec60878d).(probe_icache_tcxx . . $ probe_icache_t# *cache, SEXP_tcxx . . $ SEXP_t# *cobj, SEXP_tcxx . . $ SEXP_t# *item) |
| 402 | { |
| 403 | int ret; |
| 404 | |
| 405 | if (cache == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || cobj == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 406 | return (-1); /* XXX: EFAULT */ |
| 407 | |
| 408 | if (pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 409 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while locking the queue mutex: %u, %s", |
| 410 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 411 | return (-1); |
| 412 | } |
| 413 | |
| 414 | ret = __probe_icache_add_nolockcxx . . $ __probe_icache_add_nolock(bab030a7ff87791b).(cache, cobj, item, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 415 | |
| 416 | if (pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&cache->queue_notemptycxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notempty.) != 0) { |
| 417 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while signaling the `notempty' condition: %u, %s", |
| 418 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 419 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 420 | return (-1); |
| 421 | } |
| 422 | |
| 423 | if (pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 424 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while unlocking the queue mutex: %u, %s", |
| 425 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 426 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 427 | } |
| 428 | |
| 429 | if (ret != 0) |
| 430 | return (-1); |
| 431 | |
| 432 | return (0); |
| 433 | } |
| 434 | |
| 435 | int probe_icache_nopcxx . . $ probe_icache_nop(dc98f03c45e0d51f).(probe_icache_tcxx . . $ probe_icache_t# *cache) |
| 436 | { |
| 437 | pthread_cond_tcxx . . $ pthread_cond_t# cond; |
| 438 | |
| 439 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("NOP"); |
| 440 | |
| 441 | if (pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 442 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while locking the queue mutex: %u, %s", |
| 443 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 444 | return (-1); |
| 445 | } |
| 446 | |
| 447 | if (pthread_cond_initcxx . . $ pthread_cond_init(fc876bc1ec1249fc).(&cond, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) { |
| 448 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't initialize icache queue condition variable (NOP): %u, %s", |
| 449 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 450 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 451 | return (-1); |
| 452 | } |
| 453 | |
| 454 | if (__probe_icache_add_nolockcxx . . $ __probe_icache_add_nolock(bab030a7ff87791b).(cache, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &cond) != 0) { |
| 455 | if (pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 456 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while unlocking the queue mutex: %u, %s", |
| 457 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 458 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 459 | } |
| 460 | |
| 461 | pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d).(&cond); |
| 462 | return (-1); |
| 463 | } |
| 464 | |
| 465 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Signaling `notempty'"); |
| 466 | |
| 467 | if (pthread_cond_signalcxx . . $ pthread_cond_signal(98095c34a2b0149d).(&cache->queue_notemptycxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notempty.) != 0) { |
| 468 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while signaling the `notempty' condition: %u, %s", |
| 469 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 470 | |
| 471 | pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d).(&cond); |
| 472 | pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 473 | return (-1); |
| 474 | } |
| 475 | |
| 476 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Waiting for icache worker to handle the NOP"); |
| 477 | |
| 478 | if (pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).(&cond, &cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 479 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while waiting for the `NOP' queue condition: %u, %s", |
| 480 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 481 | return (-1); |
| 482 | } |
| 483 | |
| 484 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Sync"); |
| 485 | |
| 486 | if (pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.) != 0) { |
| 487 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while unlocking the queue mutex: %u, %s", |
| 488 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 489 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 490 | } |
| 491 | |
| 492 | pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d).(&cond); |
| 493 | |
| 494 | return (0); |
| 495 | } |
| 496 | |
| 497 | #define PROBE_RESULT_MEMCHECK_CTRESHOLDcxx . . $ `src/OVAL/probes/probe/icache.c:497:9`! 1000 /* item count */ |
| 498 | |
| 499 | /** |
| 500 | * Returns 0 if the memory constraints are not reached. Otherwise, 1 is returned. |
| 501 | * In case of an error, -1 is returned. |
| 502 | */ |
| 503 | static int probe_cobj_memcheckcxx . . $ probe_cobj_memcheck(6f32f325420a45bb).(size_t item_cnt, double max_ratio) |
| 504 | { |
| 505 | if (item_cnt > PROBE_RESULT_MEMCHECK_CTRESHOLDcxx . . $ `src/OVAL/probes/probe/icache.c:497:9`!) { |
| 506 | struct proc_memusagecxx . . $ proc_memusage# mu_proc; |
| 507 | struct sys_memusagecxx . . $ sys_memusage# mu_sys; |
| 508 | double c_ratio; |
| 509 | |
| 510 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&mu_proc, 0, sizeof(mu_proc)); |
| 511 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&mu_sys, 0, sizeof(mu_sys)); |
| 512 | |
| 513 | if (oscap_proc_memusagecxx . . $ oscap_proc_memusage(bd134701dab08304). (&mu_proc) != 0) |
| 514 | return (-1); |
| 515 | |
| 516 | if (oscap_sys_memusagecxx . . $ oscap_sys_memusage(99e7a5fcafeb1462). (&mu_sys) != 0) |
| 517 | return (-1); |
| 518 | |
| 519 | c_ratio = (double)mu_proc.mu_rsscxx . . $ proc_memusage#mu_rss./(double)(mu_sys.mu_totalcxx . . $ sys_memusage#mu_total.); |
| 520 | |
| 521 | if (c_ratio > max_ratio) { |
| 522 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("Memory usage ratio limit reached! limit=%f, current=%f, used=%ld MB, free=%ld MB, total=%ld MB, count of items=%ld", |
| 523 | max_ratio, c_ratio, mu_proc.mu_rss / 1024, mu_sys.mu_realfree / 1024, mu_sys.mu_total / 1024, item_cnt); |
| 524 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!; |
| 525 | return (1); |
| 526 | } |
| 527 | |
| 528 | } |
| 529 | |
| 530 | return (0); |
| 531 | } |
| 532 | |
| 533 | static int _mark_collected_object_as_incompletecxx . . $ _mark_collected_object_as_incomplete(b1f85f4a43858216).(struct probe_ctxcxx . . $ probe_ctx# *ctx, const char *message) |
| 534 | { |
| 535 | /* |
| 536 | * Don't set the message again if the collected object is |
| 537 | * already flagged as incomplete. |
| 538 | */ |
| 539 | if (probe_cobj_get_flagcxx . . $ probe_cobj_get_flag(e91d00b32587b9e6).(ctx->probe_outcxx . . $ probe_ctx#probe_out.) == SYSCHAR_FLAG_INCOMPLETEcxx . . $ SYSCHAR_FLAG_INCOMPLETE.) { |
| 540 | return 0; |
| 541 | } |
| 542 | /* |
| 543 | * Sync with the icache thread before modifying the |
| 544 | * collected object. |
| 545 | */ |
| 546 | if (probe_icache_nopcxx . . $ probe_icache_nop(dc98f03c45e0d51f).(ctx->icachecxx . . $ probe_ctx#icache.) != 0) { |
| 547 | return -1; |
| 548 | } |
| 549 | |
| 550 | SEXP_tcxx . . $ SEXP_t# *sexp_msg = probe_msg_creatcxx . . $ probe_msg_creat(c07e3aa4e7ab9719).(OVAL_MESSAGE_LEVEL_WARNINGcxx . . $ OVAL_MESSAGE_LEVEL_WARNING., (char *) message); |
| 551 | probe_cobj_add_msgcxx . . $ probe_cobj_add_msg(ef7ee42b5817e0be).(ctx->probe_outcxx . . $ probe_ctx#probe_out., sexp_msg); |
| 552 | probe_cobj_set_flagcxx . . $ probe_cobj_set_flag(644bab5dffe689c).(ctx->probe_outcxx . . $ probe_ctx#probe_out., SYSCHAR_FLAG_INCOMPLETEcxx . . $ SYSCHAR_FLAG_INCOMPLETE.); |
| 553 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(sexp_msg); |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Collect an item |
| 559 | * This function adds an item the collected object assosiated |
| 560 | * with the given probe context. |
| 561 | * |
| 562 | * Returns: |
| 563 | * 0 ... the item was succesfully added to the collected object |
| 564 | * 1 ... the item was filtered out |
| 565 | * 2 ... the item was not added because of memory constraints |
| 566 | * and the collected object was flagged as incomplete |
| 567 | *-1 ... unexpected/internal error |
| 568 | * |
| 569 | * The caller must not free the item, it's freed automatically |
| 570 | * by this function or by the icache worker thread. |
| 571 | */ |
| 572 | int probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(struct probe_ctxcxx . . $ probe_ctx# *ctx, SEXP_tcxx . . $ SEXP_t# *item) |
| 573 | { |
| 574 | if (ctx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || ctx->probe_outcxx . . $ probe_ctx#probe_out. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 575 | return -1; |
| 576 | } |
| 577 | |
| 578 | if (ctx->max_collected_itemscxx . . $ probe_ctx#max_collected_items. != OSCAP_PROBE_COLLECT_UNLIMITEDcxx . . $ `src/OVAL/probes/probe/probe.h:53:9`! && ctx->collected_itemscxx . . $ probe_ctx#collected_items. >= ctx->max_collected_itemscxx . . $ probe_ctx#max_collected_items.) { |
| 579 | char *message = oscap_sprintfcxx . . $ oscap_sprintf(a849077ff1b8d812).("Object is incomplete because the object matches more than %ld items.", ctx->max_collected_itemscxx . . $ probe_ctx#max_collected_items.); |
| 580 | if (_mark_collected_object_as_incompletecxx . . $ _mark_collected_object_as_incomplete(b1f85f4a43858216).(ctx, message) != 0) { |
| 581 | freecxx . . $ free(5d22bdacc48458e8).(message); |
| 582 | return -1; |
| 583 | } |
| 584 | freecxx . . $ free(5d22bdacc48458e8).(message); |
| 585 | return 2; |
| 586 | } |
| 587 | |
| 588 | int memcheck_ret = probe_cobj_memcheckcxx . . $ probe_cobj_memcheck(6f32f325420a45bb).(ctx->collected_itemscxx . . $ probe_ctx#collected_items., ctx->max_mem_ratiocxx . . $ probe_ctx#max_mem_ratio.); |
| 589 | if (memcheck_ret == -1) { |
| 590 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Failed to check available memory"); |
| 591 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(item); |
| 592 | return -1; |
| 593 | } |
| 594 | if (memcheck_ret == 1) { |
| 595 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(item); |
| 596 | const char *message = "Object is incomplete due to memory constraints."; |
| 597 | if (_mark_collected_object_as_incompletecxx . . $ _mark_collected_object_as_incomplete(b1f85f4a43858216).(ctx, message) != 0) { |
| 598 | return -1; |
| 599 | } |
| 600 | |
| 601 | return 2; |
| 602 | } |
| 603 | |
| 604 | if (ctx->filterscxx . . $ probe_ctx#filters. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && probe_item_filteredcxx . . $ probe_item_filtered(24018bafaaa94db3).(item, ctx->filterscxx . . $ probe_ctx#filters.)) { |
| 605 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(item); |
| 606 | return (1); |
| 607 | } |
| 608 | |
| 609 | if (probe_icache_addcxx . . $ probe_icache_add(5a71e861ec60878d).(ctx->icachecxx . . $ probe_ctx#icache., ctx->probe_outcxx . . $ probe_ctx#probe_out., item) != 0) { |
| 610 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't add item (%p) to the item cache (%p)", item, ctx->icache); |
| 611 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(item); |
| 612 | return (-1); |
| 613 | } |
| 614 | |
| 615 | ctx->collected_itemscxx . . $ probe_ctx#collected_items.++; |
| 616 | return (0); |
| 617 | } |
| 618 | |
| 619 | static void probe_icache_free_nodecxx . . $ probe_icache_free_node(2075c23c59102cb3).(struct rbt_i64_nodecxx . . $ rbt_i64_node# *n) |
| 620 | { |
| 621 | probe_citem_tcxx . . $ probe_citem_t# *ci = (probe_citem_tcxx . . $ probe_citem_t# *)n->datacxx . . $ rbt_i64_node#data.; |
| 622 | |
| 623 | for ( ; ci->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count. > 0 ; --ci->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count. ) { |
| 624 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ci->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.[ci->countcxx . . $ $anonymous_type_e14da216e1c852e7_3#count. - 1]); |
| 625 | } |
| 626 | |
| 627 | freecxx . . $ free(5d22bdacc48458e8).(ci->itemcxx . . $ $anonymous_type_e14da216e1c852e7_3#item.); |
| 628 | freecxx . . $ free(5d22bdacc48458e8).(ci); |
| 629 | return; |
| 630 | } |
| 631 | |
| 632 | void probe_icache_freecxx . . $ probe_icache_free(b601f10d292cbb66).(probe_icache_tcxx . . $ probe_icache_t# *cache) |
| 633 | { |
| 634 | void *ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 635 | |
| 636 | pthread_cancelcxx . . $ pthread_cancel(15f694ef3c96d230).(cache->thidcxx . . $ $anonymous_type_e14da216e1c852e7_2#thid.); |
| 637 | pthread_joincxx . . $ pthread_join(269902cf949f12c5).(cache->thidcxx . . $ $anonymous_type_e14da216e1c852e7_2#thid., &ret); |
| 638 | pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9).(&cache->queue_mutexcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_mutex.); |
| 639 | pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d).(&cache->queue_notemptycxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notempty.); |
| 640 | pthread_cond_destroycxx . . $ pthread_cond_destroy(98095c34a2b0149d).(&cache->queue_notfullcxx . . $ $anonymous_type_e14da216e1c852e7_2#queue_notfull.); |
| 641 | |
| 642 | rbt_i64_free_cbcxx . . $ rbt_i64_free_cb(7bd0bad35cac1c5c).(cache->treecxx . . $ $anonymous_type_e14da216e1c852e7_2#tree., &probe_icache_free_nodecxx . . $ probe_icache_free_node(2075c23c59102cb3).); |
| 643 | freecxx . . $ free(5d22bdacc48458e8).(cache); |
| 644 | return; |
| 645 | } |