]> git.baikalelectronics.ru Git - kernel.git/commit
net, neigh: Add build-time assertion to avoid neigh->flags overflow
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 13 Oct 2021 13:21:38 +0000 (15:21 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 Oct 2021 02:16:21 +0000 (19:16 -0700)
commit34d3b400e75cb87c94f104b657fb6403c0289c9b
tree039b87bb94c7a7a0874ca532bb6711c59b1923a8
parent03788612c1b9a2b94cfe0c326d4a28e0a473d135
net, neigh: Add build-time assertion to avoid neigh->flags overflow

Currently, NDA_FLAGS_EXT flags allow a maximum of 24 bits to be used for
extended neighbor flags. These are eventually fed into neigh->flags by
shifting with NTF_EXT_SHIFT as per commit 68c6f2d503d1 ("net, neigh:
Extend neigh->flags to 32 bit to allow for extensions").

If really ever needed in future, the full 32 bits from NDA_FLAGS_EXT can
be used, it would only require to move neigh->flags from u32 to u64 inside
the kernel.

Add a build-time assertion such that when extending the NTF_EXT_MASK with
new bits, we'll trigger an error once we surpass the 24th bit. This assumes
that no bit holes in new NTF_EXT_* flags will slip in from UAPI, but I
think this is reasonable to assume.

Suggested-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/neighbour.c