mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-26 20:58:33 +00:00
tipc: allow service ranges to be connect()'ed on RDM/DGRAM
We move the check that prevents connecting service ranges to after the RDM/DGRAM check, and move address sanity control to a separate function that also validates the service range. Fixes: 23998835be98 ("tipc: improve address sanity check in tipc_connect()") Signed-off-by: Erik Hugne <erik.hugne@gmail.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
65e9a6d25d
commit
ea239314fe
@ -2349,6 +2349,16 @@ static int tipc_wait_for_connect(struct socket *sock, long *timeo_p)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool tipc_sockaddr_is_sane(struct sockaddr_tipc *addr)
|
||||||
|
{
|
||||||
|
if (addr->family != AF_TIPC)
|
||||||
|
return false;
|
||||||
|
if (addr->addrtype == TIPC_SERVICE_RANGE)
|
||||||
|
return (addr->addr.nameseq.lower <= addr->addr.nameseq.upper);
|
||||||
|
return (addr->addrtype == TIPC_SERVICE_ADDR ||
|
||||||
|
addr->addrtype == TIPC_SOCKET_ADDR);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tipc_connect - establish a connection to another TIPC port
|
* tipc_connect - establish a connection to another TIPC port
|
||||||
* @sock: socket structure
|
* @sock: socket structure
|
||||||
@ -2384,18 +2394,18 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
|
|||||||
if (!tipc_sk_type_connectionless(sk))
|
if (!tipc_sk_type_connectionless(sk))
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
} else if (dst->family != AF_TIPC) {
|
|
||||||
res = -EINVAL;
|
|
||||||
}
|
}
|
||||||
if (dst->addrtype != TIPC_ADDR_ID && dst->addrtype != TIPC_ADDR_NAME)
|
if (!tipc_sockaddr_is_sane(dst)) {
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
if (res)
|
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
/* DGRAM/RDM connect(), just save the destaddr */
|
/* DGRAM/RDM connect(), just save the destaddr */
|
||||||
if (tipc_sk_type_connectionless(sk)) {
|
if (tipc_sk_type_connectionless(sk)) {
|
||||||
memcpy(&tsk->peer, dest, destlen);
|
memcpy(&tsk->peer, dest, destlen);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
} else if (dst->addrtype == TIPC_SERVICE_RANGE) {
|
||||||
|
res = -EINVAL;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
previous = sk->sk_state;
|
previous = sk->sk_state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user