From bd34c46b858426b5e4219ce63d7962472f511614 Mon Sep 17 00:00:00 2001 From: Steffen Schulz Date: Sun, 22 May 2022 21:42:43 +0200 Subject: [PATCH] fix printf format string errors --- accel/kvm/kvm-all.c | 4 ++-- nyx/helpers.c | 6 +++--- nyx/hypercall/hypercall.c | 8 ++++---- nyx/sharedir.c | 3 ++- nyx/snapshot/block/block_cow.c | 3 ++- nyx/snapshot/devices/nyx_device_state.c | 2 -- nyx/snapshot/devices/state_reallocation.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 0f64d90085..bed9d32b62 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2572,7 +2572,7 @@ int kvm_cpu_exec(CPUState *cpu) handle_hypercall_kafl_release(run, cpu, (uint64_t)run->hypercall.args[0]); ret = 0; #else - debug_fprintf(stderr "Got KVM_EXIT_SHUTDOWN while in fuzzing mode => panic\n",); + debug_fprintf(stderr, "Got KVM_EXIT_SHUTDOWN while in fuzzing mode => panic\n"); handle_hypercall_kafl_panic(run, cpu, (uint64_t)run->hypercall.args[0]); ret = 0; #endif @@ -2693,7 +2693,7 @@ int kvm_cpu_exec(CPUState *cpu) ret = kvm_arch_handle_exit(cpu, run); assert(ret == 0); #else - debug_fprintf("kvm_arch_handle_exit(%d) => panic\n", run->exit_reason); + debug_fprintf(stderr, "kvm_arch_handle_exit(%d) => panic\n", run->exit_reason); ret = kvm_arch_handle_exit(cpu, run); if (ret != 0) handle_hypercall_kafl_panic(run, cpu, (uint64_t)run->hypercall.args[0]); diff --git a/nyx/helpers.c b/nyx/helpers.c index 9f850395ca..3f1f797791 100644 --- a/nyx/helpers.c +++ b/nyx/helpers.c @@ -127,8 +127,8 @@ bool apply_capabilities(CPUState *cpu){ debug_printf("--------------------------\n"); debug_printf("GET_GLOBAL_STATE()->cap_compile_time_tracing_buffer_vaddr: %lx\n", GET_GLOBAL_STATE()->cap_compile_time_tracing_buffer_vaddr); - debug_printf("GET_GLOBAL_STATE()->shared_bitmap_fd: %lx\n", GET_GLOBAL_STATE()->shared_bitmap_fd); - debug_printf("GET_GLOBAL_STATE()->shared_bitmap_size: %lx\n", GET_GLOBAL_STATE()->shared_bitmap_size); + debug_printf("GET_GLOBAL_STATE()->shared_bitmap_fd: %d\n", GET_GLOBAL_STATE()->shared_bitmap_fd); + debug_printf("GET_GLOBAL_STATE()->shared_bitmap_size: %x\n", GET_GLOBAL_STATE()->shared_bitmap_size); debug_printf("GET_GLOBAL_STATE()->cap_cr3: %lx\n", GET_GLOBAL_STATE()->cap_cr3); debug_printf("--------------------------\n"); @@ -153,7 +153,7 @@ bool apply_capabilities(CPUState *cpu){ } if(GET_GLOBAL_STATE()->cap_ijon_tracing){ - debug_printf(stderr, "%s: agent trace buffer at vaddr: %lx\n", __func__, GET_GLOBAL_STATE()->cap_ijon_tracing_buffer_vaddr); + debug_printf("%s: agent trace buffer at vaddr: %lx\n", __func__, GET_GLOBAL_STATE()->cap_ijon_tracing_buffer_vaddr); if(GET_GLOBAL_STATE()->cap_ijon_tracing_buffer_vaddr&0xfff){ fprintf(stderr, "[QEMU-Nyx] Error: guest's ijon buffer v_addr (0x%lx) is not page aligned!\n", GET_GLOBAL_STATE()->cap_ijon_tracing_buffer_vaddr); diff --git a/nyx/hypercall/hypercall.c b/nyx/hypercall/hypercall.c index dd5598c73e..9925c41e53 100644 --- a/nyx/hypercall/hypercall.c +++ b/nyx/hypercall/hypercall.c @@ -315,7 +315,7 @@ static void handle_hypercall_kafl_range_submit(struct kvm_run *run, CPUState *cp } if(GET_GLOBAL_STATE()->pt_ip_filter_configured[buffer[2]]){ - QEMU_PT_PRINTF(CORE_PREFIX, "Ignoring agent-provided address ranges (abort reason: 1) - %d", buffer[2]); + QEMU_PT_PRINTF(CORE_PREFIX, "Ignoring agent-provided address ranges (abort reason: 1) - %ld", buffer[2]); return; } @@ -324,7 +324,7 @@ static void handle_hypercall_kafl_range_submit(struct kvm_run *run, CPUState *cp GET_GLOBAL_STATE()->pt_ip_filter_b[buffer[2]] = buffer[1]; GET_GLOBAL_STATE()->pt_ip_filter_configured[buffer[2]] = true; QEMU_PT_PRINTF(CORE_PREFIX, "Configuring agent-provided address ranges:"); - QEMU_PT_PRINTF(CORE_PREFIX, "\tIP%d: %lx-%lx [ENABLED]", buffer[2], GET_GLOBAL_STATE()->pt_ip_filter_a[buffer[2]], GET_GLOBAL_STATE()->pt_ip_filter_b[buffer[2]]); + QEMU_PT_PRINTF(CORE_PREFIX, "\tIP%ld: %lx-%lx [ENABLED]", buffer[2], GET_GLOBAL_STATE()->pt_ip_filter_a[buffer[2]], GET_GLOBAL_STATE()->pt_ip_filter_b[buffer[2]]); } else{ QEMU_PT_PRINTF(CORE_PREFIX, "Ignoring agent-provided address ranges (abort reason: 2)"); @@ -626,7 +626,7 @@ static void handle_hypercall_kafl_lock(struct kvm_run *run, CPUState *cpu, uint6 QEMU_PT_PRINTF(CORE_PREFIX, "Creating pre image snapshot <%s> ...", GET_GLOBAL_STATE()->fast_reload_pre_path); - printf("Creating pre image snapshot"); + debug_printf("Creating pre image snapshot"); request_fast_vm_reload(GET_GLOBAL_STATE()->reload_state, REQUEST_SAVE_SNAPSHOT_PRE); } @@ -794,7 +794,7 @@ static void handle_hypercall_kafl_dump_file(struct kvm_run *run, CPUState *cpu, void* page = malloc(PAGE_SIZE); uint32_t written = 0; - QEMU_PT_PRINTF(CORE_PREFIX, "%s: dump %d bytes to %s (append=%u)\n", + QEMU_PT_PRINTF(CORE_PREFIX, "%s: dump %d bytes to %s (append=%u)", __func__, bytes, host_path, file_obj.append); while (bytes > 0) { diff --git a/nyx/sharedir.c b/nyx/sharedir.c index 9ca6823c37..c5f26f1fe8 100644 --- a/nyx/sharedir.c +++ b/nyx/sharedir.c @@ -6,6 +6,7 @@ #include #include #include +#include "nyx/debug.h" //#define SHAREDIR_DEBUG @@ -167,7 +168,7 @@ uint64_t sharedir_request_file(sharedir_t* self, const char* file, uint8_t* page } } else{ - fprintf(stderr, "WARNING: No such file in sharedir: %s\n", file); + debug_fprintf(stderr, "WARNING: No such file in sharedir: %s\n", file); return 0xFFFFFFFFFFFFFFFFUL; } } diff --git a/nyx/snapshot/block/block_cow.c b/nyx/snapshot/block/block_cow.c index dab91421f0..b4ffd339e0 100644 --- a/nyx/snapshot/block/block_cow.c +++ b/nyx/snapshot/block/block_cow.c @@ -4,6 +4,7 @@ #include "nyx/snapshot/block/block_cow.h" #include "sysemu/block-backend.h" #include "nyx/state/state.h" +#include "nyx/debug.h" //#define COW_CACHE_DEBUG @@ -547,7 +548,7 @@ static int cow_cache_write(cow_cache_t* self, BlockBackend *blk, int64_t offset, void switch_to_fuzz_mode(cow_cache_t* self){ self->enabled_fuzz = true; assert(!mprotect(self->data_primary, self->cow_primary_size, PROT_READ)); - printf("[qemu-nyx] switching to secondary CoW buffer\n"); + debug_printf("[qemu-nyx] switching to secondary CoW buffer\n"); } void cow_cache_read_entry(void* opaque){ diff --git a/nyx/snapshot/devices/nyx_device_state.c b/nyx/snapshot/devices/nyx_device_state.c index 098d9b7af8..e387642e5a 100644 --- a/nyx/snapshot/devices/nyx_device_state.c +++ b/nyx/snapshot/devices/nyx_device_state.c @@ -346,8 +346,6 @@ nyx_device_state_t* nyx_device_state_init_from_snapshot(const char* snapshot_fol struct stat buffer; assert(stat (qemu_state_file, &buffer) == 0); - debug_printf("FILE EXISTS...\n"); - void* state_buf2 = malloc(STATE_BUFFER); f = fopen(qemu_state_file, "r"); diff --git a/nyx/snapshot/devices/state_reallocation.c b/nyx/snapshot/devices/state_reallocation.c index 120dccd619..1a5985ef71 100644 --- a/nyx/snapshot/devices/state_reallocation.c +++ b/nyx/snapshot/devices/state_reallocation.c @@ -877,7 +877,7 @@ static int fdl_enumerate_section(state_reallocation_t* self, QEMUFile *f, Migrat ret = fdl_vmstate_load(self, f, se, version_id); } else{ - debug_fprintf(stderr, "---------------------------------\nVMSD2: %x\n", se->vmsd); + debug_fprintf(stderr, "---------------------------------\nVMSD2: %p\n", (void*)se->vmsd); //abort(); //fprintf(stderr, "---------------------------------\nVMSD2: %s\n", (VMStateDescription *)(se->vmsd)->name); ret = vmstate_load(f, se);