]> asedeno.scripts.mit.edu Git - linux.git/commit
bpf: sockmap: initialize sg table entries properly
authorPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Fri, 30 Mar 2018 00:21:00 +0000 (09:21 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 30 Mar 2018 20:50:15 +0000 (22:50 +0200)
commit6ef6d84ceee2262a8c7a4247616c7eb71268b3f9
tree630eb9ec8764b825abe20e0457df291dd0c1f9eb
parentf385178679b6561d2e717567d12e07c7f927ee59
bpf: sockmap: initialize sg table entries properly

When CONFIG_DEBUG_SG is set, sg->sg_magic is initialized in
sg_init_table() and it is verified in sg api while navigating. We hit
BUG_ON when magic check is failed.

In functions sg_tcp_sendpage and sg_tcp_sendmsg, the struct containing
the scatterlist is already zeroed out. So to avoid extra memset, we
use sg_init_marker() to initialize sg_magic.

Fixed following things:
- In bpf_tcp_sendpage: initialize sg using sg_init_marker
- In bpf_tcp_sendmsg: Replace sg_init_table with sg_init_marker
- In bpf_tcp_push: Replace memset with sg_init_table where consumed
  sg entry needs to be re-initialized.

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/sockmap.c