History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf

Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for your net tree, they are: 1) Use mod_timer_pending() to avoid reactivating a dead expectation in the h323 conntrack helper, from Liping Zhang. 2) Oneliner to fix a type in the register name defined in the nf_tables header. 3) Don't try to look further when we find an inactive elements with no descendants in the rbtree set implementation, otherwise we crash. 4) Handle valid zero CSeq in the SIP conntrack helper, from Christophe Leroy. 5) Don't display a trailing slash in conntrack helper with no classes via /proc/net/nf_conntrack_expect, from Liping Zhang. 6) Fix an expectation leak during creation from the nfqueue path, again from Liping Zhang. 7) Validate netlink port ID in verdict message from nfqueue, otherwise an injection can be possible. Again from Zhang. 8) Reject conntrack tuples with different transport protocol on original and reply tuples, also from Zhang. 9) Validate offset and length in nft_exthdr, make sure they are under sizeof(u8), from Laura Garcia Liebana. ====================

David S. Miller committed 10 years ago

Commit 293fddf2 parents 7bb90c3 4da449a8 files · +27 −21Browse files

Unified · Split

8 files
  1. include/uapi/linux/netfilter/nf_tables.h +1 −1
  2. net/netfilter/nf_conntrack_expect.c +1 −1
  3. net/netfilter/nf_conntrack_h323_main.c +2 −1
  4. net/netfilter/nf_conntrack_netlink.c +4 −6
  5. net/netfilter/nf_conntrack_sip.c +2 −2
  6. net/netfilter/nfnetlink_queue.c +2 −4
  7. net/netfilter/nft_exthdr.c +9 −2
  8. net/netfilter/nft_rbtree.c +6 −4
