* [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation
@ 2021-06-18 13:05 Krzysztof Kozlowski
2021-06-18 13:05 ` [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci Krzysztof Kozlowski
2021-06-24 19:32 ` [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
0 siblings, 2 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-06-18 13:05 UTC (permalink / raw)
To: ltp
Fix NULL pointer dereference when a ltp_tpci test case is started before
choosing the device:
ltp_tpci: test-case 12
ltp_tpci: assign resources
ltp_tpci: assign resource #0
BUG: kernel NULL pointer dereference, address: 00000000000003b8
...
Call Trace:
dev_attr_store+0x17/0x30
sysfs_kf_write+0x3e/0x50
kernfs_fop_write_iter+0x13c/0x1d0
new_sync_write+0x113/0x1a0
vfs_write+0x1c5/0x200
ksys_write+0x67/0xe0
__x64_sys_write+0x1a/0x20
do_syscall_64+0x49/0xc0
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
index 5b48aa0c7ece..f2d4a4ba497c 100644
--- a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
+++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
@@ -556,6 +556,11 @@ static int test_case(unsigned int cmd)
{
int rc = TSKIP;
+ if (!ltp_pci.dev || !ltp_pci.bus) {
+ prk_err("device or bus not selected for test");
+ return TFAIL;
+ }
+
switch (cmd) {
case PCI_ENABLE:
rc = pci_enable();
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci
2021-06-18 13:05 [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
@ 2021-06-18 13:05 ` Krzysztof Kozlowski
2021-06-28 20:24 ` Petr Vorel
2021-06-24 19:32 ` [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
1 sibling, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-06-18 13:05 UTC (permalink / raw)
To: ltp
Assigning the memory prefetch resource to virtio-pci might fail on VM
guests. For example on Oracle cloud instance (describing itself as
"Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.4.1
12/03/2020"):
test_pci 76 TFAIL : tpci.c:73: PCI bus 00 slot 20 : Test-case '12'
In dmesg:
ltp_tpci: test-case 12
ltp_tpci: assign resources
ltp_tpci: assign resource #0
ltp_tpci: name = 0000:00:04.0, flags = 262401, start 0xc000, end 0xc03f
ltp_tpci: assign resource #1
ltp_tpci: name = 0000:00:04.0, flags = 262656, start 0xc1010000, end 0xc1010fff
ltp_tpci: assign resource #2
ltp_tpci: name = 0000:00:04.0, flags = 0, start 0x0, end 0x0
ltp_tpci: assign resource #3
ltp_tpci: name = 0000:00:04.0, flags = 0, start 0x0, end 0x0
ltp_tpci: assign resource #4
ltp_tpci: name = 0000:00:04.0, flags = 538190348, start 0x800004000, end 0x800007fff
virtio-pci 0000:00:04.0: BAR 4: no space for [mem size 0x00004000 64bit pref]
virtio-pci 0000:00:04.0: BAR 4: failed to assign [mem size 0x00004000 64bit pref]
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
Found the failure on multiple different kernels in different cloud
providers (Oracle, AWS, Azure):
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1878389
---
.../device-drivers/pci/tpci_kernel/ltp_tpci.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
index f2d4a4ba497c..41462d4ead6d 100644
--- a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
+++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
@@ -108,8 +108,9 @@ static int probe_pci_dev(unsigned int bus, unsigned int slot)
if (!dev || !dev->driver)
return -ENODEV;
- prk_info("found pci_dev '%s', bus %u, devfn %u",
- pci_name(dev), bus, slot);
+ prk_info("found pci_dev '%s', driver '%s', bus %u, devfn %u",
+ pci_name(dev), (dev->driver) ? dev->driver->name : "",
+ bus, slot);
ltp_pci.dev = dev;
ltp_pci.bus = dev->bus;
@@ -444,7 +445,15 @@ static int test_assign_resources(void)
r->flags & IORESOURCE_PREFETCH) {
ret = pci_assign_resource(dev, i);
prk_info("assign resource to '%d', ret '%d'", i, ret);
- rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
+ if (dev->driver && !strncmp(dev->driver->name, "virtio-pci",
+ strlen("virtio-pci"))) {
+ if (ret < 0 && ret != -EBUSY && ret != -ENOMEM)
+ rc |= TFAIL;
+ else
+ rc |= TPASS;
+ } else {
+ rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
+ }
}
}
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation
2021-06-18 13:05 [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
2021-06-18 13:05 ` [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci Krzysztof Kozlowski
@ 2021-06-24 19:32 ` Krzysztof Kozlowski
2021-06-28 20:00 ` Petr Vorel
1 sibling, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-06-24 19:32 UTC (permalink / raw)
To: ltp
On 18/06/2021 15:05, Krzysztof Kozlowski wrote:
> Fix NULL pointer dereference when a ltp_tpci test case is started before
> choosing the device:
>
> ltp_tpci: test-case 12
> ltp_tpci: assign resources
> ltp_tpci: assign resource #0
> BUG: kernel NULL pointer dereference, address: 00000000000003b8
> ...
> Call Trace:
> dev_attr_store+0x17/0x30
> sysfs_kf_write+0x3e/0x50
> kernfs_fop_write_iter+0x13c/0x1d0
> new_sync_write+0x113/0x1a0
> vfs_write+0x1c5/0x200
> ksys_write+0x67/0xe0
> __x64_sys_write+0x1a/0x20
> do_syscall_64+0x49/0xc0
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
> testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
Hi everyone,
Any comments on these two tpci patches? Do they look reasonable?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation
2021-06-24 19:32 ` [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
@ 2021-06-28 20:00 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-06-28 20:00 UTC (permalink / raw)
To: ltp
Hi Krzysztof,
> On 18/06/2021 15:05, Krzysztof Kozlowski wrote:
> > Fix NULL pointer dereference when a ltp_tpci test case is started before
> > choosing the device:
> > ltp_tpci: test-case 12
> > ltp_tpci: assign resources
> > ltp_tpci: assign resource #0
> > BUG: kernel NULL pointer dereference, address: 00000000000003b8
> > ...
> > Call Trace:
> > dev_attr_store+0x17/0x30
> > sysfs_kf_write+0x3e/0x50
> > kernfs_fop_write_iter+0x13c/0x1d0
> > new_sync_write+0x113/0x1a0
> > vfs_write+0x1c5/0x200
> > ksys_write+0x67/0xe0
> > __x64_sys_write+0x1a/0x20
> > do_syscall_64+0x49/0xc0
> > entry_SYSCALL_64_after_hwframe+0x44/0xa9
Merged this one, thanks!
Kind regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci
2021-06-18 13:05 ` [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci Krzysztof Kozlowski
@ 2021-06-28 20:24 ` Petr Vorel
2021-07-26 11:43 ` Petr Vorel
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2021-06-28 20:24 UTC (permalink / raw)
To: ltp
Hi Krzysztof,
> Assigning the memory prefetch resource to virtio-pci might fail on VM
> guests. For example on Oracle cloud instance (describing itself as
> "Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.4.1
> 12/03/2020"):
> test_pci 76 TFAIL : tpci.c:73: PCI bus 00 slot 20 : Test-case '12'
I'm not sure if we don't cover actual bug. Because I haven't found any issues on
virtio_pci used on VM boxes. But probably failing to assign memory is something
else than kernel bug.
> In dmesg:
> ltp_tpci: test-case 12
> ltp_tpci: assign resources
> ltp_tpci: assign resource #0
> ltp_tpci: name = 0000:00:04.0, flags = 262401, start 0xc000, end 0xc03f
> ltp_tpci: assign resource #1
> ltp_tpci: name = 0000:00:04.0, flags = 262656, start 0xc1010000, end 0xc1010fff
> ltp_tpci: assign resource #2
> ltp_tpci: name = 0000:00:04.0, flags = 0, start 0x0, end 0x0
> ltp_tpci: assign resource #3
> ltp_tpci: name = 0000:00:04.0, flags = 0, start 0x0, end 0x0
> ltp_tpci: assign resource #4
> ltp_tpci: name = 0000:00:04.0, flags = 538190348, start 0x800004000, end 0x800007fff
> virtio-pci 0000:00:04.0: BAR 4: no space for [mem size 0x00004000 64bit pref]
> virtio-pci 0000:00:04.0: BAR 4: failed to assign [mem size 0x00004000 64bit pref]
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
> Found the failure on multiple different kernels in different cloud
> providers (Oracle, AWS, Azure):
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1878389
> ---
> .../device-drivers/pci/tpci_kernel/ltp_tpci.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
> diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
> index f2d4a4ba497c..41462d4ead6d 100644
> --- a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
> +++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c
> @@ -108,8 +108,9 @@ static int probe_pci_dev(unsigned int bus, unsigned int slot)
> if (!dev || !dev->driver)
> return -ENODEV;
> - prk_info("found pci_dev '%s', bus %u, devfn %u",
> - pci_name(dev), bus, slot);
> + prk_info("found pci_dev '%s', driver '%s', bus %u, devfn %u",
> + pci_name(dev), (dev->driver) ? dev->driver->name : "",
> + bus, slot);
> ltp_pci.dev = dev;
> ltp_pci.bus = dev->bus;
> @@ -444,7 +445,15 @@ static int test_assign_resources(void)
> r->flags & IORESOURCE_PREFETCH) {
> ret = pci_assign_resource(dev, i);
> prk_info("assign resource to '%d', ret '%d'", i, ret);
> - rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
> + if (dev->driver && !strncmp(dev->driver->name, "virtio-pci",
> + strlen("virtio-pci"))) {
> + if (ret < 0 && ret != -EBUSY && ret != -ENOMEM)
> + rc |= TFAIL;
> + else
Shouldn't ENOMEM/EBUSY result to TCONF or TBROK?
https://github.com/linux-test-project/ltp/wiki/C-Test-API#12-basic-test-interface
Kind regards,
Petr
> + rc |= TPASS;
> + } else {
> + rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS;
> + }
> }
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci
2021-06-28 20:24 ` Petr Vorel
@ 2021-07-26 11:43 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2021-07-26 11:43 UTC (permalink / raw)
To: ltp
Hi,
just for a record: Krzysztof confirmed [1] that d631e9cae ("ltp_tpci.c: Add release
operation before allocation") fixed issue with virtio-pci reported here,
suggested to refuse this patch.
Kind regards,
Petr
[1] https://lists.linux.it/pipermail/ltp/2021-July/024053.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-07-26 11:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 13:05 [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
2021-06-18 13:05 ` [LTP] [PATCH 2/2] tpci: accept ENOMEM resource failure with virtio-pci Krzysztof Kozlowski
2021-06-28 20:24 ` Petr Vorel
2021-07-26 11:43 ` Petr Vorel
2021-06-24 19:32 ` [LTP] [PATCH 1/2] tpci: fix NULL pointer dereference on wrong test invocation Krzysztof Kozlowski
2021-06-28 20:00 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.