[PATCH 3.13.y-ckt 115/138] af_iucv: Validate socket address length in iucv_sock_bind()

From: Kamal Mostafa
Date: Wed Mar 09 2016 - 18:20:35 EST


3.13.11-ckt36 -stable review patch. If anyone has any objections, please let me know.

---8<------------------------------------------------------------

From: Ursula Braun <ursula.braun@xxxxxxxxxx>

commit 52a82e23b9f2a9e1d429c5207f8575784290d008 upstream.

Signed-off-by: Ursula Braun <ursula.braun@xxxxxxxxxx>
Reported-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Reviewed-by: Evgeny Cherkashin <Eugene.Crosser@xxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Luis Henriques <luis.henriques@xxxxxxxxxxxxx>
Signed-off-by: Kamal Mostafa <kamal@xxxxxxxxxxxxx>
---
net/iucv/af_iucv.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 1465363..bb3969a 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -697,6 +697,9 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
if (!addr || addr->sa_family != AF_IUCV)
return -EINVAL;

+ if (addr_len < sizeof(struct sockaddr_iucv))
+ return -EINVAL;
+
lock_sock(sk);
if (sk->sk_state != IUCV_OPEN) {
err = -EBADFD;
--
2.7.0