Re: [PATCH v15 2/3] virt: Add TDX guest driver

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

 



On Thu, Oct 20, 2022 at 05:00:27PM -0700, Sathyanarayanan Kuppuswamy wrote:
> Hi,
> 
> On 10/19/22 10:38 PM, Greg Kroah-Hartman wrote:
> > On Wed, Oct 19, 2022 at 09:58:27PM -0700, Kuppuswamy Sathyanarayanan wrote:
> >> +static long tdx_get_report(void __user *argp)
> >> +{
> >> +	u8 *reportdata, *tdreport;
> >> +	struct tdx_report_req req;
> >> +	long ret;
> >> +
> >> +	if (copy_from_user(&req, argp, sizeof(req)))
> >> +		return -EFAULT;
> >> +
> >> +	/*
> >> +	 * Per TDX Module 1.0 specification, section titled
> >> +	 * "TDG.MR.REPORT", REPORTDATA length is fixed as
> >> +	 * TDX_REPORTDATA_LEN, TDREPORT length is fixed as
> >> +	 * TDX_REPORT_LEN, and TDREPORT subtype is fixed as 0.
> >> +	 */
> >> +	if (req.subtype || req.rpd_len != TDX_REPORTDATA_LEN ||
> >> +	    req.tdr_len != TDX_REPORT_LEN) {
> >> +		pr_err("TDX_CMD_GET_REPORT: invalid req: subtype:%u rpd_len:%u tdr_len:%u\n",
> >> +		       req.subtype, req.rpd_len, req.tdr_len);
> > 
> > You are allowing userspace to spam the kernel logs, please do not do
> > that.
> 
> Added it to help userspace understand the reason for the failure (only for
> the cases like request param issues and TDCALL failure). Boris recommended
> adding it in the previous review.

Again, you just created a vector for userspace to spam the kernel log.
No kernel driver should ever do that.

> >> +#ifdef MODULE
> >> +static const struct x86_cpu_id tdx_guest_ids[] = {
> >> +	X86_MATCH_FEATURE(X86_FEATURE_TDX_GUEST, NULL),
> >> +	{}
> >> +};
> >> +MODULE_DEVICE_TABLE(x86cpu, tdx_guest_ids);
> >> +#endif
> > 
> > Why the #ifdef?  Should not be needed, right?
> 
> I have added it to fix the following warning reported by 0-day.
> 
> https://lore.kernel.org/lkml/202209211607.tCtTWKbV-lkp@xxxxxxxxx/
> 
> It is related to nullifying the MODULE_DEVICE_TABLE in #ifndef MODULE
> case in linux/module.h.

Then fix it properly, by correctly using that structure no matter what.
You don't do that here...

greg k-h



[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