Page MenuHomeFreeBSD

tcp, udp: Permit binding with AF_UNSPEC if the address is INADDR_ANY
ClosedPublic

Authored by markj on May 28 2021, 10:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 29 2024, 12:53 AM
Unknown Object (File)
Oct 22 2024, 1:22 PM
Unknown Object (File)
Oct 18 2024, 9:57 AM
Unknown Object (File)
Oct 15 2024, 3:12 AM
Unknown Object (File)
Oct 8 2024, 8:56 AM
Unknown Object (File)
Oct 4 2024, 9:52 PM
Unknown Object (File)
Oct 2 2024, 4:36 AM
Unknown Object (File)
Oct 2 2024, 1:00 AM
Subscribers

Details

Summary

Prior to commit f161d294b we only checked the sockaddr length, but now
we verify the address family as well. This breaks ttcp. Relax the
check to avoid breaking compatibility too much: permit AF_UNSPEC if the
address is INADDR_ANY. This matches Linux.

Fixes: f161d294b
Reported by: Bakul Shah

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningsys/netinet/tcp_usrreq.c:324SPELL1Possible Spelling Mistake
Warningsys/netinet/tcp_usrreq.c:328SPELL1Possible Spelling Mistake
Warningsys/netinet/tcp_usrreq.c:331SPELL1Possible Spelling Mistake
Warningsys/netinet/udp_usrreq.c:1632SPELL1Possible Spelling Mistake
Warningsys/netinet/udp_usrreq.c:1633SPELL1Possible Spelling Mistake
Warningsys/netinet/udp_usrreq.c:1637SPELL1Possible Spelling Mistake
Warningsys/netinet/udp_usrreq.c:1640SPELL1Possible Spelling Mistake
Unit
No Test Coverage
Build Status
Buildable 39558
Build 36447: arc lint + arc unit

Event Timeline

Hmm. What about the corresponding case for IPv6 sockets? ttcp would still fail, since it also provides a sin_len of 0. I was expecting some fallout...

Hmm. What about the corresponding case for IPv6 sockets? ttcp would still fail, since it also provides a sin_len of 0. I was expecting some fallout...

Do you know of any applications that depend on that? ttcp is IPv4-only.

sin_len is a funny case. bind(2), connect(2) and sendto(2) also have a socklen parameter. Our getsockaddr(), which is responsible for copying in sockaddrs from user memory, overwrites the sa_len with the length provided in that parameter. So the sin_len provided by userspace is effectively ignored, for better or worse.

Hmm. What about the corresponding case for IPv6 sockets? ttcp would still fail, since it also provides a sin_len of 0. I was expecting some fallout...

Do you know of any applications that depend on that? ttcp is IPv4-only.

No, I don't. Just prefer consistency, But if you prefer to add a special case only for IPv4, I'm fine.

sin_len is a funny case. bind(2), connect(2) and sendto(2) also have a socklen parameter. Our getsockaddr(), which is responsible for copying in sockaddrs from user memory, overwrites the sa_len with the length provided in that parameter. So the sin_len provided by userspace is effectively ignored, for better or worse.

Ahh, OK. I missed that. Then I'm fine.

This revision is now accepted and ready to land.May 28 2021, 11:48 PM

Hmm. What about the corresponding case for IPv6 sockets? ttcp would still fail, since it also provides a sin_len of 0. I was expecting some fallout...

Do you know of any applications that depend on that? ttcp is IPv4-only.

No, I don't. Just prefer consistency, But if you prefer to add a special case only for IPv4, I'm fine.

Well, this way we are more consistent with other kernels. :)

Linux and OpenBSD are strict about checking sa_family == AF_INET6 so I think it is reasonable to do the same.

Hi Mark,

I'd personally like the approach D29519 . Is it desirable to have a dedicated sysctl variable to flag the compatible mode? The default value could be set to true.

In D30539#686316, @zlei.huang_gmail.com wrote:

Hi Mark,

I'd personally like the approach D29519 . Is it desirable to have a dedicated sysctl variable to flag the compatible mode? The default value could be set to true.

I'm not sure. This is really a quite minor modification to D29519, I'd personally prefer not to add yet another sysctl for it. Maybe we should make this behaviour conditional on COMPAT_FREEBSD13 instead.

In D30539#686316, @zlei.huang_gmail.com wrote:

Hi Mark,

I'd personally like the approach D29519 . Is it desirable to have a dedicated sysctl variable to flag the compatible mode? The default value could be set to true.

I'm not sure. This is really a quite minor modification to D29519, I'd personally prefer not to add yet another sysctl for it. Maybe we should make this behaviour conditional on COMPAT_FREEBSD13 instead.

I agree, no sysctl variable. I'm fine with adding it to COMPAT_FREEBSD13.

In D30539#686316, @zlei.huang_gmail.com wrote:

Hi Mark,

I'd personally like the approach D29519 . Is it desirable to have a dedicated sysctl variable to flag the compatible mode? The default value could be set to true.

I'm not sure. This is really a quite minor modification to D29519, I'd personally prefer not to add yet another sysctl for it. Maybe we should make this behaviour conditional on COMPAT_FREEBSD13 instead.

I agree, no sysctl variable. I'm fine with adding it to COMPAT_FREEBSD13.

I'll do it as a separate change, since this one should be MFCed to stable/13.

This revision was landed with ongoing or failed builds.May 31 2021, 11:10 PM
This revision was automatically updated to reflect the committed changes.