Skip to content

Commit fb60bcc

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
Pablo Neira Ayuso says: ==================== Netfilter/IPVS fixes for net The following patchset contains Netfilter/IPVS fixes for your net tree, they are: 1) Fix packet drops due to incorrect ECN handling in IPVS, from Vadim Fedorenko. 2) Fix splat with mark restoration in xt_socket with non-full-sock, patch from Subash Abhinov Kasiviswanathan. 3) ipset bogusly bails out when adding IPv4 range containing more than 2^31 addresses, from Jozsef Kadlecsik. 4) Incorrect pernet unregistration order in ipset, from Florian Westphal. 5) Races between dump and swap in ipset results in BUG_ON splats, from Ross Lagerwall. 6) Fix chain renames in nf_tables, from JingPiao Chen. 7) Fix race in pernet codepath with ebtables table registration, from Artem Savkov. 8) Memory leak in error path in set name allocation in nf_tables, patch from Arvind Yadav. 9) Don't dump chain counters if they are not available, this fixes a crash when listing the ruleset. 10) Fix out of bound memory read in strlcpy() in x_tables compat code, from Eric Dumazet. 11) Make sure we only process TCP packets in SYNPROXY hooks, patch from Lin Zhang. 12) Cannot load rules incrementally anymore after xt_bpf with pinned objects, added in revision 1. From Shmulik Ladkani. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 5766cd6 + 98589a0 commit fb60bcc

26 files changed

Lines changed: 107 additions & 64 deletions

‎include/linux/bpf.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ static inline void __bpf_prog_uncharge(struct user_struct *user, u32 pages)
368368
{
369369
}
370370

