]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip xfrm: use correct key length for netlink message
authorMichal Kubecek <mkubecek@suse.cz>
Fri, 29 Sep 2017 11:41:05 +0000 (13:41 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 1 Oct 2017 20:44:38 +0000 (13:44 -0700)
commit4c0939a29e2c1739f0141c87ecd7940825734a22
tree098509415018703804eb9550e79900eb35da303f
parent73451259daaa84185bd151461252590ba67cdee0
ip xfrm: use correct key length for netlink message

When SA is added manually using "ip xfrm state add", xfrm_state_modify()
uses alg_key_len field of struct xfrm_algo for the length of key passed to
kernel in the netlink message. However alg_key_len is bit length of the key
while we need byte length here. This is usually harmless as kernel ignores
the excess data but when the bit length of the key exceeds 512
(XFRM_ALGO_KEY_BUF_SIZE), it can result in buffer overflow.

We can simply divide by 8 here as the only place setting alg_key_len is in
xfrm_algo_parse() where it is always set to a multiple of 8 (and there are
already multiple places using "algo->alg_key_len / 8").

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
ip/xfrm_state.c