Skip to content

Commit 3a69c0f

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: x_tables: xt_compat_match_from_user doesn't need a retval
commit 0188346f21e6546498c2a0f84888797ad4063fc5 upstream. Always returned 0. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0fab6d3 commit 3a69c0f

5 files changed

Lines changed: 26 additions & 51 deletions

File tree

include/linux/netfilter/x_tables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ void xt_compat_init_offsets(u_int8_t af, unsigned int number);
482482
int xt_compat_calc_jump(u_int8_t af, unsigned int offset);
483483

484484
int xt_compat_match_offset(const struct xt_match *match);
485-
int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
485+
void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
486486
unsigned int *size);
487487
int xt_compat_match_to_user(const struct xt_entry_match *m,
488488
void __user **dstptr, unsigned int *size);

net/ipv4/netfilter/arp_tables.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
13091309
return ret;
13101310
}
13111311

1312-
static int
1312+
static void
13131313
compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
13141314
unsigned int *size,
13151315
struct xt_table_info *newinfo, unsigned char *base)
@@ -1318,9 +1318,8 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
13181318
struct xt_target *target;
13191319
struct arpt_entry *de;
13201320
unsigned int origsize;
1321-
int ret, h;
1321+
int h;
13221322

1323-
ret = 0;
13241323
origsize = *size;
13251324
de = (struct arpt_entry *)*dstptr;
13261325
memcpy(de, e, sizeof(struct arpt_entry));
@@ -1341,7 +1340,6 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
13411340
if ((unsigned char *)de - base < newinfo->underflow[h])
13421341
newinfo->underflow[h] -= origsize - *size;
13431342
}
1344-
return ret;
13451343
}
13461344

13471345
static int translate_compat_table(struct xt_table_info **pinfo,
@@ -1420,16 +1418,11 @@ static int translate_compat_table(struct xt_table_info **pinfo,
14201418
entry1 = newinfo->entries;
14211419
pos = entry1;
14221420
size = compatr->size;
1423-
xt_entry_foreach(iter0, entry0, compatr->size) {
1424-
ret = compat_copy_entry_from_user(iter0, &pos, &size,
1425-
newinfo, entry1);
1426-
if (ret != 0)
1427-
break;
1428-
}
1421+
xt_entry_foreach(iter0, entry0, compatr->size)
1422+
compat_copy_entry_from_user(iter0, &pos, &size,
1423+
newinfo, entry1);
14291424
xt_compat_flush_offsets(NFPROTO_ARP);
14301425
xt_compat_unlock(NFPROTO_ARP);
1431-
if (ret)
1432-
goto free_newinfo;
14331426

14341427
ret = -ELOOP;
14351428
if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1))

net/ipv4/netfilter/ip_tables.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
15671567
return ret;
15681568
}
15691569

1570-
static int
1570+
static void
15711571
compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
15721572
unsigned int *size,
15731573
struct xt_table_info *newinfo, unsigned char *base)
@@ -1576,10 +1576,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
15761576
struct xt_target *target;
15771577
struct ipt_entry *de;
15781578
unsigned int origsize;
1579-
int ret, h;
1579+
int h;
15801580
struct xt_entry_match *ematch;
15811581

1582-
ret = 0;
15831582
origsize = *size;
15841583
de = (struct ipt_entry *)*dstptr;
15851584
memcpy(de, e, sizeof(struct ipt_entry));
@@ -1588,11 +1587,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
15881587
*dstptr += sizeof(struct ipt_entry);
15891588
*size += sizeof(struct ipt_entry) - sizeof(struct compat_ipt_entry);
15901589

1591-
xt_ematch_foreach(ematch, e) {
1592-
ret = xt_compat_match_from_user(ematch, dstptr, size);
1593-
if (ret != 0)
1594-
return ret;
1595-
}
1590+
xt_ematch_foreach(ematch, e)
1591+
xt_compat_match_from_user(ematch, dstptr, size);
1592+
15961593
de->target_offset = e->target_offset - (origsize - *size);
15971594
t = compat_ipt_get_target(e);
15981595
target = t->u.kernel.target;
@@ -1605,7 +1602,6 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
16051602
if ((unsigned char *)de - base < newinfo->underflow[h])
16061603
newinfo->underflow[h] -= origsize - *size;
16071604
}
1608-
return ret;
16091605
}
16101606

