History

rxrpc: Trace protocol errors in received packets

Add a tracepoint (rxrpc_rx_proto) to record protocol errors in received packets. The following changes are made: (1) Add a function, __rxrpc_abort_eproto(), to note a protocol error on a call and mark the call aborted. This is wrapped by rxrpc_abort_eproto() that makes the why string usable in trace. (2) Add trace_rxrpc_rx_proto() or rxrpc_abort_eproto() to protocol error generation points, replacing rxrpc_abort_call() with the latter. (3) Only send an abort packet in rxkad_verify_packet*() if we actually managed to abort the call. Note that a trace event is also emitted if a kernel user (e.g. afs) tries to send data through a call when it's not in the transmission phase, though it's not technically a receive event.

David Howells committed 9 years ago

Commit fb46f6e1 parent ef686228 files · +138 −40Browse files

Unified · Split

8 files
  1. include/trace/events/rxrpc.h +24 −0
  2. net/rxrpc/ar-internal.h +19 −0
  3. net/rxrpc/conn_event.c +6 −3
  4. net/rxrpc/input.c +4 −1
  5. net/rxrpc/insecure.c +8 −2
  6. net/rxrpc/recvmsg.c +2 −0
  7. net/rxrpc/rxkad.c +73 −33
  8. net/rxrpc/sendmsg.c +2 −1
include/trace/events/rxrpc.h+24−0
@@ -1087,6 +1087,30 @@ TRACE_EVENT(rxrpc_improper_term, · 1086 unmodified lines
1087 __entry->abort_code)1087 __entry->abort_code)
1088 );1088 );
1089 1089
1090TRACE_EVENT(rxrpc_rx_eproto,
1091 TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
1092 const char *why),
1093
1094 TP_ARGS(call, serial, why),
1095
1096 TP_STRUCT__entry(
1097 __field(struct rxrpc_call *, call )
1098 __field(rxrpc_serial_t, serial )
1099 __field(const char *, why )
1100 ),
1101
1102 TP_fast_assign(
1103 __entry->call = call;
1104 __entry->serial = serial;
1105 __entry->why = why;
1106 ),
1107
1108 TP_printk("c=%p EPROTO %08x %s",
1109 __entry->call,
1110 __entry->serial,
1111 __entry->why)
1112 );
1113
1090#endif /* _TRACE_RXRPC_H */1114#endif /* _TRACE_RXRPC_H */
1091 1115
1092/* This part must be outside protection */1116/* This part must be outside protection */
net/rxrpc/ar-internal.h+19−0
@@ -739,6 +739,25 @@ static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call, · 738 unmodified lines
739 return ret;739 return ret;
740}740}
741 741
742/*
743 * Abort a call due to a protocol error.
744 */
745static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call,
746 struct sk_buff *skb,
747 const char *eproto_why,
748 const char *why,
749 u32 abort_code)
750{
751 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
752
753 trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why);
754 return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO);
755}
756
757#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \
758 __rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \
759 (abort_why), (abort_code))
760
742/*761/*
743 * conn_client.c762 * conn_client.c
744 */763 */
net/rxrpc/conn_event.c+6−3
@@ -281,8 +281,11 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, · 280 unmodified lines
281 281
282 case RXRPC_PACKET_TYPE_ABORT:282 case RXRPC_PACKET_TYPE_ABORT:
283 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),283 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
284 &wtmp, sizeof(wtmp)) < 0)284 &wtmp, sizeof(wtmp)) < 0) {
285 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
286 tracepoint_string("bad_abort"));
285 return -EPROTO;287 return -EPROTO;
288 }
286 abort_code = ntohl(wtmp);289 abort_code = ntohl(wtmp);
287 _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);290 _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
288 291
@@ -327,7 +330,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, · 38 unmodified lines
327 return 0;330 return 0;
328 331
329 default:332 default:
330 _leave(" = -EPROTO [%u]", sp->hdr.type);333 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
334 tracepoint_string("bad_conn_pkt"));
331 return -EPROTO;335 return -EPROTO;
332 }336 }
333}337}
@@ -422,6 +426,5 @@ protocol_error: · 88 unmodified lines
422 if (rxrpc_abort_connection(conn, ret, abort_code) < 0)426 if (rxrpc_abort_connection(conn, ret, abort_code) < 0)
423 goto requeue_and_leave;427 goto requeue_and_leave;
424 rxrpc_free_skb(skb, rxrpc_skb_rx_freed);428 rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
425 _leave(" [EPROTO]");
426 goto out;429 goto out;
427}430}
net/rxrpc/input.c+4−1
@@ -1017,8 +1017,11 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb) · 1016 unmodified lines
1017 struct rxrpc_wire_header whdr;1017 struct rxrpc_wire_header whdr;
1018 1018
1019 /* dig out the RxRPC connection details */1019 /* dig out the RxRPC connection details */
1020 if (skb_copy_bits(skb, 0, &whdr, sizeof(whdr)) < 0)1020 if (skb_copy_bits(skb, 0, &whdr, sizeof(whdr)) < 0) {
1021 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
1022 tracepoint_string("bad_hdr"));
1021 return -EBADMSG;1023 return -EBADMSG;
1024 }
1022 1025
1023 memset(sp, 0, sizeof(*sp));1026 memset(sp, 0, sizeof(*sp));
1024 sp->hdr.epoch = ntohl(whdr.epoch);1027 sp->hdr.epoch = ntohl(whdr.epoch);
net/rxrpc/insecure.c+8−2
@@ -46,7 +46,10 @@ static int none_respond_to_challenge(struct rxrpc_connection *conn, · 45 unmodified lines
46 struct sk_buff *skb,46 struct sk_buff *skb,
47 u32 *_abort_code)47 u32 *_abort_code)
48{48{
49 *_abort_code = RX_PROTOCOL_ERROR;49 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
50
51 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
52 tracepoint_string("chall_none"));
50 return -EPROTO;53 return -EPROTO;
51}54}
52 55
@@ -54,7 +57,10 @@ static int none_verify_response(struct rxrpc_connection *conn, · 1 unmodified line
54 struct sk_buff *skb,57 struct sk_buff *skb,
55 u32 *_abort_code)58 u32 *_abort_code)
56{59{
57 *_abort_code = RX_PROTOCOL_ERROR;60 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
61
62 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
63 tracepoint_string("resp_none"));
58 return -EPROTO;64 return -EPROTO;
59}65}
60 66
net/rxrpc/recvmsg.c+2−0
@@ -682,9 +682,11 @@ out: · 681 unmodified lines
682 return ret;682 return ret;
683 683
684short_data:684short_data:
685 trace_rxrpc_rx_eproto(call, 0, tracepoint_string("short_data"));
685 ret = -EBADMSG;686 ret = -EBADMSG;
686 goto out;687 goto out;
687excess_data:688excess_data:
689 trace_rxrpc_rx_eproto(call, 0, tracepoint_string("excess_data"));
688 ret = -EMSGSIZE;690 ret = -EMSGSIZE;
689 goto out;691 goto out;
690call_complete:692call_complete:
net/rxrpc/rxkad.c+73−33
@@ -148,15 +148,13 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call, · 147 unmodified lines
148 u32 data_size,148 u32 data_size,
149 void *sechdr)149 void *sechdr)
150{150{
151 struct rxrpc_skb_priv *sp;151 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
152 SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher);152 SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher);
153 struct rxkad_level1_hdr hdr;153 struct rxkad_level1_hdr hdr;
154 struct rxrpc_crypt iv;154 struct rxrpc_crypt iv;
155 struct scatterlist sg;155 struct scatterlist sg;
156 u16 check;156 u16 check;
157 157
158 sp = rxrpc_skb(skb);
159
160 _enter("");158 _enter("");
161 159
162 check = sp->hdr.seq ^ call->call_id;160 check = sp->hdr.seq ^ call->call_id;
@@ -323,6 +321,7 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, · 160 unmodified lines
323 struct rxrpc_crypt iv;321 struct rxrpc_crypt iv;
324 struct scatterlist sg[16];322 struct scatterlist sg[16];
325 struct sk_buff *trailer;323 struct sk_buff *trailer;
324 bool aborted;
326 u32 data_size, buf;325 u32 data_size, buf;
327 u16 check;326 u16 check;
328 int nsg;327 int nsg;
@@ -330,7 +329,8 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, · 1 unmodified line
330 _enter("");329 _enter("");
331 330
332 if (len < 8) {331 if (len < 8) {
333 rxrpc_abort_call("V1H", call, seq, RXKADSEALEDINCON, -EPROTO);332 aborted = rxrpc_abort_eproto(call, skb, "rxkad_1_hdr", "V1H",
333 RXKADSEALEDINCON);
334 goto protocol_error;334 goto protocol_error;
335 }335 }
336 336
@@ -355,7 +355,8 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, · 18 unmodified lines
355 355
356 /* Extract the decrypted packet length */356 /* Extract the decrypted packet length */
357 if (skb_copy_bits(skb, offset, &sechdr, sizeof(sechdr)) < 0) {357 if (skb_copy_bits(skb, offset, &sechdr, sizeof(sechdr)) < 0) {
358 rxrpc_abort_call("XV1", call, seq, RXKADDATALEN, -EPROTO);358 aborted = rxrpc_abort_eproto(call, skb, "rxkad_1_len", "XV1",
359 RXKADDATALEN);
359 goto protocol_error;360 goto protocol_error;
360 }361 }
361 offset += sizeof(sechdr);362 offset += sizeof(sechdr);
@@ -368,12 +369,14 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, · 6 unmodified lines
368 check ^= seq ^ call->call_id;369 check ^= seq ^ call->call_id;
369 check &= 0xffff;370 check &= 0xffff;
370 if (check != 0) {371 if (check != 0) {
371 rxrpc_abort_call("V1C", call, seq, RXKADSEALEDINCON, -EPROTO);372 aborted = rxrpc_abort_eproto(call, skb, "rxkad_1_check", "V1C",
373 RXKADSEALEDINCON);
372 goto protocol_error;374 goto protocol_error;
373 }375 }
374 376
375 if (data_size > len) {377 if (data_size > len) {
376 rxrpc_abort_call("V1L", call, seq, RXKADDATALEN, -EPROTO);378 aborted = rxrpc_abort_eproto(call, skb, "rxkad_1_datalen", "V1L",
379 RXKADDATALEN);
377 goto protocol_error;380 goto protocol_error;
378 }381 }
379 382
@@ -381,8 +384,8 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, · 1 unmodified line
381 return 0;384 return 0;
382 385
383protocol_error:386protocol_error:
384 rxrpc_send_abort_packet(call);387 if (aborted)
385 _leave(" = -EPROTO");388 rxrpc_send_abort_packet(call);
386 return -EPROTO;389 return -EPROTO;
387 390
388nomem:391nomem:
@@ -403,6 +406,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, · 14 unmodified lines
403 struct rxrpc_crypt iv;406 struct rxrpc_crypt iv;
404 struct scatterlist _sg[4], *sg;407 struct scatterlist _sg[4], *sg;
405 struct sk_buff *trailer;408 struct sk_buff *trailer;
409 bool aborted;
406 u32 data_size, buf;410 u32 data_size, buf;
407 u16 check;411 u16 check;
408 int nsg;412 int nsg;
@@ -410,7 +414,8 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, · 1 unmodified line
410 _enter(",{%d}", skb->len);414 _enter(",{%d}", skb->len);
411 415
412 if (len < 8) {416 if (len < 8) {
413 rxrpc_abort_call("V2H", call, seq, RXKADSEALEDINCON, -EPROTO);417 aborted = rxrpc_abort_eproto(call, skb, "rxkad_2_hdr", "V2H",
418 RXKADSEALEDINCON);
414 goto protocol_error;419 goto protocol_error;
415 }420 }
416 421
@@ -445,7 +450,8 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, · 28 unmodified lines
445 450
446 /* Extract the decrypted packet length */451 /* Extract the decrypted packet length */
447 if (skb_copy_bits(skb, offset, &sechdr, sizeof(sechdr)) < 0) {452 if (skb_copy_bits(skb, offset, &sechdr, sizeof(sechdr)) < 0) {
448 rxrpc_abort_call("XV2", call, seq, RXKADDATALEN, -EPROTO);453 aborted = rxrpc_abort_eproto(call, skb, "rxkad_2_len", "XV2",
454 RXKADDATALEN);
449 goto protocol_error;455 goto protocol_error;
450 }456 }
451 offset += sizeof(sechdr);457 offset += sizeof(sechdr);
@@ -458,12 +464,14 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, · 6 unmodified lines
458 check ^= seq ^ call->call_id;464 check ^= seq ^ call->call_id;
459 check &= 0xffff;465 check &= 0xffff;
460 if (check != 0) {466 if (check != 0) {
461 rxrpc_abort_call("V2C", call, seq, RXKADSEALEDINCON, -EPROTO);467 aborted = rxrpc_abort_eproto(call, skb, "rxkad_2_check", "V2C",
468 RXKADSEALEDINCON);
462 goto protocol_error;469 goto protocol_error;
463 }470 }
464 471
465 if (data_size > len) {472 if (data_size > len) {
466 rxrpc_abort_call("V2L", call, seq, RXKADDATALEN, -EPROTO);473 aborted = rxrpc_abort_eproto(call, skb, "rxkad_2_datalen", "V2L",
474 RXKADDATALEN);
467 goto protocol_error;475 goto protocol_error;
468 }476 }
469 477
@@ -471,8 +479,8 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, · 1 unmodified line
471 return 0;479 return 0;
472 480
473protocol_error:481protocol_error:
474 rxrpc_send_abort_packet(call);482 if (aborted)
475 _leave(" = -EPROTO");483 rxrpc_send_abort_packet(call);
476 return -EPROTO;484 return -EPROTO;
477 485
478nomem:486nomem:
@@ -491,6 +499,7 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb, · 12 unmodified lines
491 SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher);499 SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher);
492 struct rxrpc_crypt iv;500 struct rxrpc_crypt iv;
493 struct scatterlist sg;501 struct scatterlist sg;
502 bool aborted;
494 u16 cksum;503 u16 cksum;
495 u32 x, y;504 u32 x, y;
496 505
@@ -522,10 +531,9 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb, · 25 unmodified lines
522 cksum = 1; /* zero checksums are not permitted */531 cksum = 1; /* zero checksums are not permitted */
523 532
524 if (cksum != expected_cksum) {533 if (cksum != expected_cksum) {
525 rxrpc_abort_call("VCK", call, seq, RXKADSEALEDINCON, -EPROTO);534 aborted = rxrpc_abort_eproto(call, skb, "rxkad_csum", "VCK",
526 rxrpc_send_abort_packet(call);535 RXKADSEALEDINCON);
527 _leave(" = -EPROTO [csum failed]");536 goto protocol_error;
528 return -EPROTO;
529 }537 }
530 538
531 switch (call->conn->params.security_level) {539 switch (call->conn->params.security_level) {
@@ -538,6 +546,11 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb, · 6 unmodified lines
538 default:546 default:
539 return -ENOANO;547 return -ENOANO;
540 }548 }
549
550protocol_error:
551 if (aborted)
552 rxrpc_send_abort_packet(call);
553 return -EPROTO;
541}554}
542 555
543/*556/*
@@ -754,11 +767,13 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, · 210 unmodified lines
754 struct rxkad_response resp767 struct rxkad_response resp
755 __attribute__((aligned(8))); /* must be aligned for crypto */768 __attribute__((aligned(8))); /* must be aligned for crypto */
756 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);769 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
770 const char *eproto;
757 u32 version, nonce, min_level, abort_code;771 u32 version, nonce, min_level, abort_code;
758 int ret;772 int ret;
759 773
760 _enter("{%d,%x}", conn->debug_id, key_serial(conn->params.key));774 _enter("{%d,%x}", conn->debug_id, key_serial(conn->params.key));
761 775
776 eproto = tracepoint_string("chall_no_key");
762 abort_code = RX_PROTOCOL_ERROR;777 abort_code = RX_PROTOCOL_ERROR;
763 if (!conn->params.key)778 if (!conn->params.key)
764 goto protocol_error;779 goto protocol_error;
@@ -768,6 +783,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, · 3 unmodified lines
768 if (ret < 0)783 if (ret < 0)
769 goto other_error;784 goto other_error;
770 785
786 eproto = tracepoint_string("chall_short");
771 abort_code = RXKADPACKETSHORT;787 abort_code = RXKADPACKETSHORT;
772 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),788 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
773 &challenge, sizeof(challenge)) < 0)789 &challenge, sizeof(challenge)) < 0)
@@ -780,6 +796,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, · 6 unmodified lines
780 _proto("Rx CHALLENGE %%%u { v=%u n=%u ml=%u }",796 _proto("Rx CHALLENGE %%%u { v=%u n=%u ml=%u }",
781 sp->hdr.serial, version, nonce, min_level);797 sp->hdr.serial, version, nonce, min_level);
782 798
799 eproto = tracepoint_string("chall_ver");
783 abort_code = RXKADINCONSISTENCY;800 abort_code = RXKADINCONSISTENCY;
784 if (version != RXKAD_VERSION)801 if (version != RXKAD_VERSION)
785 goto protocol_error;802 goto protocol_error;
@@ -814,6 +831,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, · 28 unmodified lines
814 return rxkad_send_response(conn, &sp->hdr, &resp, token->kad);831 return rxkad_send_response(conn, &sp->hdr, &resp, token->kad);
815 832
816protocol_error:833protocol_error:
834 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial, eproto);
817 ret = -EPROTO;835 ret = -EPROTO;
818other_error:836other_error:
819 *_abort_code = abort_code;837 *_abort_code = abort_code;
@@ -824,19 +842,23 @@ other_error: · 4 unmodified lines
824 * decrypt the kerberos IV ticket in the response842 * decrypt the kerberos IV ticket in the response
825 */843 */
826static int rxkad_decrypt_ticket(struct rxrpc_connection *conn,844static int rxkad_decrypt_ticket(struct rxrpc_connection *conn,
845 struct sk_buff *skb,
827 void *ticket, size_t ticket_len,846 void *ticket, size_t ticket_len,
828 struct rxrpc_crypt *_session_key,847 struct rxrpc_crypt *_session_key,
829 time_t *_expiry,848 time_t *_expiry,
830 u32 *_abort_code)849 u32 *_abort_code)
831{850{
832 struct skcipher_request *req;851 struct skcipher_request *req;
852 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
833 struct rxrpc_crypt iv, key;853 struct rxrpc_crypt iv, key;
834 struct scatterlist sg[1];854 struct scatterlist sg[1];
835 struct in_addr addr;855 struct in_addr addr;
836 unsigned int life;856 unsigned int life;
857 const char *eproto;
837 time_t issue, now;858 time_t issue, now;
838 bool little_endian;859 bool little_endian;
839 int ret;860 int ret;
861 u32 abort_code;
840 u8 *p, *q, *name, *end;862 u8 *p, *q, *name, *end;
841 863
842 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->server_key));864 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->server_key));
@@ -847,10 +869,10 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, · 4 unmodified lines
847 if (ret < 0) {869 if (ret < 0) {
848 switch (ret) {870 switch (ret) {
849 case -EKEYEXPIRED:871 case -EKEYEXPIRED:
850 *_abort_code = RXKADEXPIRED;872 abort_code = RXKADEXPIRED;
851 goto other_error;873 goto other_error;
852 default:874 default:
853 *_abort_code = RXKADNOAUTH;875 abort_code = RXKADNOAUTH;
854 goto other_error;876 goto other_error;
855 }877 }
856 }878 }
@@ -875,11 +897,12 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, · 18 unmodified lines
875 p = ticket;897 p = ticket;
876 end = p + ticket_len;898 end = p + ticket_len;
877 899
878#define Z(size) \900#define Z(field) \
879 ({ \901 ({ \
880 u8 *__str = p; \902 u8 *__str = p; \
903 eproto = tracepoint_string("rxkad_bad_"#field); \
881 q = memchr(p, 0, end - p); \904 q = memchr(p, 0, end - p); \
882 if (!q || q - p > (size)) \905 if (!q || q - p > (field##_SZ)) \
883 goto bad_ticket; \906 goto bad_ticket; \
884 for (; p < q; p++) \907 for (; p < q; p++) \
885 if (!isprint(*p)) \908 if (!isprint(*p)) \
@@ -894,17 +917,18 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, · 8 unmodified lines
894 p++;917 p++;
895 918
896 /* extract the authentication name */919 /* extract the authentication name */
897 name = Z(ANAME_SZ);920 name = Z(ANAME);
898 _debug("KIV ANAME: %s", name);921 _debug("KIV ANAME: %s", name);
899 922
900 /* extract the principal's instance */923 /* extract the principal's instance */
901 name = Z(INST_SZ);924 name = Z(INST);
902 _debug("KIV INST : %s", name);925 _debug("KIV INST : %s", name);
903 926
904 /* extract the principal's authentication domain */927 /* extract the principal's authentication domain */
905 name = Z(REALM_SZ);928 name = Z(REALM);
906 _debug("KIV REALM: %s", name);929 _debug("KIV REALM: %s", name);
907 930
931 eproto = tracepoint_string("rxkad_bad_len");
908 if (end - p < 4 + 8 + 4 + 2)932 if (end - p < 4 + 8 + 4 + 2)
909 goto bad_ticket;933 goto bad_ticket;
910 934
@@ -939,13 +963,13 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, · 28 unmodified lines
939 963
940 /* check the ticket is in date */964 /* check the ticket is in date */
941 if (issue > now) {965 if (issue > now) {
942 *_abort_code = RXKADNOAUTH;966 abort_code = RXKADNOAUTH;
943 ret = -EKEYREJECTED;967 ret = -EKEYREJECTED;
944 goto other_error;968 goto other_error;
945 }969 }
946 970
947 if (issue < now - life) {971 if (issue < now - life) {
948 *_abort_code = RXKADEXPIRED;972 abort_code = RXKADEXPIRED;
949 ret = -EKEYEXPIRED;973 ret = -EKEYEXPIRED;
950 goto other_error;974 goto other_error;
951 }975 }
@@ -953,18 +977,20 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, · 1 unmodified line
953 *_expiry = issue + life;977 *_expiry = issue + life;
954 978
955 /* get the service name */979 /* get the service name */
956 name = Z(SNAME_SZ);980 name = Z(SNAME);
957 _debug("KIV SNAME: %s", name);981 _debug("KIV SNAME: %s", name);
958 982
959 /* get the service instance name */983 /* get the service instance name */
960 name = Z(INST_SZ);984 name = Z(INST);
961 _debug("KIV SINST: %s", name);985 _debug("KIV SINST: %s", name);
962 return 0;986 return 0;
963 987
964bad_ticket:988bad_ticket:
965 *_abort_code = RXKADBADTICKET;989 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial, eproto);
990 abort_code = RXKADBADTICKET;
966 ret = -EPROTO;991 ret = -EPROTO;
967other_error:992other_error:
993 *_abort_code = abort_code;
968 return ret;994 return ret;
969temporary_error:995temporary_error:
970 return ret;996 return ret;
@@ -1017,6 +1043,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 46 unmodified lines
1017 __attribute__((aligned(8))); /* must be aligned for crypto */1043 __attribute__((aligned(8))); /* must be aligned for crypto */
1018 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);1044 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
1019 struct rxrpc_crypt session_key;1045 struct rxrpc_crypt session_key;
1046 const char *eproto;
1020 time_t expiry;1047 time_t expiry;
1021 void *ticket;1048 void *ticket;
1022 u32 abort_code, version, kvno, ticket_len, level;1049 u32 abort_code, version, kvno, ticket_len, level;
@@ -1025,6 +1052,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 2 unmodified lines
1025 1052
1026 _enter("{%d,%x}", conn->debug_id, key_serial(conn->server_key));1053 _enter("{%d,%x}", conn->debug_id, key_serial(conn->server_key));
1027 1054
1055 eproto = tracepoint_string("rxkad_rsp_short");
1028 abort_code = RXKADPACKETSHORT;1056 abort_code = RXKADPACKETSHORT;
1029 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),1057 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
1030 &response, sizeof(response)) < 0)1058 &response, sizeof(response)) < 0)
@@ -1038,14 +1066,17 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 7 unmodified lines
1038 _proto("Rx RESPONSE %%%u { v=%u kv=%u tl=%u }",1066 _proto("Rx RESPONSE %%%u { v=%u kv=%u tl=%u }",
1039 sp->hdr.serial, version, kvno, ticket_len);1067 sp->hdr.serial, version, kvno, ticket_len);
1040 1068
1069 eproto = tracepoint_string("rxkad_rsp_ver");
1041 abort_code = RXKADINCONSISTENCY;1070 abort_code = RXKADINCONSISTENCY;
1042 if (version != RXKAD_VERSION)1071 if (version != RXKAD_VERSION)
1043 goto protocol_error;1072 goto protocol_error;
1044 1073
1074 eproto = tracepoint_string("rxkad_rsp_tktlen");
1045 abort_code = RXKADTICKETLEN;1075 abort_code = RXKADTICKETLEN;
1046 if (ticket_len < 4 || ticket_len > MAXKRB5TICKETLEN)1076 if (ticket_len < 4 || ticket_len > MAXKRB5TICKETLEN)
1047 goto protocol_error;1077 goto protocol_error;
1048 1078
1079 eproto = tracepoint_string("rxkad_rsp_unkkey");
1049 abort_code = RXKADUNKNOWNKEY;1080 abort_code = RXKADUNKNOWNKEY;
1050 if (kvno >= RXKAD_TKT_TYPE_KERBEROS_V5)1081 if (kvno >= RXKAD_TKT_TYPE_KERBEROS_V5)
1051 goto protocol_error;1082 goto protocol_error;
@@ -1056,12 +1087,13 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 4 unmodified lines
1056 if (!ticket)1087 if (!ticket)
1057 goto temporary_error;1088 goto temporary_error;
1058 1089
1090 eproto = tracepoint_string("rxkad_tkt_short");
1059 abort_code = RXKADPACKETSHORT;1091 abort_code = RXKADPACKETSHORT;
1060 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),1092 if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
1061 ticket, ticket_len) < 0)1093 ticket, ticket_len) < 0)
1062 goto protocol_error_free;1094 goto protocol_error_free;
1063 1095
1064 ret = rxkad_decrypt_ticket(conn, ticket, ticket_len, &session_key,1096 ret = rxkad_decrypt_ticket(conn, skb, ticket, ticket_len, &session_key,
1065 &expiry, _abort_code);1097 &expiry, _abort_code);
1066 if (ret < 0)1098 if (ret < 0)
1067 goto temporary_error_free;1099 goto temporary_error_free;
@@ -1070,6 +1102,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 2 unmodified lines
1070 * response */1102 * response */
1071 rxkad_decrypt_response(conn, &response, &session_key);1103 rxkad_decrypt_response(conn, &response, &session_key);
1072 1104
1105 eproto = tracepoint_string("rxkad_rsp_param");
1073 abort_code = RXKADSEALEDINCON;1106 abort_code = RXKADSEALEDINCON;
1074 if (ntohl(response.encrypted.epoch) != conn->proto.epoch)1107 if (ntohl(response.encrypted.epoch) != conn->proto.epoch)
1075 goto protocol_error_free;1108 goto protocol_error_free;
@@ -1080,6 +1113,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 4 unmodified lines
1080 csum = response.encrypted.checksum;1113 csum = response.encrypted.checksum;
1081 response.encrypted.checksum = 0;1114 response.encrypted.checksum = 0;
1082 rxkad_calc_response_checksum(&response);1115 rxkad_calc_response_checksum(&response);
1116 eproto = tracepoint_string("rxkad_rsp_csum");
1083 if (response.encrypted.checksum != csum)1117 if (response.encrypted.checksum != csum)
1084 goto protocol_error_free;1118 goto protocol_error_free;
1085 1119
@@ -1088,11 +1122,15 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 2 unmodified lines
1088 struct rxrpc_call *call;1122 struct rxrpc_call *call;
1089 u32 call_id = ntohl(response.encrypted.call_id[i]);1123 u32 call_id = ntohl(response.encrypted.call_id[i]);
1090 1124
1125 eproto = tracepoint_string("rxkad_rsp_callid");
1091 if (call_id > INT_MAX)1126 if (call_id > INT_MAX)
1092 goto protocol_error_unlock;1127 goto protocol_error_unlock;
1093 1128
1129 eproto = tracepoint_string("rxkad_rsp_callctr");
1094 if (call_id < conn->channels[i].call_counter)1130 if (call_id < conn->channels[i].call_counter)
1095 goto protocol_error_unlock;1131 goto protocol_error_unlock;
1132
1133 eproto = tracepoint_string("rxkad_rsp_callst");
1096 if (call_id > conn->channels[i].call_counter) {1134 if (call_id > conn->channels[i].call_counter) {
1097 call = rcu_dereference_protected(1135 call = rcu_dereference_protected(
1098 conn->channels[i].call,1136 conn->channels[i].call,
@@ -1104,10 +1142,12 @@ static int rxkad_verify_response(struct rxrpc_connection *conn, · 5 unmodified lines
1104 }1142 }
1105 spin_unlock(&conn->channel_lock);1143 spin_unlock(&conn->channel_lock);
1106 1144
1145 eproto = tracepoint_string("rxkad_rsp_seq");
1107 abort_code = RXKADOUTOFSEQUENCE;1146 abort_code = RXKADOUTOFSEQUENCE;
1108 if (ntohl(response.encrypted.inc_nonce) != conn->security_nonce + 1)1147 if (ntohl(response.encrypted.inc_nonce) != conn->security_nonce + 1)
1109 goto protocol_error_free;1148 goto protocol_error_free;
1110 1149
1150 eproto = tracepoint_string("rxkad_rsp_level");
1111 abort_code = RXKADLEVELFAIL;1151 abort_code = RXKADLEVELFAIL;
1112 level = ntohl(response.encrypted.level);1152 level = ntohl(response.encrypted.level);
1113 if (level > RXRPC_SECURITY_ENCRYPT)1153 if (level > RXRPC_SECURITY_ENCRYPT)
@@ -1130,8 +1170,8 @@ protocol_error_unlock: · 16 unmodified lines
1130protocol_error_free:1170protocol_error_free:
1131 kfree(ticket);1171 kfree(ticket);
1132protocol_error:1172protocol_error:
1173 trace_rxrpc_rx_eproto(NULL, sp->hdr.serial, eproto);
1133 *_abort_code = abort_code;1174 *_abort_code = abort_code;
1134 _leave(" = -EPROTO [%d]", abort_code);
1135 return -EPROTO;1175 return -EPROTO;
1136 1176
1137temporary_error_free:1177temporary_error_free:
net/rxrpc/sendmsg.c+2−1
@@ -623,7 +623,8 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, · 622 unmodified lines
623 read_unlock_bh(&call->state_lock);623 read_unlock_bh(&call->state_lock);
624 break;624 break;
625 default:625 default:
626 /* Request phase complete for this client call */626 /* Request phase complete for this client call */
627 trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send"));
627 ret = -EPROTO;628 ret = -EPROTO;
628 break;629 break;
629 }630 }