@@ -301,6 +301,40 @@ void pfun(void *var_ty_void, const char *var_nm, LocType loc_t, target_ulong loc
301
301
}
302
302
}
303
303
304
+ // Taken from taint2_hypercalls.cpp, not sure why but at the moment
305
+ // AttackPoints is never populated.
306
+ Panda__SrcInfo *pandalog_src_info_create (PandaHypercallStruct phs) {
307
+ Panda__SrcInfo *si = (Panda__SrcInfo *) malloc (sizeof (Panda__SrcInfo));
308
+ *si = PANDA__SRC_INFO__INIT;
309
+ si->filename = phs.src_filename ;
310
+ si->astnodename = phs.src_ast_node_name ;
311
+ si->linenum = phs.src_linenum ;
312
+ si->has_insertionpoint = 0 ;
313
+ if (phs.insertion_point ) {
314
+ si->has_insertionpoint = 1 ;
315
+ si->insertionpoint = phs.insertion_point ;
316
+ }
317
+ si->has_ast_loc_id = 1 ;
318
+ si->ast_loc_id = phs.src_filename ;
319
+ return si;
320
+ }
321
+
322
+ void lava_attack_point (PandaHypercallStruct phs) {
323
+ if (pandalog) {
324
+ Panda__AttackPoint *ap = (Panda__AttackPoint *)malloc (sizeof (Panda__AttackPoint));
325
+ *ap = PANDA__ATTACK_POINT__INIT;
326
+ ap->info = phs.info ;
327
+ Panda__LogEntry ple = PANDA__LOG_ENTRY__INIT;
328
+ ple.attack_point = ap;
329
+ ple.attack_point ->src_info = pandalog_src_info_create (phs);
330
+ ple.attack_point ->call_stack = pandalog_callstack_create ();
331
+ pandalog_write_entry (&ple);
332
+ free (ple.attack_point ->src_info );
333
+ pandalog_callstack_free (ple.attack_point ->call_stack );
334
+ free (ap);
335
+ }
336
+ }
337
+
304
338
/*
305
339
// Trace logging in the level of source code
306
340
void hypercall_log_trace(unsigned ast_loc_id) {
@@ -363,22 +397,24 @@ void lava_hypercall(CPUState *cpu) {
363
397
// lava/include/pirate_mark_lava.h
364
398
if (phs.action == 13 ) {
365
399
target_ulong pc = panda_current_pc (cpu);
366
- SrcInfo info;
367
400
// Calls 'pri_get_pc_source_info' in pri.c, which calls 'on_get_pc_source_info'
368
401
// In Dwarf2, the function 'on_get_pc_source_info' is mapped to 'dwarf_get_pc_source_info'
402
+ SrcInfo info;
369
403
int rc = pri_get_pc_source_info (cpu, pc, &info);
370
404
if (!rc) {
371
405
struct args args = {cpu, info.filename , info.line_number , phs.src_filename };
372
406
dprintf (" [pri_taint] panda hypercall: [%s], "
373
407
" ln: %4ld, pc @ 0x" TARGET_FMT_lx " \n " ,
374
408
info.filename ,
375
409
info.line_number , pc);
376
-
377
410
// Calls 'pri_funct_livevar_iter' in pri.c, which calls 'on_funct_livevar_iter'
378
411
// In Dwarf2, the function 'on_funct_livevar_iter' is mapped to 'dwarf_funct_livevar_iter'
379
412
// This is passing the function 'pfun' to 'pri_funct_livevar_iter', which is called at the end
380
413
pri_funct_livevar_iter (cpu, pc, (liveVarCB) pfun, (void *)&args);
381
414
}
415
+ else if (phs.action == 12 ) {
416
+ lava_attack_point (phs);
417
+ }
382
418
else {
383
419
dprintf (" [pri_taint] pri_get_pc_src_info has failed: %d != 0.\n " , rc);
384
420
}
0 commit comments