include/uapi/linux/netfilter/nf_tables.h+1−1
@@ -24,7 +24,7 @@ enum nft_registers { · 23 unmodified lines
2424 __NFT_REG_MAX,
2525
2626 NFT_REG32_00 = 8,
27− MFT_REG32_01,
27+ NFT_REG32_01,
2828 NFT_REG32_02,
2929 NFT_REG32_03,
3030 NFT_REG32_04,
net/netfilter/nf_conntrack_expect.c+1−1
@@ -574,7 +574,7 @@ static int exp_seq_show(struct seq_file *s, void *v) · 573 unmodified lines
574574 helper = rcu_dereference(nfct_help(expect->master)->helper);
575575 if (helper) {
576576 seq_printf(s, "%s%s", expect->flags ? " " : "", helper->name);
577− if (helper->expect_policy[expect->class].name)
577+ if (helper->expect_policy[expect->class].name[0])
578578 seq_printf(s, "/%s",
579579 helper->expect_policy[expect->class].name);
580580 }
net/netfilter/nf_conntrack_h323_main.c+2−1
@@ -1473,7 +1473,8 @@ static int process_rcf(struct sk_buff *skb, struct nf_conn *ct, · 1472 unmodified lines
14731473 "timeout to %u seconds for",
14741474 info->timeout);
14751475 nf_ct_dump_tuple(&exp->tuple);
1476− mod_timer(&exp->timeout, jiffies + info->timeout * HZ);
1476+ mod_timer_pending(&exp->timeout,
1477+ jiffies + info->timeout * HZ);
14771478 }
14781479 spin_unlock_bh(&nf_conntrack_expect_lock);
14791480 }
net/netfilter/nf_conntrack_netlink.c+4−6
@@ -1894,6 +1894,8 @@ static int ctnetlink_new_conntrack(struct net *net, struct sock *ctnl, · 1893 unmodified lines
18941894
18951895 if (!cda[CTA_TUPLE_ORIG] || !cda[CTA_TUPLE_REPLY])
18961896 return -EINVAL;
1897+ if (otuple.dst.protonum != rtuple.dst.protonum)
1898+ return -EINVAL;
18971899
18981900 ct = ctnetlink_create_conntrack(net, &zone, cda, &otuple,
18991901 &rtuple, u3);
@@ -2362,12 +2364,8 @@ ctnetlink_glue_attach_expect(const struct nlattr *attr, struct nf_conn *ct, · 462 unmodified lines
23622364 return PTR_ERR(exp);
23632365
23642366 err = nf_ct_expect_related_report(exp, portid, report);
2365− if (err < 0) {
2366− nf_ct_expect_put(exp);
2367− return err;
2368− }
2369−
2370− return 0;
2367+ nf_ct_expect_put(exp);
2368+ return err;
23712369 }
23722370
23732371 static void ctnetlink_glue_seqadj(struct sk_buff *skb, struct nf_conn *ct,
net/netfilter/nf_conntrack_sip.c+2−2
@@ -1383,7 +1383,7 @@ static int process_sip_response(struct sk_buff *skb, unsigned int protoff, · 1382 unmodified lines
13831383 return NF_DROP;
13841384 }
13851385 cseq = simple_strtoul(*dptr + matchoff, NULL, 10);
1386− if (!cseq) {
1386+ if (!cseq && *(*dptr + matchoff) != '0') {
13871387 nf_ct_helper_log(skb, ct, "cannot get cseq");
13881388 return NF_DROP;
13891389 }
@@ -1446,7 +1446,7 @@ static int process_sip_request(struct sk_buff *skb, unsigned int protoff, · 56 unmodified lines
14461446 return NF_DROP;
14471447 }
14481448 cseq = simple_strtoul(*dptr + matchoff, NULL, 10);
1449− if (!cseq) {
1449+ if (!cseq && *(*dptr + matchoff) != '0') {
14501450 nf_ct_helper_log(skb, ct, "cannot get cseq");
14511451 return NF_DROP;
14521452 }
net/netfilter/nfnetlink_queue.c+2−4
@@ -1145,10 +1145,8 @@ static int nfqnl_recv_verdict(struct net *net, struct sock *ctnl, · 1144 unmodified lines
11451145 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
11461146 int err;
11471147
1148− queue = instance_lookup(q, queue_num);
1149− if (!queue)
1150− queue = verdict_instance_lookup(q, queue_num,
1151− NETLINK_CB(skb).portid);
1148+ queue = verdict_instance_lookup(q, queue_num,
1149+ NETLINK_CB(skb).portid);
11521150 if (IS_ERR(queue))
11531151 return PTR_ERR(queue);
11541152
net/netfilter/nft_exthdr.c+9−2
@@ -59,6 +59,7 @@ static int nft_exthdr_init(const struct nft_ctx *ctx, · 58 unmodified lines
5959 const struct nlattr * const tb[])
6060 {
6161 struct nft_exthdr *priv = nft_expr_priv(expr);
62+ u32 offset, len;
6263
6364 if (tb[NFTA_EXTHDR_DREG] == NULL ||
6465 tb[NFTA_EXTHDR_TYPE] == NULL ||
@@ -66,9 +67,15 @@ static int nft_exthdr_init(const struct nft_ctx *ctx, · 1 unmodified line
6667 tb[NFTA_EXTHDR_LEN] == NULL)
6768 return -EINVAL;
6869
70+ offset = ntohl(nla_get_be32(tb[NFTA_EXTHDR_OFFSET]));
71+ len = ntohl(nla_get_be32(tb[NFTA_EXTHDR_LEN]));
72+
73+ if (offset > U8_MAX || len > U8_MAX)
74+ return -ERANGE;
75+
6976 priv->type = nla_get_u8(tb[NFTA_EXTHDR_TYPE]);
70− priv->offset = ntohl(nla_get_be32(tb[NFTA_EXTHDR_OFFSET]));
71− priv->len = ntohl(nla_get_be32(tb[NFTA_EXTHDR_LEN]));
77+ priv->offset = offset;
78+ priv->len = len;
7279 priv->dreg = nft_parse_register(tb[NFTA_EXTHDR_DREG]);
7380
7481 return nft_validate_register_store(ctx, priv->dreg, NULL,
net/netfilter/nft_rbtree.c+6−4
@@ -70,7 +70,6 @@ static bool nft_rbtree_lookup(const struct net *net, const struct nft_set *set, · 69 unmodified lines
7070 } else if (d > 0)
7171 parent = parent->rb_right;
7272 else {
73−found:
7473 if (!nft_set_elem_active(&rbe->ext, genmask)) {
7574 parent = parent->rb_left;
7675 continue;
@@ -84,9 +83,12 @@ found: · 7 unmodified lines
8483 }
8584 }
8685
87− if (set->flags & NFT_SET_INTERVAL && interval != NULL) {
88− rbe = interval;
89− goto found;
86+ if (set->flags & NFT_SET_INTERVAL && interval != NULL &&
87+ nft_set_elem_active(&interval->ext, genmask) &&
88+ !nft_rbtree_interval_end(interval)) {
89+ spin_unlock_bh(&nft_rbtree_lock);
90+ *ext = &interval->ext;
91+ return true;
9092 }
9193 out:
9294 spin_unlock_bh(&nft_rbtree_lock);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t