linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Holger Hoffstätte" <holger@applied-asynchrony.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Curious problem: btrfs device stats & unpriviliged access
Date: Mon, 8 Oct 2018 16:27:48 +0200	[thread overview]
Message-ID: <05c64256-71d3-81dc-3189-628e8cc0a5db@applied-asynchrony.com> (raw)

(moving the discussion here from GH [1])

Apparently there is something weird going on with the device stats
ioctls. I cannot get them to work as regular user, while they work
for David. A friend confirms the same issue on his system - no access
as non-root.

So I made a new empty fs, mounted it, built btrfs-progs-4.17.1 with
debug symbols and stepped into search_chunk_tree_for_fs_info().
Everything is fine, all args are correct, right until:

(gdb) s
1614	ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &search_args);
(gdb) s
1615	if (ret < 0)
(gdb) p ret
$4 = -1
(gdb) p search_args
$5 = {key = {tree_id = 3, min_objectid = 1, max_objectid = 1, min_offset = 1,
max_offset = 18446744073709551615, min_transid = 0, max_transid = 18446744073709551615,
min_type = 216, max_type = 216, nr_items = 30, unused = 0, unused1 = 0, unused2 = 0,
unused3 = 0, unused4 = 0}, buf = '\000' <repeats 3991 times>}

Looking at the kernel side of things in fs/btrfs/ioctl.c I see both
BTRFS_IOC_TREE_SEARCH[_V2} unconditionally require CAP_SYS_ADMIN.

So why can Dave get his dev stats as unprivileged user?
Does this work for anybody else? And why? :)

cheers
Holger

[1] https://github.com/prometheus/node_exporter/issues/1100#issuecomment-427823190

             reply	other threads:[~2018-10-08 14:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 14:27 Holger Hoffstätte [this message]
2018-10-08 14:40 ` Curious problem: btrfs device stats & unpriviliged access Hans van Kranenburg
2018-10-08 14:54   ` Hans van Kranenburg
2018-10-08 15:29   ` Holger Hoffstätte
2018-10-08 15:46     ` Hans van Kranenburg
2018-10-08 16:37       ` Holger Hoffstätte
2018-10-08 20:02         ` Hans van Kranenburg
2019-10-23 14:24           ` Holger Hoffstätte

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=05c64256-71d3-81dc-3189-628e8cc0a5db@applied-asynchrony.com \
    --to=holger@applied-asynchrony.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).