Skip to content

Commit

Permalink
kernel/ksysfs.c: expose file_caps_enabled in sysfs
Browse files Browse the repository at this point in the history
A kernel booted with no_file_caps allows to install fscaps on a binary
but doesn't actually honor the fscaps when running the binary. Userspace
currently has no sane way to determine whether installing fscaps
actually has any effect. Since parsing /proc/cmdline is fragile this
patch exposes the current setting (1 or 0) via /sys/kernel/fscaps

Signed-off-by: Ludwig Nussel <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
lnussel authored and gregkh committed Apr 19, 2011
1 parent aed65af commit 088ab0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Documentation/ABI/testing/sysfs-kernel-fscaps
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
What: /sys/kernel/fscaps
Date: February 2011
KernelVersion: 2.6.38
Contact: Ludwig Nussel <[email protected]>
Description
Shows whether file system capabilities are honored
when executing a binary

10 changes: 10 additions & 0 deletions kernel/ksysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/kexec.h>
#include <linux/profile.h>
#include <linux/sched.h>
#include <linux/capability.h>

#define KERNEL_ATTR_RO(_name) \
static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
Expand Down Expand Up @@ -131,6 +132,14 @@ KERNEL_ATTR_RO(vmcoreinfo);

#endif /* CONFIG_KEXEC */

/* whether file capabilities are enabled */
static ssize_t fscaps_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", file_caps_enabled);
}
KERNEL_ATTR_RO(fscaps);

/*
* Make /sys/kernel/notes give the raw contents of our kernel .notes section.
*/
Expand Down Expand Up @@ -158,6 +167,7 @@ struct kobject *kernel_kobj;
EXPORT_SYMBOL_GPL(kernel_kobj);

static struct attribute * kernel_attrs[] = {
&fscaps_attr.attr,
#if defined(CONFIG_HOTPLUG)
&uevent_seqnum_attr.attr,
&uevent_helper_attr.attr,
Expand Down

0 comments on commit 088ab0b

Please sign in to comment.