[3.19.y-ckt stable] Patch "sock, diag: fix panic in sock_diag_put_filterinfo" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Mon Oct 19 22:40:40 UTC 2015


This is a note to let you know that I have just added a patch titled

    sock, diag: fix panic in sock_diag_put_filterinfo

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.8-ckt8.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From 93f3a0ce519e05507dd8fc51c400b798c9288616 Mon Sep 17 00:00:00 2001
From: Daniel Borkmann <daniel at iogearbox.net>
Date: Wed, 2 Sep 2015 14:00:36 +0200
Subject: sock, diag: fix panic in sock_diag_put_filterinfo

commit b382c08656000c12a146723a153b85b13a855b49 upstream.

diag socket's sock_diag_put_filterinfo() dumps classic BPF programs
upon request to user space (ss -0 -b). However, native eBPF programs
attached to sockets (SO_ATTACH_BPF) cannot be dumped with this method:

Their orig_prog is always NULL. However, sock_diag_put_filterinfo()
unconditionally tries to access its filter length resp. wants to copy
the filter insns from there. Internal cBPF to eBPF transformations
attached to sockets don't have this issue, as orig_prog state is kept.

It's currently only used by packet sockets. If we would want to add
native eBPF support in the future, this needs to be done through
a different attribute than PACKET_DIAG_FILTER to not confuse possible
user space disassemblers that work on diag data.

Fixes: 89aa075832b0 ("net: sock: allow eBPF programs to be attached to sockets")
Signed-off-by: Daniel Borkmann <daniel at iogearbox.net>
Acked-by: Nicolas Dichtel <nicolas.dichtel at 6wind.com>
Acked-by: Alexei Starovoitov <ast at plumgrid.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 net/core/sock_diag.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index ad704c7..91c2630 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -69,6 +69,9 @@ int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
 		goto out;

 	fprog = filter->prog->orig_prog;
+	if (!fprog)
+		goto out;
+
 	flen = bpf_classic_proglen(fprog);

 	attr = nla_reserve(skb, attrtype, flen);
--
1.9.1





More information about the kernel-team mailing list