linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] [RFC] sysfs: Add hook for checking the file capability of opener
@ 2018-12-30 13:28 Lee, Chun-Yi
  2018-12-30 13:28 ` [PATCH 1/2] sysfs: Add hook for checking the file capable for opener Lee, Chun-Yi
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Lee, Chun-Yi @ 2018-12-30 13:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Pavel Machek, Len Brown,
	Martin K . Petersen, Randy Dunlap, Joe Perches, Bart Van Assche
  Cc: linux-kernel, linux-pm, Lee, Chun-Yi, Chen Yu,
	Giovanni Gherdovich, Jann Horn, Andy Lutomirski

There have some discussion in the following mail loop about checking
capability in sysfs write handler:
    https://lkml.org/lkml/2018/9/13/978

Sometimes we check the capability in sysfs implementation by using
capable function. But the checking can be bypassed by opening sysfs
file within an unprivileged process then writing the file within a
privileged process. The tricking way has been exposed by Andy Lutomirski
for CVE-2013-1959.

Because the sysfs_ops does not forward the file descriptor to the
show/store callback, there doesn't have chance to check the capability
of file's opener. This patch adds the hook to sysfs_ops that allows
different implementation in object and attribute levels for checking
file capable before accessing sysfs interfaces.

The callback function of kobject sysfs_ops is the first implementation
of new hook. It casts attribute to kobj_attribute then calls the file
capability callback function of attribute level. The same logic can
be implemented in other sysfs file types, like: device, driver and
bus type. 

The capability checking logic in wake_lock/wake_unlock sysfs interface
is the first example for kobject. It will check the opener's capability.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Chen Yu <yu.c.chen@intel.com>
Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Joe Perches <joe@perches.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>

Lee, Chun-Yi (2):
  sysfs: Add hook for checking the file capable
  PM / Sleep: Checking the file capability when writing wak lock
    interface

 fs/sysfs/file.c         |  8 ++++++++
 include/linux/kobject.h |  2 ++
 include/linux/sysfs.h   |  2 ++
 kernel/power/main.c     | 14 ++++++++++++++
 kernel/power/wakelock.c |  6 ------
 lib/kobject.c           | 26 ++++++++++++++++++++++++++
 6 files changed, 52 insertions(+), 6 deletions(-)

-- 
2.13.6


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

end of thread, other threads:[~2018-12-31 15:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-30 13:28 [PATCH 0/2] [RFC] sysfs: Add hook for checking the file capability of opener Lee, Chun-Yi
2018-12-30 13:28 ` [PATCH 1/2] sysfs: Add hook for checking the file capable for opener Lee, Chun-Yi
2018-12-30 13:28 ` [PATCH 2/2] PM / Sleep: Check the file capability when writing wake lock interface Lee, Chun-Yi
2018-12-30 14:48   ` Greg Kroah-Hartman
2018-12-31  9:38     ` joeyli
2018-12-31 10:40       ` Greg Kroah-Hartman
2018-12-31 12:02         ` Jann Horn
2018-12-31 12:33           ` Greg Kroah-Hartman
2018-12-31 15:31             ` Andy Lutomirski
2018-12-30 14:45 ` [PATCH 0/2] [RFC] sysfs: Add hook for checking the file capability of opener Greg Kroah-Hartman
2018-12-31  9:41   ` joeyli
2018-12-31 10:38     ` Greg Kroah-Hartman

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