Skip to content

Commit d03539d

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: Display security params in the afs_cb_call tracepoint
Make the afs_cb_call tracepoint display some security parameters to make debugging easier. Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Simon Horman <[email protected]> cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b794dc1 commit d03539d

File tree

8 files changed

+41
-2
lines changed

8 files changed

+41
-2
lines changed

Documentation/networking/rxrpc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ API Function Reference
11781178
======================
11791179

11801180
.. kernel-doc:: net/rxrpc/af_rxrpc.c
1181+
.. kernel-doc:: net/rxrpc/call_object.c
11811182
.. kernel-doc:: net/rxrpc/key.c
11821183
.. kernel-doc:: net/rxrpc/oob.c
11831184
.. kernel-doc:: net/rxrpc/peer_object.c

fs/afs/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ struct afs_call {
176176
bool intr; /* T if interruptible */
177177
bool unmarshalling_error; /* T if an unmarshalling error occurred */
178178
bool responded; /* Got a response from the call (may be abort) */
179+
u8 security_ix; /* Security class */
179180
u16 service_id; /* Actual service ID (after upgrade) */
180181
unsigned int debug_id; /* Trace ID */
182+
u32 enctype; /* Security encoding type */
181183
u32 operation_ID; /* operation ID for an incoming call */
182184
u32 count; /* count for use in unmarshalling */
183185
union { /* place to extract temporary data */

fs/afs/rxrpc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,10 @@ static int afs_deliver_cm_op_id(struct afs_call *call)
813813
if (!afs_cm_incoming_call(call))
814814
return -ENOTSUPP;
815815

816+
call->security_ix = rxrpc_kernel_query_call_security(call->rxcall,
817+
&call->service_id,
818+
&call->enctype);
819+
816820
trace_afs_cb_call(call);
817821
call->work.func = call->type->work;
818822

include/net/af_rxrpc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,7 @@ int rxkad_kernel_respond_to_challenge(struct sk_buff *challenge);
112112
u32 rxgk_kernel_query_challenge(struct sk_buff *challenge);
113113
int rxgk_kernel_respond_to_challenge(struct sk_buff *challenge,
114114
struct krb5_buffer *appdata);
115+
u8 rxrpc_kernel_query_call_security(struct rxrpc_call *call,
116+
u16 *_service_id, u32 *_enctype);
115117

116118
#endif /* _NET_RXRPC_H */

include/trace/events/afs.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,19 +663,26 @@ TRACE_EVENT(afs_cb_call,
663663
__field(unsigned int, call)
664664
__field(u32, op)
665665
__field(u16, service_id)
666+
__field(u8, security_ix)
667+
__field(u32, enctype)
666668
),
667669

668670
TP_fast_assign(
669671
__entry->call = call->debug_id;
670672
__entry->op = call->operation_ID;
671673
__entry->service_id = call->service_id;
674+
__entry->security_ix = call->security_ix;
675+
__entry->enctype = call->enctype;
672676
),
673677

674-
TP_printk("c=%08x %s",
678+
TP_printk("c=%08x %s sv=%u sx=%u en=%u",
675679
__entry->call,
676680
__entry->service_id == 2501 ?
677681
__print_symbolic(__entry->op, yfs_cm_operations) :
678-
__print_symbolic(__entry->op, afs_cm_operations))
682+
__print_symbolic(__entry->op, afs_cm_operations),
683+
__entry->service_id,
684+
__entry->security_ix,
685+
__entry->enctype)
679686
);
680687

681688
TRACE_EVENT(afs_call,

net/rxrpc/ar-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ struct rxrpc_call {
740740
u32 call_id; /* call ID on connection */
741741
u32 cid; /* connection ID plus channel index */
742742
u32 security_level; /* Security level selected */
743+
u32 security_enctype; /* Security-specific encoding type (or 0) */
743744
int debug_id; /* debug ID for printks */
744745
unsigned short rx_pkt_offset; /* Current recvmsg packet offset */
745746
unsigned short rx_pkt_len; /* Current recvmsg packet len */

net/rxrpc/call_object.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,23 @@ void rxrpc_destroy_all_calls(struct rxrpc_net *rxnet)
760760
atomic_dec(&rxnet->nr_calls);
761761
wait_var_event(&rxnet->nr_calls, !atomic_read(&rxnet->nr_calls));
762762
}
763+
764+
/**
765+
* rxrpc_kernel_query_call_security - Query call's security parameters
766+
* @call: The call to query
767+
* @_service_id: Where to return the service ID
768+
* @_enctype: Where to return the "encoding type"
769+
*
770+
* This queries the security parameters of a call, setting *@_service_id and
771+
* *@_enctype and returning the security class.
772+
*
773+
* Return: The security class protocol number.
774+
*/
775+
u8 rxrpc_kernel_query_call_security(struct rxrpc_call *call,
776+
u16 *_service_id, u32 *_enctype)
777+
{
778+
*_service_id = call->dest_srx.srx_service;
779+
*_enctype = call->security_enctype;
780+
return call->security_ix;
781+
}
782+
EXPORT_SYMBOL(rxrpc_kernel_query_call_security);

net/rxrpc/rxgk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ static int rxgk_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
443443
if (ret < 0)
444444
return ret;
445445

446+
call->security_enctype = gk->krb5->etype;
446447
txb->cksum = htons(gk->key_number);
447448

448449
switch (call->conn->security_level) {
@@ -590,6 +591,7 @@ static int rxgk_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
590591
}
591592
}
592593

594+
call->security_enctype = gk->krb5->etype;
593595
switch (call->conn->security_level) {
594596
case RXRPC_SECURITY_PLAIN:
595597
return 0;

0 commit comments

Comments
 (0)