From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
netdev@vger.kernel.org, dhowells@redhat.com
Subject: [PATCH 6/8] AFS: AF_RXRPC key changes
Date: Wed, 11 Apr 2007 20:10:27 +0100 [thread overview]
Message-ID: <20070411191027.15499.8147.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20070411190956.15499.55352.stgit@warthog.cambridge.redhat.com>
Make two changes to the AF_RXRPC key handling to make it easier for AFS to
use:
(1) Export key_type_rxrpc so that AFS can request keys of this type.
(2) Make it possible to have keys that represent "no security". These are
created by instantiating the keys with no data.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
include/keys/rxrpc-type.h | 22 ++++++++++++++++++++++
net/rxrpc/af_rxrpc.c | 2 ++
net/rxrpc/ar-key.c | 10 +++++++++-
net/rxrpc/ar-output.c | 6 +++++-
4 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/include/keys/rxrpc-type.h b/include/keys/rxrpc-type.h
new file mode 100644
index 0000000..e2ee73a
--- /dev/null
+++ b/include/keys/rxrpc-type.h
@@ -0,0 +1,22 @@
+/* RxRPC key type
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _KEYS_RXRPC_TYPE_H
+#define _KEYS_RXRPC_TYPE_H
+
+#include <linux/key.h>
+
+/*
+ * key type for AF_RXRPC keys
+ */
+extern struct key_type key_type_rxrpc;
+
+#endif /* _KEYS_USER_TYPE_H */
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 115ad19..9e37e4f 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -299,6 +299,8 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
if (!key)
key = rx->key;
+ if (key && !key->payload.data)
+ key = NULL; /* a no-security key */
bundle = rxrpc_get_bundle(rx, trans, key, service_id, gfp);
if (IS_ERR(bundle)) {
diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c
index 869a96c..7e049ff 100644
--- a/net/rxrpc/ar-key.c
+++ b/net/rxrpc/ar-key.c
@@ -19,6 +19,7 @@
#include <linux/crypto.h>
#include <net/sock.h>
#include <net/af_rxrpc.h>
+#include <keys/rxrpc-type.h>
#include <keys/user-type.h>
#include "ar-internal.h"
@@ -40,6 +41,8 @@ struct key_type key_type_rxrpc = {
.describe = rxrpc_describe,
};
+EXPORT_SYMBOL(key_type_rxrpc);
+
/*
* rxrpc server defined keys take "<serviceId>:<securityIndex>" as the
* description and an 8-byte decryption key as the payload
@@ -63,6 +66,8 @@ struct key_type key_type_rxrpc_s = {
* 12 4 kvno
* 16 8 session key
* 24 [len] ticket
+ *
+ * if no data is provided, then a no-security key is made
*/
static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
{
@@ -74,6 +79,10 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
_enter("{%x},,%zu", key_serial(key), datalen);
+ /* handle a no-security key */
+ if (!data && datalen == 0)
+ return 0;
+
/* get the key interface version number */
ret = -EINVAL;
if (datalen <= 4 || !data)
@@ -287,7 +296,6 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn,
struct rxkad_key tsec;
} data;
-
_enter("");
key = key_alloc(&key_type_rxrpc, "x", 0, 0, current, 0,
diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
index ed7f3f4..d2d0baa 100644
--- a/net/rxrpc/ar-output.c
+++ b/net/rxrpc/ar-output.c
@@ -132,6 +132,7 @@ int rxrpc_client_sendmsg(struct kiocb *iocb, struct rxrpc_sock *rx,
enum rxrpc_command cmd;
struct rxrpc_call *call;
unsigned long user_call_ID = 0;
+ struct key *key;
__be16 service_id;
u32 abort_code = 0;
int ret;
@@ -153,7 +154,10 @@ int rxrpc_client_sendmsg(struct kiocb *iocb, struct rxrpc_sock *rx,
(struct sockaddr_rxrpc *) msg->msg_name;
service_id = htons(srx->srx_service);
}
- bundle = rxrpc_get_bundle(rx, trans, rx->key, service_id,
+ key = rx->key;
+ if (key && !rx->key->payload.data)
+ key = NULL;
+ bundle = rxrpc_get_bundle(rx, trans, key, service_id,
GFP_KERNEL);
if (IS_ERR(bundle))
return PTR_ERR(bundle);
next prev parent reply other threads:[~2007-04-11 19:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 19:09 [PATCH 0/8] AFS: Add security support and fix bugs David Howells
2007-04-11 19:10 ` [PATCH 1/8] AF_RXRPC: Use own workqueues David Howells
2007-04-11 19:10 ` [PATCH 2/8] AF_RXRPC: Lower dead call timeout and fix available call counting on connections David Howells
2007-04-11 19:10 ` [PATCH 3/8] AFS: Fix callback aggregator work item deadlock David Howells
2007-04-11 19:10 ` [PATCH 4/8] AFS: Correctly alter relocation state after update and show state in /proc David Howells
2007-04-11 19:10 ` [PATCH 5/8] AFS: Handle multiple mounts of an AFS superblock correctly David Howells
2007-04-11 19:10 ` David Howells [this message]
2007-04-11 19:10 ` [PATCH 7/8] AFS: Permit key to be cached in nameidata David Howells
2007-04-11 19:10 ` [PATCH 8/8] AFS: Add security support David Howells
2007-04-11 19:38 ` J. Bruce Fields
2007-04-11 20:10 ` David Howells
2007-04-11 20:17 ` J. Bruce Fields
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=20070411191027.15499.8147.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@osdl.org \
/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 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).