From: no-reply@sashiko.virtuozzo.com
To: khorenko@virtuozzo.com,
Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>,
alexander.ivanov@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v4 6/6] drivers/md/push_backup: add event file descriptor interface
Date: Tue, 3 Nov 2026 08:17:44 +0000 [thread overview]
Message-ID: <010701a1a07c534d-225718d1-c87f-40cc-a16d-20b99466eea8-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261103080358.723186-7-andrey.zhadchenko@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] dm-push-backup: pb_fops has no .poll, so the event fd cannot be polled
- [Low] dm-push-backup: push_backup_write() checks range before -ENODEV/-ESTALE
- [Low] dm push_backup: fd_install() in message handler precedes ioctl result copy-out
--
commit 34e71a14b728d9c4ab310c5d9fc752f38ad72889
Author: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
drivers/md/push_backup: add event file descriptor interface
This patch adds a push_backup_get_fd target message that returns an anon
inode fd. The backup tool can read() the next range to back up from the fd
and write() to acknowledge it, instead of sleeping inside a dm message. A
kref on struct push_backup ties the lifetime to the number of open fds.
Link: https://virtuozzo.atlassian.net/browse/VSTOR-152912
[ ... ]
> diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
> --- a/drivers/md/dm-push-backup.c
> +++ b/drivers/md/dm-push-backup.c
[ ... ]
> @@ -471,11 +528,13 @@ static int push_backup_write(struct push_backup *pb,
> return -EBADF;
> if (clu >= nr_clus || nr > nr_clus - clu)
> return -E2BIG;
> - if (!pb->map)
> - return -ESTALE;
>
> spin_lock_irq(&pb->lock);
> - if (pb->destroyed) {
> + spin_unlock_irq(&pb->lock);
> + return -ENODEV;
> + }
[Severity: Low]
Can the -ENODEV and -ESTALE results documented for write() on the fd be
hidden here?
In push_backup_write(), the range check returns -E2BIG before pb->lock is
taken and before pb->destroyed and "!pb->map || !pb->alive" are tested:
if (clu >= nr_clus || nr > nr_clus - clu)
return -E2BIG;
spin_lock_irq(&pb->lock);
if (pb->destroyed) {
A caller of pb_fd_write() that passes an out of range value to a stopped or
destroyed target gets -E2BIG instead of -ESTALE or -ENODEV. Would it make
sense to test the target state first, or to document the ordering in the
UAPI header?
[ ... ]
> +static const struct file_operations pb_fops = {
> + .owner = THIS_MODULE,
> + .read = pb_fd_read,
> + .write = pb_fd_write,
> + .release = pb_fd_release,
> +};
[Severity: Low]
This isn't a bug, but pb_fops has no .poll callback. The UAPI header
documents -EAGAIN for O_NONBLOCK read(), yet the fd cannot be used with
poll, select or epoll.
Without it, how is a single-threaded tool expected to wait for readiness
on this fd? It would need a dedicated blocking thread or a busy loop on
O_NONBLOCK read().
pb->waitq and pb_has_event() already exist, so would a .poll implementation
based on poll_wait(file, &pb->waitq, wait) and pb_has_event() be
reasonable here?
> +static int push_backup_get_fd(struct push_backup *pb,
> + char *result, unsigned int maxlen)
> +{
[ ... ]
> + fd_install(fd, file);
> + return 1;
> +}
[Severity: Low]
Can this leave an installed fd whose number is never delivered to
userspace?
push_backup_get_fd() calls fd_install() and returns 1 from within the
message handler. The result buffer is copied out by dm-ioctl only after
the target returns:
drivers/md/dm-ioctl.c:ctl_ioctl() {
...
if (!r && copy_to_user(user, param, param->data_size))
r = -EFAULT;
...
}
If this copy_to_user() fails, for example because the user buffer is
unmapped or read-only, the ioctl returns -EFAULT. The fd stays installed
in the caller's fd table and nothing rolls it back.
The fd holds a kref on struct push_backup and a module reference on
dm-push-backup through anon_inode_getfile(). The target and the module
therefore stay pinned until the process exits or closes the fd by guessing
its number.
Only a CAP_SYS_ADMIN caller passing a bad buffer can reach this. Would it
be worth documenting this behaviour, or is there a way to defer
fd_install() until the result has been delivered?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261103080358.723186-1-andrey.zhadchenko@virtuozzo.com?part=6
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-03 8:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 8:03 [Devel] [PATCH hci-8.1 v4 0/6] dm/push_backup: event fd interface and fixes Andrey Zhadchenko
2026-11-03 8:03 ` [Devel] [PATCH hci-8.1 v4 1/6] drivers/md/push_backup: correct initialization Andrey Zhadchenko
2026-11-03 8:11 ` no-reply
2026-11-03 10:11 ` Konstantin Khorenko
2026-11-03 8:03 ` [Devel] [PATCH hci-8.1 v4 2/6] drivers/md/push_backup: clear pb->alive under pb->lock Andrey Zhadchenko
2026-11-03 8:11 ` no-reply
2026-11-03 10:11 ` Konstantin Khorenko
2026-11-03 8:03 ` [Devel] [PATCH hci-8.1 v4 3/6] drivers/md/push_backup: do not re-arm deadline timer in push_backup_write() Andrey Zhadchenko
2026-11-03 8:13 ` no-reply
2026-11-03 10:11 ` Konstantin Khorenko
2026-11-03 8:03 ` [Devel] [PATCH hci-8.1 v4 4/6] drivers/md/push_backup: fix mod_timer() usage Andrey Zhadchenko
2026-11-03 8:12 ` no-reply
2026-11-03 10:11 ` Konstantin Khorenko
2026-11-03 8:03 ` [Devel] [PATCH hci-8.1 v4 5/6] drivers/md/push_backup: arm deadline timer under pb->lock Andrey Zhadchenko
2026-11-03 8:14 ` no-reply
2026-11-03 10:11 ` Konstantin Khorenko
2026-11-03 8:03 ` [Devel] [PATCH hci-8.1 v4 6/6] drivers/md/push_backup: add event file descriptor interface Andrey Zhadchenko
2026-11-03 8:17 ` no-reply [this message]
2026-11-03 10:11 ` Konstantin Khorenko
2026-11-03 12:38 ` Andrey Zhadchenko
2026-11-03 10:11 ` [Devel] [PATCH hci-8.1 v4 0/6] dm/push_backup: event fd interface and fixes 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=010701a1a07c534d-225718d1-c87f-40cc-a16d-20b99466eea8-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@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 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.