netfilter: x_tables: fix incorrect parameter length before call copy_from_sockptr
Subsystems (4)
PATCH 1/1 netfilter: x_tables: fix incorrect parameter length before call copy_from_sockptr
If len < sizeof(tmp) it will trigger oob, so take the min of them.
Signed-off-by Edward Adam Davis <[email protected]>
--- net/ipv4/netfilter/arp_tables.c | 4 ++-- net/ipv4/netfilter/ip_tables.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
net/ipv4/netfilter/arp_tables.c +2 -2
@@ -956,7 +956,7 @@ static int do_replace(struct net *net, sockptr_t arg, unsigned int len)void *loc_cpu_entry;struct arpt_entry *iter; -if (copy_from_sockptr (&tmp, arg,sizeof (tmp)) !=0 ) + if (copy_from_sockptr(&tmp, arg, min_t(unsigned int, sizeof(tmp), len)) != 0)return -EFAULT ;/* overflow check */
@@ -1254,7 +1254,7 @@ static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len)void *loc_cpu_entry;struct arpt_entry *iter; -if (copy_from_sockptr (&tmp, arg,sizeof (tmp)) !=0 ) + if (copy_from_sockptr(&tmp, arg, min_t(unsigned int, sizeof(tmp), len)) != 0)return -EFAULT ;/* overflow check */
net/ipv4/netfilter/ip_tables.c +2 -2
@@ -1108,7 +1108,7 @@ do_replace(struct net *net, sockptr_t arg, unsigned int len)void *loc_cpu_entry;struct ipt_entry *iter; -if (copy_from_sockptr (&tmp, arg,sizeof (tmp)) !=0 ) + if (copy_from_sockptr(&tmp, arg, min_t(unsigned int, sizeof(tmp), len)) != 0)return -EFAULT ;/* overflow check */
@@ -1492,7 +1492,7 @@ compat_do_replace(struct net *net, sockptr_t arg, unsigned int len)void *loc_cpu_entry;struct ipt_entry *iter; -if (copy_from_sockptr (&tmp, arg,sizeof (tmp)) !=0 ) + if (copy_from_sockptr(&tmp, arg, min_t(unsigned int, sizeof(tmp), len)) != 0)return -EFAULT ;/* overflow check */
Signature · 1 line
2.43.0
Quoted 7 lines · Edward Adam Davis
If len < sizeof(tmp) it will trigger oob, so take the min of them.
Signed-off-by Edward Adam Davis <[email protected]>--- net/ipv4/netfilter/arp_tables.c | 4 ++-- net/ipv4/netfilter/ip_tables.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Hi Edward
Already fixed in net tree
Also a followup has been sent today
https://lore.kernel.org/netdev/[email protected]/T/#u
Thanks.