Memory Corruption Vulnerability in IPT_SO_SET_REPLACE
A memory corruption vulnerability exists in the IPT_SO_SET_REPLACE setsockopt in the netfilter code for iptables support. This setsockopt is can be triggered by an unprivileged user on PF_INET sockets when unprivileged user namespaces are available (CONFIG_USER_NS=y). In the mark_source_chains function (net/ipv4/netfilter/ip_tables.c) it is possible for a user-supplied ipt_entry structure to have a large next_offset field. This field is not bounds checked prior to writing a counter value at the supplied offset, leading to an out of bounds 32-bit write in a 64kb range from the allocated heap entry, with a controlled offset and a partially controlled write value. Furthermore, a recent refactoring of this codepath introduced an integer overflow in xt_alloc_table_info, which on 32-bit systems can lead to small structure allocation and a copy_from_user based heap corruption.