|
|
38a7f7 |
From ad8e02485791023dcf66ef4612616f03895ceeb3 Mon Sep 17 00:00:00 2001
|
|
|
38a7f7 |
From: Greg Hudson <ghudson@mit.edu>
|
|
|
38a7f7 |
Date: Fri, 4 Mar 2022 00:45:00 -0500
|
|
|
38a7f7 |
Subject: [PATCH] Try harder to avoid password change replay errors
|
|
|
38a7f7 |
|
|
|
38a7f7 |
Commit d7b3018d338fc9c989c3fa17505870f23c3759a8 (ticket 7905) changed
|
|
|
38a7f7 |
change_set_password() to prefer TCP. However, because UDP_LAST falls
|
|
|
38a7f7 |
back to UDP after one second, we can still get a replay error due to a
|
|
|
38a7f7 |
dropped packet, before the TCP layer has a chance to retry.
|
|
|
38a7f7 |
|
|
|
38a7f7 |
Instead, try k5_sendto() with NO_UDP, and only fall back to UDP after
|
|
|
38a7f7 |
TCP fails completely without reaching a server. In sendto_kdc.c,
|
|
|
38a7f7 |
implement an ONLY_UDP transport strategy to allow the UDP fallback.
|
|
|
38a7f7 |
|
|
|
38a7f7 |
ticket: 9037
|
|
|
38a7f7 |
---
|
|
|
38a7f7 |
src/lib/krb5/os/changepw.c | 9 ++++++++-
|
|
|
38a7f7 |
src/lib/krb5/os/os-proto.h | 1 +
|
|
|
38a7f7 |
src/lib/krb5/os/sendto_kdc.c | 12 ++++++++----
|
|
|
38a7f7 |
3 files changed, 17 insertions(+), 5 deletions(-)
|
|
|
38a7f7 |
|
|
|
38a7f7 |
diff --git a/src/lib/krb5/os/changepw.c b/src/lib/krb5/os/changepw.c
|
|
|
38a7f7 |
index 9f968da7f..c59232586 100644
|
|
|
38a7f7 |
--- a/src/lib/krb5/os/changepw.c
|
|
|
38a7f7 |
+++ b/src/lib/krb5/os/changepw.c
|
|
|
38a7f7 |
@@ -255,9 +255,16 @@ change_set_password(krb5_context context,
|
|
|
38a7f7 |
callback_info.pfn_cleanup = kpasswd_sendto_msg_cleanup;
|
|
|
38a7f7 |
krb5_free_data_contents(callback_ctx.context, &chpw_rep);
|
|
|
38a7f7 |
|
|
|
38a7f7 |
+ /* UDP retransmits may be seen as replays. Only try UDP after other
|
|
|
38a7f7 |
+ * transports fail completely. */
|
|
|
38a7f7 |
code = k5_sendto(callback_ctx.context, NULL, &creds->server->realm,
|
|
|
38a7f7 |
- &sl, UDP_LAST, &callback_info, &chpw_rep,
|
|
|
38a7f7 |
+ &sl, NO_UDP, &callback_info, &chpw_rep,
|
|
|
38a7f7 |
ss2sa(&remote_addr), &addrlen, NULL, NULL, NULL);
|
|
|
38a7f7 |
+ if (code == KRB5_KDC_UNREACH) {
|
|
|
38a7f7 |
+ code = k5_sendto(callback_ctx.context, NULL, &creds->server->realm,
|
|
|
38a7f7 |
+ &sl, ONLY_UDP, &callback_info, &chpw_rep,
|
|
|
38a7f7 |
+ ss2sa(&remote_addr), &addrlen, NULL, NULL, NULL);
|
|
|
38a7f7 |
+ }
|
|
|
38a7f7 |
if (code)
|
|
|
38a7f7 |
goto cleanup;
|
|
|
38a7f7 |
|
|
|
38a7f7 |
diff --git a/src/lib/krb5/os/os-proto.h b/src/lib/krb5/os/os-proto.h
|
|
|
38a7f7 |
index a985f2aec..91d2791ce 100644
|
|
|
38a7f7 |
--- a/src/lib/krb5/os/os-proto.h
|
|
|
38a7f7 |
+++ b/src/lib/krb5/os/os-proto.h
|
|
|
38a7f7 |
@@ -49,6 +49,7 @@ typedef enum {
|
|
|
38a7f7 |
UDP_FIRST = 0,
|
|
|
38a7f7 |
UDP_LAST,
|
|
|
38a7f7 |
NO_UDP,
|
|
|
38a7f7 |
+ ONLY_UDP
|
|
|
38a7f7 |
} k5_transport_strategy;
|
|
|
38a7f7 |
|
|
|
38a7f7 |
/* A single server hostname or address. */
|
|
|
38a7f7 |
diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c
|
|
|
38a7f7 |
index 0eedec175..c7f5d861a 100644
|
|
|
38a7f7 |
--- a/src/lib/krb5/os/sendto_kdc.c
|
|
|
38a7f7 |
+++ b/src/lib/krb5/os/sendto_kdc.c
|
|
|
38a7f7 |
@@ -802,11 +802,14 @@ resolve_server(krb5_context context, const krb5_data *realm,
|
|
|
38a7f7 |
int err, result;
|
|
|
38a7f7 |
char portbuf[PORT_LENGTH];
|
|
|
38a7f7 |
|
|
|
38a7f7 |
- /* Skip UDP entries if we don't want UDP. */
|
|
|
38a7f7 |
+ /* Skip entries excluded by the strategy. */
|
|
|
38a7f7 |
if (strategy == NO_UDP && entry->transport == UDP)
|
|
|
38a7f7 |
return 0;
|
|
|
38a7f7 |
+ if (strategy == ONLY_UDP && entry->transport != UDP &&
|
|
|
38a7f7 |
+ entry->transport != TCP_OR_UDP)
|
|
|
38a7f7 |
+ return 0;
|
|
|
38a7f7 |
|
|
|
38a7f7 |
- transport = (strategy == UDP_FIRST) ? UDP : TCP;
|
|
|
38a7f7 |
+ transport = (strategy == UDP_FIRST || strategy == ONLY_UDP) ? UDP : TCP;
|
|
|
38a7f7 |
if (entry->hostname == NULL) {
|
|
|
38a7f7 |
/* Added by a module, so transport is either TCP or UDP. */
|
|
|
38a7f7 |
ai.ai_socktype = socktype_for_transport(entry->transport);
|
|
|
38a7f7 |
@@ -850,8 +853,9 @@ resolve_server(krb5_context context, const krb5_data *realm,
|
|
|
38a7f7 |
}
|
|
|
38a7f7 |
|
|
|
38a7f7 |
/* For TCP_OR_UDP entries, add each address again with the non-preferred
|
|
|
38a7f7 |
- * transport, unless we are avoiding UDP. Flag these as deferred. */
|
|
|
38a7f7 |
- if (retval == 0 && entry->transport == TCP_OR_UDP && strategy != NO_UDP) {
|
|
|
38a7f7 |
+ * transport, if there is one. Flag these as deferred. */
|
|
|
38a7f7 |
+ if (retval == 0 && entry->transport == TCP_OR_UDP &&
|
|
|
38a7f7 |
+ (strategy == UDP_FIRST || strategy == UDP_LAST)) {
|
|
|
38a7f7 |
transport = (strategy == UDP_FIRST) ? TCP : UDP;
|
|
|
38a7f7 |
for (a = addrs; a != 0 && retval == 0; a = a->ai_next) {
|
|
|
38a7f7 |
a->ai_socktype = socktype_for_transport(transport);
|
|
|
38a7f7 |
--
|
|
|
38a7f7 |
2.35.1
|
|
|
38a7f7 |
|