]> Pileus Git - ~andy/linux/commitdiff
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
authorDavid S. Miller <davem@davemloft.net>
Wed, 8 Jan 2014 20:04:56 +0000 (15:04 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Jan 2014 20:04:56 +0000 (15:04 -0500)
Pablo Neira Ayuso says:

====================
Netfilter updates for net-next

The following patchset contains three Netfilter updates, they are:

* Fix wrong usage of skb_header_pointer in the DCCP protocol helper that
  has been there for quite some time. It was resulting in copying the dccp
  header to a pointer allocated in the stack. Fortunately, this pointer
  provides room for the dccp header is 4 bytes long, so no crashes have been
  reported so far. From Daniel Borkmann.

* Use format string to print in the invocation of nf_log_packet(), again
  in the DCCP helper. Also from Daniel Borkmann.

* Revert "netfilter: avoid get_random_bytes call" as prandom32 does not
  guarantee enough entropy when being calling this at boot time, that may
  happen when reloading the rule.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
net/netfilter/nf_conntrack_proto_dccp.c
net/netfilter/nfnetlink_log.c
net/netfilter/nft_hash.c
net/netfilter/xt_RATEEST.c
net/netfilter/xt_connlimit.c
net/netfilter/xt_hashlimit.c
net/netfilter/xt_recent.c

index a99b6c3427b0ce3e06458cb1fd37bc3bfac98723..cb372f96f10dc3c2f60064e49b86d35c76c6cd1b 100644 (file)
@@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
        const char *msg;
        u_int8_t state;
 
-       dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
+       dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
        BUG_ON(dh == NULL);
 
        state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
@@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
 out_invalid:
        if (LOG_INVALID(net, IPPROTO_DCCP))
                nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
-                             NULL, msg);
+                             NULL, "%s", msg);
        return false;
 }
 
@@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
        u_int8_t type, old_state, new_state;
        enum ct_dccp_roles role;
 
-       dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
+       dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
        BUG_ON(dh == NULL);
        type = dh->dccph_type;
 
@@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
        unsigned int cscov;
        const char *msg;
 
-       dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
+       dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
        if (dh == NULL) {
                msg = "nf_ct_dccp: short packet ";
                goto out_invalid;
@@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
 
 out_invalid:
        if (LOG_INVALID(net, IPPROTO_DCCP))
-               nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
+               nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
        return -NF_ACCEPT;
 }
 
index d292c8d286ebeac22f688d47df8b793e9c90cc6b..a155d19a225edcfb4b1a550ebc898f40d51c564d 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/proc_fs.h>
 #include <linux/security.h>
 #include <linux/list.h>
+#include <linux/jhash.h>
+#include <linux/random.h>
 #include <linux/slab.h>
 #include <net/sock.h>
 #include <net/netfilter/nf_log.h>
@@ -73,6 +75,7 @@ struct nfulnl_instance {
 };
 
 #define INSTANCE_BUCKETS       16
+static unsigned int hash_init;
 
 static int nfnl_log_net_id __read_mostly;
 
@@ -1064,6 +1067,11 @@ static int __init nfnetlink_log_init(void)
 {
        int status = -ENOMEM;
 
+       /* it's not really all that important to have a random value, so
+        * we can do this from the init function, even if there hasn't
+        * been that much entropy yet */
+       get_random_bytes(&hash_init, sizeof(hash_init));
+
        netlink_register_notifier(&nfulnl_rtnl_notifier);
        status = nfnetlink_subsys_register(&nfulnl_subsys);
        if (status < 0) {
index 6aae699aeb46016f0c8af26412153cca3d34f479..3d3f8fce10a5136391e53bd75b13498a45e82e96 100644 (file)
@@ -164,7 +164,7 @@ static int nft_hash_init(const struct nft_set *set,
        unsigned int cnt, i;
 
        if (unlikely(!nft_hash_rnd_initted)) {
-               nft_hash_rnd = prandom_u32();
+               get_random_bytes(&nft_hash_rnd, 4);
                nft_hash_rnd_initted = true;
        }
 
index 190854be76294577e4542e49fc79fc2e18f5665b..370adf622cefd29f04f39cd227a9d4f9869d3b88 100644 (file)
@@ -100,7 +100,7 @@ static int xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
        int ret;
 
        if (unlikely(!rnd_inited)) {
-               jhash_rnd = prandom_u32();
+               get_random_bytes(&jhash_rnd, sizeof(jhash_rnd));
                rnd_inited = true;
        }
 
index 7671e8214919e346e1db44ffc3d38331f36371b0..c40b2695633b15960ac65eb84ebc2405b4aa2c1c 100644 (file)
@@ -229,7 +229,7 @@ static int connlimit_mt_check(const struct xt_mtchk_param *par)
                u_int32_t rand;
 
                do {
-                       rand = prandom_u32();
+                       get_random_bytes(&rand, sizeof(rand));
                } while (!rand);
                cmpxchg(&connlimit_rnd, 0, rand);
        }
index d819f62b3b7c7517eb128ac6e522a64273eef752..a3910fc2122bc1aa560815394b525098cb02e85c 100644 (file)
@@ -177,7 +177,7 @@ dsthash_alloc_init(struct xt_hashlimit_htable *ht,
        /* initialize hash with random val at the time we allocate
         * the first hashtable entry */
        if (unlikely(!ht->rnd_initialized)) {
-               ht->rnd = prandom_u32();
+               get_random_bytes(&ht->rnd, sizeof(ht->rnd));
                ht->rnd_initialized = true;
        }
 
index bfdc29f1a04a82073a8527c599f7ca4dfdf09b78..1e657cf715c478d9a9ec77411bf7536b14278d14 100644 (file)
@@ -334,7 +334,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
        size_t sz;
 
        if (unlikely(!hash_rnd_inited)) {
-               hash_rnd = prandom_u32();
+               get_random_bytes(&hash_rnd, sizeof(hash_rnd));
                hash_rnd_inited = true;
        }
        if (info->check_set & ~XT_RECENT_VALID_FLAGS) {