]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
bpf: Sockmap/tls, fix pop data with SK_DROP return code
authorJohn Fastabend <john.fastabend@gmail.com>
Sat, 11 Jan 2020 06:12:06 +0000 (06:12 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 06:00:53 +0000 (01:00 -0500)
commit5b3c883bc8dc7fc5c2f9361e72fb464ebc6ae1a5
tree162e3eed53cac86ff6685570f020c9d0b316a2dd
parent1a30393a9ba29c7a62b060d8acab571a2f630f62
bpf: Sockmap/tls, fix pop data with SK_DROP return code

BugLink: https://bugs.launchpad.net/bugs/1862429
commit 7361d44896ff20d48bdd502d1a0cd66308055d45 upstream.

When user returns SK_DROP we need to reset the number of copied bytes
to indicate to the user the bytes were dropped and not sent. If we
don't reset the copied arg sendmsg will return as if those bytes were
copied giving the user a positive return value.

This works as expected today except in the case where the user also
pops bytes. In the pop case the sg.size is reduced but we don't correctly
account for this when copied bytes is reset. The popped bytes are not
accounted for and we return a small positive value potentially confusing
the user.

The reason this happens is due to a typo where we do the wrong comparison
when accounting for pop bytes. In this fix notice the if/else is not
needed and that we have a similar problem if we push data except its not
visible to the user because if delta is larger the sg.size we return a
negative value so it appears as an error regardless.

Fixes: 7246d8ed4dcce ("bpf: helper to pop data from messages")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/bpf/20200111061206.8028-9-john.fastabend@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/ipv4/tcp_bpf.c
net/tls/tls_sw.c