From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Thoughts on 'btrfs device stats' and security.
Date: Fri, 17 Mar 2017 14:25:48 -0400 [thread overview]
Message-ID: <f0bd54bf-930b-c489-8bd3-e3b5a4cc965e@gmail.com> (raw)
I'm currently working on a plugin for colllectd [1] to track per-device
per-filesystem error rates for BTRFS volumes. Overall, this is actually
going quite well (I've got most of the secondary logic like matching
filesystems to watch and parsing the data done already), but I've come
across a rather nasty caveat on the actual data collection part.
As of right now, there are only two ways I can see to get this data:
1. Parse the output of `btrfs device stats` for the filesystem.
2. Make the same ioctl() call that `btrfs device stats` does and compose
the data yourself.
In both cases, one of the following has to be the case:
1. You're running as root.
2. You're running SUID root.
3. You're running with CAP_SYS_ADMIN (I'm not 100% certain that this is
the correct capability, but it appears to be the case from my testing).
In other words, you have to reduce the overall security of your system
to be able to get this data which is itself not security sensitive for
most intents and purposes.
Looking at this from the perspective of actual data collection, there
are a handful of things that come to mind:
* You already know either device names or device-id's, because the ioctl
is called per-device and uses one of those to identify the device to
return data for (I'm not sure from reading the code which), so this
aspect is by definition not sensitive data.
* While there are theoretically attacks that this data could be useful
for, the only ones I can think of are largely pointless because they
require write access to the underlying storage and provide information
which would by definition already be available by other (more efficient
and less obtrusive) means if you had such access.
* This is somewhat useful data for an admin who may not have root access
to retrieve.
* The use of an ioctl makes it non-trivial to access this data.
* We already expose allocation data through /sys/fs/btrfs (in the
per-filesystem `allocation` directory).
On this note, I'd like to propose that the error counters be exposed in
some way through sysfs so you don't have to parse the output of `btrfs
device stats` (and incur the fork()+exec() overhead) or fight with
ioctls. I would offer to work on this myself, but I have exactly zero
experience with the kernel side of sysfs, very limited experience with
kernel coding in general, and I'm not likely to have much (if any) time
to work on this for quite a while.
[1] https://collectd.org/
next reply other threads:[~2017-03-17 18:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 18:25 Austin S. Hemmelgarn [this message]
2017-03-17 19:01 ` Thoughts on 'btrfs device stats' and security Eric Sandeen
2017-03-17 19:45 ` Austin S. Hemmelgarn
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=f0bd54bf-930b-c489-8bd3-e3b5a4cc965e@gmail.com \
--to=ahferroin7@gmail.com \
--cc=linux-btrfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).