AF_RXRPC socket family and AFS rewrite [try #3]
Subsystems (10)
David Howells
maintainercover AF_RXRPC socket family and AFS rewrite [try #3]
The first of these patches together provide secure client-side RxRPC connectivity as a Linux kernel socket family. Only the RxRPC transport/session side is supplied - the presentation side (marshalling the data) is left to the client. Copies of the patches can be found here:
http://people.redhat.com/~dhowells/rxrpc/series
http://people.redhat.com/~dhowells/rxrpc/01-move-skb-generic.diff
http://people.redhat.com/~dhowells/rxrpc/02-cancel_delayed_work.diff
http://people.redhat.com/~dhowells/rxrpc/03-keys.diff
http://people.redhat.com/~dhowells/rxrpc/04-timer-exports.diff
http://people.redhat.com/~dhowells/rxrpc/05-af_rxrpc.diff
Further patches make the in-kernel AFS filesystem use AF_RXRPC and delete the old RxRPC implementation:
http://people.redhat.com/~dhowells/rxrpc/06-afs-cleanup.diff
http://people.redhat.com/~dhowells/rxrpc/07-af_rxrpc-kernel.diff
http://people.redhat.com/~dhowells/rxrpc/08-af_rxrpc-afs.diff
http://people.redhat.com/~dhowells/rxrpc/09-af_rxrpc-delete-old.diff
And then the rest of the patches extend AFS to provide automatic unmounting of automount trees, security support and directory-level write support (create, mkdir, etc.):
http://people.redhat.com/~dhowells/rxrpc/10-afs-multimount.diff
http://people.redhat.com/~dhowells/rxrpc/11-afs-security.diff
http://people.redhat.com/~dhowells/rxrpc/12-afs-doc.diff
http://people.redhat.com/~dhowells/rxrpc/13-netlink-support-MSG_TRUNC.diff
http://people.redhat.com/~dhowells/rxrpc/14-afs-get-capabilities.diff
http://people.redhat.com/~dhowells/rxrpc/15-afs-initcallbackstate3.diff
http://people.redhat.com/~dhowells/rxrpc/16-afs-dir-write-support.diff
Note that file-level write support is not yet complete and so is not included in this patch set.
The userspace access methods make use of the control data passed to/by sendmsg() and recvmsg(). See the three simple test programs:
http://people.redhat.com/~dhowells/rxrpc/klog.c
http://people.redhat.com/~dhowells/rxrpc/rxrpc.c
http://people.redhat.com/~dhowells/rxrpc/listen.c
The klog program is provided to go and get a Kerberos IV key from the AFS kaserver. Currently it must be edited before compiling to note the right server IP address and the appropriate credentials.
These programs can be compiled by:
make klog rxrpc listen CFLAGS="-Wall -g" LDLIBS="-lcrypto -lcrypt -lkrb4 -lkeyutils"
Then a ticket can be obtained by:
./klog
If a security key is acquired in this way, then all subsequent AFS operations - including VL lookups and mounts - performed with that session keyring will be authenticated using that key. The key can be viewed like so:
[root@andromeda ~]# keyctl show Session Keyring -3 --alswrv 0 0 keyring: _ses.3268 2 --alswrv 0 0 \_ keyring: _uid.0 111416553 --als--v 0 0 \_ rxrpc: [email protected]
TODO:
(*) Make certain parameters (such as connection timeouts) userspace
configurable.
(*) Make userspace utilities use it; librxrpc.
(*) Userspace documentation.
(*) KerberosV security.
Changes:
(*) SOCK_RPC has been removed. SOCK_DGRAM is now used instead.
(*) I've add a facility whereby calls can be made to destinations other than
the connect() address of a client socket by making use of msg_name in the msghdr struct when using sendmsg() to send the first data packet of a call. Indeed, a client socket need not be connected before being used so.
(*) I've also added a facility whereby client calls may also be made on
server sockets, again by using msg_name in the msghdr struct. In such a case, the server's local transport endpoint is used.
(*) I've made the write buffer space check available to various callers
(sk_write_space) and implemented poll support.
(*) Rewrote rxrpc_recvmsg(). It now concatenates adjacent data messages from
the same call when delivering them.
(*) Updated the documentation to include notes on recvmsg, cover control
messages and cover SOL_RXRPC-level socket options.
(*) Provided an in-kernel interface to give in-kernel utilities easier access
to the facility.
(*) Made fs/afs/ use it.
(*) Deleted the old contents of net/rxrpc/.
(*) Use the scatterlist interface to the crypto API for now. The patch that
added the direct access interface conflicts with patches Herbert Xu is producing, so I've dropped it for the moment.
(*) Moved a bug fix to make secure connection reuse work from the
af_rxrpc-kernel patch to the af_rxrpc main patch.
(*) Make RxRPC use its own private work queues rather than keventd's to avoid
deadlocks when AFS tries to use keventd too. This also puts encryption in the private work queue rather than keventd's queue as that might take a relatively long time to process.
(*) Shorten the dead call timeout to 2 seconds. Without this, each completed
call sits around eating up resources for 10 seconds. The calls need to hang around for a little while in case duplicate packets appear, but 10 seconds is excessive.
(*) Decrement the number of available calls on a connection when a new call is
allocated for a connection that doesn't have any calls in progress.
David
David Howells
maintainerPATCH 1/16 AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code [try #3]
Move generic skbuff stuff from XFRM code to generic code so that AF_RXRPC can use it too.
The kdoc comments I've attached to the functions needs to be checked by whoever wrote them as I had to make some guesses about the workings of these functions.
---
include/linux/skbuff.h | 6 ++ include/net/esp.h | 2 - net/core/skbuff.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++ net/xfrm/xfrm_algo.c | 169 ------------------------------------------- 4 files changed, 194 insertions(+), 171 deletions(-)
include/linux/skbuff.h +6 -0
@@ -83,6 +83,7 @@*/ struct net_device ; +struct scatterlist ;#ifdef CONFIG_NETFILTER struct nf_conntrack {
@@ -361,6 +362,11 @@ extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,extern struct sk_buff *skb_copy_expand (const struct sk_buff *skb,int newheadroom,int newtailroom,gfp_t priority); +extern int skb_to_sgvec (struct sk_buff *skb, +struct scatterlist *sg,int offset, +int len); +extern int skb_cow_data (struct sk_buff *skb,int tailbits, +struct sk_buff **trailer);extern int skb_pad (struct sk_buff *skb,int pad);#define dev_kfree_skb (a) kfree_skb(a) extern void skb_over_panic(struct sk_buff *skb, int len,
include/net/esp.h +0 -2
@@ -40,8 +40,6 @@ struct esp_data } auth; }; -extern int skb_to_sgvec (struct sk_buff *skb,struct scatterlist *sg,int offset,int len); -extern int skb_cow_data (struct sk_buff *skb,int tailbits,struct sk_buff **trailer);extern void *pskb_put (struct sk_buff *skb,struct sk_buff *tail,int len); static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
net/core/skbuff.c +188 -0
203 lines not on this page · raw message
net/xfrm/xfrm_algo.c +0 -169
175 lines not on this page · raw message
David Howells
maintainerPATCH 2/16 cancel_delayed_work: use del_timer() instead of del_timer_sync() [try #3]
In reply to David Howellsdel_timer_sync() buys nothing for cancel_delayed_work(), but it is less efficient since it locks the timer unconditionally, and may wait for the completion of the delayed_work_timer_fn().
cancel_delayed_work() == 0 means:
before this patch:
work->func may still be running or queued
after this patch:
work->func may still be running or queued, or delayed_work_timer_fn->__queue_work() in progress.
The latter doesn't differ from the caller's POV, delayed_work_timer_fn() is called with _PENDING bit set.
cancel_delayed_work() == 1 with this patch adds a new possibility:
delayed_work->work was cancelled, but delayed_work_timer_fn is still running (this is only possible for the re-arming works on single-threaded workqueue).
In this case the timer was re-started by work->func(), nobody else can do this. This in turn means that delayed_work_timer_fn has already passed __queue_work() (and wont't touch delayed_work) because nobody else can queue delayed_work->work.
---
include/linux/workqueue.h | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
include/linux/workqueue.h +4 -3
@@ -191,14 +191,15 @@ int execute_in_process_context(work_func_t fn, struct execute_work *);/* * Kill off a pending schedule_delayed_work(). Note that the work callback -* function may still be running on return from cancel_delayed_work(). Run -* flush_scheduled_work() to wait on it. +* function may still be running on return from cancel_delayed_work(), unless +* it returns 1 and the work doesn't re-arm itself. Run flush_workqueue() or +* cancel_work_sync() to wait on it. */ static inline int cancel_delayed_work (struct delayed_work *work) {int ret; - ret =del_timer_sync (&work->timer); + ret =del_timer (&work->timer);if (ret)work_release (&work->work);return ret;
David Howells
maintainerPATCH 3/16 AF_RXRPC: Key facility changes for AF_RXRPC [try #3]
In reply to David HowellsExport the keyring key type definition and document its availability.
Add alternative types into the key's type_data union to make it more useful. Not all users necessarily want to use it as a list_head (AF_RXRPC doesn't, for example), so make it clear that it can be used in other ways.
---
Documentation/keys.txt | 12 ++++++++++++ include/linux/key.h | 2 ++ security/keys/keyring.c | 2 ++ 3 files changed, 16 insertions(+), 0 deletions(-)
Documentation/keys.txt +12 -0
@@ -859,6 +859,18 @@ payload contents" for more information. void unregister_key_type(struct key_type *type); +Under some circumstances, it may be desirable to desirable to deal with a +bundle of keys. The facility provides access to the keyring type for managing +such a bundle: + + struct key_type key_type_keyring; + +This can be used with a function such as request_key() to find a specific +keyring in a process's keyrings. A keyring thus found can then be searched +with keyring_search(). Note that it is not possible to use request_key() to +search a specific keyring, so using keyrings in this way is of limited utility. + + =================================== NOTES ON ACCESSING PAYLOAD CONTENTS ===================================
include/linux/key.h +2 -0
@@ -160,6 +160,8 @@ struct key {*/ union {struct list_head link; +unsigned long x[2 ]; +void *p[2 ]; } type_data;/* key data
security/keys/keyring.c +2 -0
@@ -66,6 +66,8 @@ struct key_type key_type_keyring = { .read = keyring_read, }; +EXPORT_SYMBOL (key_type_keyring); +/* * semaphore to serialise link/link calls to prevent two link calls in parallel * introducing a cycle
David Howells
maintainerPATCH 4/16 AF_RXRPC: Make it possible to merely try to cancel timers from a module [try #3]
In reply to David HowellsExport try_to_del_timer_sync() for use by the AF_RXRPC module.
---
kernel/timer.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/timer.c +2 -0
@@ -505,6 +505,8 @@ out:return ret; } +EXPORT_SYMBOL (try_to_del_timer_sync); +/** * del_timer_sync - deactivate a timer and wait for the handler to finish. * @timer: the timer to be deactivated
David Howells
maintainerPATCH 7/16 AF_RXRPC: Add an interface to the AF_RXRPC module for the AFS filesystem to use [try #3]
In reply to David HowellsAdd an interface to the AF_RXRPC module so that the AFS filesystem module can more easily make use of the services available. AFS still opens a socket but then uses the action functions in lieu of sendmsg() and registers an intercept functions to grab messages before they're queued on the socket Rx queue.
This permits AFS (or whatever) to:
(1) Avoid the overhead of using the recvmsg() call.
(2) Use different keys directly on individual client calls on one socket rather than having to open a whole slew of sockets, one for each key it might want to use.
(3) Avoid calling request_key() at the point of issue of a call or opening of a socket. This is done instead by AFS at the point of open(), unlink() or other VFS operation and the key handed through.
(4) Request the use of something other than GFP_KERNEL to allocate memory.
Furthermore:
(*) The socket buffer markings used by RxRPC are made available for AFS so
that it can interpret the cooked RxRPC messages itself.
(*) rxgen (un)marshalling abort codes are made available.
The following documentation for the kernel interface is added to Documentation/networking/rxrpc.txt:
=========================AF_RXRPC KERNEL INTERFACE
=========================
The AF_RXRPC module also provides an interface for use by in-kernel utilities such as the AFS filesystem. This permits such a utility to:
(1) Use different keys directly on individual client calls on one socket rather than having to open a whole slew of sockets, one for each key it might want to use.
(2) Avoid having RxRPC call request_key() at the point of issue of a call or opening of a socket. Instead the utility is responsible for requesting a key at the appropriate point. AFS, for instance, would do this during VFS operations such as open() or unlink(). The key is then handed through when the call is initiated.
(3) Request the use of something other than GFP_KERNEL to allocate memory.
(4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be intercepted before they get put into the socket Rx queue and the socket buffers manipulated directly.
To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket, bind an addess as appropriate and listen if it's to be a server socket, but then it passes this to the kernel interface functions.
The kernel interface functions are as follows:
(*) Begin a new client call.
struct rxrpc_call * rxrpc_kernel_begin_call(struct socket *sock,
struct sockaddr_rxrpc *srx, struct key *key, unsigned long user_call_ID, gfp_t gfp);
This allocates the infrastructure to make a new RxRPC call and assigns call and connection numbers. The call will be made on the UDP port that the socket is bound to. The call will go to the destination address of a connected client socket unless an alternative is supplied (srx is non-NULL).
If a key is supplied then this will be used to secure the call instead of the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls secured in this way will still share connections if at all possible.
The user_call_ID is equivalent to that supplied to sendmsg() in the control data buffer. It is entirely feasible to use this to point to a kernel data structure.
If this function is successful, an opaque reference to the RxRPC call is returned. The caller now holds a reference on this and it must be properly ended.
(*) End a client call.
void rxrpc_kernel_end_call(struct rxrpc_call *call);
This is used to end a previously begun call. The user_call_ID is expunged from AF_RXRPC's knowledge and will not be seen again in association with the specified call.
(*) Send data through a call.
int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg,
size_t len);
This is used to supply either the request part of a client call or the reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the data buffers to be used. msg_iov may not be NULL and must point exclusively to in-kernel virtual addresses. msg.msg_flags may be given MSG_MORE if there will be subsequent data sends for this call.
The msg must not specify a destination address, control data or any flags other than MSG_MORE. len is the total amount of data to transmit.
(*) Abort a call.
void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code);
This is used to abort a call if it's still in an abortable state. The abort code specified will be placed in the ABORT message sent.
(*) Intercept received RxRPC messages.
typedef void (*rxrpc_interceptor_t)(struct sock *sk,
unsigned long user_call_ID, struct sk_buff *skb);
void
rxrpc_kernel_intercept_rx_messages(struct socket *sock,
rxrpc_interceptor_t interceptor);
This installs an interceptor function on the specified AF_RXRPC socket. All messages that would otherwise wind up in the socket's Rx queue are then diverted to this function. Note that care must be taken to process the messages in the right order to maintain DATA message sequentiality.
The interceptor function itself is provided with the address of the socket and handling the incoming message, the ID assigned by the kernel utility to the call and the socket buffer containing the message.
The skb->mark field indicates the type of message:
MARK MEANING
=============================== =======================================
RXRPC_SKB_MARK_DATA Data message
RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call
RXRPC_SKB_MARK_BUSY Client call rejected as server busy
RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer
RXRPC_SKB_MARK_NET_ERROR Network error detected
RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered
RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance
The remote abort message can be probed with rxrpc_kernel_get_abort_code(). The two error messages can be probed with rxrpc_kernel_get_error_number(). A new call can be accepted with rxrpc_kernel_accept_call().
Data messages can have their contents extracted with the usual bunch of socket buffer manipulation functions. A data message can be determined to be the last one in a sequence with rxrpc_kernel_is_data_last(). When a data message has been used up, rxrpc_kernel_data_delivered() should be called on it..
Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose of. It is possible to get extra refs on all types of message for later freeing, but this may pin the state of a call until the message is finally freed.
(*) Accept an incoming call.
struct rxrpc_call * rxrpc_kernel_accept_call(struct socket *sock,
unsigned long user_call_ID);
This is used to accept an incoming call and to assign it a call ID. This function is similar to rxrpc_kernel_begin_call() and calls accepted must be ended in the same way.
If this function is successful, an opaque reference to the RxRPC call is returned. The caller now holds a reference on this and it must be properly ended.
(*) Reject an incoming call.
int rxrpc_kernel_reject_call(struct socket *sock);
This is used to reject the first incoming call on the socket's queue with a BUSY message. -ENODATA is returned if there were no incoming calls. Other errors may be returned if the call had been aborted (-ECONNABORTED) or had timed out (-ETIME).
(*) Record the delivery of a data message and free it.
void rxrpc_kernel_data_delivered(struct sk_buff *skb);
This is used to record a data message as having been delivered and to update the ACK state for the call. The socket buffer will be freed.
(*) Free a message.
void rxrpc_kernel_free_skb(struct sk_buff *skb);
This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC
socket.(*) Determine if a data message is the last one on a call.
bool rxrpc_kernel_is_data_last(struct sk_buff *skb);
This is used to determine if a socket buffer holds the last data message to be received for a call (true will be returned if it does, false if not).
The data message will be part of the reply on a client call and the request on an incoming call. In the latter case there will be more messages, but in the former case there will not.
(*) Get the abort code from an abort message.
u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb);
This is used to extract the abort code from a remote abort message.(*) Get the error number from a local or network error message.
int rxrpc_kernel_get_error_number(struct sk_buff *skb);
This is used to extract the error number from a message indicating either a local error occurred or a network error occurred.
---
Documentation/networking/rxrpc.txt | 196 ++++++++++++++++++++++++++++++++++++ include/net/af_rxrpc.h | 44 ++++++++ include/rxrpc/packet.h | 12 ++ net/rxrpc/af_rxrpc.c | 141 ++++++++++++++++++++++++-- net/rxrpc/ar-accept.c | 119 +++++++++++++++++++++- net/rxrpc/ar-ack.c | 10 +- net/rxrpc/ar-call.c | 75 ++++++++------ net/rxrpc/ar-connection.c | 28 ++++- net/rxrpc/ar-connevent.c | 20 +++- net/rxrpc/ar-error.c | 6 + net/rxrpc/ar-input.c | 60 ++++++----- net/rxrpc/ar-internal.h | 44 +++----- net/rxrpc/ar-local.c | 2 net/rxrpc/ar-output.c | 84 +++++++++++++++ net/rxrpc/ar-peer.c | 2 net/rxrpc/ar-recvmsg.c | 75 +++++++++++++- net/rxrpc/ar-skbuff.c | 16 +++ net/rxrpc/ar-transport.c | 8 + 18 files changed, 813 insertions(+), 129 deletions(-)
Documentation/networking/rxrpc.txt +196 -0
@@ -25,6 +25,8 @@ Contents of this document: (*) Example server usage. + (*) AF_RXRPC kernel interface. + ======== OVERVIEW
@@ -661,3 +663,197 @@ A server would be set up to accept operations in the following manner: Note that all the communications for a particular service take place through the one server socket, using control messages on sendmsg() and recvmsg() to determine the call affected. + + +========================= +AF_RXRPC KERNEL INTERFACE +========================= + +The AF_RXRPC module also provides an interface for use by in-kernel utilities +such as the AFS filesystem. This permits such a utility to: + + (1) Use different keys directly on individual client calls on one socket + rather than having to open a whole slew of sockets, one for each key it + might want to use. + + (2) Avoid having RxRPC call request_key() at the point of issue of a call or + opening of a socket. Instead the utility is responsible for requesting a + key at the appropriate point. AFS, for instance, would do this during VFS + operations such as open() or unlink(). The key is then handed through + when the call is initiated. + + (3) Request the use of something other than GFP_KERNEL to allocate memory. + + (4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be + intercepted before they get put into the socket Rx queue and the socket + buffers manipulated directly. + +To use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket, +bind an addess as appropriate and listen if it's to be a server socket, but +then it passes this to the kernel interface functions. + +The kernel interface functions are as follows: + + (*) Begin a new client call. + + struct rxrpc_call * + rxrpc_kernel_begin_call(struct socket *sock, + struct sockaddr_rxrpc *srx, + struct key *key, + unsigned long user_call_ID, + gfp_t gfp); + + This allocates the infrastructure to make a new RxRPC call and assigns + call and connection numbers. The call will be made on the UDP port that + the socket is bound to. The call will go to the destination address of a + connected client socket unless an alternative is supplied (srx is + non-NULL). + + If a key is supplied then this will be used to secure the call instead of + the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls + secured in this way will still share connections if at all possible. + + The user_call_ID is equivalent to that supplied to sendmsg() in the + control data buffer. It is entirely feasible to use this to point to a + kernel data structure. + + If this function is successful, an opaque reference to the RxRPC call is + returned. The caller now holds a reference on this and it must be + properly ended. + + (*) End a client call. + + void rxrpc_kernel_end_call(struct rxrpc_call *call); + + This is used to end a previously begun call. The user_call_ID is expunged + from AF_RXRPC's knowledge and will not be seen again in association with + the specified call. + + (*) Send data through a call. + + int rxrpc_kernel_send_data(struct rxrpc_call *call, struct msghdr *msg, + size_t len); + + This is used to supply either the request part of a client call or the + reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the + data buffers to be used. msg_iov may not be NULL and must point + exclusively to in-kernel virtual addresses. msg.msg_flags may be given + MSG_MORE if there will be subsequent data sends for this call. + + The msg must not specify a destination address, control data or any flags + other than MSG_MORE. len is the total amount of data to transmit. + + (*) Abort a call. + + void rxrpc_kernel_abort_call(struct rxrpc_call *call, u32 abort_code); + + This is used to abort a call if it's still in an abortable state. The + abort code specified will be placed in the ABORT message sent. + + (*) Intercept received RxRPC messages. + + typedef void (*rxrpc_interceptor_t)(struct sock *sk, + unsigned long user_call_ID, + struct sk_buff *skb); + + void + rxrpc_kernel_intercept_rx_messages(struct socket *sock, + rxrpc_interceptor_t interceptor); + + This installs an interceptor function on the specified AF_RXRPC socket. + All messages that would otherwise wind up in the socket's Rx queue are + then diverted to this function. Note that care must be taken to process + the messages in the right order to maintain DATA message sequentiality. + + The interceptor function itself is provided with the address of the socket + and handling the incoming message, the ID assigned by the kernel utility + to the call and the socket buffer containing the message. + + The skb->mark field indicates the type of message: + + MARK MEANING + =============================== ======================================= + RXRPC_SKB_MARK_DATA Data message + RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call + RXRPC_SKB_MARK_BUSY Client call rejected as server busy + RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer + RXRPC_SKB_MARK_NET_ERROR Network error detected + RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered + RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance + + The remote abort message can be probed with rxrpc_kernel_get_abort_code(). + The two error messages can be probed with rxrpc_kernel_get_error_number(). + A new call can be accepted with rxrpc_kernel_accept_call(). + + Data messages can have their contents extracted with the usual bunch of + socket buffer manipulation functions. A data message can be determined to + be the last one in a sequence with rxrpc_kernel_is_data_last(). When a + data message has been used up, rxrpc_kernel_data_delivered() should be + called on it.. + + Non-data messages should be handled to rxrpc_kernel_free_skb() to dispose + of. It is possible to get extra refs on all types of message for later + freeing, but this may pin the state of a call until the message is finally + freed. + + (*) Accept an incoming call. + + struct rxrpc_call * + rxrpc_kernel_accept_call(struct socket *sock, + unsigned long user_call_ID); + + This is used to accept an incoming call and to assign it a call ID. This + function is similar to rxrpc_kernel_begin_call() and calls accepted must + be ended in the same way. + + If this function is successful, an opaque reference to the RxRPC call is + returned. The caller now holds a reference on this and it must be + properly ended. + + (*) Reject an incoming call. + + int rxrpc_kernel_reject_call(struct socket *sock); + + This is used to reject the first incoming call on the socket's queue with + a BUSY message. -ENODATA is returned if there were no incoming calls. + Other errors may be returned if the call had been aborted (-ECONNABORTED) + or had timed out (-ETIME). + + (*) Record the delivery of a data message and free it. + + void rxrpc_kernel_data_delivered(struct sk_buff *skb); + + This is used to record a data message as having been delivered and to + update the ACK state for the call. The socket buffer will be freed. + + (*) Free a message. + + void rxrpc_kernel_free_skb(struct sk_buff *skb); + + This is used to free a non-DATA socket buffer intercepted from an AF_RXRPC + socket. + + (*) Determine if a data message is the last one on a call. + + bool rxrpc_kernel_is_data_last(struct sk_buff *skb); + + This is used to determine if a socket buffer holds the last data message + to be received for a call (true will be returned if it does, false + if not). + + The data message will be part of the reply on a client call and the + request on an incoming call. In the latter case there will be more + messages, but in the former case there will not. + + (*) Get the abort code from an abort message. + + u32 rxrpc_kernel_get_abort_code(struct sk_buff *skb); + + This is used to extract the abort code from a remote abort message. + + (*) Get the error number from a local or network error message. + + int rxrpc_kernel_get_error_number(struct sk_buff *skb); + + This is used to extract the error number from a message indicating either + a local error occurred or a network error occurred.
include/net/af_rxrpc.h +42 -2
54 lines not on this page · raw message
include/rxrpc/packet.h +12 -0
@@ -186,6 +186,18 @@ struct rxkad_response {#define RX_DEBUGI_BADTYPE -8/* bad debugging packet type */ /* +* (un)marshalling abort codes (rxgen) +*/ +#define RXGEN_CC_MARSHAL -450 +#define RXGEN_CC_UNMARSHAL -451 +#define RXGEN_SS_MARSHAL -452 +#define RXGEN_SS_UNMARSHAL -453 +#define RXGEN_DECODE -454 +#define RXGEN_OPCODE -455 +#define RXGEN_SS_XDRFREE -456 +#define RXGEN_CC_XDRFREE -457 + +/* * 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
net/rxrpc/af_rxrpc.c +133 -8
214 lines not on this page · raw message
net/rxrpc/ar-accept.c +112 -7
155 lines not on this page · raw message
net/rxrpc/ar-ack.c +5 -5
@@ -113,7 +113,7 @@ cancel_timer:read_lock_bh (&call->state_lock);if (call->state <=RXRPC_CALL_COMPLETE && !test_and_set_bit (RXRPC_CALL_ACK , &call->events)) -schedule_work (&call->processor); +rxrpc_queue_call (call);read_unlock_bh (&call->state_lock); }
@@ -1166,7 +1166,7 @@ send_message_2:_debug ("sendmsg failed: %d" , ret);read_lock_bh (&call->state_lock);if (call->state <RXRPC_CALL_DEAD ) -schedule_work (&call->processor); +rxrpc_queue_call (call);read_unlock_bh (&call->state_lock); goto error; }
@@ -1210,7 +1210,7 @@ maybe_reschedule:if (call->events || !skb_queue_empty (&call->rx_queue)) {read_lock_bh (&call->state_lock);if (call->state <RXRPC_CALL_DEAD ) -schedule_work (&call->processor); +rxrpc_queue_call (call);read_unlock_bh (&call->state_lock); }
@@ -1224,7 +1224,7 @@ maybe_reschedule:read_lock_bh (&call->state_lock);if (!test_bit (RXRPC_CALL_RELEASED , &call->flags) && !test_and_set_bit (RXRPC_CALL_RELEASE , &call->events)) -schedule_work (&call->processor); +rxrpc_queue_call (call);read_unlock_bh (&call->state_lock); }
@@ -1238,7 +1238,7 @@ error:* work pending bit and the work item being processed again */ if (call->events && !work_pending (&call->processor)) {_debug ("jumpstart %x" ,ntohl (call->conn->cid)); -schedule_work (&call->processor); +rxrpc_queue_call (call); }_leave ("" );
net/rxrpc/ar-call.c +46 -29
152 lines not on this page · raw message
net/rxrpc/ar-connection.c +22 -6
@@ -356,7 +356,7 @@ static int rxrpc_connect_exclusive(struct rxrpc_sock *rx, conn->out_clientflag =RXRPC_CLIENT_INITIATED ; conn->cid =0 ; conn->state =RXRPC_CONN_CLIENT ; - conn->avail_calls =RXRPC_MAXCALLS ; + conn->avail_calls =RXRPC_MAXCALLS -1 ; conn->security_level = rx->min_sec_level; conn->key =key_get (rx->key);
@@ -447,6 +447,11 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,if (--conn->avail_calls ==0 )list_move (&conn->bundle_link, &bundle->busy_conns); + ASSERTCMP(conn->avail_calls, <, RXRPC_MAXCALLS); +ASSERT (conn->channels[0 ] ==NULL || + conn->channels[1 ] ==NULL || + conn->channels[2 ] ==NULL || + conn->channels[3 ] ==NULL );atomic_inc (&conn->usage);break ; }
@@ -456,6 +461,12 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, conn =list_entry (bundle->unused_conns.next, struct rxrpc_connection, bundle_link); + ASSERTCMP(conn->avail_calls, ==, RXRPC_MAXCALLS); + conn->avail_calls =RXRPC_MAXCALLS -1 ; +ASSERT (conn->channels[0 ] ==NULL && + conn->channels[1 ] ==NULL && + conn->channels[2 ] ==NULL && + conn->channels[3 ] ==NULL );atomic_inc (&conn->usage);list_move (&conn->bundle_link, &bundle->avail_conns);break ;
@@ -512,7 +523,7 @@ int rxrpc_connect_call(struct rxrpc_sock *rx, candidate->state =RXRPC_CONN_CLIENT ; candidate->avail_calls =RXRPC_MAXCALLS ; candidate->security_level = rx->min_sec_level; - candidate->key =key_get (rx->key); + candidate->key =key_get (bundle->key); ret =rxrpc_init_client_conn_security (candidate);if (ret <0 ) {
@@ -555,6 +566,10 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,for (chan =0 ; chan <RXRPC_MAXCALLS ; chan++)if (!conn->channels[chan]) goto found_channel; +ASSERT (conn->channels[0 ] ==NULL || + conn->channels[1 ] ==NULL || + conn->channels[2 ] ==NULL || + conn->channels[3 ] ==NULL );BUG (); found_channel:
@@ -567,6 +582,7 @@ found_channel:_net ("CONNECT client on conn %d chan %d as call %x" , conn->debug_id, chan,ntohl (call->call_id)); + ASSERTCMP(conn->avail_calls, <, RXRPC_MAXCALLS);spin_unlock (&trans->client_lock);rxrpc_add_call_ID_to_conn (conn, call);
@@ -778,7 +794,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn) conn->put_time = xtime.tv_sec;if (atomic_dec_and_test (&conn->usage)) {_debug ("zombie" ); -schedule_delayed_work (&rxrpc_connection_reap,0 ); +rxrpc_queue_delayed_work (&rxrpc_connection_reap,0 ); }_leave ("" );
@@ -862,8 +878,8 @@ void rxrpc_connection_reaper(struct work_struct *work)if (earliest !=ULONG_MAX ) {_debug ("reschedule reaper %ld" , (long ) earliest - now); ASSERTCMP(earliest, >, now); -schedule_delayed_work (&rxrpc_connection_reap, - (earliest - now) *HZ ); +rxrpc_queue_delayed_work (&rxrpc_connection_reap, + (earliest - now) *HZ ); }/* then destroy all those pulled out */
@@ -889,7 +905,7 @@ void __exit rxrpc_destroy_all_connections(void) rxrpc_connection_timeout =0 ;cancel_delayed_work (&rxrpc_connection_reap); -schedule_delayed_work (&rxrpc_connection_reap,0 ); +rxrpc_queue_delayed_work (&rxrpc_connection_reap,0 );_leave ("" ); }
net/rxrpc/ar-connevent.c +18 -2
@@ -45,7 +45,7 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, int state,set_bit (RXRPC_CALL_CONN_ABORT , &call->events); else set_bit(RXRPC_CALL_RCVD_ABORT, &call->events); -schedule_work (&call->processor); +rxrpc_queue_call (call); }write_unlock (&call->state_lock); }
@@ -133,7 +133,7 @@ void rxrpc_call_is_secure(struct rxrpc_call *call)read_lock (&call->state_lock);if (call->state <RXRPC_CALL_COMPLETE && !test_and_set_bit (RXRPC_CALL_SECURED , &call->events)) -schedule_work (&call->processor); +rxrpc_queue_call (call);read_unlock (&call->state_lock); } }
@@ -308,6 +308,22 @@ protocol_error: }/* +* put a packet up for transport-level abort +*/ +void rxrpc_reject_packet (struct rxrpc_local *local,struct sk_buff *skb) +{ +CHECK_SLAB_OKAY (&local->usage); + +if (!atomic_inc_not_zero (&local->usage)) { +printk ("resurrected on reject\n" ); +BUG (); + } + +skb_queue_tail (&local->reject_queue, skb); +rxrpc_queue_work (&local->rejecter); +} + +/* * reject packets through the local endpoint */ void rxrpc_reject_packets (struct work_struct *work)
net/rxrpc/ar-error.c +3 -3
@@ -111,7 +111,7 @@ void rxrpc_UDP_error_report(struct sock *sk)/* pass the transport ref to error_handler to release */ skb_queue_tail (&trans->error_queue, skb); -schedule_work (&trans->error_handler); +rxrpc_queue_work (&trans->error_handler);/* reset and regenerate socket error */ spin_lock_bh (&sk->sk_error_queue.lock);
@@ -235,7 +235,7 @@ void rxrpc_UDP_error_handler(struct work_struct *work) call->state < RXRPC_CALL_NETWORK_ERROR) { call->state =RXRPC_CALL_NETWORK_ERROR ;set_bit (RXRPC_CALL_RCVD_ERROR , &call->events); -schedule_work (&call->processor); +rxrpc_queue_call (call); }write_unlock (&call->state_lock);list_del_init (&call->error_link);
@@ -245,7 +245,7 @@ void rxrpc_UDP_error_handler(struct work_struct *work) }if (!skb_queue_empty (&trans->error_queue)) -schedule_work (&trans->error_handler); +rxrpc_queue_work (&trans->error_handler);rxrpc_free_skb (skb);rxrpc_put_transport (trans);
net/rxrpc/ar-input.c +33 -27
155 lines not on this page · raw message
net/rxrpc/ar-internal.h +17 -27
92 lines not on this page · raw message
net/rxrpc/ar-local.c +1 -1
@@ -228,7 +228,7 @@ void rxrpc_put_local(struct rxrpc_local *local)write_lock_bh (&rxrpc_local_lock);if (unlikely (atomic_dec_and_test (&local->usage))) {_debug ("destroy local" ); -schedule_work (&local->destroyer); +rxrpc_queue_work (&local->destroyer); }write_unlock_bh (&rxrpc_local_lock);_leave ("" );
net/rxrpc/ar-output.c +80 -4
108 lines not on this page · raw message
net/rxrpc/ar-peer.c +1 -1
@@ -219,7 +219,7 @@ void rxrpc_put_peer(struct rxrpc_peer *peer)return ; } -schedule_work (&peer->destroyer); +rxrpc_queue_work (&peer->destroyer);_leave ("" ); }
net/rxrpc/ar-recvmsg.c +73 -2
90 lines not on this page · raw message
net/rxrpc/ar-skbuff.c +15 -1
@@ -36,7 +36,7 @@ static void rxrpc_request_final_ACK(struct rxrpc_call *call)rxrpc_get_call (call);set_bit (RXRPC_CALL_ACK_FINAL , &call->events);if (try_to_del_timer_sync (&call->ack_timer) >=0 ) -schedule_work (&call->processor); +rxrpc_queue_call (call);break ;case RXRPC_CALL_SERVER_RECV_REQUEST :
@@ -116,3 +116,17 @@ void rxrpc_packet_destructor(struct sk_buff *skb)sock_rfree (skb);_leave ("" ); } + +/** +* rxrpc_kernel_free_skb - Free an RxRPC socket buffer +* @skb: The socket buffer to be freed +* +* Let RxRPC free its own socket buffer, permitting it to maintain debug +* accounting. +*/ +void rxrpc_kernel_free_skb (struct sk_buff *skb) +{ +rxrpc_free_skb (skb); +} + +EXPORT_SYMBOL (rxrpc_kernel_free_skb);
net/rxrpc/ar-transport.c +4 -4
@@ -189,7 +189,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)/* let the reaper determine the timeout to avoid a race with * overextending the timeout if the reaper is running at the * same time */ -schedule_delayed_work (&rxrpc_transport_reap,0 ); +rxrpc_queue_delayed_work (&rxrpc_transport_reap,0 );_leave ("" ); }
@@ -243,8 +243,8 @@ static void rxrpc_transport_reaper(struct work_struct *work)if (earliest !=ULONG_MAX ) {_debug ("reschedule reaper %ld" , (long ) earliest - now); ASSERTCMP(earliest, >, now); -schedule_delayed_work (&rxrpc_transport_reap, - (earliest - now) *HZ ); +rxrpc_queue_delayed_work (&rxrpc_transport_reap, + (earliest - now) *HZ ); }/* then destroy all those pulled out */
@@ -270,7 +270,7 @@ void __exit rxrpc_destroy_all_transports(void) rxrpc_transport_timeout =0 ;cancel_delayed_work (&rxrpc_transport_reap); -schedule_delayed_work (&rxrpc_transport_reap,0 ); +rxrpc_queue_delayed_work (&rxrpc_transport_reap,0 );_leave ("" ); }
David Howells
maintainerPATCH 10/16 AFS: Handle multiple mounts of an AFS superblock correctly [try #3]
In reply to David HowellsHandle multiple mounts of an AFS superblock correctly, checking to see whether the superblock is already initialised after calling sget() rather than just unconditionally stamping all over it.
Also delete the "silent" parameter to afs_fill_super() as it's not used and can, in any case, be obtained from sb->s_flags.
---
fs/afs/super.c | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-)
fs/afs/super.c +16 -10
@@ -212,7 +212,7 @@ static int afs_test_super(struct super_block *sb, void *data)/* * fill in the superblock */ -static int afs_fill_super (struct super_block *sb,void *data,int silent) +static int afs_fill_super (struct super_block *sb,void *data) {struct afs_mount_params *params = data;struct afs_super_info *as =NULL ;
@@ -319,17 +319,23 @@ static int afs_get_sb(struct file_system_type *fs_type, goto error; } - sb->s_flags = flags; - - ret =afs_fill_super (sb, ¶ms, flags &MS_SILENT ?1 :0 ); -if (ret <0 ) { -up_write (&sb->s_umount); -deactivate_super (sb); - goto error; +if (!sb->s_root) { +/* initial superblock/root creation */ +_debug ("create" ); + sb->s_flags = flags; + ret =afs_fill_super (sb, ¶ms); +if (ret <0 ) { +up_write (&sb->s_umount); +deactivate_super (sb); + goto error; + } + sb->s_flags |=MS_ACTIVE ; + }else { +_debug ("reuse" ); + ASSERTCMP(sb->s_flags, &, MS_ACTIVE); } - sb->s_flags |=MS_ACTIVE ; -simple_set_mnt (mnt, sb); +simple_set_mnt (mnt, sb);afs_put_volume (params.volume);afs_put_cell (params.default_cell);_leave (" = 0 [%p]" , sb);
David Howells
maintainerPATCH 11/16 AFS: Add security support [try #3]
In reply to David HowellsAdd security support to the AFS filesystem. Kerberos IV tickets are added as RxRPC keys are added to the session keyring with the klog program. open() and other VFS operations then find this ticket with request_key() and either use it immediately (eg: mkdir, unlink) or attach it to a file descriptor (open).
---
fs/afs/AFS.h | 27 ++++ fs/afs/Makefile | 1 fs/afs/callback.c | 5 + fs/afs/cell.c | 98 ++++++++++++--- fs/afs/cmservice.c | 3 fs/afs/dir.c | 51 ++++++-- fs/afs/file.c | 60 ++++++++- fs/afs/fsclient.c | 9 + fs/afs/inode.c | 21 ++- fs/afs/internal.h | 106 ++++++++++++---- fs/afs/mntpt.c | 12 +- fs/afs/rxrpc.c | 137 ++++++++++++++++----- fs/afs/security.c | 345 ++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/afs/super.c | 142 ++++++++++++++++++--- fs/afs/vlclient.c | 6 + fs/afs/vlocation.c | 26 ++-- fs/afs/vnode.c | 25 +++- fs/afs/volume.c | 109 +++------------- 18 files changed, 945 insertions(+), 238 deletions(-)
fs/afs/AFS.h +25 -2
@@ -14,6 +14,9 @@#include <linux/in.h> +#define AFS_MAXCELLNAME 64/* maximum length of a cell name */ +#define AFS_MAXVOLNAME 64/* maximum length of a volume name */ +typedef unsigned afs_volid_t ;typedef unsigned afs_vnodeid_t ;typedef unsigned long long afs_dataversion_t ;
@@ -75,6 +78,26 @@ struct afs_volume_info { };/* +* AFS security ACE access mask +*/ +typedef u32 afs_access_t ; +#define AFS_ACE_READ 0x00000001U/* - permission to read a file/dir */ +#define AFS_ACE_WRITE 0x00000002U/* - permission to write/chmod a file */ +#define AFS_ACE_INSERT 0x00000004U/* - permission to create dirent in a dir */ +#define AFS_ACE_LOOKUP 0x00000008U/* - permission to lookup a file/dir in a dir */ +#define AFS_ACE_DELETE 0x00000010U/* - permission to delete a dirent from a dir */ +#define AFS_ACE_LOCK 0x00000020U/* - permission to lock a file */ +#define AFS_ACE_ADMINISTER 0x00000040U/* - permission to change ACL */ +#define AFS_ACE_USER_A 0x01000000U/* - 'A' user-defined permission */ +#define AFS_ACE_USER_B 0x02000000U/* - 'B' user-defined permission */ +#define AFS_ACE_USER_C 0x04000000U/* - 'C' user-defined permission */ +#define AFS_ACE_USER_D 0x08000000U/* - 'D' user-defined permission */ +#define AFS_ACE_USER_E 0x10000000U/* - 'E' user-defined permission */ +#define AFS_ACE_USER_F 0x20000000U/* - 'F' user-defined permission */ +#define AFS_ACE_USER_G 0x40000000U/* - 'G' user-defined permission */ +#define AFS_ACE_USER_H 0x80000000U/* - 'H' user-defined permission */ + +/* * AFS file status information */ struct afs_file_status {
@@ -87,8 +110,8 @@ struct afs_file_status {afs_dataversion_t data_version;/* current data version */ unsigned author;/* author ID */ unsigned owner;/* owner ID */ -unsigned caller_access;/* access rights for authenticated caller */ -unsigned anon_access;/* access rights for unauthenticated caller */ +afs_access_t caller_access;/* access rights for authenticated caller */ +afs_access_t anon_access;/* access rights for unauthenticated caller */ umode_t mode;/* UNIX mode */ struct afs_fid parent;/* parent file ID */ time_t mtime_client;/* last time client changed data */
fs/afs/Makefile +1 -0
@@ -15,6 +15,7 @@ kafs-objs := \ mntpt.o \ proc.o \ rxrpc.o \ + security.o \ server.o \ super.o \ vlclient.o \
fs/afs/callback.c +4 -1
@@ -72,7 +72,10 @@ void afs_broken_callback_work(struct work_struct *work)return ;/* someone else is dealing with it */ if (test_bit (AFS_VNODE_CB_BROKEN , &vnode->flags)) { -if (afs_vnode_fetch_status (vnode) <0 ) +if (S_ISDIR (vnode->vfs_inode.i_mode)) +afs_clear_permits (vnode); + +if (afs_vnode_fetch_status (vnode,NULL ,NULL ) <0 ) goto out;if (test_bit (AFS_VNODE_DELETED , &vnode->flags))
fs/afs/cell.c +77 -21
162 lines not on this page · raw message
fs/afs/cmservice.c +3 -0
@@ -28,6 +28,7 @@ static void afs_cm_destructor(struct afs_call *);* CB.CallBack operation type */ static const struct afs_call_type afs_SRXCBCallBack = { + .name ="CB.CallBack" , .deliver = afs_deliver_cb_callback, .abort_to_error = afs_abort_to_error, .destructor = afs_cm_destructor,
@@ -37,6 +38,7 @@ static const struct afs_call_type afs_SRXCBCallBack = {* CB.InitCallBackState operation type */ static const struct afs_call_type afs_SRXCBInitCallBackState = { + .name ="CB.InitCallBackState" , .deliver = afs_deliver_cb_init_call_back_state, .abort_to_error = afs_abort_to_error, .destructor = afs_cm_destructor,
@@ -46,6 +48,7 @@ static const struct afs_call_type afs_SRXCBInitCallBackState = {* CB.Probe operation type */ static const struct afs_call_type afs_SRXCBProbe = { + .name ="CB.Probe" , .deliver = afs_deliver_cb_probe, .abort_to_error = afs_abort_to_error, .destructor = afs_cm_destructor,
fs/afs/dir.c +38 -13
171 lines not on this page · raw message
fs/afs/file.c +53 -7
96 lines not on this page · raw message
fs/afs/fsclient.c +8 -1
@@ -148,6 +148,7 @@ static int afs_deliver_fs_fetch_status(struct afs_call *call,* FS.FetchStatus operation type */ static const struct afs_call_type afs_RXFSFetchStatus = { + .name ="FS.FetchStatus" , .deliver = afs_deliver_fs_fetch_status, .abort_to_error = afs_abort_to_error, .destructor = afs_flat_call_destructor,
@@ -157,6 +158,7 @@ static const struct afs_call_type afs_RXFSFetchStatus = {* fetch the status information for a file */ int afs_fs_fetch_file_status (struct afs_server *server, +struct key *key,struct afs_vnode *vnode,struct afs_volsync *volsync,const struct afs_wait_mode *wait_mode)
@@ -164,12 +166,13 @@ int afs_fs_fetch_file_status(struct afs_server *server,struct afs_call *call;__be32 *bp; -_enter ("" ); +_enter (",%x,,," ,key_serial (key)); call =afs_alloc_flat_call (&afs_RXFSFetchStatus,16 ,120 );if (!call)return -ENOMEM ; + call->key = key; call->reply = vnode; call->reply2 = volsync; call->service_id =FS_SERVICE ;
@@ -279,6 +282,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call,* FS.FetchData operation type */ static const struct afs_call_type afs_RXFSFetchData = { + .name ="FS.FetchData" , .deliver = afs_deliver_fs_fetch_data, .abort_to_error = afs_abort_to_error, .destructor = afs_flat_call_destructor,
@@ -288,6 +292,7 @@ static const struct afs_call_type afs_RXFSFetchData = {* fetch data from a file */ int afs_fs_fetch_data(struct afs_server *server, + struct key *key, struct afs_vnode *vnode, off_t offset, size_t length, struct page *buffer,
@@ -303,6 +308,7 @@ int afs_fs_fetch_data(struct afs_server *server,if (!call)return -ENOMEM ; + call->key = key; call->reply = vnode; call->reply2 = volsync; call->reply3 = buffer;
@@ -338,6 +344,7 @@ static int afs_deliver_fs_give_up_callbacks(struct afs_call *call,* FS.GiveUpCallBacks operation type */ static const struct afs_call_type afs_RXFSGiveUpCallBacks = { + .name ="FS.GiveUpCallBacks" , .deliver = afs_deliver_fs_give_up_callbacks, .abort_to_error = afs_abort_to_error, .destructor = afs_flat_call_destructor,
fs/afs/inode.c +15 -6
@@ -29,7 +29,7 @@ struct afs_iget_data {/* * map the AFS file status to the inode member variables */ -static int afs_inode_map_status (struct afs_vnode *vnode) +static int afs_inode_map_status (struct afs_vnode *vnode,struct key *key) {struct inode *inode =AFS_VNODE_TO_I (vnode);
@@ -44,7 +44,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode)case AFS_FTYPE_FILE : inode->i_mode =S_IFREG | vnode->status.mode; inode->i_op = &afs_file_inode_operations; - inode->i_fop = &generic_ro_fops; + inode->i_fop = &afs_file_operations;break ;case AFS_FTYPE_DIR : inode->i_mode =S_IFDIR | vnode->status.mode;
@@ -73,7 +73,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode)/* check to see whether a symbolic link is really a mountpoint */ if (vnode->status.type ==AFS_FTYPE_SYMLINK ) { -afs_mntpt_check_symlink (vnode); +afs_mntpt_check_symlink (vnode, key);if (test_bit (AFS_VNODE_MOUNTPOINT , &vnode->flags)) { inode->i_mode =S_IFDIR | vnode->status.mode;
@@ -115,7 +115,8 @@ static int afs_iget5_set(struct inode *inode, void *opaque)/* * inode retrieval */ -inline struct inode *afs_iget (struct super_block *sb,struct afs_fid *fid) +inline struct inode *afs_iget (struct super_block *sb,struct key *key, +struct afs_fid *fid) {struct afs_iget_data data = { .fid = *fid };struct afs_super_info *as;
@@ -157,10 +158,10 @@ inline struct inode *afs_iget(struct super_block *sb, struct afs_fid *fid)/* okay... it's a new inode */ set_bit (AFS_VNODE_CB_BROKEN , &vnode->flags); - ret =afs_vnode_fetch_status (vnode); + ret =afs_vnode_fetch_status (vnode,NULL , key);if (ret <0 ) goto bad_inode; - ret =afs_inode_map_status (vnode); + ret =afs_inode_map_status (vnode, key);if (ret <0 ) goto bad_inode;
@@ -201,6 +202,7 @@ int afs_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,*/ void afs_clear_inode (struct inode *inode) { +struct afs_permits *permits;struct afs_vnode *vnode; vnode =AFS_FS_I (inode);
@@ -233,5 +235,12 @@ void afs_clear_inode(struct inode *inode) vnode->cache =NULL ;#endif +mutex_lock (&vnode->permits_lock); + permits = vnode->permits; +rcu_assign_pointer (vnode->permits,NULL ); +mutex_unlock (&vnode->permits_lock); +if (permits) +call_rcu (&permits->rcu, afs_zap_permits); +_leave ("" ); }
fs/afs/internal.h +80 -26
239 lines not on this page · raw message
fs/afs/mntpt.c +8 -4
@@ -48,8 +48,11 @@ unsigned long afs_mntpt_expiry_timeout = 10 * 60;* check a symbolic link to see whether it actually encodes a mountpoint * - sets the AFS_VNODE_MOUNTPOINT flag on the vnode appropriately */ -int afs_mntpt_check_symlink (struct afs_vnode *vnode) +int afs_mntpt_check_symlink (struct afs_vnode *vnode,struct key *key) { +struct file file = { + .private_data = key, + };struct page *page;size_t size;char *buf;
@@ -58,7 +61,7 @@ int afs_mntpt_check_symlink(struct afs_vnode *vnode)_enter ("{%u,%u}" , vnode->fid.vnode, vnode->fid.unique);/* read the contents of the symlink into the pagecache */ - page =read_mapping_page (AFS_VNODE_TO_I (vnode)->i_mapping,0 ,NULL ); + page =read_mapping_page (AFS_VNODE_TO_I (vnode)->i_mapping,0 , &file);if (IS_ERR (page)) { ret =PTR_ERR (page); goto out;
@@ -214,7 +217,7 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)struct vfsmount *newmnt;int err; - _enter("%p{%s},{%s:%p{%s}}", + _enter("%p{%s},{%s:%p{%s},}", dentry, dentry->d_name.name, nd->mnt->mnt_devname,
@@ -234,7 +237,8 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd) err =do_add_mount (newmnt, nd,MNT_SHRINKABLE , &afs_vfsmounts);switch (err) {case 0 : -path_release (nd); +mntput (nd->mnt); +dput (nd->dentry); nd->mnt = newmnt; nd->dentry =dget (newmnt->mnt_root); schedule_delayed_work(&afs_mntpt_expiry_timer,
fs/afs/rxrpc.c +107 -30
281 lines not on this page · raw message
fs/afs/security.c new file +345 -0
345 lines not on this page · raw message
fs/afs/super.c +120 -22
211 lines not on this page · raw message
fs/afs/vlclient.c +6 -0
@@ -127,6 +127,7 @@ static int afs_deliver_vl_get_entry_by_xxx(struct afs_call *call,* VL.GetEntryByName operation type */ static const struct afs_call_type afs_RXVLGetEntryByName = { + .name ="VL.GetEntryByName" , .deliver = afs_deliver_vl_get_entry_by_xxx, .abort_to_error = afs_vl_abort_to_error, .destructor = afs_flat_call_destructor,
@@ -136,6 +137,7 @@ static const struct afs_call_type afs_RXVLGetEntryByName = {* VL.GetEntryById operation type */ static const struct afs_call_type afs_RXVLGetEntryById = { + .name ="VL.GetEntryById" , .deliver = afs_deliver_vl_get_entry_by_xxx, .abort_to_error = afs_vl_abort_to_error, .destructor = afs_flat_call_destructor,
@@ -145,6 +147,7 @@ static const struct afs_call_type afs_RXVLGetEntryById = {* dispatch a get volume entry by name operation */ int afs_vl_get_entry_by_name (struct in_addr *addr, +struct key *key,const char *volname,struct afs_cache_vlocation *entry,const struct afs_wait_mode *wait_mode)
@@ -163,6 +166,7 @@ int afs_vl_get_entry_by_name(struct in_addr *addr,if (!call)return -ENOMEM ; + call->key = key; call->reply = entry; call->service_id =VL_SERVICE ; call->port =htons (AFS_VL_PORT );
@@ -183,6 +187,7 @@ int afs_vl_get_entry_by_name(struct in_addr *addr,* dispatch a get volume entry by ID operation */ int afs_vl_get_entry_by_id(struct in_addr *addr, + struct key *key, afs_volid_t volid, afs_voltype_t voltype, struct afs_cache_vlocation *entry,
@@ -197,6 +202,7 @@ int afs_vl_get_entry_by_id(struct in_addr *addr,if (!call)return -ENOMEM ; + call->key = key; call->reply = entry; call->service_id =VL_SERVICE ; call->port =htons (AFS_VL_PORT );
fs/afs/vlocation.c +16 -10
@@ -33,6 +33,7 @@ static struct workqueue_struct *afs_vlocation_update_worker;* about the volume in question */ static int afs_vlocation_access_vl_by_name (struct afs_vlocation *vl, +struct key *key,struct afs_cache_vlocation *vldb) {struct afs_cell *cell = vl->cell;
@@ -49,7 +50,7 @@ static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vl,_debug ("CellServ[%hu]: %08x" , cell->vl_curr_svix, addr.s_addr);/* attempt to access the VL server */ - ret =afs_vl_get_entry_by_name (&addr, vl->vldb.name, vldb, + ret =afs_vl_get_entry_by_name (&addr, key, vl->vldb.name, vldb, &afs_sync_call);switch (ret) {case 0 :
@@ -86,6 +87,7 @@ out:* about the volume in question */ static int afs_vlocation_access_vl_by_id (struct afs_vlocation *vl, +struct key *key,afs_volid_t volid,afs_voltype_t voltype,struct afs_cache_vlocation *vldb)
@@ -104,7 +106,7 @@ static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vl,_debug ("CellServ[%hu]: %08x" , cell->vl_curr_svix, addr.s_addr);/* attempt to access the VL server */ - ret =afs_vl_get_entry_by_id (&addr, volid, voltype, vldb, + ret =afs_vl_get_entry_by_id (&addr, key, volid, voltype, vldb, &afs_sync_call);switch (ret) {case 0 :
@@ -188,6 +190,7 @@ static struct afs_vlocation *afs_vlocation_alloc(struct afs_cell *cell,* update record if we found it in the cache */ static int afs_vlocation_update_record (struct afs_vlocation *vl, +struct key *key,struct afs_cache_vlocation *vldb) {afs_voltype_t voltype;
@@ -228,7 +231,7 @@ static int afs_vlocation_update_record(struct afs_vlocation *vl,/* contact the server to make sure the volume is still available * - TODO: need to handle disconnected operation here */ - ret =afs_vlocation_access_vl_by_id (vl, vid, voltype, vldb); + ret =afs_vlocation_access_vl_by_id (vl, key, vid, voltype, vldb);switch (ret) {/* net error */ default :
@@ -287,7 +290,8 @@ static void afs_vlocation_apply_update(struct afs_vlocation *vl,* fill in a volume location record, consulting the cache and the VL server * both */ -static int afs_vlocation_fill_in_record (struct afs_vlocation *vl) +static int afs_vlocation_fill_in_record (struct afs_vlocation *vl, +struct key *key) {struct afs_cache_vlocation vldb;int ret;
@@ -310,11 +314,11 @@ static int afs_vlocation_fill_in_record(struct afs_vlocation *vl)/* try to update a known volume in the cell VL databases by * ID as the name may have changed */ _debug ("found in cache" ); - ret =afs_vlocation_update_record (vl, &vldb); + ret =afs_vlocation_update_record (vl, key, &vldb); }else {/* try to look up an unknown volume in the cell VL databases by * name */ - ret =afs_vlocation_access_vl_by_name (vl, &vldb); + ret =afs_vlocation_access_vl_by_name (vl, key, &vldb);if (ret <0 ) {printk ("kAFS: failed to locate '%s' in cell '%s'\n" , vl->vldb.name, vl->cell->name);
@@ -366,14 +370,16 @@ void afs_vlocation_queue_for_updates(struct afs_vlocation *vl)* - insert/update in the local cache if did get a VL response */ struct afs_vlocation *afs_vlocation_lookup (struct afs_cell *cell, +struct key *key,const char *name,size_t namesz) {struct afs_vlocation *vl;int ret; -_enter ("{%s},%*.*s,%zu" , - cell->name, (int ) namesz, (int ) namesz, name, namesz); +_enter ("{%s},{%x},%*.*s,%zu" , + cell->name,key_serial (key), + (int ) namesz, (int ) namesz, name, namesz);if (namesz >sizeof (vl->vldb.name)) {_leave (" = -ENAMETOOLONG" );
@@ -405,7 +411,7 @@ struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *cell,up_write (&cell->vl_sem); fill_in_record: - ret =afs_vlocation_fill_in_record (vl); + ret =afs_vlocation_fill_in_record (vl, key);if (ret <0 ) goto error_abandon; vl->state =AFS_VL_VALID ;
@@ -656,7 +662,7 @@ static void afs_vlocation_updater(struct work_struct *work) vl->upd_rej_cnt =0 ; vl->upd_busy_cnt =0 ; - ret =afs_vlocation_update_record (vl, &vldb); + ret =afs_vlocation_update_record (vl,NULL , &vldb);switch (ret) {case 0 :afs_vlocation_apply_update (vl, &vldb);
fs/afs/vnode.c +17 -8
@@ -238,9 +238,11 @@ static void afs_vnode_finalise_status_update(struct afs_vnode *vnode,* - there are any outstanding ops that will fetch the status * - TODO implement local caching */ -int afs_vnode_fetch_status (struct afs_vnode *vnode) +int afs_vnode_fetch_status (struct afs_vnode *vnode, +struct afs_vnode *auth_vnode,struct key *key) {struct afs_server *server; +unsigned long acl_order;int ret;DECLARE_WAITQUEUE (myself, current);
@@ -260,6 +262,10 @@ int afs_vnode_fetch_status(struct afs_vnode *vnode)return -ENOENT ; } + acl_order =0 ; +if (auth_vnode) + acl_order = auth_vnode->acl_order; +spin_lock (&vnode->lock); if (!test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags) &&
@@ -324,12 +330,14 @@ get_anyway:_debug ("USING SERVER: %p{%08x}" , server,ntohl (server->addr.s_addr)); - ret =afs_fs_fetch_file_status (server, vnode,NULL , + ret =afs_fs_fetch_file_status (server, key, vnode,NULL , &afs_sync_call); }while (!afs_volume_release_fileserver (vnode, server, ret));/* adjust the flags */ +if (ret ==0 && auth_vnode) +afs_cache_permit (vnode, key, acl_order);afs_vnode_finalise_status_update (vnode, server, ret);_leave (" = %d" , ret);
@@ -340,17 +348,18 @@ get_anyway:* fetch file data from the volume * - TODO implement caching and server failover */ -int afs_vnode_fetch_data (struct afs_vnode *vnode,off_t offset,size_t length, -struct page *page) +int afs_vnode_fetch_data (struct afs_vnode *vnode,struct key *key, +off_t offset,size_t length,struct page *page) {struct afs_server *server;int ret; -_enter ("%s,{%u,%u,%u}" , +_enter ("%s{%u,%u,%u},%x,,," , vnode->volume->vlocation->vldb.name, vnode->fid.vid, vnode->fid.vnode, - vnode->fid.unique); + vnode->fid.unique, +key_serial (key));/* this op will fetch the status */ spin_lock (&vnode->lock);
@@ -367,8 +376,8 @@ int afs_vnode_fetch_data(struct afs_vnode *vnode, off_t offset, size_t length,_debug ("USING SERVER: %08x\n" ,ntohl (server->addr.s_addr)); - ret =afs_fs_fetch_data (server, vnode, offset, length, page, -NULL , &afs_sync_call); + ret =afs_fs_fetch_data (server, key, vnode, offset, length, + page,NULL , &afs_sync_call); }while (!afs_volume_release_fileserver (vnode, server, ret));
fs/afs/volume.c +22 -87
173 lines not on this page · raw message
David Howells
maintainerPATCH 12/16 AFS: Update the AFS fs documentation [try #3]
In reply to David HowellsUpdate the AFS fs documentation.
---
Documentation/filesystems/afs.txt | 214 +++++++++++++++++++++++++++---------- 1 files changed, 154 insertions(+), 60 deletions(-)
Documentation/filesystems/afs.txt +154 -60
@@ -1,31 +1,82 @@ + ==================== kAFS: AFS FILESYSTEM ==================== -ABOUT -===== +Contents: + + - Overview. + - Usage. + - Mountpoints. + - Proc filesystem. + - The cell database. + - Security. + - Examples. + + +======== +OVERVIEW +======== -This filesystem provides a fairly simple AFS filesystem driver. It is under -development and only provides very basic facilities. It does not yet support -the following AFS features: +This filesystem provides a fairly simple secure AFS filesystem driver. It is +under development and does not yet provide the full feature set. The features +it does support include: - (*) Write support. - (*) Communications security. - (*) Local caching. - (*) pioctl() system call. - (*) Automatic mounting of embedded mountpoints. + (*) Security (currently only AFS kaserver and KerberosIV tickets). + (*) File reading. + (*) Automounting. + +It does not yet support the following AFS features: + + (*) Write support. + + (*) Local caching. + + (*) pioctl() system call. + + +=========== +COMPILATION +=========== + +The filesystem should be enabled by turning on the kernel configuration +options: + + CONFIG_AF_RXRPC - The RxRPC protocol transport + CONFIG_RXKAD - The RxRPC Kerberos security handler + CONFIG_AFS - The AFS filesystem + +Additionally, the following can be turned on to aid debugging: + + CONFIG_AF_RXRPC_DEBUG - Permit AF_RXRPC debugging to be enabled + CONFIG_AFS_DEBUG - Permit AFS debugging to be enabled + +They permit the debugging messages to be turned on dynamically by manipulating +the masks in the following files: + + /sys/module/af_rxrpc/parameters/debug + /sys/module/afs/parameters/debug + + +===== USAGE ===== When inserting the driver modules the root cell must be specified along with a list of volume location server IP addresses: - insmod rxrpc.o + insmod af_rxrpc.o + insmod rxkad.o insmod kafs.o rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91 -The first module is a driver for the RxRPC remote operation protocol, and the -second is the actual filesystem driver for the AFS filesystem. +The first module is the AF_RXRPC network protocol driver. This provides the +RxRPC remote operation protocol and may also be accessed from userspace. See: + + Documentation/networking/rxrpc.txt + +The second module is the kerberos RxRPC security driver, and the third module +is the actual filesystem driver for the AFS filesystem. Once the module has been loaded, more modules can be added by the following procedure:
@@ -33,7 +84,7 @@ procedure: echo add grand.central.org 18.7.14.88:128.2.191.224 >/proc/fs/afs/cells Where the parameters to the "add" command are the name of a cell and a list of -volume location servers within that cell. +volume location servers within that cell, with the latter separated by colons. Filesystems can be mounted anywhere by commands similar to the following:
@@ -42,11 +93,6 @@ Filesystems can be mounted anywhere by commands similar to the following: mount -t afs "#root.afs." /afs mount -t afs "#root.cell." /afs/cambridge - NB: When using this on Linux 2.4, the mount command has to be different, - since the filesystem doesn't have access to the device name argument: - - mount -t afs none /afs -ovol="#root.afs." - Where the initial character is either a hash or a percent symbol depending on whether you definitely want a R/W volume (hash) or whether you'd prefer a R/O volume, but are willing to use a R/W volume instead (percent).
@@ -60,55 +106,66 @@ named volume will be looked up in the cell specified during insmod. Additional cells can be added through /proc (see later section). +=========== MOUNTPOINTS =========== -AFS has a concept of mountpoints. These are specially formatted symbolic links -(of the same form as the "device name" passed to mount). kAFS presents these -to the user as directories that have special properties: +AFS has a concept of mountpoints. In AFS terms, these are specially formatted +symbolic links (of the same form as the "device name" passed to mount). kAFS +presents these to the user as directories that have a follow-link capability +(ie: symbolic link semantics). If anyone attempts to access them, they will +automatically cause the target volume to be mounted (if possible) on that site. - (*) They cannot be listed. Running a program like "ls" on them will incur an - EREMOTE error (Object is remote). +Automatically mounted filesystems will be automatically unmounted approximately +twenty minutes after they were last used. Alternatively they can be unmounted +directly with the umount() system call. - (*) Other objects can't be looked up inside of them. This also incurs an - EREMOTE error. +Manually unmounting an AFS volume will cause any idle submounts upon it to be +culled first. If all are culled, then the requested volume will also be +unmounted, otherwise error EBUSY will be returned. - (*) They can be queried with the readlink() system call, which will return - the name of the mountpoint to which they point. The "readlink" program - will also work. +This can be used by the administrator to attempt to unmount the whole AFS tree +mounted on /afs in one go by doing: - (*) They can be mounted on (which symbolic links can't). + umount /afs +=============== PROC FILESYSTEM =============== -The rxrpc module creates a number of files in various places in the /proc -filesystem: - - (*) Firstly, some information files are made available in a directory called - "/proc/net/rxrpc/". These list the extant transport endpoint, peer, - connection and call records. - - (*) Secondly, some control files are made available in a directory called - "/proc/sys/rxrpc/". Currently, all these files can be used for is to - turn on various levels of tracing. - The AFS modules creates a "/proc/fs/afs/" directory and populates it: - (*) A "cells" file that lists cells currently known to the afs module. + (*) A "cells" file that lists cells currently known to the afs module and + their usage counts: + + [root@andromeda ~]# cat /proc/fs/afs/cells + USE NAME + 3 cambridge.redhat.com (*) A directory per cell that contains files that list volume location servers, volumes, and active servers known within that cell. + [root@andromeda ~]# cat /proc/fs/afs/cambridge.redhat.com/servers + USE ADDR STATE + 4 172.16.18.91 0 + [root@andromeda ~]# cat /proc/fs/afs/cambridge.redhat.com/vlservers + ADDRESS + 172.16.18.91 + [root@andromeda ~]# cat /proc/fs/afs/cambridge.redhat.com/volumes + USE STT VLID[0] VLID[1] VLID[2] NAME + 1 Val 20000000 20000001 20000002 root.afs + +================= THE CELL DATABASE ================= -The filesystem maintains an internal database of all the cells it knows and -the IP addresses of the volume location servers for those cells. The cell to -which the computer belongs is added to the database when insmod is performed -by the "rootcell=" argument. +The filesystem maintains an internal database of all the cells it knows and the +IP addresses of the volume location servers for those cells. The cell to which +the system belongs is added to the database when insmod is performed by the +"rootcell=" argument or, if compiled in, using a "kafs.rootcell=" argument on +the kernel command line. Further cells can be added by commands similar to the following:
@@ -118,20 +175,65 @@ Further cells can be added by commands similar to the following: No other cell database operations are available at this time. +======== +SECURITY +======== + +Secure operations are initiated by acquiring a key using the klog program. A +very primitive klog program is available at: + + http://people.redhat.com/~dhowells/rxrpc/klog.c + +This should be compiled by: + + make klog LDLIBS="-lcrypto -lcrypt -lkrb4 -lkeyutils" + +And then run as: + + ./klog + +Assuming it's successful, this adds a key of type RxRPC, named for the service +and cell, eg: "afs@<cellname>". This can be viewed with the keyctl program or +by cat'ing /proc/keys: + + [root@andromeda ~]# keyctl show + Session Keyring + -3 --alswrv 0 0 keyring: _ses.3268 + 2 --alswrv 0 0 \_ keyring: _uid.0 + 111416553 --als--v 0 0 \_ rxrpc: [email protected] + +Currently the username, realm, password and proposed ticket lifetime are +compiled in to the program. + +It is not required to acquire a key before using AFS facilities, but if one is +not acquired then all operations will be governed by the anonymous user parts +of the ACLs. + +If a key is acquired, then all AFS operations, including mounts and automounts, +made by a possessor of that key will be secured with that key. + +If a file is opened with a particular key and then the file descriptor is +passed to a process that doesn't have that key (perhaps over an AF_UNIX +socket), then the operations on the file will be made with key that was used to +open the file. + + +======== EXAMPLES ======== -Here's what I use to test this. Some of the names and IP addresses are local -to my internal DNS. My "root.afs" partition has a mount point within it for +Here's what I use to test this. Some of the names and IP addresses are local +to my internal DNS. My "root.afs" partition has a mount point within it for some public volumes volumes. -insmod -S /tmp/rxrpc.o -insmod -S /tmp/kafs.o rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91 +insmod /tmp/rxrpc.o +insmod /tmp/rxkad.o +insmod /tmp/kafs.o rootcell=cambridge.redhat.com:172.16.18.91 mount -t afs \%root.afs. /afs mount -t afs \%cambridge.redhat.com:root.cell. /afs/cambridge.redhat.com/ -echo add grand.central.org 18.7.14.88:128.2.191.224 > /proc/fs/afs/cells +echo add grand.central.org 18.7.14.88:128.2.191.224 > /proc/fs/afs/cells mount -t afs "#grand.central.org:root.cell." /afs/grand.central.org/ mount -t afs "#grand.central.org:root.archive." /afs/grand.central.org/archive mount -t afs "#grand.central.org:root.contrib." /afs/grand.central.org/contrib
@@ -141,15 +243,7 @@ mount -t afs "#grand.central.org:root.service." /afs/grand.central.org/service mount -t afs "#grand.central.org:root.software." /afs/grand.central.org/software mount -t afs "#grand.central.org:root.user." /afs/grand.central.org/user -umount /afs/grand.central.org/user -umount /afs/grand.central.org/software -umount /afs/grand.central.org/service -umount /afs/grand.central.org/project -umount /afs/grand.central.org/doc -umount /afs/grand.central.org/contrib -umount /afs/grand.central.org/archive -umount /afs/grand.central.org -umount /afs/cambridge.redhat.com umount /afs rmmod kafs +rmmod rxkad rmmod rxrpc
David Howells
maintainerPATCH 13/16 commit ad495d7b6cfcd1bc2eaf06c42699be0bb5d84234 [try #3]
In reply to David Howells[NETLINK]: Mirror UDP MSG_TRUNC semantics.
If the user passes MSG_TRUNC in via msg_flags, return the full packet size not the truncated size.
Idea from Herbert Xu and Thomas Graf.
---
net/netlink/af_netlink.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
net/netlink/af_netlink.c +3 -0
@@ -1242,6 +1242,9 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,scm_recv (sock, msg, siocb->scm, flags); +if (flags &MSG_TRUNC ) + copied = skb->len; + out:netlink_rcv_wake (sk);return err ? : copied;
David Howells
maintainerPATCH 14/16 AFS: Add support for the CB.GetCapabilities operation [try #3]
In reply to David HowellsAdd support for the CB.GetCapabilities operation with which the fileserver can ask the client for the following information:
(1) The list of network interfaces it has available as IPv4 address + netmask plus the MTUs.
(2) The client's UUID.
(3) The extended capabilities of the client, for which the only current one is unified error mapping (abort code interpretation).
To support this, the patch adds the following routines to AFS:
(1) A function to iterate through all the network interfaces using RTNETLINK to extract IPv4 addresses and MTUs.
(2) A function to iterate through all the network interfaces using RTNETLINK to pull out the MAC address of the lowest index interface to use in UUID construction.
---
fs/afs/AFS_CM.h | 3 fs/afs/Makefile | 1 fs/afs/cmservice.c | 98 ++++++++++ fs/afs/internal.h | 42 ++++ fs/afs/main.c | 49 +++++ fs/afs/rxrpc.c | 39 ++++ fs/afs/use-rtnetlink.c | 473 ++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 705 insertions(+), 0 deletions(-)
fs/afs/AFS_CM.h +3 -0
@@ -23,6 +23,9 @@ enum AFS_CM_Operations { CBGetCE =208 ,/* get cache file description */ CBGetXStatsVersion =209 ,/* get version of extended statistics */ CBGetXStats =210 ,/* get contents of extended statistics data */ + CBGetCapabilities = 65538, /* get client capabilities */ }; +#define AFS_CAP_ERROR_TRANSLATION 0x1 +#endif /* AFS_FS_H */
fs/afs/Makefile +1 -0
@@ -18,6 +18,7 @@ kafs-objs := \ security.o \ server.o \ super.o \ + use-rtnetlink.o \ vlclient.o \ vlocation.o \ vnode.o \
fs/afs/cmservice.c +98 -0
119 lines not on this page · raw message
fs/afs/internal.h +42 -0
66 lines not on this page · raw message
fs/afs/main.c +49 -0
61 lines not on this page · raw message
fs/afs/rxrpc.c +39 -0
@@ -714,6 +714,45 @@ void afs_send_empty_reply(struct afs_call *call) }/* +* send a simple reply +*/ +void afs_send_simple_reply (struct afs_call *call,const void *buf,size_t len) +{ +struct msghdr msg; +struct iovec iov[1 ]; + +_enter ("" ); + + iov[0 ].iov_base = (void *) buf; + iov[0 ].iov_len = len; + msg.msg_name =NULL ; + msg.msg_namelen =0 ; + msg.msg_iov = iov; + msg.msg_iovlen =1 ; + msg.msg_control =NULL ; + msg.msg_controllen =0 ; + msg.msg_flags =0 ; + + call->state =AFS_CALL_AWAIT_ACK ; +switch (rxrpc_kernel_send_data (call->rxcall, &msg, len)) { +case 0 : +_leave (" [replied]" ); +return ; + +case -ENOMEM : +_debug ("oom" ); +rxrpc_kernel_abort_call (call->rxcall,RX_USER_ABORT ); +default : +rxrpc_kernel_end_call (call->rxcall); + call->rxcall =NULL ; + call->type->destructor (call); +afs_free_call (call); +_leave (" [error]" ); +return ; + } +} + +/* * extract a piece of data from the received data socket buffers */ int afs_extract_data(struct afs_call *call, struct sk_buff *skb,
fs/afs/use-rtnetlink.c new file +473 -0
473 lines not on this page · raw message
David Howells
maintainerPATCH 15/16 AFS: Implement the CB.InitCallBackState3 operation [try #3]
In reply to David HowellsImplement the CB.InitCallBackState3 operation for the fileserver to call. This reduces the amount of network traffic because if this op is aborted, the fileserver will then attempt an CB.InitCallBackState operation.
---
fs/afs/AFS_CM.h | 1 + fs/afs/cmservice.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)
fs/afs/AFS_CM.h +1 -0
@@ -23,6 +23,7 @@ enum AFS_CM_Operations { CBGetCE =208 ,/* get cache file description */ CBGetXStatsVersion =209 ,/* get version of extended statistics */ CBGetXStats =210 ,/* get contents of extended statistics data */ + CBInitCallBackState3 =213 ,/* initialise callback state, version 3 */ CBGetCapabilities = 65538, /* get client capabilities */ };
fs/afs/cmservice.c +46 -0
70 lines not on this page · raw message
David Howells
maintainerPATCH 16/16 AFS: Add "directory write" support [try #3]
In reply to David HowellsAdd support for the create, link, symlink, unlink, mkdir, rmdir and rename VFS operations to the in-kernel AFS filesystem.
Also:
(1) Fix dentry and inode revalidation. d_revalidate should only look at state of the dentry. Revalidation of the contents of an inode pointed to by a dentry is now separate.
(2) Fix afs_lookup() to hash negative dentries as well as positive ones.
---
fs/afs/AFS.h | 26 ++ fs/afs/AFS_FS.h | 11 + fs/afs/callback.c | 36 +++ fs/afs/dir.c | 676 ++++++++++++++++++++++++++++++++++++++++++----------- fs/afs/file.c | 7 + fs/afs/fsclient.c | 625 +++++++++++++++++++++++++++++++++++++++++++++---- fs/afs/inode.c | 115 ++++++++- fs/afs/internal.h | 54 ++++ fs/afs/misc.c | 21 ++ fs/afs/security.c | 31 ++ fs/afs/server.c | 2 fs/afs/super.c | 6 fs/afs/vnode.c | 422 +++++++++++++++++++++++++++++++-- fs/afs/volume.c | 14 + 14 files changed, 1778 insertions(+), 268 deletions(-)
fs/afs/AFS.h +22 -4
@@ -106,19 +106,37 @@ struct afs_file_status {afs_file_type_t type;/* file type */ unsigned nlink;/* link count */ -size_t size;/* file size */ +u64 size;/* file size */ afs_dataversion_t data_version;/* current data version */ -unsigned author;/* author ID */ -unsigned owner;/* owner ID */ +u32 author;/* author ID */ +u32 owner;/* owner ID */ +u32 group;/* group ID */ afs_access_t caller_access;/* access rights for authenticated caller */ afs_access_t anon_access;/* access rights for unauthenticated caller */ umode_t mode;/* UNIX mode */ -struct afs_fid parent;/* parent file ID */ +struct afs_fid parent;/* parent dir ID for non-dirs only */ time_t mtime_client;/* last time client changed data */ time_t mtime_server;/* last time server changed data */ };/* +* AFS file status change request +*/ +struct afs_store_status { +u32 mask;/* which bits of the struct are set */ +u32 mtime_client;/* last time client changed data */ +u32 owner;/* owner ID */ +u32 group;/* group ID */ +umode_t mode;/* UNIX mode */ +}; + +#define AFS_SET_MTIME 0x01/* set the mtime */ +#define AFS_SET_OWNER 0x02/* set the owner ID */ +#define AFS_SET_GROUP 0x04/* set the group ID (unsupported?) */ +#define AFS_SET_MODE 0x08/* set the UNIX mode */ +#define AFS_SET_SEG_SIZE 0x10/* set the segment size (unsupported) */ + +/* * AFS volume synchronisation information */ struct afs_volsync {
fs/afs/AFS_FS.h +9 -2
@@ -16,12 +16,19 @@#define FS_SERVICE 1/* AFS File Service ID */ enum AFS_FS_Operations { -FSFETCHSTATUS =132 ,/* AFS Fetch file status */ FSFETCHDATA =130 ,/* AFS Fetch file data */ +FSFETCHSTATUS =132 ,/* AFS Fetch file status */ +FSREMOVEFILE =136 ,/* AFS Remove a file */ +FSCREATEFILE =137 ,/* AFS Create a file */ +FSRENAME =138 ,/* AFS Rename or move a file or directory */ +FSSYMLINK =139 ,/* AFS Create a symbolic link */ +FSLINK =140 ,/* AFS Create a hard link */ +FSMAKEDIR =141 ,/* AFS Create a directory */ +FSREMOVEDIR =142 ,/* AFS Remove a directory */ FSGIVEUPCALLBACKS =147 ,/* AFS Discard callback promises */ FSGETVOLUMEINFO =148 ,/* AFS Get root volume information */ FSGETROOTVOLUME =151 ,/* AFS Get root volume name */ -FSLOOKUP =161 /* AFS lookup file in directory */ +FSLOOKUP =161 ,/* AFS lookup file in directory */ };enum AFS_FS_Errors {
fs/afs/callback.c +32 -4
@@ -44,7 +44,8 @@ void afs_init_callback_state(struct afs_server *server)while (!RB_EMPTY_ROOT (&server->cb_promises)) { vnode =rb_entry (server->cb_promises.rb_node, struct afs_vnode, cb_promise); -printk ("\nUNPROMISE on %p\n" , vnode); +_debug ("UNPROMISE { vid=%x vn=%u uq=%u}" , + vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique);rb_erase (&vnode->cb_promise, &server->cb_promises); vnode->cb_promised = false; }
@@ -68,7 +69,7 @@ void afs_broken_callback_work(struct work_struct *work)/* we're only interested in dealing with a broken callback on *this* * vnode and only if no-one else has dealt with it yet */ -if (!mutex_trylock (&vnode->cb_broken_lock)) +if (!mutex_trylock (&vnode->validate_lock))return ;/* someone else is dealing with it */ if (test_bit (AFS_VNODE_CB_BROKEN , &vnode->flags)) {
@@ -84,13 +85,14 @@ void afs_broken_callback_work(struct work_struct *work)/* if the vnode's data version number changed then its contents * are different */ if (test_and_clear_bit (AFS_VNODE_ZAP_DATA , &vnode->flags)) { -_debug ("zap data" ); +_debug ("zap data {%x:%u}" , + vnode->fid.vid, vnode->fid.vnode);invalidate_remote_inode (&vnode->vfs_inode); } } out: -mutex_unlock (&vnode->cb_broken_lock); +mutex_unlock (&vnode->validate_lock);/* avoid the potential race whereby the mutex_trylock() in this * function happens again between the clear_bit() and the
@@ -252,6 +254,32 @@ static void afs_do_give_up_callback(struct afs_server *server, }/* +* discard the callback on a deleted item +*/ +void afs_discard_callback_on_delete (struct afs_vnode *vnode) +{ +struct afs_server *server = vnode->server; + +_enter ("%d" , vnode->cb_promised); + +if (!vnode->cb_promised) { +_leave (" [not promised]" ); +return ; + } + +ASSERT (server !=NULL ); + +spin_lock (&server->cb_lock); +if (vnode->cb_promised) { +ASSERT (server->cb_promises.rb_node !=NULL ); +rb_erase (&vnode->cb_promise, &server->cb_promises); + vnode->cb_promised = false; + } +spin_unlock (&server->cb_lock); +_leave ("" ); +} + +/* * give up the callback registered for a vnode on the file server when the * inode is being cleared */
fs/afs/dir.c +536 -140
836 lines not on this page · raw message
fs/afs/file.c +7 -0
@@ -50,6 +50,7 @@ int afs_open(struct inode *inode, struct file *file) {struct afs_vnode *vnode =AFS_FS_I (inode);struct key *key; +int ret;_enter ("{%x:%x}," , vnode->fid.vid, vnode->fid.vnode);
@@ -58,6 +59,12 @@ int afs_open(struct inode *inode, struct file *file)_leave (" = %ld [key]" ,PTR_ERR (key));return PTR_ERR (key); } + + ret =afs_validate (vnode, key); +if (ret <0 ) { +_leave (" = %d [val]" , ret); +return ret; + } file->private_data = key;_leave (" = 0" );
fs/afs/fsclient.c +574 -51
716 lines not on this page · raw message
fs/afs/inode.c +105 -10
151 lines not on this page · raw message
fs/afs/internal.h +46 -8
115 lines not on this page · raw message
fs/afs/misc.c +20 -1
@@ -22,6 +22,7 @@ int afs_abort_to_error(u32 abort_code) {switch (abort_code) {case 13 :return -EACCES ; +case 30 :return -EROFS ;case VSALVAGE :return -EIO ;case VNOVNODE :return -ENOENT ;case VNOVOL :return -ENOMEDIUM ;
@@ -33,6 +34,24 @@ int afs_abort_to_error(u32 abort_code)case VOVERQUOTA :return -EDQUOT ;case VBUSY :return -EBUSY ;case VMOVED :return -ENXIO ; -default :return -EIO ; +case 0x2f6df0c :return -EACCES ; +case 0x2f6df0f :return -EBUSY ; +case 0x2f6df10 :return -EEXIST ; +case 0x2f6df11 :return -EXDEV ; +case 0x2f6df13 :return -ENOTDIR ; +case 0x2f6df14 :return -EISDIR ; +case 0x2f6df15 :return -EINVAL ; +case 0x2f6df1a :return -EFBIG ; +case 0x2f6df1b :return -ENOSPC ; +case 0x2f6df1d :return -EROFS ; +case 0x2f6df1e :return -EMLINK ; +case 0x2f6df20 :return -EDOM ; +case 0x2f6df21 :return -ERANGE ; +case 0x2f6df22 :return -EDEADLK ; +case 0x2f6df23 :return -ENAMETOOLONG ; +case 0x2f6df24 :return -ENOLCK ; +case 0x2f6df26 :return -ENOTEMPTY ; +case 0x2f6df78 :return -EDQUOT ; +default :return -EREMOTEIO ; } }
fs/afs/security.c +21 -10
@@ -92,7 +92,7 @@ static struct afs_vnode *afs_get_auth_inode(struct afs_vnode *vnode,ASSERT (auth_inode !=NULL ); }else { auth_inode =afs_iget (vnode->vfs_inode.i_sb, key, - &vnode->status.parent); + &vnode->status.parent,NULL ,NULL );if (IS_ERR (auth_inode))return ERR_PTR (PTR_ERR (auth_inode)); }
@@ -288,7 +288,8 @@ int afs_permission(struct inode *inode, int mask, struct nameidata *nd)struct key *key;int ret; -_enter ("{%x:%x},%x," , vnode->fid.vid, vnode->fid.vnode, mask); +_enter ("{{%x:%x},%lx},%x," , + vnode->fid.vid, vnode->fid.vnode, vnode->flags, mask); key =afs_request_key (vnode->volume->cell);if (IS_ERR (key)) {
@@ -296,13 +297,19 @@ int afs_permission(struct inode *inode, int mask, struct nameidata *nd)return PTR_ERR (key); } +/* if the promise has expired, we need to check the server again */ +if (!vnode->cb_promised) { +_debug ("not promised" ); + ret =afs_vnode_fetch_status (vnode,NULL , key); +if (ret <0 ) + goto error; +_debug ("new promise [fl=%lx]" , vnode->flags); + } +/* check the permits to see if we've got one yet */ ret =afs_check_permit (vnode, key, &access); -if (ret <0 ) { -key_put (key); -_leave (" = %d [check]" , ret); -return ret; - } +if (ret <0 ) + goto error;/* interpret the access mask */ _debug("REQ %x ACC %x on %s",
@@ -336,10 +343,14 @@ int afs_permission(struct inode *inode, int mask, struct nameidata *nd) }key_put (key); -return generic_permission (inode, mask,NULL ); + ret =generic_permission (inode, mask,NULL ); +_leave (" = %d" , ret); +return ret; permission_denied: + ret = -EACCES ; +error:key_put (key); -_leave (" = -EACCES" ); -return -EACCES ; +_leave (" = %d" , ret); +return ret; }
fs/afs/server.c +2 -0
@@ -223,6 +223,8 @@ void afs_put_server(struct afs_server *server)_enter ("%p{%d}" , server,atomic_read (&server->usage)); +_debug ("PUT SERVER %d" ,atomic_read (&server->usage)); + ASSERTCMP(atomic_read(&server->usage), >, 0);if (likely (!atomic_dec_and_test (&server->usage))) {
fs/afs/super.c +3 -3
@@ -331,7 +331,7 @@ static int afs_fill_super(struct super_block *sb, void *data) fid.vid = as->volume->vid; fid.vnode =1 ; fid.unique =1 ; - inode =afs_iget (sb, params->key, &fid); + inode =afs_iget (sb, params->key, &fid,NULL ,NULL );if (IS_ERR (inode)) goto error_inode;
@@ -473,9 +473,9 @@ static void afs_i_init_once(void *_vnode, struct kmem_cache *cachep,inode_init_once (&vnode->vfs_inode);init_waitqueue_head (&vnode->update_waitq);mutex_init (&vnode->permits_lock); +mutex_init (&vnode->validate_lock);spin_lock_init (&vnode->lock);INIT_WORK (&vnode->cb_broken_work, afs_broken_callback_work); -mutex_init (&vnode->cb_broken_lock); } }
@@ -497,7 +497,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb) vnode->volume =NULL ; vnode->update_cnt =0 ; - vnode->flags =0 ; + vnode->flags =1 <<AFS_VNODE_UNSET ; vnode->cb_promised = false;return &vnode->vfs_inode;
fs/afs/vnode.c +394 -28
505 lines not on this page · raw message
fs/afs/volume.c +7 -7
@@ -295,6 +295,7 @@ struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *vnode)* - releases the ref on the server struct that was acquired by picking * - records result of using a particular server to access a volume * - return 0 to try again, 1 if okay or to issue error +* - the caller must release the server struct if result was 0 */ int afs_volume_release_fileserver(struct afs_vnode *vnode, struct afs_server *server,
@@ -312,7 +313,8 @@ int afs_volume_release_fileserver(struct afs_vnode *vnode,case 0 : server->fs_act_jif = jiffies; server->fs_state =0 ; -break ; +_leave ("" ); +return 1 ;/* the fileserver denied all knowledge of the volume */ case -ENOMEDIUM :
@@ -377,14 +379,12 @@ int afs_volume_release_fileserver(struct afs_vnode *vnode, server->fs_act_jif = jiffies;case -ENOMEM :case -ENONET : -break ; +/* tell the caller to accept the result */ +afs_put_server (server); +_leave (" [local failure]" ); +return 1 ; } -/* tell the caller to accept the result */ -afs_put_server (server); -_leave ("" ); -return 1 ; -/* tell the caller to loop around and try the next server */ try_next_server_upw:up_write (&volume->server_sem);
David Howells
maintainerQuoted 5 lines · Andrew Morton
I'm ducking all feature and cleanup patches now, and probably shall continue to do so for some weeks. The priority (which I believe to be increasingly urgent) is to fix the 2.6.21 regressions and to stabilise the things which we presently have queued for 2.6.22. Not to mention the 1000ish unaddressed bug reports in bugzilla and elsewhere.
Fair enough. I think the idea is for them (or at least some of them) to go through one of DaveM's net git trees anyway.
David
David Miller
maintainerFrom: David Howells <[email protected]>
Date: Wed, 25 Apr 2007 14:38:32 +0100
Quoted 2 lines
I think the idea is for them (or at least some of them) to go through one of DaveM's net git trees anyway.
Then please generate your patches against my net-2.6.21 GIT tree. Most of your initial patches in the series (the SKB routine one for example) are already in my tree.
David Howells
maintainerQuoted 3 lines · David Miller
Then please generate your patches against my net-2.6.21 GIT tree. Most of your initial patches in the series (the SKB routine one for example) are already in my tree.
Do you mean your net-2.6.22 GIT tree?
Do you want me to make it available as a GIT tree for you to pull? Or would you prefer patches?
David
David Miller
maintainerFrom: David Howells <[email protected]>
Date: Wed, 25 Apr 2007 20:56:47 +0100
Quoted 10 lines
Quoted 3 lines · David Miller
Then please generate your patches against my net-2.6.21 GIT tree. Most of your initial patches in the series (the SKB routine one for example) are already in my tree.
Do you mean your net-2.6.22 GIT tree?
Do you want me to make it available as a GIT tree for you to pull? Or would you prefer patches?
Just patches is perfectly fine.
Also, if it's easier to diff against -mm, that works too since Andrew integrates my net-2.6.22 tree into -mm most of the time.