xfrm: prevent ipcomp scratch buffer race condition
authorMichal Kubecek <mkubecek@suse.cz>
Thu, 17 Oct 2013 13:07:40 +0000 (15:07 +0200)
committerJiri Slaby <jslaby@suse.cz>
Fri, 14 Mar 2014 21:48:58 +0000 (22:48 +0100)
commit5516d3fa4670849e446c81ddd4c00f0fd09f1173
tree07c0ac04483279ad6647020157f2edf384f93097
parent03cb0a7b03eda410fb0f7e03843e60c3318a38e7
xfrm: prevent ipcomp scratch buffer race condition

commit 12e3594698f6c3ab6ebacc79f2fb2ad2bb5952b5 upstream.

In ipcomp_compress(), sortirq is enabled too early, allowing the
per-cpu scratch buffer to be rewritten by ipcomp_decompress()
(called on the same CPU in softirq context) between populating
the buffer and copying the compressed data to the skb.

v2: as pointed out by Steffen Klassert, if we also move the
local_bh_disable() before reading the per-cpu pointers, we can
get rid of get_cpu()/put_cpu().

v3: removed ipcomp_decompress part (as explained by Herbert Xu,
it cannot be called from process context), get rid of cpu
variable (thanks to Eric Dumazet)

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
net/xfrm/xfrm_ipcomp.c