Commit 5a66cda5 authored by Alexander Lobakin's avatar Alexander Lobakin Committed by David S. Miller

ip_tunnel: harden copying IP tunnel params to userspace

Structures which are about to be copied to userspace shouldn't have
uninitialized fields or paddings.
memset() the whole &ip_tunnel_parm in ip_tunnel_parm_to_user() before
filling it with the kernel data. The compilers will hopefully combine
writes to it.

Fixes: 117aef12 ("ip_tunnel: use a separate struct to store tunnel params in the kernel")
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/netdev/5f63dd25-de94-4ca3-84e6-14095953db13@moroto.mountainSigned-off-by: default avatarAlexander Lobakin <aleksander.lobakin@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eec53cc3
...@@ -1034,6 +1034,8 @@ bool ip_tunnel_parm_to_user(void __user *data, struct ip_tunnel_parm_kern *kp) ...@@ -1034,6 +1034,8 @@ bool ip_tunnel_parm_to_user(void __user *data, struct ip_tunnel_parm_kern *kp)
!ip_tunnel_flags_is_be16_compat(kp->o_flags)) !ip_tunnel_flags_is_be16_compat(kp->o_flags))
return false; return false;
memset(&p, 0, sizeof(p));
strscpy(p.name, kp->name); strscpy(p.name, kp->name);
p.link = kp->link; p.link = kp->link;
p.i_flags = ip_tunnel_flags_to_be16(kp->i_flags); p.i_flags = ip_tunnel_flags_to_be16(kp->i_flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment