diff options
author | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> | 2021-06-28 16:13:41 -0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-28 15:34:50 -0700 |
commit | 0c5dc070ff3d6246d22ddd931f23a6266249e3db (patch) | |
tree | 434d6c40173e8b5529f60fcf72fdfb55bc359858 /net/sctp/protocol.c | |
parent | 9ea3e52c5bc8bb4a084938dc1e3160643438927a (diff) | |
download | lwn-0c5dc070ff3d6246d22ddd931f23a6266249e3db.tar.gz lwn-0c5dc070ff3d6246d22ddd931f23a6266249e3db.zip |
sctp: validate from_addr_param return
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>
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 6f2bbfeec3a4..25192b378e2e 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -254,14 +254,19 @@ static void sctp_v4_to_sk_daddr(union sctp_addr *addr, struct sock *sk) } /* Initialize a sctp_addr from an address parameter. */ -static void sctp_v4_from_addr_param(union sctp_addr *addr, +static bool sctp_v4_from_addr_param(union sctp_addr *addr, union sctp_addr_param *param, __be16 port, int iif) { + if (ntohs(param->v4.param_hdr.length) < sizeof(struct sctp_ipv4addr_param)) + return false; + addr->v4.sin_family = AF_INET; addr->v4.sin_port = port; addr->v4.sin_addr.s_addr = param->v4.addr.s_addr; memset(addr->v4.sin_zero, 0, sizeof(addr->v4.sin_zero)); + + return true; } /* Initialize an address parameter from a sctp_addr and return the length |