From: David Howells <dhowells@redhat.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Linus Torvalds <torvalds@osdl.org>,
akpm@osdl.org, James Morris <jmorris@redhat.com>,
linux-kernel@vger.kernel.org, arjanv@redhat.com,
dwmw2@infradead.org, greg@kroah.com,
Chris Wright <chrisw@osdl.org>,
sfrench@samba.org, mike@halcrow.us,
Trond Myklebust <trond.myklebust@fys.uio.no>,
Kyle Moffett <mrmacman_g4@mac.com>,
viro@parcelfarce.linux.theplanet.co.uk
Subject: [PATCH] keys & keyring management: key filesystem
Date: Wed, 11 Aug 2004 20:10:08 +0100 [thread overview]
Message-ID: <1541.1092251408@redhat.com> (raw)
In-Reply-To: <16655.1092227651@redhat.com>
Here's a preliminary look a patch I've concocted to make keys accessible
through yet another filesystem (TM). At the moment, it only gives a read-only
view onto the keys in the system.
The patch can be found at:
http://people.redhat.com/~dhowells/keys/keyfs-268rc2.diff.bz2
It requires the keys-268rc2-6.diff.bz2 patch to supply the basic key services.
Currently, it makes a filesystem that looks like:
/keyfs/
thread [symlink to process's thread key]
process [symlink to process's process key]
session [symlink to process's session key]
user [symlink to user key for process's UID]
user-session [symlink to def session key for process's UID]
<key>/ [directory representing a key]
type [file holding key type as a string]
description [file holding key description as a string]
expiry [file holding key expiry time as a decimal string]
perm [file holding key access mask as an octal string]
payload [file permitting reading/writing of key's payload data]
<key>/ [directory representing a keyring]
type [file holding key type as a string]
description [file holding key description as a string]
expiry [file holding key expiry time as a decimal string]
perm [file holding key access mask as an octal string]
keyring/ [directory representing a keyring's contents]
<key> [symlink to linked keys]
I've encountered some problems:
(1) readdir() on the root directory has to run in O(N^2) time because the key
tree lock is a spinlock and the filldir call is permitted to sleep.
I could solve this by making the spinlock into a semaphore, and just
read-locking it for the duration of the whole readdir call. But this has
other problems: it'll exclude any key changes for the duration,
especially if calling filldir causes it to swap a lot.
I don't think global enumeration is necessarily a good idea. /proc/keys
is a debugging interface, to be made root readable only at some point. I
don't think you should be able to _see_ any keys you don't have any
rights to. Do people disagree with that?
(2) It weakens security to some extent: it makes keys more accessible, more
visible.
I could, perhaps, deal with this by filtering the keys in readdir() and
lookup() on the root directory.
(3) The key permissions mask doesn't map easily to the usual RWX bits on a
file with their strictly VFS meaning. Whilst on a key I'm using the 'X'
bits to indicate search permission, that can't directly control execute
permission on the key directory.
(4) Accessing keys this way requires more syscall invocations, more locks to
be dealt with, etc. than the syscall approach. It's a lot less efficient,
particularly when it comes to producing a list of the same data seen in
/proc/keys.
(5) The kernel filesystem side of this is already much bigger than the
syscall/prctl approach, even when it's read-only.
(6) d_revalidate and getattr need to be supplied for any file or directory
that relates to a particular key to pick up UID/GID/permissions changes.
This is difficult to avoid. Each key has to be represented by several
inodes, and they all need to be kept in sync.
I still haven't seen any really good arguments why I should get rid of all the
syscalls/prctls and drive it from userspace _entirely_ through a keyfs. We
seem to be going a little overboard with the "everything must be a filesystem
approach".
I could perhaps make all the key syscalls ioctls on a control file placed in
the root directory:-)
David
next prev parent reply other threads:[~2004-08-11 19:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-07 0:31 [PATCH] implement in-kernel keys & keyring management David Howells
2004-08-07 8:17 ` Andrew Morton
2004-08-07 16:33 ` [PATCH] implement in-kernel keys & keyring management [try #2] David Howells
2004-08-07 17:48 ` [PATCH] implement in-kernel keys & keyring management [try #3] David Howells
2004-08-08 4:45 ` [PATCH] implement in-kernel keys & keyring management [try #2] James Morris
2004-08-09 9:33 ` David Howells
2004-08-09 14:08 ` James Morris
2004-08-09 14:35 ` David Howells
2004-08-09 15:47 ` James Morris
2004-08-10 18:49 ` David Howells
2004-08-08 2:52 ` [PATCH] implement in-kernel keys & keyring management Greg KH
2004-08-09 9:23 ` David Howells
2004-08-09 20:27 ` Greg KH
2004-08-07 8:59 ` Trond Myklebust
2004-08-07 17:45 ` David Howells
2004-08-08 5:14 ` James Morris
2004-08-08 5:25 ` Linus Torvalds
2004-08-09 1:14 ` James Morris
2004-08-09 4:27 ` Linus Torvalds
2004-08-09 6:32 ` bert hubert
2004-08-09 10:16 ` David Howells
2004-08-09 14:51 ` Alan Cox
2004-08-09 10:01 ` David Howells
2004-08-09 9:45 ` David Howells
2004-08-09 15:24 ` [PATCH] implement in-kernel keys & keyring management [try #4] David Howells
2004-08-09 21:13 ` Kyle Moffett
2004-08-10 17:59 ` [PATCH] implement in-kernel keys & keyring management [try #5] David Howells
2004-08-11 6:37 ` Chris Wright
2004-08-11 9:46 ` David Howells
2004-08-11 12:34 ` [PATCH] implement in-kernel keys & keyring management [try #6] David Howells
2004-08-11 19:10 ` David Howells [this message]
2004-08-09 9:40 ` [PATCH] implement in-kernel keys & keyring management David Howells
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=1541.1092251408@redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=arjanv@redhat.com \
--cc=chrisw@osdl.org \
--cc=dwmw2@infradead.org \
--cc=greg@kroah.com \
--cc=jmorris@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike@halcrow.us \
--cc=mrmacman_g4@mac.com \
--cc=sfrench@samba.org \
--cc=torvalds@osdl.org \
--cc=trond.myklebust@fys.uio.no \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.