netfilter: x_tables: enforce nul-terminated table name from getsockopt GET_ENTRIES
Make sure the table names via getsockopt GET_ENTRIES is nul-terminated in ebtables and all the x_tables variants and their respective compat code. Uncovered by KASAN. Reported-by: Baozeng Ding <sploving1@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
@@ -1521,6 +1521,8 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
|
||||
if (copy_from_user(&tmp, user, sizeof(tmp)))
|
||||
return -EFAULT;
|
||||
|
||||
tmp.name[sizeof(tmp.name) - 1] = '\0';
|
||||
|
||||
t = find_table_lock(net, tmp.name, &ret, &ebt_mutex);
|
||||
if (!t)
|
||||
return ret;
|
||||
@@ -2332,6 +2334,8 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
|
||||
if (copy_from_user(&tmp, user, sizeof(tmp)))
|
||||
return -EFAULT;
|
||||
|
||||
tmp.name[sizeof(tmp.name) - 1] = '\0';
|
||||
|
||||
t = find_table_lock(net, tmp.name, &ret, &ebt_mutex);
|
||||
if (!t)
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user