sctp: validate from_addr_param return
[ Upstream commit 0c5dc070ff3d6246d22ddd931f23a6266249e3db ] Ilja reported that, simply putting it, nothing was validating that from_addr_param functions were operating on initialized memory. That is, the parameter itself was being validated by sctp_walk_params, but it doesn't check for types and their specific sizes and it could be a 0-length one, causing from_addr_param to potentially work over the next parameter or even uninitialized memory. The fix here is to, in all calls to from_addr_param, check if enough space is there for the wanted IP address type. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e83f312114
commit
d4dbef7046
@@ -530,15 +530,20 @@ static void sctp_v6_to_sk_daddr(union sctp_addr *addr, struct sock *sk)
|
||||
}
|
||||
|
||||
/* Initialize a sctp_addr from an address parameter. */
|
||||
static void sctp_v6_from_addr_param(union sctp_addr *addr,
|
||||
static bool sctp_v6_from_addr_param(union sctp_addr *addr,
|
||||
union sctp_addr_param *param,
|
||||
__be16 port, int iif)
|
||||
{
|
||||
if (ntohs(param->v6.param_hdr.length) < sizeof(struct sctp_ipv6addr_param))
|
||||
return false;
|
||||
|
||||
addr->v6.sin6_family = AF_INET6;
|
||||
addr->v6.sin6_port = port;
|
||||
addr->v6.sin6_flowinfo = 0; /* BUG */
|
||||
addr->v6.sin6_addr = param->v6.addr;
|
||||
addr->v6.sin6_scope_id = iif;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Initialize an address parameter from a sctp_addr and return the length
|
||||
|
Reference in New Issue
Block a user