xsk: Add missing check on user supplied headroom size
authorMagnus Karlsson <magnus.karlsson@intel.com>
Tue, 14 Apr 2020 07:35:15 +0000 (09:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Apr 2020 08:30:15 +0000 (10:30 +0200)
commitad8fb61c184fe0f8d1e0b5b954d010fb9f94a6ee
tree81c44297a8c5eb48cca46e2c20c6e8e68df435d1
parent2b48629885b6f6a0f26bd51f9dbdca1a0bfa217a
xsk: Add missing check on user supplied headroom size

[ Upstream commit 99e3a236dd43d06c65af0a2ef9cb44306aef6e02 ]

Add a check that the headroom cannot be larger than the available
space in the chunk. In the current code, a malicious user can set the
headroom to a value larger than the chunk size minus the fixed XDP
headroom. That way packets with a length larger than the supported
size in the umem could get accepted and result in an out-of-bounds
write.

Fixes: c0c77d8fb787 ("xsk: add user memory registration support sockopt")
Reported-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=207225
Link: https://lore.kernel.org/bpf/1586849715-23490-1-git-send-email-magnus.karlsson@intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/xdp/xdp_umem.c