mbuf: fix boundary check at dynamic field registration
authorXiaolong Ye <xiaolong.ye@intel.com>
Sat, 13 Jun 2020 15:49:17 +0000 (23:49 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 25 Jun 2020 21:03:18 +0000 (23:03 +0200)
commitf8eb26dda8bfc806ff71f65966dc17210686fc20
tree04517489fae44cc88a45169a3a5fdb64249b6525
parent54f3fb127d9c265a5724d193e5c7c6db29fb4150
mbuf: fix boundary check at dynamic field registration

We should make sure off + size < sizeof(struct rte_mbuf) to avoid
possible out-of-bounds access of free_space array, there is no issue
currently due to the low bits of free_flags (which is adjacent to
free_space) are always set to 0. But we shouldn't rely on it since it's
fragile and layout of struct mbuf_dyn_shm may be changed in the future.
This patch adds boundary check explicitly to avoid potential risk of
out-of-bounds access.

Fixes: 4958ca3a443a ("mbuf: support dynamic fields and flags")
Cc: stable@dpdk.org
Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_mbuf/rte_mbuf_dyn.c