16111607
static int
@@ -1728,16 +1724,12 @@ translate_compat_table(struct net *net,
17281724
entry1 = newinfo->entries;
17291725
pos = entry1;
17301726
size = compatr->size;
1731-
xt_entry_foreach(iter0, entry0, compatr->size) {
1732-
ret = compat_copy_entry_from_user(iter0, &pos, &size,
1733-
newinfo, entry1);
1734-
if (ret != 0)
1735-
break;
1736-
}
1727+
xt_entry_foreach(iter0, entry0, compatr->size)
1728+
compat_copy_entry_from_user(iter0, &pos, &size,
1729+
newinfo, entry1);
1730+
17371731
xt_compat_flush_offsets(AF_INET);
17381732
xt_compat_unlock(AF_INET);
1739-
if (ret)
1740-
goto free_newinfo;
17411733

17421734
ret = -ELOOP;
17431735
if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1))

net/ipv6/netfilter/ip6_tables.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,18 +1579,17 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
15791579
return ret;
15801580
}
15811581

1582-
static int
1582+
static void
15831583
compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
15841584
unsigned int *size,
15851585
struct xt_table_info *newinfo, unsigned char *base)
15861586
{
15871587
struct xt_entry_target *t;
15881588
struct ip6t_entry *de;
15891589
unsigned int origsize;
1590-
int ret, h;
1590+
int h;
15911591
struct xt_entry_match *ematch;
15921592

1593-
ret = 0;
15941593
origsize = *size;
15951594
de = (struct ip6t_entry *)*dstptr;
15961595
memcpy(de, e, sizeof(struct ip6t_entry));
@@ -1599,11 +1598,9 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
15991598
*dstptr += sizeof(struct ip6t_entry);
16001599
*size += sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry);
16011600

1602-
xt_ematch_foreach(ematch, e) {
1603-
ret = xt_compat_match_from_user(ematch, dstptr, size);
1604-
if (ret != 0)
1605-
return ret;
1606-
}
1601+
xt_ematch_foreach(ematch, e)
1602+
xt_compat_match_from_user(ematch, dstptr, size);
1603+
16071604
de->target_offset = e->target_offset - (origsize - *size);
16081605
t = compat_ip6t_get_target(e);
16091606
xt_compat_target_from_user(t, dstptr, size);
@@ -1615,7 +1612,6 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
16151612
if ((unsigned char *)de - base < newinfo->underflow[h])
16161613
newinfo->underflow[h] -= origsize - *size;
16171614
}
1618-
return ret;
16191615
}
16201616

16211617
static int compat_check_entry(struct ip6t_entry *e, struct net *net,
@@ -1736,17 +1732,12 @@ translate_compat_table(struct net *net,
17361732
}
17371733
entry1 = newinfo->entries;
17381734
pos = entry1;
1739-
size = compatr->size;
1740-
xt_entry_foreach(iter0, entry0, compatr->size) {
1741-
ret = compat_copy_entry_from_user(iter0, &pos, &size,
1742-
newinfo, entry1);
1743-
if (ret != 0)
1744-
break;
1745-
}
1735+
xt_entry_foreach(iter0, entry0, compatr->size)
1736+
compat_copy_entry_from_user(iter0, &pos, &size,
1737+
newinfo, entry1);
1738+
17461739
xt_compat_flush_offsets(AF_INET6);
17471740
xt_compat_unlock(AF_INET6);
1748-
if (ret)
1749-
goto free_newinfo;
17501741

17511742
ret = -ELOOP;
17521743
if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1))

net/netfilter/x_tables.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ int xt_compat_match_offset(const struct xt_match *match)
525525
}
526526
EXPORT_SYMBOL_GPL(xt_compat_match_offset);
527527

528-
int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
529-
unsigned int *size)
528+
void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
529+
unsigned int *size)
530530
{
531531
const struct xt_match *match = m->u.kernel.match;
532532
struct compat_xt_entry_match *cm = (struct compat_xt_entry_match *)m;
@@ -548,7 +548,6 @@ int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
548548

549549
*size += off;
550550
*dstptr += msize;
551-
return 0;
552551
}
553552
EXPORT_SYMBOL_GPL(xt_compat_match_from_user);
554553

0 commit comments

Comments
 (0)