From 62412a235b577e095ce0277e60960f5a7f13a57c Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 7 Jan 2026 11:59:01 +0100 Subject: [PATCH] x86/cpu-policy: enable build of fuzzing harness by default ... on x86, to make sure its bit-rotting can be limited at least a little. Since on Ubuntu fread()'s return value needs evaluating, adjust the code there to also skip the test when there's no data at all. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- tools/fuzz/Makefile | 2 ++ tools/fuzz/cpu-policy/afl-policy-fuzzer.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/fuzz/Makefile b/tools/fuzz/Makefile index 85213dc895..eb70b24624 100644 --- a/tools/fuzz/Makefile +++ b/tools/fuzz/Makefile @@ -5,5 +5,7 @@ SUBDIRS-y := SUBDIRS-y += libelf SUBDIRS-y += x86_instruction_emulator +SUBDIRS-$(CONFIG_X86_64) += cpu-policy + .PHONY: all clean distclean install uninstall all clean distclean install uninstall: %: subdirs-% diff --git a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c index 7d8467b4b2..b890308fb8 100644 --- a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c +++ b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c @@ -133,6 +133,7 @@ int main(int argc, char **argv) #endif { struct cpu_policy *cp = NULL; + size_t size; if ( fp != stdin ) { @@ -150,9 +151,9 @@ int main(int argc, char **argv) if ( !cp ) goto skip; - fread(cp, sizeof(*cp), 1, fp); + size = fread(cp, sizeof(*cp), 1, fp); - if ( !feof(fp) ) + if ( !size || !feof(fp) ) goto skip; check_policy(cp);