~bodong-wang/ubuntu/+source/linux-bluefield:sru-0707-ddos

Last commit made on 2021-07-06
Get this branch:
git clone -b sru-0707-ddos https://git.launchpad.net/~bodong-wang/ubuntu/+source/linux-bluefield
Only Bodong Wang can upload to this branch. If you are Bodong Wang please log in for upload directions.

Branch merges

Branch information

Name:
sru-0707-ddos
Repository:
lp:~bodong-wang/ubuntu/+source/linux-bluefield

Recent commits

3f52684... by Maxim

UBUNTU: SAUCE: bpf: Add a helper to issue timestamp cookies in XDP

BugLink: https://bugs.launchpad.net/bugs/1934499

The new helper bpf_tcp_raw_gen_tscookie allows an XDP program to
generate timestamp cookies (to be used together with SYN cookies) which
encode different options set by the client in the SYN packet: SACK
support, ECN support, window scale. These options are encoded in lower
bits of the timestamp, which will be returned by the client in a
subsequent ACK packet. The format is the same used by synproxy.

Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Tariq Toukan <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

81becc6... by Maxim

UBUNTU: SAUCE: bpf: Add helpers to issue and check SYN cookies in XDP

BugLink: https://bugs.launchpad.net/bugs/1934499

The new helpers bpf_tcp_raw_{gen,check}_syncookie allow an XDP program
to generate SYN cookies in response to TCP SYN packets and to check
those cookies upon receiving the first ACK packet (the final packet of
the TCP handshake).

Unlike bpf_tcp_{gen,check}_syncookie these new helpers don't need a
listening socket on the local machine, which allows to use them together
with synproxy to accelerate SYN cookie generation.

Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Tariq Toukan <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

410d6d3... by Maxim

UBUNTU: SAUCE: bpf: Add a helper to query TCP conntrack information in XDP

BugLink: https://bugs.launchpad.net/bugs/1934499

The new bpf_ct_lookup_tcp helper allows to query connection tracking
information of a TCP connection based on source and destination IP
address and port. The helper returns the status flags of the conntrack
entry if found.

Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Tariq Toukan <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

a81f949... by Maxim

sch_cake: Fix out of bounds when parsing TCP options and header

BugLink: https://bugs.launchpad.net/bugs/1934499

The TCP option parser in cake qdisc (cake_get_tcpopt and
cake_tcph_may_drop) could read one byte out of bounds. When the length
is 1, the execution flow gets into the loop, reads one byte of the
opcode, and if the opcode is neither TCPOPT_EOL nor TCPOPT_NOP, it reads
one more byte, which exceeds the length of 1.

This fix is inspired by commit 9609dad263f8 ("ipv4: tcp_input: fix stack
out of bounds when parsing TCP options.").

v2 changes:

Added doff validation in cake_get_tcphdr to avoid parsing garbage as TCP
header. Although it wasn't strictly an out-of-bounds access (memory was
allocated), garbage values could be read where CAKE expected the TCP
header if doff was smaller than 5.

Cc: Young Xiao <email address hidden>
Fixes: 8b7138814f29 ("sch_cake: Add optional ACK filter")
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Acked-by: Toke Høiland-Jørgensen <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
Reviewed-by: Tariq Toukan <email address hidden>
(cherry picked from commit ba91c49dedbde758ba0b72f57ac90b06ddf8e548)
Signed-off-by: Bodong Wang <email address hidden>

665991c... by Maxim

netfilter: synproxy: Fix out of bounds when parsing TCP options

BugLink: https://bugs.launchpad.net/bugs/1934499

The TCP option parser in synproxy (synproxy_parse_options) could read
one byte out of bounds. When the length is 1, the execution flow gets
into the loop, reads one byte of the opcode, and if the opcode is
neither TCPOPT_EOL nor TCPOPT_NOP, it reads one more byte, which exceeds
the length of 1.

