[PATCH] KEYS: Make request_key() and co fundamentally asynchronous

Previous thread: Re: [patch] sunrpc: make closing of old temporary sockets work (was: problems with lockd in 2.6.22.6) by Neil Brown on Wednesday, September 12, 2007 - 10:14 am. (7 messages)

Next thread: [PATCH] update checkpatch.pl to version 0.10 by Andy Whitcroft on Wednesday, September 12, 2007 - 11:00 am. (22 messages)
To: <torvalds@...>, <akpm@...>
Cc: <kwc@...>, <Trond.Myklebust@...>, <linux-kernel@...>, <smfrench@...>, <nfsv4@...>, <dhowells@...>
Date: Wednesday, September 12, 2007 - 10:25 am

Make request_key() and co fundamentally asynchronous to make it easier for NFS
to make use of them. There are now accessor functions that do asynchronous
constructions, a wait function to wait for construction to complete, and a
completion function for the key type to indicate completion of construction.

Note that the construction queue is now gone. Instead, keys under construction
are linked in to the appropriate keyring in advance, and that anyone
encountering one must wait for it to be complete before they can use it. This
is done automatically for userspace.

The following auxiliary changes are also made:

(1) Key type implementation stuff is split from linux/key.h into
linux/key-type.h.

(2) AF_RXRPC provides a way to allocate null rxrpc-type keys so that AFS does
not need to call key_instantiate_and_link() directly.

(3) Documentation.

Signed-off-by: David Howells <dhowells@redhat.com>
---

Documentation/keys-request-key.txt | 25 +-
Documentation/keys.txt | 91 +++++-
Documentation/networking/rxrpc.txt | 7
fs/afs/cell.c | 17 -
include/keys/rxrpc-type.h | 2
include/linux/key-type.h | 112 +++++++
include/linux/key.h | 99 +-----
net/rxrpc/af_rxrpc.c | 1
net/rxrpc/ar-key.c | 31 ++
security/keys/internal.h | 29 +-
security/keys/key.c | 27 +-
security/keys/process_keys.c | 16 +
security/keys/request_key.c | 556 ++++++++++++++++++------------------
security/keys/request_key_auth.c | 9 +
14 files changed, 595 insertions(+), 427 deletions(-)

diff --git a/Documentation/keys-request-key.txt b/Documentation/keys-request-key.txt
index c1f64fd..266955d 100644
--- a/Documentation/keys-request-key.txt
+++ b/Documentation/keys-request-key.txt
@@ -20,6 +20,19 @@ or:
const char *callout_string,
void *aux);

+or:
+
+ struct key *request_key_async(cons...

To: David Howells <dhowells@...>
Cc: <torvalds@...>, <kwc@...>, <Trond.Myklebust@...>, <linux-kernel@...>, <smfrench@...>, <nfsv4@...>
Date: Friday, September 14, 2007 - 7:59 pm

On Wed, 12 Sep 2007 15:25:08 +0100

So who's going to review this? Nobody? Well gee, maybe it was my turn
anyway.

How many different&private versions of this sort of thing do we have? Sigh.

The debug infrastructure changes don't appear to be related to the intent

It'd be nice to add a comment explaining to the long-suffering reader why

You could actually use kstrdup() here, I think.

Apart from that the changes look reasonable to me, but I am not a suitable
reviewer for keys, NFS or rxrpc stuff. Who is??

-

To: Andrew Morton <akpm@...>
Cc: <dhowells@...>, <torvalds@...>, <kwc@...>, <Trond.Myklebust@...>, <linux-kernel@...>, <smfrench@...>, <nfsv4@...>
Date: Monday, September 17, 2007 - 6:56 am

For this warning:

ERROR: need space after that ',' (ctx:WxV)
#627: FILE: security/keys/internal.h:28:
+#define kenter(FMT, ...) no_printk("==> %s("FMT")\n",__FUNCTION__ ,##__VA_ARGS__)

^

This is with good reason. Some versions of cpp get the ## resolution "wrong"
if __VA_ARGS__ is empty (ie: there are no arguments to the macro that
correspond to the "..."). This can be worked around by abutting the "," the
"##" and the "__VA_ARGS__" with no spaces, and inserting a space before the
comma.

If I remember correctly, the comma won't be removed if it doesn't abut the
##__VA_ARGS__, and the comma and everthing that abuts it on its LHS can be
removed if there's also no space. Without the "##", the comma isn't removed.

Consider the result of doing x("a"); where x(y, ...) is #defined to each of the
folowing:

DEFINITION RESULT
=============================== =======================
printk(y, __VA_ARGS__) print(y, );
printk(y ,__VA_ARGS__) print(y ,);
printk(y,##__VA_ARGS__) print();
printk(y, ##__VA_ARGS__) print(y, );

I'll change the comment to:

/* make sure no one's trying to change or use the key when we mark it
* - we tell lockdep that we might nest because we might be revoking an
* authorisation key whilst holding the sem on a key we've just
* instantiated

I could, but that potentially wastes time in two ways: firstly, there can be an
error before we've finished setting up, and that can lead to us having wasted
the time spent making the copy; and secondly, the call to kstrdup itself wastes
a bit of time because of the extra call made.

On the other hand, the code might end up a bit shorter, and isn't particularly

Kevin Coffman and Trond for the NFS stuff, both of whom are CC'd.

David
-

To: David Howells <dhowells@...>
Cc: <torvalds@...>, <kwc@...>, <Trond.Myklebust@...>, <linux-kernel@...>, <smfrench@...>, <nfsv4@...>
Date: Monday, September 17, 2007 - 7:03 am

Tell me about it - I fixed that about 10000000000 times. Then we upped the
minimum required gcc version so it is no longer a problem.
-

Previous thread: Re: [patch] sunrpc: make closing of old temporary sockets work (was: problems with lockd in 2.6.22.6) by Neil Brown on Wednesday, September 12, 2007 - 10:14 am. (7 messages)

Next thread: [PATCH] update checkpatch.pl to version 0.10 by Andy Whitcroft on Wednesday, September 12, 2007 - 11:00 am. (22 messages)