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

Re: [PATCH 1/2] x86/cpu-policy: enable build of fuzzing harness by default


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 6 Jan 2026 11:41:40 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=X1VX6iq/jsPPCV+Nae6kUP/AIiuXAfJEYCYZBK32dQ8=; b=OM8r5iIK1GObMzacgAoCr3lcoRQnKYKEt0FoXZaepWG6hEYfg1hBWBzT/B01mbeYFy1uppCQeaIVm4ytzcbR0eocYxF2heqxMr8RvBUzqqO+KNTX+Jq/4zsN/JL9BFPk9yHtNv00UZw+BfHVJj2bfK+Ps+I0rYJuNxz26vyd+cmyM8KnkHTL888ak/qonuJvSnove3nJgdJvKId132hKnJNFBgeKzwrEmwqfAZfL2Q3r/UkO4DyM/mdYnpfI9EpxZnUevZiDnO/teRBtzWYlQYNL2ZD/afGAlv65y9CLWXGnneqbxn6oGAytYMbHa22Nd+5s/lAHmML2nSaS/X2nVg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KhiAvqk8lIcfxxssu1Psl0IKqCmpLroMEKcGyWfkp27z1htGfN2wCNg53inrWmE48T5d10TGAcXwLXbNek6wlvTWOpgz5IVDUatMqv9wTWQyGJ2GFXLUZD3gLj8iqSTTmVn3DJyreOYL8e52UQ4KcP7eAxrk0ftKXePnO247Qgzt9zI6HKoVAQbjEDZr/iP/nm8WGEFBQCIJkVxE3ufT62epgwXEK6aDzSa8RcIXySX3DeUpJTbuVDYkG6uhaLUCihQFlXXlVXO5vCxSullKunB4o8lp/X4Yme5CgiH6hjIPr+fG8VCCVeCRI6joDor2XdX9l+vr3gzjR95S5F1+5Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 06 Jan 2026 11:42:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06/01/2026 9:49 am, Jan Beulich wrote:
> On 06.01.2026 10:36, Jan Beulich wrote:
>> On 22.12.2025 17:53, Jan Beulich wrote:
>>> ... on x86, to make sure its bit-rotting can be limited at least a little.
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>>>
>>> --- a/tools/fuzz/Makefile
>>> +++ b/tools/fuzz/Makefile
>>> @@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
>>>  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-%
>>>
>> As it turns out this causes build failures on Ubuntu (and only there, and 
>> only
>> with gcc, which I don't understand):
>>
>> afl-policy-fuzzer.c: In function 'main':
>> afl-policy-fuzzer.c:153:9: error: ignoring return value of 'fread', declared 
>> with attribute warn_unused_result [-Werror=unused-result]
>>          fread(cp, sizeof(*cp), 1, fp);
>>          ^
>> cc1: all warnings being treated as errors
>>
>> Given how the code uses calloc() up front I don't really see why evaluating
>> the return value would actually be meaningful here, so I'm inclined to add a
>> cast to void (provided that would make a difference, which I have yet to
>> check). Opinions?
> Simply casting doesn't work. Hence what I'm intending to do is
>
> --- 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);
>
> along with amending the description:
>
> "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."
>
> May I keep your ack with that adjustment?

Yes.  This is just harness code, so whatever compiles.

~Andrew



 


Rackspace

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