[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/cpu-policy: enable build of fuzzing harness by default



commit 62412a235b577e095ce0277e60960f5a7f13a57c
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jan 7 11:59:01 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jan 7 14:45:27 2026 +0100

    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 <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 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);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.