]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86/intel/pmt: fix a crashlog NULL pointer access
authorMichael J. Ruhl <michael.j.ruhl@intel.com>
Sun, 13 Jul 2025 17:29:31 +0000 (13:29 -0400)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 22 Jul 2025 14:38:44 +0000 (17:38 +0300)
Usage of the intel_pmt_read() for binary sysfs, requires a pcidev. The
current use of the endpoint value is only valid for telemetry endpoint
usage.

Without the ep, the crashlog usage causes the following NULL pointer
exception:

BUG: kernel NULL pointer dereference, address: 0000000000000000
Oops: Oops: 0000 [#1] SMP NOPTI
RIP: 0010:intel_pmt_read+0x3b/0x70 [pmt_class]
Code:
Call Trace:
 <TASK>
 ? sysfs_kf_bin_read+0xc0/0xe0
 kernfs_fop_read_iter+0xac/0x1a0
 vfs_read+0x26d/0x350
 ksys_read+0x6b/0xe0
 __x64_sys_read+0x1d/0x30
 x64_sys_call+0x1bc8/0x1d70
 do_syscall_64+0x6d/0x110

Augment struct intel_pmt_entry with a pointer to the pcidev to avoid
the NULL pointer exception.

Fixes: 045a513040cc ("platform/x86/intel/pmt: Use PMT callbacks")
Cc: stable@vger.kernel.org
Reviewed-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Link: https://lore.kernel.org/r/20250713172943.7335-2-michael.j.ruhl@intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/pmt/class.c
drivers/platform/x86/intel/pmt/class.h

index a806a81ece5208fe78e5286f52adc8b79bdd864f..5dd80109f5917e30f5f4c2ee3e94343bd526a1b3 100644 (file)
@@ -99,7 +99,7 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
        if (count > entry->size - off)
                count = entry->size - off;
 
-       count = pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf,
+       count = pmt_telem_read_mmio(entry->pcidev, entry->cb, entry->header.guid, buf,
                                    entry->base, off, count);
 
        return count;
@@ -283,6 +283,7 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
                return -EINVAL;
        }
 
+       entry->pcidev = pci_dev;
        entry->guid = header->guid;
        entry->size = header->size;
        entry->cb = ivdev->priv_data;
index fdf7e79d8c0dcda1496247dfc2f39d20a5b370d8..ebd49e2cb2d5730ed9b92862dad0f2c70c80e603 100644 (file)
@@ -40,6 +40,7 @@ struct intel_pmt_header {
 
 struct intel_pmt_entry {
        struct telem_endpoint   *ep;
+       struct pci_dev          *pcidev;
        struct intel_pmt_header header;
        struct bin_attribute    pmt_bin_attr;
        struct kobject          *kobj;