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@intel.com/
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