Re: [PATCH v12 2/3] selftests: tdx: Test TDX attestation GetReport support

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

 




On 9/8/22 8:48 PM, Huang, Kai wrote:
> On Wed, 2022-09-07 at 17:27 -0700, Kuppuswamy Sathyanarayanan wrote:
>> +TEST(verify_report)
>> +{
>> +	__u8 reportdata[TDX_REPORTDATA_LEN];
>> +	struct tdreport tdreport;
>> +	struct tdx_report_req req;
>> +	int devfd, i;
>> +
>> +	devfd = open(TDX_GUEST_DEVNAME, O_RDWR | O_SYNC);
>> +
>> +	ASSERT_LT(0, devfd);
>> +
>> +	/* Generate sample report data */
>> +	for (i = 0; i < TDX_REPORTDATA_LEN; i++)
>> +		reportdata[i] = i;
>> +
>> +	/* Initialize IOCTL request */
>> +	req.subtype     = 0;
>> +	req.reportdata  = (__u64)reportdata;
>> +	req.rpd_len     = TDX_REPORTDATA_LEN;
>> +	req.tdreport    = (__u64)&tdreport;
>> +	req.tdr_len     = sizeof(tdreport);
>> +
> 
> 'req' is a local variable, which isn't guaranteed to be zero. Looks you need to
> explicitly clear 'req' otherwise the req.reserved[7] may not be zero.

In the next version, I explicitly set it to 0. I could initialize the struct to
0. But doing it explicitly will show the expected values clearly.

memset(req.reserved, 0, sizeof(req.reserved));

> 

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux