From: Sergei Shtepa <sergei.shtepa@veeam.com>
To: Christoph Hellwig <hch@infradead.org>,
Dave Chinner <david@fromorbit.com>
Cc: <axboe@kernel.dk>, <corbet@lwn.net>, <snitzer@kernel.org>,
<viro@zeniv.linux.org.uk>, <brauner@kernel.org>,
<dchinner@redhat.com>, <willy@infradead.org>,
<dlemoal@kernel.org>, <linux@weissschuh.net>, <jack@suse.cz>,
<ming.lei@redhat.com>, <linux-block@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-fsdevel@vger.kernel.org>,
Donald Buczek <buczek@molgen.mpg.de>
Subject: Re: [PATCH v5 04/11] blksnap: header file of the module interface
Date: Wed, 14 Jun 2023 11:26:20 +0200 [thread overview]
Message-ID: <733f591e-0e8f-8668-8298-ddb11a74df81@veeam.com> (raw)
In-Reply-To: <ZIldkb1pwhNsSlfl@infradead.org>
On 6/14/23 08:26, Christoph Hellwig wrote:
> Subject:
> Re: [PATCH v5 04/11] blksnap: header file of the module interface
> From:
> Christoph Hellwig <hch@infradead.org>
> Date:
> 6/14/23, 08:26
>
> To:
> Dave Chinner <david@fromorbit.com>
> CC:
> Sergei Shtepa <sergei.shtepa@veeam.com>, axboe@kernel.dk, hch@infradead.org, corbet@lwn.net, snitzer@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, willy@infradead.org, dlemoal@kernel.org, linux@weissschuh.net, jack@suse.cz, ming.lei@redhat.com, linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Donald Buczek <buczek@molgen.mpg.de>
>
>
> On Wed, Jun 14, 2023 at 08:25:15AM +1000, Dave Chinner wrote:
>>> + * Return: 0 if succeeded, negative errno otherwise.
>>> + */
>>> +#define IOCTL_BLKSNAP_SNAPSHOT_APPEND_STORAGE \
>>> + _IOW(BLKSNAP, blksnap_ioctl_snapshot_append_storage, \
>>> + struct blksnap_snapshot_append_storage)
>> That's an API I'm extremely uncomfortable with. We've learnt the
>> lesson *many times* that userspace physical mappings of underlying
>> file storage are unreliable.
>>
>> i.e. This is reliant on userspace telling the kernel the physical
>> mapping of the filesystem file to block device LBA space and then
>> providing a guarantee (somehow) that the mapping will always remain
>> unchanged. i.e. It's reliant on passing FIEMAP data from the
>> filesystem to userspace and then back into the kernel without it
>> becoming stale and somehow providing a guarantee that nothing (not
>> even the filesystem doing internal garbage collection) will change
>> it.
> Hmm, I never thought of this API as used on files that somewhere
> had a logical to physical mapping applied to them.
>
> Sergey, is that the indtended use case? If so we really should
> be going through the file system using direct I/O.
>
Hi!
Thank you, Dave, for such a detailed comment.
Yes, everything is really as you described.
This code worked quite successfully for the veeamsnap module, on the
basis of which blksnap was created. Indeed, such an allocation of an
area on a block device using a file does not look safe.
We've already discussed this with Donald Buczek <buczek@molgen.mpg.de>.
Link: https://github.com/veeam/blksnap/issues/57#issuecomment-1576569075
And I have planned work on moving to a more secure ioctl in the future.
Link: https://github.com/veeam/blksnap/issues/61
Now, thanks to Dave, it becomes clear to me how to solve this problem best.
swapfile is a good example of how to do it right.
Fixing this vulnerability will entail transferring the algorithm for
allocating the difference storage from the user-space to the blksnap code.
The changes are quite significant. The UAPI will be changed.
So I agree that the blksnap module is not good enough for upstream yet.
next prev parent reply other threads:[~2023-06-14 9:26 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 13:52 [PATCH v5 00/11] blksnap - block devices snapshots module Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 01/11] documentation: Block Device Filtering Mechanism Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 02/11] block: " Sergei Shtepa
2023-07-11 2:02 ` Yu Kuai
2023-07-12 10:04 ` Yu Kuai
2023-07-12 12:34 ` Yu Kuai
2023-07-17 17:39 ` Sergei Shtepa
2023-07-18 1:21 ` Yu Kuai
2023-07-17 16:22 ` Sergei Shtepa
2023-07-17 14:39 ` Sergei Shtepa
2023-07-18 1:37 ` Yu Kuai
2023-07-18 11:25 ` Sergei Shtepa
2023-07-18 12:32 ` Yu Kuai
2023-07-18 16:33 ` Sergei Shtepa
2023-07-19 7:28 ` Yu Kuai
2023-07-19 8:36 ` Sergei Shtepa
2023-07-20 6:14 ` Christoph Hellwig
2023-06-12 13:52 ` [PATCH v5 03/11] documentation: Block Devices Snapshots Module Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 04/11] blksnap: header file of the module interface Sergei Shtepa
2023-06-13 22:25 ` Dave Chinner
2023-06-14 6:26 ` Christoph Hellwig
2023-06-14 9:26 ` Sergei Shtepa [this message]
2023-06-14 14:07 ` Christoph Hellwig
2023-06-14 16:43 ` Sergei Shtepa
2023-06-15 0:08 ` Dave Chinner
2023-07-17 18:57 ` Thomas Weißschuh
2023-07-18 9:53 ` Sergei Shtepa
2023-07-20 6:16 ` Christoph Hellwig
2023-06-12 13:52 ` [PATCH v5 05/11] blksnap: module management interface functions Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 06/11] blksnap: handling and tracking I/O units Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 07/11] blksnap: minimum data storage unit of the original block device Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 08/11] blksnap: difference storage Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 09/11] blksnap: event queue from the " Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 10/11] blksnap: snapshot and snapshot image block device Sergei Shtepa
2023-06-12 13:52 ` [PATCH v5 11/11] blksnap: Kconfig and Makefile Sergei Shtepa
2023-06-12 14:32 ` [PATCH v5 00/11] blksnap - block devices snapshots module Christoph Hellwig
2023-06-12 16:19 ` Eric Biggers
2023-06-13 5:50 ` Christoph Hellwig
2023-06-13 10:12 ` Sergei Shtepa
2023-06-14 17:22 ` Eric Biggers
-- strict thread matches above, loose matches on Subject: below --
2023-06-12 13:21 Sergei Shtepa
2023-06-12 13:21 ` [PATCH v5 04/11] blksnap: header file of the module interface Sergei Shtepa
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=733f591e-0e8f-8668-8298-ddb11a74df81@veeam.com \
--to=sergei.shtepa@veeam.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=buczek@molgen.mpg.de \
--cc=corbet@lwn.net \
--cc=david@fromorbit.com \
--cc=dchinner@redhat.com \
--cc=dlemoal@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=ming.lei@redhat.com \
--cc=snitzer@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®