From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Mark Harmstone <mark@harmstone.com>, Boris Burkov <boris@bur.io>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: add BTRFS_IOC_GET_CSUMS ioctl
Date: Wed, 8 Apr 2026 07:22:44 +0930 [thread overview]
Message-ID: <7c2377be-ceca-44ce-8bcb-e201d142b4f8@gmx.com> (raw)
In-Reply-To: <a40afd17-bfb6-486d-8632-9663d6cf7ce3@harmstone.com>
在 2026/4/8 03:43, Mark Harmstone 写道:
> I think all three of us are confusing each other a little here.
>
> The ioctl answers the question: if I were to read X bytes of data from a
> file at Y offset and calculated the csums manually, what would the value
> be? To which the kernel responds either with the values, that the read
> is guaranteed to return zero and thus we can use the precomputed csum
> for the zero sector, or that the value isn't known and userspace has to
> do it anyway.
>
> The value isn't known if it's a nodatasum file or if it's compressed. We
> store the csums of compressed extents, but crucially it's over the
> compressed data. So there's no one-to-one mapping between file blocks
> and compressed sectors (by definition, because it's compressed), and
> bookending means that it might be data we don't have access to.
>
> We absolutely can't give non-root users csums to arbitrary data, that's
> definitely a security breach.
If getting csums for random logical is a security breach, I do not think
the new GET_CSUM ioctl is any better.
>
> Userspace can already obtain the csums from the disk for a file by using
> FIEMAP and the tree search ioctl. But I believe the consensus around the
> tree search ioctl is a) that it's very difficult to use, as you need to
> know the internals of btrfs,
I completely agree with this part, furthermore due to the layout of csum
tree, one has to workaround by searching with a much smaller value than
the bytenr as the min_key, which means possible unnecessary reads of
previous leaves.
Thanks,
Qu
> and b) it requires CAP_SYS_ADMIN, at a time
> when containerization and finer-grained access controls means this is
> frowned upon.
>
> This ioctl is a simpler way of doing the csum lookup, and without
> requiring root.
>
next prev parent reply other threads:[~2026-04-07 21:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 12:50 [PATCH] btrfs: add BTRFS_IOC_GET_CSUMS ioctl Mark Harmstone
2026-03-20 13:03 ` Mark Harmstone
2026-03-20 22:18 ` Qu Wenruo
2026-03-25 7:34 ` Qu Wenruo
2026-03-25 14:43 ` Mark Harmstone
2026-03-25 21:04 ` Qu Wenruo
2026-04-02 17:05 ` Mark Harmstone
2026-04-02 21:46 ` Qu Wenruo
2026-04-03 22:44 ` Boris Burkov
2026-04-03 23:00 ` Qu Wenruo
2026-04-07 18:13 ` Mark Harmstone
2026-04-07 21:52 ` Qu Wenruo [this message]
2026-04-07 22:13 ` Boris Burkov
2026-04-07 22:39 ` Qu Wenruo
2026-04-08 13:22 ` Mark Harmstone
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=7c2377be-ceca-44ce-8bcb-e201d142b4f8@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=boris@bur.io \
--cc=linux-btrfs@vger.kernel.org \
--cc=mark@harmstone.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