mbox series

[bpf,0/3] Fix csum unnecessary on bpf_skb_adjust_room

Message ID cover.1591108731.git.daniel@iogearbox.net
Headers show
Series Fix csum unnecessary on bpf_skb_adjust_room | expand

Message

Daniel Borkmann June 2, 2020, 2:58 p.m. UTC
This series fixes an issue originally reported by Lorenz Bauer where using
the bpf_skb_adjust_room() helper hid a checksum bug since it wasn't adjusting
CHECKSUM_UNNECESSARY's skb->csum_level after decap. The fix is two-fold:
 i) We do a safe reset in bpf_skb_adjust_room() to CHECKSUM_NONE with an opt-
    out flag BPF_F_ADJ_ROOM_NO_CSUM_RESET.
ii) We add a new bpf_csum_level() for the latter in order to allow users to
    manually inc/dec the skb->csum_level when needed.
The series is rebased against latest bpf-next tree. It can be applied there,
or to bpf after the merge win sync from net-next.

Thanks!

Daniel Borkmann (3):
  bpf: Fix up bpf_skb_adjust_room helper's skb csum setting
  bpf: add csum_level helper for fixing up csum levels
  bpf, selftests: adapt cls_redirect to call csum_level helper

 include/linux/skbuff.h                        |  8 +++
 include/uapi/linux/bpf.h                      | 51 ++++++++++++++++++-
 net/core/filter.c                             | 46 ++++++++++++++++-
 tools/include/uapi/linux/bpf.h                | 51 ++++++++++++++++++-
 .../selftests/bpf/progs/test_cls_redirect.c   |  9 ++--
 5 files changed, 158 insertions(+), 7 deletions(-)

Comments

Lorenz Bauer June 2, 2020, 3:19 p.m. UTC | #1
On Tue, 2 Jun 2020 at 15:58, Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> This series fixes an issue originally reported by Lorenz Bauer where using
> the bpf_skb_adjust_room() helper hid a checksum bug since it wasn't adjusting
> CHECKSUM_UNNECESSARY's skb->csum_level after decap. The fix is two-fold:
>  i) We do a safe reset in bpf_skb_adjust_room() to CHECKSUM_NONE with an opt-
>     out flag BPF_F_ADJ_ROOM_NO_CSUM_RESET.
> ii) We add a new bpf_csum_level() for the latter in order to allow users to
>     manually inc/dec the skb->csum_level when needed.
> The series is rebased against latest bpf-next tree. It can be applied there,
> or to bpf after the merge win sync from net-next.
>
> Thanks!
>
> Daniel Borkmann (3):
>   bpf: Fix up bpf_skb_adjust_room helper's skb csum setting
>   bpf: add csum_level helper for fixing up csum levels
>   bpf, selftests: adapt cls_redirect to call csum_level helper
>
>  include/linux/skbuff.h                        |  8 +++
>  include/uapi/linux/bpf.h                      | 51 ++++++++++++++++++-
>  net/core/filter.c                             | 46 ++++++++++++++++-
>  tools/include/uapi/linux/bpf.h                | 51 ++++++++++++++++++-
>  .../selftests/bpf/progs/test_cls_redirect.c   |  9 ++--
>  5 files changed, 158 insertions(+), 7 deletions(-)
>
> --
> 2.21.0
>

Thanks for pushing this out, Daniel!
Alexei Starovoitov June 2, 2020, 6:59 p.m. UTC | #2
On Tue, Jun 2, 2020 at 7:58 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> This series fixes an issue originally reported by Lorenz Bauer where using
> the bpf_skb_adjust_room() helper hid a checksum bug since it wasn't adjusting
> CHECKSUM_UNNECESSARY's skb->csum_level after decap. The fix is two-fold:
>  i) We do a safe reset in bpf_skb_adjust_room() to CHECKSUM_NONE with an opt-
>     out flag BPF_F_ADJ_ROOM_NO_CSUM_RESET.
> ii) We add a new bpf_csum_level() for the latter in order to allow users to
>     manually inc/dec the skb->csum_level when needed.
> The series is rebased against latest bpf-next tree. It can be applied there,
> or to bpf after the merge win sync from net-next.

Applied. Thanks