Skip to content

Commit 0188346

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: x_tables: xt_compat_match_from_user doesn't need a retval
Always returned 0. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 8dddd32 commit 0188346

File tree

5 files changed

+26
-51
lines changed

5 files changed

+26
-51
lines changed

include/linux/netfilter/x_tables.h

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

486486
int xt_compat_match_offset(const struct xt_match *match);
487-
int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
487+
void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
488488
unsigned int *size);
489489
int xt_compat_match_to_user(const struct xt_entry_match *m,
490490
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
@@ -1310,7 +1310,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
13101310
return ret;
13111311
}
13121312

1313-
static int
1313+
static void
13141314
compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
13151315
unsigned int *size,
13161316
struct xt_table_info *newinfo, unsigned char *base)
@@ -1319,9 +1319,8 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
13191319
struct xt_target *target;
13201320
struct arpt_entry *de;
13211321
unsigned int origsize;
1322-
int ret, h;
1322+
int h;
13231323

1324-
ret = 0;
13251324
origsize = *size;
13261325
de = (struct arpt_entry *)*dstptr;
13271326
memcpy(de, e, sizeof(struct arpt_entry));
@@ -1342,7 +1341,6 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
13421341
if ((unsigned char *)de - base < newinfo->underflow[h])
13431342
newinfo->underflow[h] -= origsize - *size;
13441343
}
1345-
return ret;
13461344
}
13471345

13481346
static int translate_compat_table(struct xt_table_info **pinfo,
@@ -1421,16 +1419,11 @@ static int translate_compat_table(struct xt_table_info **pinfo,
14211419
entry1 = newinfo->entries;
14221420
pos = entry1;
14231421
size = compatr->size;
1424-
xt_entry_foreach(iter0, entry0, compatr->size) {
1425-
ret = compat_copy_entry_from_user(iter0, &pos, &size,
1426-
newinfo, entry1);
1427-
if (ret != 0)
1428-
break;
1429-
}
1422+
xt_entry_foreach(iter0, entry0, compatr->size)
1423+
compat_copy_entry_from_user(iter0, &pos, &size,
1424+
newinfo, entry1);
14301425
xt_compat_flush_offsets(NFPROTO_ARP);
14311426
xt_compat_unlock(NFPROTO_ARP);
1432-
if (ret)
1433-
goto free_newinfo;
14341427

14351428
ret = -ELOOP;
14361429
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
@@ -1568,7 +1568,7 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
15681568
return ret;
15691569
}
15701570

1571-
static int
1571+
static void
15721572
compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
15731573
unsigned int *size,
15741574
struct xt_table_info *newinfo, unsigned char *base)
@@ -1577,10 +1577,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
15771577
struct xt_target *target;
15781578
struct ipt_entry *de;
15791579
unsigned int origsize;
1580-
int ret, h;
1580+
int h;
15811581
struct xt_entry_match *ematch;
15821582

1583-
ret = 0;
15841583
origsize = *size;
15851584
de = (struct ipt_entry *)*dstptr;
15861585
memcpy(de, e, sizeof(struct ipt_entry));
@@ -1589,11 +1588,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
15891588
*dstptr += sizeof(struct ipt_entry);
15901589
*size += sizeof(struct ipt_entry) - sizeof(struct compat_ipt_entry);
15911590

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

16121608
static int
@@ -1729,16 +1725,12 @@ translate_compat_table(struct net *net,
17291725
entry1 = newinfo->entries;
17301726
pos = entry1;
17311727
size = compatr->size;
1732-
xt_entry_foreach(iter0, entry0, compatr->size) {
1733-
ret = compat_copy_entry_from_user(iter0, &pos, &size,
1734-
newinfo, entry1);
1735-
if (ret != 0)
1736-
break;
1737-
}
1728+
xt_entry_foreach(iter0, entry0, compatr->size)
1729+
compat_copy_entry_from_user(iter0, &pos, &size,
1730+
newinfo, entry1);
1731+
17381732
xt_compat_flush_offsets(AF_INET);
17391733
xt_compat_unlock(AF_INET);
1740-
if (ret)
1741-
goto free_newinfo;
17421734

17431735
ret = -ELOOP;
17441736
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
@@ -1580,18 +1580,17 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
15801580
return ret;
15811581
}
15821582

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

1594-
ret = 0;
15951594
origsize = *size;
15961595
de = (struct ip6t_entry *)*dstptr;
15971596
memcpy(de, e, sizeof(struct ip6t_entry));
@@ -1600,11 +1599,9 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
16001599
*dstptr += sizeof(struct ip6t_entry);
16011600
*size += sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry);
16021601

1603-
xt_ematch_foreach(ematch, e) {
1604-
ret = xt_compat_match_from_user(ematch, dstptr, size);
1605-
if (ret != 0)
1606-
return ret;
1607-
}
1602+
xt_ematch_foreach(ematch, e)
1603+
xt_compat_match_from_user(ematch, dstptr, size);
1604+
16081605
de->target_offset = e->target_offset - (origsize - *size);
16091606
t = compat_ip6t_get_target(e);
16101607
xt_compat_target_from_user(t, dstptr, size);
@@ -1616,7 +1613,6 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
16161613
if ((unsigned char *)de - base < newinfo->underflow[h])
16171614
newinfo->underflow[h] -= origsize - *size;
16181615
}
1619-
return ret;
16201616
}
16211617

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

17521743
ret = -ELOOP;
17531744
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
@@ -526,8 +526,8 @@ int xt_compat_match_offset(const struct xt_match *match)
526526
}
527527
EXPORT_SYMBOL_GPL(xt_compat_match_offset);
528528

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

550550
*size += off;
551551
*dstptr += msize;
552-
return 0;
553552
}
554553
EXPORT_SYMBOL_GPL(xt_compat_match_from_user);
555554

0 commit comments

Comments
 (0)