OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page
@ 2026-11-27 12:31 Vasileios Almpanis
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch Vasileios Almpanis
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Vasileios Almpanis @ 2026-11-27 12:31 UTC (permalink / raw)
  To: Konstantin Khorenko, Denis V. Lunev, Andrey Zhadchenko
  Cc: devel, Artem Bulgakov

Two small fixes from Artem's review.

The first one stops a container from triggering a WARN in
blk_cbt_ioctl() with a wrong ABI version. With panic_on_warn=1 this
panics the host.

The second one fixes an oops in ploop_free_piwb() when the atomic bat
page allocation fails in ploop_prepare_bat_update().

I reproduced both on 8.1 with the stock kernel, the second one with a
kprobe that fails the bat page allocation. With both patches applied,
the first one only prints a warning and the second one fails the write
with an I/O error instead of an oops.

Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
Vasileios Almpanis (2):
      block/blk-cbt: don't WARN on an ABI version mismatch
      dm-ploop: don't put a NULL bat page in ploop_free_piwb()

 block/blk-cbt.c           | 4 ++--
 drivers/md/dm-ploop-map.c | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
---
base-commit: aef96420256e57bf1291859a844800a462f2790e
change-id: 20261127-cbt-ploop-fixes-33bd6e802462

-- 
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch
  2026-11-27 12:31 [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Vasileios Almpanis
@ 2026-11-27 12:31 ` Vasileios Almpanis
  2026-11-30 11:58   ` Konstantin Khorenko
  2026-12-01  0:47   ` no-reply
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb() Vasileios Almpanis
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Vasileios Almpanis @ 2026-11-27 12:31 UTC (permalink / raw)
  To: Konstantin Khorenko, Denis V. Lunev, Andrey Zhadchenko
  Cc: devel, Artem Bulgakov

blk_cbt_ioctl() checks the ABI version that userspace passes before it
checks CAP_SYS_ADMIN, and BLKCBTGET does not need CAP_SYS_ADMIN at all.
So anyone who can open a block device can trigger the WARN_ONCE with a
wrong version. Inside a container, root can open its own disk and do
this. On a node with panic_on_warn=1 this panics the host.

A wrong ABI version is a userspace error, so print a warning instead.

https://virtuozzo.atlassian.net/browse/VSTOR-157563

Fixes: 421362cbc789 ("block/blk-cbt: introduce ABI versioning")
Feature: cbt: changed block tracking (for backup)
Reported-by: Artem Bulgakov <artem.bulgakov@virtuozzo.com>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
 block/blk-cbt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index baa56ab1a538..af897e2677ee 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -1322,8 +1322,8 @@ int blk_cbt_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
 		return -EFAULT;
 
 	if (abi_version != CBT_ABI_VERSION) {
-		WARN_ONCE(1, "blk-cbt ABI mimatch: kernel has %d, userspace uses %d",
-			  CBT_ABI_VERSION, abi_version);
+		pr_warn_once("blk-cbt ABI mismatch: kernel has %d, userspace uses %u\n",
+			     CBT_ABI_VERSION, abi_version);
 		return -EOPNOTSUPP;
 	}
 

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb()
  2026-11-27 12:31 [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Vasileios Almpanis
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch Vasileios Almpanis
@ 2026-11-27 12:31 ` Vasileios Almpanis
  2026-11-30 11:58   ` Konstantin Khorenko
  2026-12-01  0:48   ` no-reply
  2026-11-30 11:58 ` [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Konstantin Khorenko
  2026-11-30 11:58 ` Konstantin Khorenko
  3 siblings, 2 replies; 9+ messages in thread
From: Vasileios Almpanis @ 2026-11-27 12:31 UTC (permalink / raw)
  To: Konstantin Khorenko, Denis V. Lunev, Andrey Zhadchenko
  Cc: devel, Artem Bulgakov

ploop_prepare_bat_update() allocates the bat page and the pio with
GFP_ATOMIC. If one of the allocations fails, it calls ploop_free_piwb(),
which calls put_page() on the bat page even if it is NULL. Under memory
pressure this oopses with bat_lock held.

Put the bat page only if it was allocated.

https://virtuozzo.atlassian.net/browse/VSTOR-157566

Fixes: 90bb85536272 ("dm-ploop: Add ploop target driver")
Feature: dm-ploop: ploop target driver
Reported-by: Artem Bulgakov <artem.bulgakov@virtuozzo.com>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index c62b414862b1..866def8f5304 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -918,7 +918,8 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
 static void ploop_free_piwb(struct ploop_index_wb *piwb)
 {
 	ploop_free_pio(piwb->ploop, piwb->pio);
-	put_page(piwb->bat_page);
+	if (piwb->bat_page)
+		put_page(piwb->bat_page);
 	kfree(piwb);
 }
 

-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page
  2026-11-27 12:31 [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Vasileios Almpanis
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch Vasileios Almpanis
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb() Vasileios Almpanis
@ 2026-11-30 11:58 ` Konstantin Khorenko
  2026-11-30 11:58 ` Konstantin Khorenko
  3 siblings, 0 replies; 9+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 11:58 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel, Artem Bulgakov

Applying with these fixes on my side:

- 2/2: "If one of the allocations fails" -> "If the bat page
  allocation fails" in the commit message.

On Fri, 27 Nov 2026 12:31:03 +0000, Vasileios Almpanis wrote:
> blk-cbt and dm-ploop: fix a host WARN and a NULL put_page

Both fixes are correct. Only a failed alloc_page() oopses: a NULL pio
was already fine, mempool_free() ignores NULL. Hence the change in the
message of 2/2.

> With both patches applied,
> the first one only prints a warning and the second one fails the write
> with an I/O error instead of an oops.

Not quite an I/O error: the request ends with BLK_STS_RESOURCE, so the
upper layer gets -ENOMEM. That is item 2 below.

Separate patches, not needed for this series. I created a task for
each:

1. BLKCBTGET with CI_FLAG_ONCE clears the bits it reports, and it runs
   before the CAP_SYS_ADMIN check with no open mode check either. So
   container root that opens its own disk read-only can wipe the CBT
   map, and the next incremental backup silently misses those blocks.
   https://virtuozzo.atlassian.net/browse/VSTOR-157680

2. A failed GFP_ATOMIC allocation in ploop_prepare_bat_update() under
   bat_lock is a transient condition, but the callers end the guest
   write with BLK_STS_RESOURCE. For ext4 in a container that is a
   journal abort and a read-only remount. It should be retried instead.
   https://virtuozzo.atlassian.net/browse/VSTOR-157681

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch Vasileios Almpanis
@ 2026-11-30 11:58   ` Konstantin Khorenko
  2026-12-01  0:47   ` no-reply
  1 sibling, 0 replies; 9+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 11:58 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel, Artem Bulgakov

Applying as is.

On Fri, 27 Nov 2026 12:31:04 +0000, Vasileios Almpanis wrote:

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb()
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb() Vasileios Almpanis
@ 2026-11-30 11:58   ` Konstantin Khorenko
  2026-12-01  0:48   ` no-reply
  1 sibling, 0 replies; 9+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 11:58 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel, Artem Bulgakov

Applying with these fixes on my side:

- "If one of the allocations fails" -> "If the bat page allocation
  fails".

On Fri, 27 Nov 2026 12:31:05 +0000, Vasileios Almpanis wrote:
> ploop_prepare_bat_update() allocates the bat page and the pio with
> GFP_ATOMIC. If one of the allocations fails, it calls ploop_free_piwb(),
> which calls put_page() on the bat page even if it is NULL.

A failed pio allocation alone does not oops: ploop_free_pio() ends in
mempool_free(), which ignores NULL. Only a NULL bat page does.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page
  2026-11-27 12:31 [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Vasileios Almpanis
                   ` (2 preceding siblings ...)
  2026-11-30 11:58 ` [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Konstantin Khorenko
@ 2026-11-30 11:58 ` Konstantin Khorenko
  3 siblings, 0 replies; 9+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 11:58 UTC (permalink / raw)
  To: Denis V. Lunev, Andrey Zhadchenko, Vasileios Almpanis
  Cc: devel, Artem Bulgakov

On Fri, 27 Nov 2026 12:31:03 +0000, Vasileios Almpanis wrote:
> blk-cbt and dm-ploop: fix a host WARN and a NULL put_page
> 
> Two small fixes from Artem's review.
> 
> The first one stops a container from triggering a WARN in
> blk_cbt_ioctl() with a wrong ABI version. With panic_on_warn=1 this
> panics the host.
> 
> [...]

Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.26.6.vz10, thanks!

[1/2] block/blk-cbt: don't WARN on an ABI version mismatch
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/241a165dee9e
[2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb()
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/f26039a7e415

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch Vasileios Almpanis
  2026-11-30 11:58   ` Konstantin Khorenko
@ 2026-12-01  0:47   ` no-reply
  1 sibling, 0 replies; 9+ messages in thread
From: no-reply @ 2026-12-01  0:47 UTC (permalink / raw)
  To: Vasileios Almpanis, Konstantin Khorenko, Denis V. Lunev,
	Andrey Zhadchenko
  Cc: devel, Artem Bulgakov

> blk_cbt_ioctl() checks the ABI version that userspace passes before it
> checks CAP_SYS_ADMIN, and BLKCBTGET does not need CAP_SYS_ADMIN at all.
> So anyone who can open a block device can trigger the WARN_ONCE with a
> wrong version. Inside a container, root can open its own disk and do
> this. On a node with panic_on_warn=1 this panics the host.
> 
> A wrong ABI version is a userspace error, so print a warning instead.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157563
> 
> Fixes: 421362cbc789 ("block/blk-cbt: introduce ABI versioning")
> Feature: cbt: changed block tracking (for backup)
> Reported-by: Artem Bulgakov <artem.bulgakov@virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261127-cbt-ploop-fixes-v1-0-d6559232b819@virtuozzo.com?part=1


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb()
  2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb() Vasileios Almpanis
  2026-11-30 11:58   ` Konstantin Khorenko
@ 2026-12-01  0:48   ` no-reply
  1 sibling, 0 replies; 9+ messages in thread
From: no-reply @ 2026-12-01  0:48 UTC (permalink / raw)
  To: Vasileios Almpanis, Konstantin Khorenko, Denis V. Lunev,
	Andrey Zhadchenko
  Cc: devel, Artem Bulgakov

> ploop_prepare_bat_update() allocates the bat page and the pio with
> GFP_ATOMIC. If one of the allocations fails, it calls ploop_free_piwb(),
> which calls put_page() on the bat page even if it is NULL. Under memory
> pressure this oopses with bat_lock held.
> 
> Put the bat page only if it was allocated.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-157566
> 
> Fixes: 90bb85536272 ("dm-ploop: Add ploop target driver")
> Feature: dm-ploop: ploop target driver
> Reported-by: Artem Bulgakov <artem.bulgakov@virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261127-cbt-ploop-fixes-v1-0-d6559232b819@virtuozzo.com?part=2


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-12-01  0:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 12:31 [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Vasileios Almpanis
2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 1/2] block/blk-cbt: don't WARN on an ABI version mismatch Vasileios Almpanis
2026-11-30 11:58   ` Konstantin Khorenko
2026-12-01  0:47   ` no-reply
2026-11-27 12:31 ` [Devel] [PATCH hci-8.2 2/2] dm-ploop: don't put a NULL bat page in ploop_free_piwb() Vasileios Almpanis
2026-11-30 11:58   ` Konstantin Khorenko
2026-12-01  0:48   ` no-reply
2026-11-30 11:58 ` [Devel] [PATCH hci-8.2 0/2] blk-cbt and dm-ploop: fix a host WARN and a NULL put_page Konstantin Khorenko
2026-11-30 11:58 ` Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox