* [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo
@ 2015-09-02 12:00 Daniel Borkmann
2015-09-02 13:10 ` Nicolas Dichtel
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Borkmann @ 2015-09-02 12:00 UTC (permalink / raw)
To: davem; +Cc: ast, nicolas.dichtel, netdev, Daniel Borkmann
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@iogearbox.net>
---
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 d79866c..817622f 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -90,6 +90,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.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo
2015-09-02 12:00 [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo Daniel Borkmann
@ 2015-09-02 13:10 ` Nicolas Dichtel
2015-09-02 15:03 ` Alexei Starovoitov
2015-09-02 18:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2015-09-02 13:10 UTC (permalink / raw)
To: Daniel Borkmann, davem; +Cc: ast, netdev
Le 02/09/2015 14:00, Daniel Borkmann a écrit :
> 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@iogearbox.net>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo
2015-09-02 12:00 [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo Daniel Borkmann
2015-09-02 13:10 ` Nicolas Dichtel
@ 2015-09-02 15:03 ` Alexei Starovoitov
2015-09-02 18:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2015-09-02 15:03 UTC (permalink / raw)
To: Daniel Borkmann, davem; +Cc: nicolas.dichtel, netdev
On 9/2/15 5:00 AM, Daniel Borkmann wrote:
> 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:
...
> Fixes: 89aa075832b0 ("net: sock: allow eBPF programs to be attached to sockets")
> Signed-off-by: Daniel Borkmann<daniel@iogearbox.net>
good catch. thanks
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo
2015-09-02 12:00 [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo Daniel Borkmann
2015-09-02 13:10 ` Nicolas Dichtel
2015-09-02 15:03 ` Alexei Starovoitov
@ 2015-09-02 18:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-09-02 18:31 UTC (permalink / raw)
To: daniel; +Cc: ast, nicolas.dichtel, netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Wed, 2 Sep 2015 14:00:36 +0200
> 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@iogearbox.net>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-02 18:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-02 12:00 [PATCH net] sock, diag: fix panic in sock_diag_put_filterinfo Daniel Borkmann
2015-09-02 13:10 ` Nicolas Dichtel
2015-09-02 15:03 ` Alexei Starovoitov
2015-09-02 18:31 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).