Skip to content

Commit

Permalink
[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and ker…
Browse files Browse the repository at this point in the history
…nel both

Provide AF_RXRPC sockets that can be used to talk to AFS servers, or serve
answers to AFS clients.  KerberosIV security is fully supported.  The patches
and some example test programs can be found in:

	http://people.redhat.com/~dhowells/rxrpc/

This will eventually replace the old implementation of kernel-only RxRPC
currently resident in net/rxrpc/.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
dhowells authored and davem330 committed Apr 26, 2007
1 parent e19dff1 commit 17926a7
Show file tree
Hide file tree
Showing 31 changed files with 11,275 additions and 7 deletions.
663 changes: 663 additions & 0 deletions Documentation/networking/rxrpc.txt

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions include/keys/rxrpc-type.h
Original file line number Diff line number Diff line change
@@ -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 */
2 changes: 1 addition & 1 deletion include/linux/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
struct poll_table_struct;
struct inode;

#define NPROTO 33 /* should be enough for now.. */
#define NPROTO 34 /* should be enough for now.. */

#define SYS_SOCKET 1 /* sys_socket(2) */
#define SYS_BIND 2 /* sys_bind(2) */
Expand Down
62 changes: 62 additions & 0 deletions include/linux/rxrpc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* AF_RXRPC parameters
*
* 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 _LINUX_RXRPC_H
#define _LINUX_RXRPC_H

#include <linux/in.h>
#include <linux/in6.h>

/*
* RxRPC socket address
*/
struct sockaddr_rxrpc {
sa_family_t srx_family; /* address family */
u16 srx_service; /* service desired */
u16 transport_type; /* type of transport socket (SOCK_DGRAM) */
u16 transport_len; /* length of transport address */
union {
sa_family_t family; /* transport address family */
struct sockaddr_in sin; /* IPv4 transport address */
struct sockaddr_in6 sin6; /* IPv6 transport address */
} transport;
};

/*
* RxRPC socket options
*/
#define RXRPC_SECURITY_KEY 1 /* [clnt] set client security key */
#define RXRPC_SECURITY_KEYRING 2 /* [srvr] set ring of server security keys */
#define RXRPC_EXCLUSIVE_CONNECTION 3 /* [clnt] use exclusive RxRPC connection */
#define RXRPC_MIN_SECURITY_LEVEL 4 /* minimum security level */

/*
* RxRPC control messages
* - terminal messages mean that a user call ID tag can be recycled
*/
#define RXRPC_USER_CALL_ID 1 /* user call ID specifier */
#define RXRPC_ABORT 2 /* abort request / notification [terminal] */
#define RXRPC_ACK 3 /* [Server] RPC op final ACK received [terminal] */
#define RXRPC_NET_ERROR 5 /* network error received [terminal] */
#define RXRPC_BUSY 6 /* server busy received [terminal] */
#define RXRPC_LOCAL_ERROR 7 /* local error generated [terminal] */
#define RXRPC_NEW_CALL 8 /* [Server] new incoming call notification */
#define RXRPC_ACCEPT 9 /* [Server] accept request */

/*
* RxRPC security levels
*/
#define RXRPC_SECURITY_PLAIN 0 /* plain secure-checksummed packets only */
#define RXRPC_SECURITY_AUTH 1 /* authenticated packets */
#define RXRPC_SECURITY_ENCRYPT 2 /* encrypted packets */


#endif /* _LINUX_RXRPC_H */
5 changes: 4 additions & 1 deletion include/linux/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ struct ucred {
#define AF_TIPC 30 /* TIPC sockets */
#define AF_BLUETOOTH 31 /* Bluetooth sockets */
#define AF_IUCV 32 /* IUCV sockets */
#define AF_MAX 33 /* For now.. */
#define AF_RXRPC 33 /* RxRPC sockets */
#define AF_MAX 34 /* For now.. */

/* Protocol families, same as address families. */
#define PF_UNSPEC AF_UNSPEC
Expand Down Expand Up @@ -222,6 +223,7 @@ struct ucred {
#define PF_TIPC AF_TIPC
#define PF_BLUETOOTH AF_BLUETOOTH
#define PF_IUCV AF_IUCV
#define PF_RXRPC AF_RXRPC
#define PF_MAX AF_MAX

/* Maximum queue length specifiable by listen. */
Expand Down Expand Up @@ -284,6 +286,7 @@ struct ucred {
#define SOL_DCCP 269
#define SOL_NETLINK 270
#define SOL_TIPC 271
#define SOL_RXRPC 272

/* IPX options */
#define IPX_TYPE 1
Expand Down
17 changes: 17 additions & 0 deletions include/net/af_rxrpc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* RxRPC definitions
*
* Copyright (C) 2006 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 _NET_RXRPC_H
#define _NET_RXRPC_H

#include <linux/rxrpc.h>

#endif /* _NET_RXRPC_H */
85 changes: 83 additions & 2 deletions include/rxrpc/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ struct rxrpc_header
#define RXRPC_MAXCALLS 4 /* max active calls per conn */
#define RXRPC_CHANNELMASK (RXRPC_MAXCALLS-1) /* mask for channel ID */
#define RXRPC_CIDMASK (~RXRPC_CHANNELMASK) /* mask for connection ID */
#define RXRPC_CIDSHIFT 2 /* shift for connection ID */
#define RXRPC_CIDSHIFT ilog2(RXRPC_MAXCALLS) /* shift for connection ID */
#define RXRPC_CID_INC (1 << RXRPC_CIDSHIFT) /* connection ID increment */

__be32 callNumber; /* call ID (0 for connection-level packets) */
#define RXRPC_PROCESS_MAXCALLS (1<<2) /* maximum number of active calls per conn (power of 2) */
Expand Down Expand Up @@ -62,7 +63,10 @@ struct rxrpc_header

uint8_t userStatus; /* app-layer defined status */
uint8_t securityIndex; /* security protocol ID */
__be16 _rsvd; /* reserved (used by kerberos security as cksum) */
union {
__be16 _rsvd; /* reserved */
__be16 cksum; /* kerberos security checksum */
};
__be16 serviceId; /* service ID */

} __attribute__((packed));
Expand Down Expand Up @@ -124,4 +128,81 @@ struct rxrpc_ackpacket

} __attribute__((packed));

/*
* ACK packets can have a further piece of information tagged on the end
*/
struct rxrpc_ackinfo {
__be32 rxMTU; /* maximum Rx MTU size (bytes) [AFS 3.3] */
__be32 maxMTU; /* maximum interface MTU size (bytes) [AFS 3.3] */
__be32 rwind; /* Rx window size (packets) [AFS 3.4] */
__be32 jumbo_max; /* max packets to stick into a jumbo packet [AFS 3.5] */
};

/*****************************************************************************/
/*
* Kerberos security type-2 challenge packet
*/
struct rxkad_challenge {
__be32 version; /* version of this challenge type */
__be32 nonce; /* encrypted random number */
__be32 min_level; /* minimum security level */
__be32 __padding; /* padding to 8-byte boundary */
} __attribute__((packed));

/*****************************************************************************/
/*
* Kerberos security type-2 response packet
*/
struct rxkad_response {
__be32 version; /* version of this reponse type */
__be32 __pad;

/* encrypted bit of the response */
struct {
__be32 epoch; /* current epoch */
__be32 cid; /* parent connection ID */
__be32 checksum; /* checksum */
__be32 securityIndex; /* security type */
__be32 call_id[4]; /* encrypted call IDs */
__be32 inc_nonce; /* challenge nonce + 1 */
__be32 level; /* desired level */
} encrypted;

__be32 kvno; /* Kerberos key version number */
__be32 ticket_len; /* Kerberos ticket length */
} __attribute__((packed));

/*****************************************************************************/
/*
* RxRPC-level abort codes
*/
#define RX_CALL_DEAD -1 /* call/conn has been inactive and is shut down */
#define RX_INVALID_OPERATION -2 /* invalid operation requested / attempted */
#define RX_CALL_TIMEOUT -3 /* call timeout exceeded */
#define RX_EOF -4 /* unexpected end of data on read op */
#define RX_PROTOCOL_ERROR -5 /* low-level protocol error */
#define RX_USER_ABORT -6 /* generic user abort */
#define RX_ADDRINUSE -7 /* UDP port in use */
#define RX_DEBUGI_BADTYPE -8 /* bad debugging packet type */

/*
* Rx kerberos security abort codes
* - unfortunately we have no generalised security abort codes to say things
* like "unsupported security", so we have to use these instead and hope the
* other side understands
*/
#define RXKADINCONSISTENCY 19270400 /* security module structure inconsistent */
#define RXKADPACKETSHORT 19270401 /* packet too short for security challenge */
#define RXKADLEVELFAIL 19270402 /* security level negotiation failed */
#define RXKADTICKETLEN 19270403 /* ticket length too short or too long */
#define RXKADOUTOFSEQUENCE 19270404 /* packet had bad sequence number */
#define RXKADNOAUTH 19270405 /* caller not authorised */
#define RXKADBADKEY 19270406 /* illegal key: bad parity or weak */
#define RXKADBADTICKET 19270407 /* security object was passed a bad ticket */
#define RXKADUNKNOWNKEY 19270408 /* ticket contained unknown key version number */
#define RXKADEXPIRED 19270409 /* authentication expired */
#define RXKADSEALEDINCON 19270410 /* sealed data inconsistent */
#define RXKADDATALEN 19270411 /* user data too long */
#define RXKADILLEGALLEVEL 19270412 /* caller not authorised to use encrypted conns */

#endif /* _LINUX_RXRPC_PACKET_H */
1 change: 1 addition & 0 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ endmenu
source "net/ax25/Kconfig"
source "net/irda/Kconfig"
source "net/bluetooth/Kconfig"
source "net/rxrpc/Kconfig"

config FIB_RULES
bool
Expand Down
1 change: 1 addition & 0 deletions net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ obj-$(CONFIG_IRDA) += irda/
obj-$(CONFIG_BT) += bluetooth/
obj-$(CONFIG_SUNRPC) += sunrpc/
obj-$(CONFIG_RXRPC) += rxrpc/
obj-$(CONFIG_AF_RXRPC) += rxrpc/
obj-$(CONFIG_ATM) += atm/
obj-$(CONFIG_DECNET) += decnet/
obj-$(CONFIG_ECONET) += econet/
Expand Down
6 changes: 4 additions & 2 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ static const char *af_family_key_strings[AF_MAX+1] = {
"sk_lock-21" , "sk_lock-AF_SNA" , "sk_lock-AF_IRDA" ,
"sk_lock-AF_PPPOX" , "sk_lock-AF_WANPIPE" , "sk_lock-AF_LLC" ,
"sk_lock-27" , "sk_lock-28" , "sk_lock-29" ,
"sk_lock-AF_TIPC" , "sk_lock-AF_BLUETOOTH", "sk_lock-AF_MAX"
"sk_lock-AF_TIPC" , "sk_lock-AF_BLUETOOTH", "sk_lock-IUCV" ,
"sk_lock-AF_RXRPC" , "sk_lock-AF_MAX"
};
static const char *af_family_slock_key_strings[AF_MAX+1] = {
"slock-AF_UNSPEC", "slock-AF_UNIX" , "slock-AF_INET" ,
Expand All @@ -167,7 +168,8 @@ static const char *af_family_slock_key_strings[AF_MAX+1] = {
"slock-21" , "slock-AF_SNA" , "slock-AF_IRDA" ,
"slock-AF_PPPOX" , "slock-AF_WANPIPE" , "slock-AF_LLC" ,
"slock-27" , "slock-28" , "slock-29" ,
"slock-AF_TIPC" , "slock-AF_BLUETOOTH", "slock-AF_MAX"
"slock-AF_TIPC" , "slock-AF_BLUETOOTH", "slock-AF_IUCV" ,
"slock-AF_RXRPC" , "slock-AF_MAX"
};
#endif

Expand Down
37 changes: 37 additions & 0 deletions net/rxrpc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# RxRPC session sockets
#

config AF_RXRPC
tristate "RxRPC session sockets"
depends on EXPERIMENTAL
help
Say Y or M here to include support for RxRPC session sockets (just
the transport part, not the presentation part: (un)marshalling is
left to the application).

These are used for AFS kernel filesystem and userspace utilities.

This module at the moment only supports client operations and is
currently incomplete.

See Documentation/networking/rxrpc.txt.


config AF_RXRPC_DEBUG
bool "RxRPC dynamic debugging"
depends on AF_RXRPC
help
Say Y here to make runtime controllable debugging messages appear.

See Documentation/networking/rxrpc.txt.


config RXKAD
tristate "RxRPC Kerberos security"
depends on AF_RXRPC && KEYS
help
Provide kerberos 4 and AFS kaserver security handling for AF_RXRPC
through the use of the key retention service.

See Documentation/networking/rxrpc.txt.
31 changes: 30 additions & 1 deletion net/rxrpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@

#CFLAGS += -finstrument-functions

af-rxrpc-objs := \
af_rxrpc.o \
ar-accept.o \
ar-ack.o \
ar-call.o \
ar-connection.o \
ar-connevent.o \
ar-error.o \
ar-input.o \
ar-key.o \
ar-local.o \
ar-output.o \
ar-peer.o \
ar-recvmsg.o \
ar-security.o \
ar-skbuff.o \
ar-transport.o

ifeq ($(CONFIG_PROC_FS),y)
af-rxrpc-objs += ar-proc.o
endif

obj-$(CONFIG_AF_RXRPC) += af-rxrpc.o

obj-$(CONFIG_RXKAD) += rxkad.o

#
# obsolete RxRPC interface, still used by fs/afs/
#
rxrpc-objs := \
call.o \
connection.o \
Expand All @@ -22,4 +51,4 @@ ifeq ($(CONFIG_SYSCTL),y)
rxrpc-objs += sysctl.o
endif

obj-$(CONFIG_RXRPC) := rxrpc.o
obj-$(CONFIG_RXRPC) += rxrpc.o
Loading

0 comments on commit 17926a7

Please sign in to comment.