Skip Menu |
 

To: krb5-bugs@mit.edu
Subject: UDP datagrams > 4K do not work.
Date: Wed, 16 Sep 2009 07:01:24 +0800
From: elric@mournblade.imrryr.org
Download (untitled) / with headers
text/plain 1.6KiB
In src/kdc/network.c, in the function:

process_packet():

We find:

response = NULL;
saddr_len = sizeof(saddr);
cc = recvfrom(port_fd, pktbuf, sizeof(pktbuf), 0,
(struct sockaddr *)&saddr, &saddr_len);
if (cc == -1) {
if (errno != EINTR
/* This is how Linux indicates that a previous
transmission was refused, e.g., if the client timed out
before getting the response packet. */
&& errno != ECONNREFUSED
)
com_err(prog, errno, "while receiving from network");
return;
}
if (!cc)
return; /* zero-length packet? */

Unfortunately, if you receive a datagram of over sizeof(pktbuf)
you will succeed with cc == sizeof(pktbuf) not detecting the fact
that there was additional data. This results in an ASN.1 parse
error. What should happen is that the KDC should return an
appropriate error to the client indicating that TCP should be used.
Or maybe the buffer size should be increased to the maximum allowable
for UDP. I prefer the second option as there is nothing inherently
wrong with 64K UDP packets.

I noticed this while debugging a JGSS problem. Apparently, the
Java Kerberos libraries do not fail over from UDP to TCP unless
the KDC specifically tells them to. And they have no default
setting for udp_preference_limit. And so, if you are constructing
tickets of over 4K because, let's say, a user is in a lot of groups
in Windows, JGSS will just fail against an MIT KDC.

Fix:

change MAX_DGRAM_SIZE in /include/krb5/stock/osconf.h to be the
actual maximum datagram size, 65536.

--
Roland Dowdeswell http://Imrryr.ORG/~elric/
From: Ken Raeburn <raeburn@MIT.EDU>
To: rt@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #6566] UDP datagrams > 4K do not work.
Date: Wed, 16 Sep 2009 00:35:34 -0400
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1.8KiB
On Sep 15, 2009, at 22:02, elric@mournblade.imrryr.org via RT wrote:
Show quoted text
> Unfortunately, if you receive a datagram of over sizeof(pktbuf)
> you will succeed with cc == sizeof(pktbuf) not detecting the fact
> that there was additional data. This results in an ASN.1 parse
> error. What should happen is that the KDC should return an
> appropriate error to the client indicating that TCP should be used.

Regardless of other options, it sounds like cc==sizeof(pktbuf) should
trigger the use-TCP error, since we can't distinguish between a packet
equal in size to the buffer and a packet that was larger but got
truncated. Either that, or we could peek at the size of the next
datagram and grow the buffer as needed, but I'm not sure that peeking
can be done portably.

Show quoted text
> Or maybe the buffer size should be increased to the maximum allowable
> for UDP. I prefer the second option as there is nothing inherently
> wrong with 64K UDP packets.

With jumbograms, UDP messages larger than 64K are possible. (RFC
2675) Still, 64K does seem like a reasonable limit (i.e., way larger
than we would normally expect).

Show quoted text
> I noticed this while debugging a JGSS problem. Apparently, the
> Java Kerberos libraries do not fail over from UDP to TCP unless
> the KDC specifically tells them to. And they have no default
> setting for udp_preference_limit. And so, if you are constructing
> tickets of over 4K because, let's say, a user is in a lot of groups
> in Windows, JGSS will just fail against an MIT KDC.

From what I've read, the common wisdom still seems to be that some
gateways/routers/NAT boxes/firewalls/whatever will not properly
process UDP fragments, so UDP traffic over ~1500 bytes (or less) may
never get to the KDC. So this sounds like a bug in the Java Kerberos
libraries.

Ken

--
Ken Raeburn / raeburn@mit.edu / no longer at MIT Kerberos Consortium
To: rt-comment@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #6566] UDP datagrams > 4K do not work.
Date: Wed, 16 Sep 2009 09:08:43 +0100
From: elric@mournblade.imrryr.org
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1.8KiB
On 1253075737 seconds since the Beginning of the UNIX epoch
"Ken Raeburn via RT" wrote:
Show quoted text
>
>On Sep 15, 2009, at 22:02, elric@mournblade.imrryr.org via RT wrote:
>> Unfortunately, if you receive a datagram of over sizeof(pktbuf)
>> you will succeed with cc == sizeof(pktbuf) not detecting the fact
>> that there was additional data. This results in an ASN.1 parse
>> error. What should happen is that the KDC should return an
>> appropriate error to the client indicating that TCP should be used.
>
>Regardless of other options, it sounds like cc==sizeof(pktbuf) should
>trigger the use-TCP error, since we can't distinguish between a packet
>equal in size to the buffer and a packet that was larger but got
>truncated. Either that, or we could peek at the size of the next
>datagram and grow the buffer as needed, but I'm not sure that peeking
>can be done portably.

Yes, this sounds like exactly the approach I would think about
implementing.

Show quoted text
>> I noticed this while debugging a JGSS problem. Apparently, the
>> Java Kerberos libraries do not fail over from UDP to TCP unless
>> the KDC specifically tells them to. And they have no default
>> setting for udp_preference_limit. And so, if you are constructing
>> tickets of over 4K because, let's say, a user is in a lot of groups
>> in Windows, JGSS will just fail against an MIT KDC.
>
> From what I've read, the common wisdom still seems to be that some
>gateways/routers/NAT boxes/firewalls/whatever will not properly
>process UDP fragments, so UDP traffic over ~1500 bytes (or less) may
>never get to the KDC. So this sounds like a bug in the Java Kerberos
>libraries.

It's most certainly a bug in the Java Kerberos libraries. I've also
run into them breaking when frags are dropped, etc.

Thanks,

--
Roland Dowdeswell http://Imrryr.ORG/~elric/
From: ghudson@mit.edu
Subject: SVN Commit

Increase MAX_DGRAM_SIZE

Accept UDP datagrams up to 64K in size. We should still detect when
an oversized datagram comes in by comparing against the maximum size,
but this is trivial and covers 90% of the practical issues.

https://github.com/krb5/krb5/commit/b5da0b454caf1057d8dc9669737ffe89be5551e4
Author: Greg Hudson <ghudson@mit.edu>
Commit: b5da0b454caf1057d8dc9669737ffe89be5551e4
Branch: master
src/include/osconf.hin | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)