371+
static inline int bpf_obj_get_user(const char __user *pathname)
372+
{
373+
return -EOPNOTSUPP;
374+
}
375+
371376
static inline struct net_device *__dev_map_lookup_elem(struct bpf_map *map,
372377
u32 key)
373378
{

‎include/linux/netfilter_bridge/ebtables.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ struct ebt_table {
108108

109109
#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
110110
~(__alignof__(struct _xt_align)-1))
111-
extern struct ebt_table *ebt_register_table(struct net *net,
112-
const struct ebt_table *table,
113-
const struct nf_hook_ops *);
111+
extern int ebt_register_table(struct net *net,
112+
const struct ebt_table *table,
113+
const struct nf_hook_ops *ops,
114+
struct ebt_table **res);
114115
extern void ebt_unregister_table(struct net *net, struct ebt_table *table,
115116
const struct nf_hook_ops *);
116117
extern unsigned int ebt_do_table(struct sk_buff *skb,

‎include/uapi/linux/netfilter/xt_bpf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum xt_bpf_modes {
2323
XT_BPF_MODE_FD_PINNED,
2424
XT_BPF_MODE_FD_ELF,
2525
};
26+
#define XT_BPF_MODE_PATH_PINNED XT_BPF_MODE_FD_PINNED
2627

2728
struct xt_bpf_info_v1 {
2829
__u16 mode;

‎kernel/bpf/inode.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ int bpf_obj_get_user(const char __user *pathname)
363363
putname(pname);
364364
return ret;
365365
}
366+
EXPORT_SYMBOL_GPL(bpf_obj_get_user);
366367

367368
static void bpf_evict_inode(struct inode *inode)
368369
{

‎net/bridge/netfilter/ebtable_broute.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ static int ebt_broute(struct sk_buff *skb)
6565

6666
static int __net_init broute_net_init(struct net *net)
6767
{
68-
net->xt.broute_table = ebt_register_table(net, &broute_table, NULL);
69-
return PTR_ERR_OR_ZERO(net->xt.broute_table);
68+
return ebt_register_table(net, &broute_table, NULL,
69+
&net->xt.broute_table);
7070
}
7171

7272
static void __net_exit broute_net_exit(struct net *net)

‎net/bridge/netfilter/ebtable_filter.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ static const struct nf_hook_ops ebt_ops_filter[] = {
9393

9494
static int __net_init frame_filter_net_init(struct net *net)
9595
{
96-
net->xt.frame_filter = ebt_register_table(net, &frame_filter, ebt_ops_filter);
97-
return PTR_ERR_OR_ZERO(net->xt.frame_filter);
96+
return ebt_register_table(net, &frame_filter, ebt_ops_filter,
97+
&net->xt.frame_filter);
9898
}
9999

100100
static void __net_exit frame_filter_net_exit(struct net *net)

‎net/bridge/netfilter/ebtable_nat.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ static const struct nf_hook_ops ebt_ops_nat[] = {
9393

9494
static int __net_init frame_nat_net_init(struct net *net)
9595
{
96-
net->xt.frame_nat = ebt_register_table(net, &frame_nat, ebt_ops_nat);
97-
return PTR_ERR_OR_ZERO(net->xt.frame_nat);
96+
return ebt_register_table(net, &frame_nat, ebt_ops_nat,
97+
&net->xt.frame_nat);
9898
}
9999

100100
static void __net_exit frame_nat_net_exit(struct net *net)

‎net/bridge/netfilter/ebtables.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,9 +1169,8 @@ static void __ebt_unregister_table(struct net *net, struct ebt_table *table)
11691169
kfree(table);
11701170
}
11711171

1172-
struct ebt_table *
1173-
ebt_register_table(struct net *net, const struct ebt_table *input_table,
1174-
const struct nf_hook_ops *ops)
1172+
int ebt_register_table(struct net *net, const struct ebt_table *input_table,
1173+
const struct nf_hook_ops *ops, struct ebt_table **res)
11751174
{
11761175
struct ebt_table_info *newinfo;
11771176
struct ebt_table *t, *table;
@@ -1183,7 +1182,7 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table,
11831182
repl->entries == NULL || repl->entries_size == 0 ||
11841183
repl->counters != NULL || input_table->private != NULL) {
11851184
BUGPRINT("Bad table data for ebt_register_table!!!\n");
1186-
return ERR_PTR(-EINVAL);
1185+
return -EINVAL;
11871186
}
11881187

11891188
/* Don't add one table to multiple lists. */
@@ -1252,16 +1251,18 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table,
12521251
list_add(&table->list, &net->xt.tables[NFPROTO_BRIDGE]);
12531252
mutex_unlock(&ebt_mutex);
12541253

1254+
WRITE_ONCE(*res, table);
1255+
12551256
if (!ops)
1256-
return table;
1257+
return 0;
12571258

12581259
ret = nf_register_net_hooks(net, ops, hweight32(table->valid_hooks));
12591260
if (ret) {
12601261
__ebt_unregister_table(net, table);
1261-
return ERR_PTR(ret);
1262+
*res = NULL;
12621263
}
12631264

1264-
return table;
1265+
return ret;
12651266
free_unlock:
12661267
mutex_unlock(&ebt_mutex);
12671268
free_chainstack:
@@ -1276,7 +1277,7 @@ ebt_register_table(struct net *net, const struct ebt_table *input_table,
12761277
free_table:
12771278
kfree(table);
12781279
out:
1279-
return ERR_PTR(ret);
1280+
return ret;
12801281
}
12811282

12821283
void ebt_unregister_table(struct net *net, struct ebt_table *table,

‎net/ipv4/netfilter/ipt_SYNPROXY.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ static unsigned int ipv4_synproxy_hook(void *priv,
330330
if (synproxy == NULL)
331331
return NF_ACCEPT;
332332

333-
if (nf_is_loopback_packet(skb))
333+
if (nf_is_loopback_packet(skb) ||
334+
ip_hdr(skb)->protocol != IPPROTO_TCP)
334335
return NF_ACCEPT;
335336

336337
thoff = ip_hdrlen(skb);

‎net/ipv6/netfilter/ip6t_SYNPROXY.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static unsigned int ipv6_synproxy_hook(void *priv,
353353
nexthdr = ipv6_hdr(skb)->nexthdr;
354354
thoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
355355
&frag_off);
356-
if (thoff < 0)
356+
if (thoff < 0 || nexthdr != IPPROTO_TCP)
357357
return NF_ACCEPT;
358358

359359
th = skb_header_pointer(skb, thoff, sizeof(_th), &_th);

0 commit comments

Comments
 (0)