Skip to content

Commit da5f44a

Browse files
mjruhlopsiff
authored andcommitted
platform/x86/intel/pmt: fix a crashlog NULL pointer access
commit 54d5cd4719c5e87f33d271c9ac2e393147d934f8 upstream. 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: 045a513 ("platform/x86/intel/pmt: Use PMT callbacks") Cc: [email protected] Reviewed-by: David E. Box <[email protected]> Reviewed-by: Tejas Upadhyay <[email protected]> Signed-off-by: Michael J. Ruhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 860d93bd6a21f08883711196344c353bc3936a2b)
1 parent 4db0b41 commit da5f44a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

drivers/platform/x86/intel/pmt/class.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ intel_pmt_read(struct file *filp, struct kobject *kobj,
9797
if (count > entry->size - off)
9898
count = entry->size - off;
9999

100-
count = pmt_telem_read_mmio(entry->ep->pcidev, entry->cb, entry->header.guid, buf,
100+
count = pmt_telem_read_mmio(entry->pcidev, entry->cb, entry->header.guid, buf,
101101
entry->base, off, count);
102102

103103
return count;
@@ -252,6 +252,7 @@ static int intel_pmt_populate_entry(struct intel_pmt_entry *entry,
252252
return -EINVAL;
253253
}
254254

255+
entry->pcidev = pci_dev;
255256
entry->guid = header->guid;
256257
entry->size = header->size;
257258
entry->cb = ivdev->priv_data;

drivers/platform/x86/intel/pmt/class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct intel_pmt_header {
3939

4040
struct intel_pmt_entry {
4141
struct telem_endpoint *ep;
42+
struct pci_dev *pcidev;
4243
struct intel_pmt_header header;
4344
struct bin_attribute pmt_bin_attr;
4445
struct kobject *kobj;

0 commit comments

Comments
 (0)