OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: Den Lunev <den@virtuozzo.com>, devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages
Date: Wed, 18 Nov 2026 13:57:27 +0000	[thread overview]
Message-ID: <20261118-vstor-153891-v2-1-e91753150b91@virtuozzo.com> (raw)
In-Reply-To: <20261118-vstor-153891-v2-0-e91753150b91@virtuozzo.com>

pb_message() sets ret to -EINVAL before it checks the arguments, but
then it overwrites ret with the result of taking ctl_rwsem, which is 0
on success. Because of that every argument check after the lock jumps
to unlock with ret == 0. The message is rejected and nothing is done,
but the caller sees success:

  # dmsetup message pbt 0 push_backup_start abc
  # echo $?
  0
  # dmsetup status pbt
  0 2097152 push_backup 7:0 128 0 inactive

This affects push_backup_start with a wrong number of arguments or an
unparsable timeout or mask, push_backup_read and push_backup_get_fd
with extra arguments, and push_backup_write with a malformed range.
push_backup_stop is not affected, because it checks its arguments
before the lock is taken.

Fix this by setting ret back to -EINVAL after the lock is taken.

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

Feature: dm-backup: push backup target driver
Fixes: 162123bc62c7 ("dm: Add push backup driver")
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
 drivers/md/dm-push-backup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 4f6dc1f3c130..4406f0dc8f68 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -723,6 +723,7 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
 	if (unlikely(ret))
 		goto out;
 
+	ret = -EINVAL;
 	if (!strcmp(argv[0], "push_backup_start")) {
 		if (argc < 2 || argc > 3)
 			goto unlock;

-- 
2.43.0

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

  reply	other threads:[~2026-11-18 13:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 13:57 ` Vasileios Almpanis [this message]
2026-11-18 14:00   ` [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages no-reply
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session Vasileios Almpanis
2026-11-18 14:00   ` no-reply
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 14:04   ` no-reply
2026-11-18 14:05 ` [Devel] [PATCH hci-8.2 v2 0/3] " Andrey Zhadchenko
2026-11-18 15:20 ` Konstantin Khorenko
2026-11-18 15:20 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118-vstor-153891-v2-1-e91753150b91@virtuozzo.com \
    --to=vasileios.almpanis@virtuozzo.com \
    --cc=den@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox