| @@ -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 | |
| 383 | protocol_error: | 386 | protocol_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 | |
| 388 | nomem: | 391 | nomem: |
| @@ -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 | |
| 473 | protocol_error: | 481 | protocol_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 | |
| 478 | nomem: | 486 | nomem: |
| @@ -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 | |
| | 550 | protocol_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 resp | 767 | 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 | |
| 816 | protocol_error: | 833 | protocol_error: |
| | 834 | trace_rxrpc_rx_eproto(NULL, sp->hdr.serial, eproto); |
| 817 | ret = -EPROTO; | 835 | ret = -EPROTO; |
| 818 | other_error: | 836 | other_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 response | 842 | * decrypt the kerberos IV ticket in the response |
| 825 | */ | 843 | */ |
| 826 | static int rxkad_decrypt_ticket(struct rxrpc_connection *conn, | 844 | static 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 | |
| 964 | bad_ticket: | 988 | bad_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; |
| 967 | other_error: | 992 | other_error: |
| | 993 | *_abort_code = abort_code; |
| 968 | return ret; | 994 | return ret; |
| 969 | temporary_error: | 995 | temporary_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 |
| 1130 | protocol_error_free: | 1170 | protocol_error_free: |
| 1131 | kfree(ticket); | 1171 | kfree(ticket); |
| 1132 | protocol_error: | 1172 | protocol_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 | |
| 1137 | temporary_error_free: | 1177 | temporary_error_free: |