]> git.ipfire.org Git - thirdparty/nftables.git/commit
netlink: add and use nft_data_memcpy helper
authorFlorian Westphal <fw@strlen.de>
Fri, 8 Dec 2023 14:34:29 +0000 (15:34 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 12 Dec 2023 14:20:41 +0000 (15:20 +0100)
commit130060afa9f6f11e14ea5cf372545407179f16ac
treea30d250d7129ac8f1d3adbeb0e4b3d47baabe9ad
parent21608263cc1ae489326e743957bfe34b05414a44
netlink: add and use nft_data_memcpy helper

There is a stack overflow somewhere in this code, we end
up memcpy'ing a way too large expr into a fixed-size on-stack
buffer.

This is hard to diagnose, most of this code gets inlined so
the crash happens later on return from alloc_nftnl_setelem.

Condense the mempy into a helper and add a BUG so we can catch
the overflow before it occurs.

->value is too small (4, should be 16), but for normal
cases (well-formed data must fit into max reg space, i.e.
64 byte) the chain buffer that comes after value in the
structure provides a cushion.

In order to have the new BUG() not trigger on valid data,
bump value to the correct size, this is userspace so the additional
60 bytes of stack usage is no concern.

Signed-off-by: Florian Westphal <fw@strlen.de>
include/netlink.h
src/netlink.c