This fix is inspired by commit 9609dad263f8 ("ipv4: tcp_input: fix stack
out of bounds when parsing TCP options.").

v2 changes:

Added an early return when length < 0 to avoid calling
skb_header_pointer with negative length.

Cc: Young Xiao <email address hidden>
Fixes: 48b1de4c110a ("netfilter: add SYNPROXY core/target")
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Florian Westphal <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
Reviewed-by: Tariq Toukan <email address hidden>
(cherry picked from commit 5fc177ab759418c9537433e63301096e733fb915)
Signed-off-by: Bodong Wang <email address hidden>

726f09c... by Jesper Dangaard Brouer

bpf: Fix too large copy from user in bpf_test_init

BugLink: https://bugs.launchpad.net/bugs/1934499

Commit bc56c919fce7 ("bpf: Add xdp.frame_sz in bpf_prog_test_run_xdp().")
recently changed bpf_prog_test_run_xdp() to use larger frames for XDP in
order to test tail growing frames (via bpf_xdp_adjust_tail) and to have
memory backing frame better resemble drivers.

The commit contains a bug, as it tries to copy the max data size from
userspace, instead of the size provided by userspace. This cause XDP
unit tests to fail sporadically with EFAULT, an unfortunate behavior.
The fix is to only copy the size specified by userspace.

Fixes: bc56c919fce7 ("bpf: Add xdp.frame_sz in bpf_prog_test_run_xdp().")
Signed-off-by: Jesper Dangaard Brouer <email address hidden>
Signed-off-by: Daniel Borkmann <email address hidden>
Acked-by: Andrii Nakryiko <email address hidden>
Link: https://lore.kernel.org/bpf/158980712729.256597.6115007718472928659.stgit@firesoul
(cherry picked from commit d800bad67d4c21aaf11722f04e0f7547fb915ab5)
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Moshe Shemesh <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

6440188... by =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <email address hidden>

xsk: Fix xsk_umem_xdp_frame_sz()

BugLink: https://bugs.launchpad.net/bugs/1934499

Calculating the "data_hard_end" for an XDP buffer coming from AF_XDP
zero-copy mode, the return value of xsk_umem_xdp_frame_sz() is added
to "data_hard_start".

Currently, the chunk size of the UMEM is returned by
xsk_umem_xdp_frame_sz(). This is not correct, if the fixed UMEM
headroom is non-zero. Fix this by returning the chunk_size without the
UMEM headroom.

Fixes: 2a637c5b1aaf ("xdp: For Intel AF_XDP drivers add XDP frame_sz")
Signed-off-by: Björn Töpel <email address hidden>
Signed-off-by: Alexei Starovoitov <email address hidden>
Link: https://<email address hidden>
(cherry picked from commit 44ac082b30dc2a05a7e23ed7e17b5f9513873386)
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Moshe Shemesh <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

3b5c027... by Hangbin Liu <email address hidden>

xdp: Handle frame_sz in xdp_convert_zc_to_xdp_frame()

BugLink: https://bugs.launchpad.net/bugs/1934499

In commit 34cc0b338a61 we only handled the frame_sz in convert_to_xdp_frame().
This patch will also handle frame_sz in xdp_convert_zc_to_xdp_frame().

Fixes: 34cc0b338a61 ("xdp: Xdp_frame add member frame_sz and handle in convert_to_xdp_frame")
Signed-off-by: Hangbin Liu <email address hidden>
Signed-off-by: Alexei Starovoitov <email address hidden>
Acked-by: Jesper Dangaard Brouer <email address hidden>
Acked-by: John Fastabend <email address hidden>
Link: https://<email address hidden>
(cherry picked from commit 3ff2351651a2ecb73ec9d29119793bde190b2850)
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Moshe Shemesh <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

d324ad2... by Jesper Dangaard Brouer

bpf: Add xdp.frame_sz in bpf_prog_test_run_xdp().

BugLink: https://bugs.launchpad.net/bugs/1934499

Update the memory requirements, when adding xdp.frame_sz in BPF test_run
function bpf_prog_test_run_xdp() which e.g. is used by XDP selftests.

Specifically add the expected reserved tailroom, but also allocated a
larger memory area to reflect that XDP frames usually comes in this
format. Limit the provided packet data size to 4096 minus headroom +
tailroom, as this also reflect a common 3520 bytes MTU limit with XDP.

Note that bpf_test_init already use a memory allocation method that clears
memory. Thus, this already guards against leaking uninit kernel memory.

Signed-off-by: Jesper Dangaard Brouer <email address hidden>
Signed-off-by: Alexei Starovoitov <email address hidden>
Link: https://lore.kernel.org/bpf/158945349549.97035.15316291762482444006.stgit@firesoul
(cherry picked from commit bc56c919fce782f616823b76fb70a788f4762cf5)
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Moshe Shemesh <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>

866c45e... by Jesper Dangaard Brouer

xdp: Clear grow memory in bpf_xdp_adjust_tail()

BugLink: https://bugs.launchpad.net/bugs/1934499

Clearing memory of tail when grow happens, because it is too easy
to write a XDP_PASS program that extend the tail, which expose
this memory to users that can run tcpdump.

Signed-off-by: Jesper Dangaard Brouer <email address hidden>
Signed-off-by: Alexei Starovoitov <email address hidden>
Acked-by: Toke Høiland-Jørgensen <email address hidden>
Link: https://lore.kernel.org/bpf/158945349039.97035.5262100484553494.stgit@firesoul
(cherry picked from commit ddb47d518ca10948d1f64a983cb9274720f691cd)
Signed-off-by: Maxim Mikityanskiy <email address hidden>
Reviewed-by: Moshe Shemesh <email address hidden>
Signed-off-by: Bodong Wang <email address hidden>