Merge branch 'master' of git://dev.medozas.de/linux
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Copyright (C) 2002 David S. Miller (davem@redhat.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
@@ -341,15 +341,11 @@ unsigned int arpt_do_table(struct sk_buff *skb,
|
||||
}
|
||||
|
||||
/* All zeroes == unconditional rule. */
|
||||
static inline int unconditional(const struct arpt_arp *arp)
|
||||
static inline bool unconditional(const struct arpt_arp *arp)
|
||||
{
|
||||
unsigned int i;
|
||||
static const struct arpt_arp uncond;
|
||||
|
||||
for (i = 0; i < sizeof(*arp)/sizeof(__u32); i++)
|
||||
if (((__u32 *)arp)[i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return memcmp(arp, &uncond, sizeof(uncond)) == 0;
|
||||
}
|
||||
|
||||
/* Figures out from what hook each rule can be called: returns 0 if
|
||||
@@ -537,12 +533,28 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool check_underflow(struct arpt_entry *e)
|
||||
{
|
||||
const struct arpt_entry_target *t;
|
||||
unsigned int verdict;
|
||||
|
||||
if (!unconditional(&e->arp))
|
||||
return false;
|
||||
t = arpt_get_target(e);
|
||||
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)
|
||||
return false;
|
||||
verdict = ((struct arpt_standard_target *)t)->verdict;
|
||||
verdict = -verdict - 1;
|
||||
return verdict == NF_DROP || verdict == NF_ACCEPT;
|
||||
}
|
||||
|
||||
static inline int check_entry_size_and_hooks(struct arpt_entry *e,
|
||||
struct xt_table_info *newinfo,
|
||||
unsigned char *base,
|
||||
unsigned char *limit,
|
||||
const unsigned int *hook_entries,
|
||||
const unsigned int *underflows,
|
||||
unsigned int valid_hooks,
|
||||
unsigned int *i)
|
||||
{
|
||||
unsigned int h;
|
||||
@@ -562,15 +574,21 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
|
||||
|
||||
/* Check hooks & underflows */
|
||||
for (h = 0; h < NF_ARP_NUMHOOKS; h++) {
|
||||
if (!(valid_hooks & (1 << h)))
|
||||
continue;
|
||||
if ((unsigned char *)e - base == hook_entries[h])
|
||||
newinfo->hook_entry[h] = hook_entries[h];
|
||||
if ((unsigned char *)e - base == underflows[h])
|
||||
if ((unsigned char *)e - base == underflows[h]) {
|
||||
if (!check_underflow(e)) {
|
||||
pr_err("Underflows must be unconditional and "
|
||||
"use the STANDARD target with "
|
||||
"ACCEPT/DROP\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
newinfo->underflow[h] = underflows[h];
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: underflows must be unconditional, standard verdicts
|
||||
< 0 (not ARPT_RETURN). --RR */
|
||||
|
||||
/* Clear counters and comefrom */
|
||||
e->counters = ((struct xt_counters) { 0, 0 });
|
||||
e->comefrom = 0;
|
||||
@@ -630,7 +648,7 @@ static int translate_table(const char *name,
|
||||
newinfo,
|
||||
entry0,
|
||||
entry0 + size,
|
||||
hook_entries, underflows, &i);
|
||||
hook_entries, underflows, valid_hooks, &i);
|
||||
duprintf("translate_table: ARPT_ENTRY_ITERATE gives %d\n", ret);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
#include <linux/cache.h>
|
||||
#include <linux/capability.h>
|
||||
#include <linux/skbuff.h>
|
||||
@@ -190,16 +191,11 @@ get_entry(void *base, unsigned int offset)
|
||||
|
||||
/* All zeroes == unconditional rule. */
|
||||
/* Mildly perf critical (only if packet tracing is on) */
|
||||
static inline int
|
||||
unconditional(const struct ipt_ip *ip)
|
||||
static inline bool unconditional(const struct ipt_ip *ip)
|
||||
{
|
||||
unsigned int i;
|
||||
static const struct ipt_ip uncond;
|
||||
|
||||
for (i = 0; i < sizeof(*ip)/sizeof(__u32); i++)
|
||||
if (((__u32 *)ip)[i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return memcmp(ip, &uncond, sizeof(uncond)) == 0;
|
||||
#undef FWINV
|
||||
}
|
||||
|
||||
@@ -315,7 +311,6 @@ ipt_do_table(struct sk_buff *skb,
|
||||
|
||||
static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
|
||||
const struct iphdr *ip;
|
||||
u_int16_t datalen;
|
||||
bool hotdrop = false;
|
||||
/* Initializing verdict to NF_DROP keeps gcc happy. */
|
||||
unsigned int verdict = NF_DROP;
|
||||
@@ -328,7 +323,6 @@ ipt_do_table(struct sk_buff *skb,
|
||||
|
||||
/* Initialization */
|
||||
ip = ip_hdr(skb);
|
||||
datalen = skb->len - ip->ihl * 4;
|
||||
indev = in ? in->name : nulldevname;
|
||||
outdev = out ? out->name : nulldevname;
|
||||
/* We handle fragments by dealing with the first fragment as
|
||||
@@ -427,8 +421,6 @@ ipt_do_table(struct sk_buff *skb,
|
||||
#endif
|
||||
/* Target might have changed stuff. */
|
||||
ip = ip_hdr(skb);
|
||||
datalen = skb->len - ip->ihl * 4;
|
||||
|
||||
if (verdict == IPT_CONTINUE)
|
||||
e = ipt_next_entry(e);
|
||||
else
|
||||
@@ -716,6 +708,21 @@ find_check_entry(struct ipt_entry *e, const char *name, unsigned int size,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool check_underflow(struct ipt_entry *e)
|
||||
{
|
||||
const struct ipt_entry_target *t;
|
||||
unsigned int verdict;
|
||||
|
||||
if (!unconditional(&e->ip))
|
||||
return false;
|
||||
t = ipt_get_target(e);
|
||||
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0)
|
||||
return false;
|
||||
verdict = ((struct ipt_standard_target *)t)->verdict;
|
||||
verdict = -verdict - 1;
|
||||
return verdict == NF_DROP || verdict == NF_ACCEPT;
|
||||
}
|
||||
|
||||
static int
|
||||
check_entry_size_and_hooks(struct ipt_entry *e,
|
||||
struct xt_table_info *newinfo,
|
||||
@@ -723,6 +730,7 @@ check_entry_size_and_hooks(struct ipt_entry *e,
|
||||
unsigned char *limit,
|
||||
const unsigned int *hook_entries,
|
||||
const unsigned int *underflows,
|
||||
unsigned int valid_hooks,
|
||||
unsigned int *i)
|
||||
{
|
||||
unsigned int h;
|
||||
@@ -742,15 +750,21 @@ check_entry_size_and_hooks(struct ipt_entry *e,
|
||||
|
||||
/* Check hooks & underflows */
|
||||
for (h = 0; h < NF_INET_NUMHOOKS; h++) {
|
||||
if (!(valid_hooks & (1 << h)))
|
||||
continue;
|
||||
if ((unsigned char *)e - base == hook_entries[h])
|
||||
newinfo->hook_entry[h] = hook_entries[h];
|
||||
if ((unsigned char *)e - base == underflows[h])
|
||||
if ((unsigned char *)e - base == underflows[h]) {
|
||||
if (!check_underflow(e)) {
|
||||
pr_err("Underflows must be unconditional and "
|
||||
"use the STANDARD target with "
|
||||
"ACCEPT/DROP\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
newinfo->underflow[h] = underflows[h];
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: underflows must be unconditional, standard verdicts
|
||||
< 0 (not IPT_RETURN). --RR */
|
||||
|
||||
/* Clear counters and comefrom */
|
||||
e->counters = ((struct xt_counters) { 0, 0 });
|
||||
e->comefrom = 0;
|
||||
@@ -813,7 +827,7 @@ translate_table(const char *name,
|
||||
newinfo,
|
||||
entry0,
|
||||
entry0 + size,
|
||||
hook_entries, underflows, &i);
|
||||
hook_entries, underflows, valid_hooks, &i);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
|
@@ -57,7 +57,7 @@ static struct xt_table packet_filter = {
|
||||
.name = "filter",
|
||||
.valid_hooks = FILTER_VALID_HOOKS,
|
||||
.me = THIS_MODULE,
|
||||
.af = AF_INET,
|
||||
.af = NFPROTO_IPV4,
|
||||
};
|
||||
|
||||
/* The work comes in here from netfilter.c. */
|
||||
@@ -102,21 +102,21 @@ static struct nf_hook_ops ipt_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = ipt_local_in_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_IN,
|
||||
.priority = NF_IP_PRI_FILTER,
|
||||
},
|
||||
{
|
||||
.hook = ipt_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_FORWARD,
|
||||
.priority = NF_IP_PRI_FILTER,
|
||||
},
|
||||
{
|
||||
.hook = ipt_local_out_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_FILTER,
|
||||
},
|
||||
|
@@ -68,7 +68,7 @@ static struct xt_table packet_mangler = {
|
||||
.name = "mangle",
|
||||
.valid_hooks = MANGLE_VALID_HOOKS,
|
||||
.me = THIS_MODULE,
|
||||
.af = AF_INET,
|
||||
.af = NFPROTO_IPV4,
|
||||
};
|
||||
|
||||
/* The work comes in here from netfilter.c. */
|
||||
@@ -162,35 +162,35 @@ static struct nf_hook_ops ipt_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = ipt_pre_routing_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_PRE_ROUTING,
|
||||
.priority = NF_IP_PRI_MANGLE,
|
||||
},
|
||||
{
|
||||
.hook = ipt_local_in_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_IN,
|
||||
.priority = NF_IP_PRI_MANGLE,
|
||||
},
|
||||
{
|
||||
.hook = ipt_forward_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_FORWARD,
|
||||
.priority = NF_IP_PRI_MANGLE,
|
||||
},
|
||||
{
|
||||
.hook = ipt_local_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_MANGLE,
|
||||
},
|
||||
{
|
||||
.hook = ipt_post_routing_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_POST_ROUTING,
|
||||
.priority = NF_IP_PRI_MANGLE,
|
||||
},
|
||||
|
@@ -40,7 +40,7 @@ static struct xt_table packet_raw = {
|
||||
.name = "raw",
|
||||
.valid_hooks = RAW_VALID_HOOKS,
|
||||
.me = THIS_MODULE,
|
||||
.af = AF_INET,
|
||||
.af = NFPROTO_IPV4,
|
||||
};
|
||||
|
||||
/* The work comes in here from netfilter.c. */
|
||||
@@ -74,14 +74,14 @@ ipt_local_hook(unsigned int hook,
|
||||
static struct nf_hook_ops ipt_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = ipt_hook,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_PRE_ROUTING,
|
||||
.priority = NF_IP_PRI_RAW,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
{
|
||||
.hook = ipt_local_hook,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_RAW,
|
||||
.owner = THIS_MODULE,
|
||||
|
@@ -61,7 +61,7 @@ static struct xt_table security_table = {
|
||||
.name = "security",
|
||||
.valid_hooks = SECURITY_VALID_HOOKS,
|
||||
.me = THIS_MODULE,
|
||||
.af = AF_INET,
|
||||
.af = NFPROTO_IPV4,
|
||||
};
|
||||
|
||||
static unsigned int
|
||||
@@ -105,21 +105,21 @@ static struct nf_hook_ops ipt_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = ipt_local_in_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_IN,
|
||||
.priority = NF_IP_PRI_SECURITY,
|
||||
},
|
||||
{
|
||||
.hook = ipt_forward_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_FORWARD,
|
||||
.priority = NF_IP_PRI_SECURITY,
|
||||
},
|
||||
{
|
||||
.hook = ipt_local_out_hook,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_SECURITY,
|
||||
},
|
||||
|
@@ -158,28 +158,28 @@ static struct nf_hook_ops ipv4_conntrack_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = ipv4_conntrack_in,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_PRE_ROUTING,
|
||||
.priority = NF_IP_PRI_CONNTRACK,
|
||||
},
|
||||
{
|
||||
.hook = ipv4_conntrack_local,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_CONNTRACK,
|
||||
},
|
||||
{
|
||||
.hook = ipv4_confirm,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_POST_ROUTING,
|
||||
.priority = NF_IP_PRI_CONNTRACK_CONFIRM,
|
||||
},
|
||||
{
|
||||
.hook = ipv4_confirm,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_IN,
|
||||
.priority = NF_IP_PRI_CONNTRACK_CONFIRM,
|
||||
},
|
||||
|
@@ -62,7 +62,7 @@ static struct xt_table nat_table = {
|
||||
.name = "nat",
|
||||
.valid_hooks = NAT_VALID_HOOKS,
|
||||
.me = THIS_MODULE,
|
||||
.af = AF_INET,
|
||||
.af = NFPROTO_IPV4,
|
||||
};
|
||||
|
||||
/* Source NAT */
|
||||
|
@@ -251,7 +251,7 @@ static struct nf_hook_ops nf_nat_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = nf_nat_in,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_PRE_ROUTING,
|
||||
.priority = NF_IP_PRI_NAT_DST,
|
||||
},
|
||||
@@ -259,7 +259,7 @@ static struct nf_hook_ops nf_nat_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = nf_nat_out,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_POST_ROUTING,
|
||||
.priority = NF_IP_PRI_NAT_SRC,
|
||||
},
|
||||
@@ -267,7 +267,7 @@ static struct nf_hook_ops nf_nat_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = nf_nat_local_fn,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_OUT,
|
||||
.priority = NF_IP_PRI_NAT_DST,
|
||||
},
|
||||
@@ -275,7 +275,7 @@ static struct nf_hook_ops nf_nat_ops[] __read_mostly = {
|
||||
{
|
||||
.hook = nf_nat_fn,
|
||||
.owner = THIS_MODULE,
|
||||
.pf = PF_INET,
|
||||
.pf = NFPROTO_IPV4,
|
||||
.hooknum = NF_INET_LOCAL_IN,
|
||||
.priority = NF_IP_PRI_NAT_SRC,
|
||||
},
|
||||
|
Reference in New Issue
Block a user