Skip to content

Commit 585b5bd

Browse files
ghananigansRebase bot
authored andcommitted
[starnix] Return EAFNOSUPPORT when bind fails
...with an address family mismatch on `AF_INET` (IPv4) sockets. Bug: b/286855878 Change-Id: Ied3a27ebf9188215ae4c2767d5d558f5bcf4e2d4 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/871678 Fuchsia-Auto-Submit: Ghanan Gowripalan <[email protected]> Reviewed-by: Kevin Lindkvist <[email protected]> Commit-Queue: Ghanan Gowripalan <[email protected]>
1 parent 9add601 commit 585b5bd

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/starnix/kernel/fs/socket/syscalls.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ pub fn sys_bind(
123123
let socket = file.node().socket().ok_or_else(|| errno!(ENOTSOCK))?;
124124
let address = parse_socket_address(current_task, user_socket_address, address_length)?;
125125
if !address.valid_for_domain(socket.domain) {
126-
return error!(EINVAL);
126+
return match socket.domain {
127+
SocketDomain::Unix
128+
| SocketDomain::Vsock
129+
| SocketDomain::Inet6
130+
| SocketDomain::Netlink => error!(EINVAL),
131+
SocketDomain::Inet => error!(EAFNOSUPPORT),
132+
};
127133
}
128134
match address {
129135
SocketAddress::Unspecified => return error!(EINVAL),

src/starnix/tests/gvisor/expectations/default.json5

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,6 @@
410410
"PingSocket.PayloadTooLarge",
411411
"PingSocket.ReceiveIPPacketInfo",
412412
"PingSocket.ReceiveIPv6PktInfo",
413-
"PingSockets/Fixture.Bind/ICMP_socket_V6Any",
414-
"PingSockets/Fixture.Bind/ICMP_socket_V6Loopback",
415-
"PingSockets/Fixture.Bind/ICMP_socket_V6Multicast",
416-
"PingSockets/Fixture.Bind/ICMP_socket_V6MulticastInterfaceLocalAllNodes",
417-
"PingSockets/Fixture.Bind/ICMP_socket_V6MulticastLinkLocalAllNodes",
418-
"PingSockets/Fixture.Bind/ICMP_socket_V6MulticastLinkLocalAllRouters",
419-
"PingSockets/Fixture.Bind/ICMP_socket_IPv6UnknownUnicast",
420413

421414
// pivot_root_test
422415
"PivotRootTest.WithoutCapability",

src/starnix/tests/ltp/expectations/ltp.json5

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
"asapi_01",
4747
"asapi_03",
4848
"autogroup01",
49-
"bind01",
50-
"bind01",
5149
"bind02",
5250
"bind05",
5351
"bind06",

0 commit comments

Comments
 (0)