linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Curious problem: btrfs device stats & unpriviliged access
@ 2018-10-08 14:27 Holger Hoffstätte
  2018-10-08 14:40 ` Hans van Kranenburg
  0 siblings, 1 reply; 8+ messages in thread
From: Holger Hoffstätte @ 2018-10-08 14:27 UTC (permalink / raw)
  To: linux-btrfs

(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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-23 14:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-08 14:27 Curious problem: btrfs device stats & unpriviliged access Holger Hoffstätte
2018-10-08 14:40 ` 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

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).