[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251224092721.2034529-3-duziming2@huawei.com>
Date: Wed, 24 Dec 2025 17:27:18 +0800
From: Ziming Du <duziming2@...wei.com>
To: <bhelgaas@...gle.com>, <jbarnes@...tuousgeek.org>, <chrisw@...hat.com>,
<alex.williamson@...hat.com>
CC: <linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<liuyongqiang13@...wei.com>, <duziming2@...wei.com>
Subject: [PATCH v2 2/3] PCI: Prevent overflow in proc_bus_pci_write()
From: Yongqiang Liu <liuyongqiang13@...wei.com>
When the value of ppos over the INT_MAX, the pos is over set to a negtive
value which will be passed to get_user() or pci_user_write_config_dword().
Unexpected behavior such as a softlock will happen as follows:
watchdog: BUG: soft lockup - CPU#0 stuck for 130s! [syz.3.109:3444]
RIP: 0010:_raw_spin_unlock_irq+0x17/0x30
Call Trace:
<TASK>
pci_user_write_config_dword+0x126/0x1f0
proc_bus_pci_write+0x273/0x470
proc_reg_write+0x1b6/0x280
do_iter_write+0x48e/0x790
vfs_writev+0x125/0x4a0
__x64_sys_pwritev+0x1e2/0x2a0
do_syscall_64+0x59/0x110
entry_SYSCALL_64_after_hwframe+0x78/0xe2
Fix this by add check for the pos.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Yongqiang Liu <liuyongqiang13@...wei.com>
Signed-off-by: Ziming Du <duziming2@...wei.com>
---
drivers/pci/proc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 9348a0fb8084..200d42feafd8 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -121,7 +121,7 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
if (ret)
return ret;
- if (pos >= size)
+ if (pos >= size || pos < 0)
return 0;
if (nbytes >= size)
nbytes = size;
--
2.43.0
Powered by blists - more mailing lists