Skip to content

Commit 9d1d2b5

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI)
Implement the basic parts of the yfs-rxgk security class (security index 6) to support GSSAPI-negotiated security. Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Herbert Xu <[email protected]> cc: Chuck Lever <[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 c86f9b9 commit 9d1d2b5

File tree

12 files changed

+1694
-5
lines changed

12 files changed

+1694
-5
lines changed

Documentation/networking/rxrpc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ API Function Reference
11821182
.. kernel-doc:: net/rxrpc/oob.c
11831183
.. kernel-doc:: net/rxrpc/peer_object.c
11841184
.. kernel-doc:: net/rxrpc/recvmsg.c
1185+
.. kernel-doc:: net/rxrpc/rxgk.c
11851186
.. kernel-doc:: net/rxrpc/rxkad.c
11861187
.. kernel-doc:: net/rxrpc/sendmsg.c
11871188
.. kernel-doc:: net/rxrpc/server_key.c

fs/afs/cm_security.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/slab.h>
9+
#include <crypto/krb5.h>
910
#include "internal.h"
1011
#include "afs_fs.h"
1112
#include "protocol_yfs.h"
@@ -17,6 +18,9 @@
1718
*/
1819
static int afs_respond_to_challenge(struct sk_buff *challenge)
1920
{
21+
#ifdef CONFIG_RXGK
22+
struct krb5_buffer appdata = {};
23+
#endif
2024
struct rxrpc_peer *peer;
2125
unsigned long peer_data;
2226
u16 service_id;
@@ -44,8 +48,16 @@ static int afs_respond_to_challenge(struct sk_buff *challenge)
4448
}
4549

4650
switch (security_index) {
51+
#ifdef CONFIG_RXKAD
4752
case RXRPC_SECURITY_RXKAD:
4853
return rxkad_kernel_respond_to_challenge(challenge);
54+
#endif
55+
56+
#ifdef CONFIG_RXGK
57+
case RXRPC_SECURITY_RXGK:
58+
case RXRPC_SECURITY_YFS_RXGK:
59+
return rxgk_kernel_respond_to_challenge(challenge, &appdata);
60+
#endif
4961

5062
default:
5163
return rxrpc_kernel_reject_challenge(challenge, RX_USER_ABORT, -EPROTO,

include/trace/events/rxrpc.h

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@
6969
EM(rxkad_abort_resp_tkt_sname, "rxkad-resp-tk-sname") \
7070
EM(rxkad_abort_resp_unknown_tkt, "rxkad-resp-unknown-tkt") \
7171
EM(rxkad_abort_resp_version, "rxkad-resp-version") \
72+
/* RxGK security errors */ \
73+
EM(rxgk_abort_1_verify_mic_eproto, "rxgk1-vfy-mic-eproto") \
74+
EM(rxgk_abort_2_decrypt_eproto, "rxgk2-dec-eproto") \
75+
EM(rxgk_abort_2_short_data, "rxgk2-short-data") \
76+
EM(rxgk_abort_2_short_encdata, "rxgk2-short-encdata") \
77+
EM(rxgk_abort_2_short_header, "rxgk2-short-hdr") \
78+
EM(rxgk_abort_bad_key_number, "rxgk-bad-key-num") \
79+
EM(rxgk_abort_chall_key_expired, "rxgk-chall-key-exp") \
80+
EM(rxgk_abort_chall_no_key, "rxgk-chall-nokey") \
81+
EM(rxgk_abort_chall_short, "rxgk-chall-short") \
82+
EM(rxgk_abort_resp_auth_dec, "rxgk-resp-auth-dec") \
83+
EM(rxgk_abort_resp_bad_callid, "rxgk-resp-bad-callid") \
84+
EM(rxgk_abort_resp_bad_nonce, "rxgk-resp-bad-nonce") \
85+
EM(rxgk_abort_resp_bad_param, "rxgk-resp-bad-param") \
86+
EM(rxgk_abort_resp_call_ctr, "rxgk-resp-call-ctr") \
87+
EM(rxgk_abort_resp_call_state, "rxgk-resp-call-state") \
88+
EM(rxgk_abort_resp_internal_error, "rxgk-resp-int-error") \
89+
EM(rxgk_abort_resp_nopkg, "rxgk-resp-nopkg") \
90+
EM(rxgk_abort_resp_short_applen, "rxgk-resp-short-applen") \
91+
EM(rxgk_abort_resp_short_auth, "rxgk-resp-short-auth") \
92+
EM(rxgk_abort_resp_short_call_list, "rxgk-resp-short-callls") \
93+
EM(rxgk_abort_resp_short_packet, "rxgk-resp-short-packet") \
94+
EM(rxgk_abort_resp_short_yfs_klen, "rxgk-resp-short-yfs-klen") \
95+
EM(rxgk_abort_resp_short_yfs_key, "rxgk-resp-short-yfs-key") \
96+
EM(rxgk_abort_resp_short_yfs_tkt, "rxgk-resp-short-yfs-tkt") \
97+
EM(rxgk_abort_resp_tok_dec, "rxgk-resp-tok-dec") \
98+
EM(rxgk_abort_resp_tok_internal_error, "rxgk-resp-tok-int-err") \
99+
EM(rxgk_abort_resp_tok_keyerr, "rxgk-resp-tok-keyerr") \
100+
EM(rxgk_abort_resp_tok_nokey, "rxgk-resp-tok-nokey") \
101+
EM(rxgk_abort_resp_tok_nopkg, "rxgk-resp-tok-nopkg") \
102+
EM(rxgk_abort_resp_tok_short, "rxgk-resp-tok-short") \
103+
EM(rxgk_abort_resp_xdr_align, "rxgk-resp-xdr-align") \
72104
/* rxrpc errors */ \
73105
EM(rxrpc_abort_call_improper_term, "call-improper-term") \
74106
EM(rxrpc_abort_call_reset, "call-reset") \
@@ -471,6 +503,7 @@
471503
EM(rxrpc_tx_point_call_final_resend, "CallFinalResend") \
472504
EM(rxrpc_tx_point_conn_abort, "ConnAbort") \
473505
EM(rxrpc_tx_point_reject, "Reject") \
506+
EM(rxrpc_tx_point_rxgk_challenge, "RxGKChall") \
474507
EM(rxrpc_tx_point_rxkad_challenge, "RxkadChall") \
475508
EM(rxrpc_tx_point_response, "Response") \
476509
EM(rxrpc_tx_point_version_keepalive, "VerKeepalive") \
@@ -489,13 +522,15 @@
489522

490523
#define rxrpc_txbuf_traces \
491524
EM(rxrpc_txbuf_alloc_data, "ALLOC DATA ") \
525+
EM(rxrpc_txbuf_alloc_response, "ALLOC RESP ") \
492526
EM(rxrpc_txbuf_free, "FREE ") \
493527
EM(rxrpc_txbuf_get_buffer, "GET BUFFER ") \
494528
EM(rxrpc_txbuf_get_trans, "GET TRANS ") \
495529
EM(rxrpc_txbuf_get_retrans, "GET RETRANS") \
496530
EM(rxrpc_txbuf_put_cleaned, "PUT CLEANED") \
497531
EM(rxrpc_txbuf_put_nomem, "PUT NOMEM ") \
498532
EM(rxrpc_txbuf_put_rotated, "PUT ROTATED") \
533+
EM(rxrpc_txbuf_put_response_tx, "PUT RESP TX") \
499534
EM(rxrpc_txbuf_put_send_aborted, "PUT SEND-X ") \
500535
EM(rxrpc_txbuf_put_trans, "PUT TRANS ") \
501536
EM(rxrpc_txbuf_see_lost, "SEE LOST ") \
@@ -1178,6 +1213,7 @@ TRACE_EVENT(rxrpc_rx_challenge,
11781213
__field(u32, version)
11791214
__field(u32, nonce)
11801215
__field(u32, min_level)
1216+
__field(u8, security_ix)
11811217
),
11821218

11831219
TP_fast_assign(
@@ -1186,11 +1222,13 @@ TRACE_EVENT(rxrpc_rx_challenge,
11861222
__entry->version = version;
11871223
__entry->nonce = nonce;
11881224
__entry->min_level = min_level;
1225+
__entry->security_ix = conn->security_ix;
11891226
),
11901227

1191-
TP_printk("C=%08x CHALLENGE %08x v=%x n=%x ml=%x",
1228+
TP_printk("C=%08x CHALLENGE r=%08x sx=%u v=%x n=%x ml=%x",
11921229
__entry->conn,
11931230
__entry->serial,
1231+
__entry->security_ix,
11941232
__entry->version,
11951233
__entry->nonce,
11961234
__entry->min_level)
@@ -1208,6 +1246,7 @@ TRACE_EVENT(rxrpc_rx_response,
12081246
__field(u32, version)
12091247
__field(u32, kvno)
12101248
__field(u32, ticket_len)
1249+
__field(u8, security_ix)
12111250
),
12121251

12131252
TP_fast_assign(
@@ -1216,11 +1255,13 @@ TRACE_EVENT(rxrpc_rx_response,
12161255
__entry->version = version;
12171256
__entry->kvno = kvno;
12181257
__entry->ticket_len = ticket_len;
1258+
__entry->security_ix = conn->security_ix;
12191259
),
12201260

1221-
TP_printk("C=%08x RESPONSE %08x v=%x kvno=%x tl=%x",
1261+
TP_printk("C=%08x RESPONSE r=%08x sx=%u v=%x kvno=%x tl=%x",
12221262
__entry->conn,
12231263
__entry->serial,
1264+
__entry->security_ix,
12241265
__entry->version,
12251266
__entry->kvno,
12261267
__entry->ticket_len)

net/rxrpc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ rxrpc-$(CONFIG_PROC_FS) += proc.o
4141
rxrpc-$(CONFIG_RXKAD) += rxkad.o
4242
rxrpc-$(CONFIG_SYSCTL) += sysctl.o
4343
rxrpc-$(CONFIG_RXGK) += \
44+
rxgk.o \
45+
rxgk_app.o \
4446
rxgk_kdf.o
4547

4648
obj-$(CONFIG_RXPERF) += rxperf.o

net/rxrpc/ar-internal.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct key_preparsed_payload;
3131
struct rxrpc_connection;
3232
struct rxrpc_txbuf;
3333
struct rxrpc_txqueue;
34+
struct rxgk_context;
3435

3536
/*
3637
* Mark applied to socket buffers in skb->mark. skb->priority is used
@@ -312,6 +313,11 @@ struct rxrpc_security {
312313

313314
/* clear connection security */
314315
void (*clear)(struct rxrpc_connection *);
316+
317+
/* Default ticket -> key decoder */
318+
int (*default_decode_ticket)(struct rxrpc_connection *conn, struct sk_buff *skb,
319+
unsigned int ticket_offset, unsigned int ticket_len,
320+
struct key **_key);
315321
};
316322

317323
/*
@@ -559,7 +565,10 @@ struct rxrpc_connection {
559565
u32 nonce; /* response re-use preventer */
560566
} rxkad;
561567
struct {
568+
struct rxgk_context *keys[1];
562569
u64 start_time; /* The start time for TK derivation */
570+
u8 nonce[20]; /* Response re-use preventer */
571+
u32 enctype; /* Kerberos 5 encoding type */
563572
} rxgk;
564573
};
565574
struct sk_buff *tx_response; /* Response packet to be transmitted */
@@ -903,6 +912,8 @@ struct rxrpc_txbuf {
903912
unsigned short len; /* Amount of data in buffer */
904913
unsigned short space; /* Remaining data space */
905914
unsigned short offset; /* Offset of fill point */
915+
unsigned short crypto_header; /* Size of crypto header */
916+
unsigned short sec_header; /* Size of security header */
906917
unsigned short pkt_len; /* Size of packet content */
907918
unsigned short alloc_size; /* Amount of bufferage allocated */
908919
unsigned int flags;
@@ -1339,6 +1350,7 @@ int rxrpc_sendmsg_oob(struct rxrpc_sock *rx, struct msghdr *msg, size_t len);
13391350
/*
13401351
* output.c
13411352
*/
1353+
ssize_t do_udp_sendmsg(struct socket *socket, struct msghdr *msg, size_t len);
13421354
void rxrpc_send_ACK(struct rxrpc_call *call, u8 ack_reason,
13431355
rxrpc_serial_t serial, enum rxrpc_propose_ack_trace why);
13441356
void rxrpc_send_probe_for_pmtud(struct rxrpc_call *call);
@@ -1411,6 +1423,11 @@ void rxrpc_call_add_rtt(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,
14111423
ktime_t rxrpc_get_rto_backoff(struct rxrpc_call *call, bool retrans);
14121424
void rxrpc_call_init_rtt(struct rxrpc_call *call);
14131425

1426+
/*
1427+
* rxgk.c
1428+
*/
1429+
extern const struct rxrpc_security rxgk_yfs;
1430+
14141431
/*
14151432
* rxkad.c
14161433
*/

net/rxrpc/output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
extern int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
2020

21-
static ssize_t do_udp_sendmsg(struct socket *socket, struct msghdr *msg, size_t len)
21+
ssize_t do_udp_sendmsg(struct socket *socket, struct msghdr *msg, size_t len)
2222
{
2323
struct sockaddr *sa = msg->msg_name;
2424
struct sock *sk = socket->sk;

net/rxrpc/protocol.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,24 @@ struct rxkad_response {
181181
__be32 ticket_len; /* Kerberos ticket length */
182182
} __packed;
183183

184+
/*
185+
* GSSAPI security type-4 and type-6 data header.
186+
*/
187+
struct rxgk_header {
188+
__be32 epoch;
189+
__be32 cid;
190+
__be32 call_number;
191+
__be32 seq;
192+
__be32 sec_index;
193+
__be32 data_len;
194+
} __packed;
195+
196+
/*
197+
* GSSAPI security type-4 and type-6 response packet header.
198+
*/
199+
struct rxgk_response {
200+
__be64 start_time;
201+
__be32 token_len;
202+
} __packed;
203+
184204
#endif /* _LINUX_RXRPC_PACKET_H */

0 commit comments

Comments
 (0)