All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 8/9] bpf: Check address length before reading address family
@ 2019-04-12 10:55 Tetsuo Handa
  2019-04-12 16:19 ` Alexei Starovoitov
  2019-04-12 17:26 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Tetsuo Handa @ 2019-04-12 10:55 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann; +Cc: David S. Miller, netdev, Tetsuo Handa

KMSAN will complain if valid address length passed to bpf_bind() is
shorter than sizeof("struct sockaddr"->sa_family) bytes.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 net/core/filter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 41f633cf4fc1..b9089fda4367 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4458,6 +4458,8 @@ BPF_CALL_3(bpf_bind, struct bpf_sock_addr_kern *, ctx, struct sockaddr *, addr,
 	 * Only binding to IP is supported.
 	 */
 	err = -EINVAL;
+	if (addr_len < offsetofend(struct sockaddr, sa_family))
+		return err;
 	if (addr->sa_family == AF_INET) {
 		if (addr_len < sizeof(struct sockaddr_in))
 			return err;
-- 
2.16.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-12 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 10:55 [PATCH 8/9] bpf: Check address length before reading address family Tetsuo Handa
2019-04-12 16:19 ` Alexei Starovoitov
2019-04-12 16:51   ` Andrey Ignatov
2019-04-12 17:26 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.