* [PATCH] caif: Add sockaddr length check before accessing sa_family in connect handler
@ 2017-06-13 18:06 Mateusz Jurczyk
0 siblings, 0 replies; only message in thread
From: Mateusz Jurczyk @ 2017-06-13 18:06 UTC (permalink / raw)
To: Dmitry Tarnyagin, David S. Miller; +Cc: netdev, linux-kernel
Verify that the caller-provided sockaddr structure is large enough to
contain the sa_family field, before accessing it in the connect()
handler of the AF_CAIF socket. Since the syscall doesn't enforce a minimum
size of the corresponding memory region, very short sockaddrs (zero or one
byte long) result in operating on uninitialized memory while referencing
sa_family.
Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com>
---
net/caif/caif_socket.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index adcad344c843..21f18ea2fce4 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -754,6 +754,10 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr,
lock_sock(sk);
+ err = -EINVAL;
+ if (addr_len < offsetofend(struct sockaddr, sa_family))
+ goto out;
+
err = -EAFNOSUPPORT;
if (uaddr->sa_family != AF_CAIF)
goto out;
--
2.13.1.508.gb3defc5cc-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-13 18:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-13 18:06 [PATCH] caif: Add sockaddr length check before accessing sa_family in connect handler Mateusz Jurczyk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox