]> git.baikalelectronics.ru Git - kernel.git/commit
flow_dissector: lookup netns by skb->sk if skb->dev is NULL
authorWillem de Bruijn <willemb@google.com>
Mon, 24 Sep 2018 20:49:57 +0000 (16:49 -0400)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 25 Sep 2018 15:31:19 +0000 (17:31 +0200)
commitf83d422c274febcb0b30d6f8cc279af9dcdb88b1
tree1a15d2fdf34411e490eb568710becbf156b97dac
parentce51b4798c3b5eab012d559279b4f48241dc67e5
flow_dissector: lookup netns by skb->sk if skb->dev is NULL

BPF flow dissectors are configured per network namespace.
__skb_flow_dissect looks up the netns through dev_net(skb->dev).

In some dissector paths skb->dev is NULL, such as for Unix sockets.
In these cases fall back to looking up the netns by socket.

Analyzing the codepaths leading to __skb_flow_dissect I did not find
a case where both skb->dev and skb->sk are NULL. Warn and fall back to
standard flow dissector if one is found.

Fixes: 23513a901445 ("flow_dissector: implements flow dissector BPF hook")
Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/core/flow_dissector.c