]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rxrpc: Display security params in the afs_cb_call tracepoint
authorDavid Howells <dhowells@redhat.com>
Fri, 11 Apr 2025 09:52:56 +0000 (10:52 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 15 Apr 2025 00:36:42 +0000 (17:36 -0700)
Make the afs_cb_call tracepoint display some security parameters to make
debugging easier.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
Link: https://patch.msgid.link/20250411095303.2316168-12-dhowells@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/rxrpc.rst
fs/afs/internal.h
fs/afs/rxrpc.c
include/net/af_rxrpc.h
include/trace/events/afs.h
net/rxrpc/ar-internal.h
net/rxrpc/call_object.c
net/rxrpc/rxgk.c

index a01f0c81ca4b28fe42a572d6f337c42bdf9c66f1..fe2ea73be4417d934c0bd49d1d9ccced7c69e64b 100644 (file)
@@ -1178,6 +1178,7 @@ API Function Reference
 ======================
 
 .. kernel-doc:: net/rxrpc/af_rxrpc.c
+.. kernel-doc:: net/rxrpc/call_object.c
 .. kernel-doc:: net/rxrpc/key.c
 .. kernel-doc:: net/rxrpc/oob.c
 .. kernel-doc:: net/rxrpc/peer_object.c
index b3612b700c6a1f063eb494598dd754fa31c4b2f3..178804817efbfe014f91693eb1627790fa3b1d41 100644 (file)
@@ -176,8 +176,10 @@ struct afs_call {
        bool                    intr;           /* T if interruptible */
        bool                    unmarshalling_error; /* T if an unmarshalling error occurred */
        bool                    responded;      /* Got a response from the call (may be abort) */
+       u8                      security_ix;    /* Security class */
        u16                     service_id;     /* Actual service ID (after upgrade) */
        unsigned int            debug_id;       /* Trace ID */
+       u32                     enctype;        /* Security encoding type */
        u32                     operation_ID;   /* operation ID for an incoming call */
        u32                     count;          /* count for use in unmarshalling */
        union {                                 /* place to extract temporary data */
index 212af2aa85bf4d9c555b4884c87f0bfac6da5f3e..00b3bc087f61ffa00a037972d5ab3f5109aab594 100644 (file)
@@ -813,6 +813,10 @@ static int afs_deliver_cm_op_id(struct afs_call *call)
        if (!afs_cm_incoming_call(call))
                return -ENOTSUPP;
 
+       call->security_ix = rxrpc_kernel_query_call_security(call->rxcall,
+                                                            &call->service_id,
+                                                            &call->enctype);
+
        trace_afs_cb_call(call);
        call->work.func = call->type->work;
 
index 0b209f703ffc1c7d36d0784fc442719eb6bb368d..f15341594cc8fd8411fbcd2213a9d20c9d4d9811 100644 (file)
@@ -112,5 +112,7 @@ int rxkad_kernel_respond_to_challenge(struct sk_buff *challenge);
 u32 rxgk_kernel_query_challenge(struct sk_buff *challenge);
 int rxgk_kernel_respond_to_challenge(struct sk_buff *challenge,
                                     struct krb5_buffer *appdata);
+u8 rxrpc_kernel_query_call_security(struct rxrpc_call *call,
+                                   u16 *_service_id, u32 *_enctype);
 
 #endif /* _NET_RXRPC_H */
index 8857f5ea77d4807e55820745bdbfc1dfc1c5d43c..7f83d242c8e9f83a5dafb938aa3326bba3cdc8d0 100644 (file)
@@ -663,19 +663,26 @@ TRACE_EVENT(afs_cb_call,
                    __field(unsigned int,               call)
                    __field(u32,                        op)
                    __field(u16,                        service_id)
+                   __field(u8,                         security_ix)
+                   __field(u32,                        enctype)
                             ),
 
            TP_fast_assign(
                    __entry->call       = call->debug_id;
                    __entry->op         = call->operation_ID;
                    __entry->service_id = call->service_id;
+                   __entry->security_ix = call->security_ix;
+                   __entry->enctype    = call->enctype;
                           ),
 
-           TP_printk("c=%08x %s",
+           TP_printk("c=%08x %s sv=%u sx=%u en=%u",
                      __entry->call,
                      __entry->service_id == 2501 ?
                      __print_symbolic(__entry->op, yfs_cm_operations) :
-                     __print_symbolic(__entry->op, afs_cm_operations))
+                     __print_symbolic(__entry->op, afs_cm_operations),
+                     __entry->service_id,
+                     __entry->security_ix,
+                     __entry->enctype)
            );
 
 TRACE_EVENT(afs_call,
index fd235bfa226d7231d5bfa6d34b8c2817b6bd3dc3..ca62a1db32866fdcf00a5248288d785ffb2cec81 100644 (file)
@@ -740,6 +740,7 @@ struct rxrpc_call {
        u32                     call_id;        /* call ID on connection  */
        u32                     cid;            /* connection ID plus channel index */
        u32                     security_level; /* Security level selected */
+       u32                     security_enctype; /* Security-specific encoding type (or 0) */
        int                     debug_id;       /* debug ID for printks */
        unsigned short          rx_pkt_offset;  /* Current recvmsg packet offset */
        unsigned short          rx_pkt_len;     /* Current recvmsg packet len */
index fc88ffe1b0503680fbd9c8cade7f4a3ac80ce304..e9e8f0ef3fd58ef01bfc3ee12eda618662df91c0 100644 (file)
@@ -760,3 +760,23 @@ void rxrpc_destroy_all_calls(struct rxrpc_net *rxnet)
        atomic_dec(&rxnet->nr_calls);
        wait_var_event(&rxnet->nr_calls, !atomic_read(&rxnet->nr_calls));
 }
+
+/**
+ * rxrpc_kernel_query_call_security - Query call's security parameters
+ * @call: The call to query
+ * @_service_id: Where to return the service ID
+ * @_enctype: Where to return the "encoding type"
+ *
+ * This queries the security parameters of a call, setting *@_service_id and
+ * *@_enctype and returning the security class.
+ *
+ * Return: The security class protocol number.
+ */
+u8 rxrpc_kernel_query_call_security(struct rxrpc_call *call,
+                                   u16 *_service_id, u32 *_enctype)
+{
+       *_service_id = call->dest_srx.srx_service;
+       *_enctype = call->security_enctype;
+       return call->security_ix;
+}
+EXPORT_SYMBOL(rxrpc_kernel_query_call_security);
index 8b1ccdf8bc58e89c38a2344fdc52289f2609cb6f..6175fc54ba90a2238b9afd5475ff1cebb90596c4 100644 (file)
@@ -443,6 +443,7 @@ static int rxgk_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
        if (ret < 0)
                return ret;
 
+       call->security_enctype = gk->krb5->etype;
        txb->cksum = htons(gk->key_number);
 
        switch (call->conn->security_level) {
@@ -590,6 +591,7 @@ static int rxgk_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
                }
        }
 
+       call->security_enctype = gk->krb5->etype;
        switch (call->conn->security_level) {
        case RXRPC_SECURITY_PLAIN:
                return 0;