]> www.infradead.org Git - users/dwmw2/linux.git/commit
bpf: fix sg shift repair start offset in bpf_msg_pull_data
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 29 Aug 2018 14:50:36 +0000 (16:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Oct 2018 06:55:53 +0000 (08:55 +0200)
commitcf09d1f5a507d0e609992ad9b502fd0a10e9b2b8
tree39c51cadbb52b67ca85518586e3effeacfb08640
parent89826ce1bbcad04c17d65f7d8fa7b457c3bdce7c
bpf: fix sg shift repair start offset in bpf_msg_pull_data

[ Upstream commit a8cf76a9023bc6709b1361d06bb2fae5227b9d68 ]

When we perform the sg shift repair for the scatterlist ring, we
currently start out at i = first_sg + 1. However, this is not
correct since the first_sg could point to the sge sitting at slot
MAX_SKB_FRAGS - 1, and a subsequent i = MAX_SKB_FRAGS will access
the scatterlist ring (sg) out of bounds. Add the sk_msg_iter_var()
helper for iterating through the ring, and apply the same rule
for advancing to the next ring element as we do elsewhere. Later
work will use this helper also in other places.

Fixes: 015632bb30da ("bpf: sk_msg program helper bpf_sk_msg_pull_data")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/filter.c