Netfilter updates for net-next
Subsystems (7)
Pablo Neira Ayuso
maintainercover Netfilter updates for net-next
Hi,
1) UAF in chain binding support from previous batch, from Dan Carpenter.
2) Queue up delayed work to expire connections with no destination, from Andrew Sy Kim.
3) Use fallthrough pseudo-keyword, from Gustavo A. R. Silva.
4) Replace HTTP links with HTTPS, from Alexander A. Klimov.
5) Remove superfluous null header checks in ip6tables, from Gaurav Singh.
6) Add extended netlink error reporting for expression.
7) Report EEXIST on overlapping chain, set elements and flowtable devices.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thank you.
----------------------------------------------------------------
The following changes since commit 4ff91fa0a3acd072c9a46ebe08a6e2471ddd3c95:
Merge branch 'udp_tunnel-NIC-RX-port-offload-infrastructure' (2020-07-14 17:04:28 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git HEAD
for you to fetch changes up to 77a92189ecfd061616ad531d386639aab7baaad9:
netfilter: nf_tables: report EEXIST on overlaps (2020-08-02 19:53:45 +0200)
----------------------------------------------------------------
Alexander A. Klimov (1):
netfilter: Replace HTTP links with HTTPS ones
Andrew Sy Kim (1):
ipvs: queue delayed work to expire no destination connections if expire_nodest_conn=1
Dan Carpenter (1):
netfilter: nf_tables: Fix a use after free in nft_immediate_destroy()
Gaurav Singh (1):
netfilter: ip6tables: Remove redundant null checks
Gustavo A. R. Silva (1):
netfilter: Use fallthrough pseudo-keyword
Pablo Neira Ayuso (2):
netfilter: nf_tables: extended netlink error reporting for expressions
netfilter: nf_tables: report EEXIST on overlaps
include/net/ip_vs.h | 29 ++++++++++++++++++ include/uapi/linux/netfilter/xt_connmark.h | 2 +- net/bridge/netfilter/ebtables.c | 2 +- net/decnet/netfilter/dn_rtmsg.c | 2 +- net/ipv6/netfilter/ip6t_ah.c | 3 +- net/ipv6/netfilter/ip6t_frag.c | 3 +- net/ipv6/netfilter/ip6t_hbh.c | 3 +- net/ipv6/netfilter/ip6t_rt.c | 3 +- net/netfilter/Kconfig | 2 +- net/netfilter/ipset/ip_set_core.c | 2 +- net/netfilter/ipvs/ip_vs_conn.c | 39 +++++++++++++++++++++++++ net/netfilter/ipvs/ip_vs_core.c | 47 +++++++++++++----------------- net/netfilter/ipvs/ip_vs_ctl.c | 22 ++++++++++++++ net/netfilter/nf_conntrack_h323_asn1.c | 6 ++-- net/netfilter/nf_conntrack_proto.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_nat_core.c | 12 ++++---- net/netfilter/nf_synproxy_core.c | 6 ++-- net/netfilter/nf_tables_api.c | 31 +++++++++++--------- net/netfilter/nf_tables_core.c | 2 +- net/netfilter/nfnetlink_acct.c | 2 +- net/netfilter/nfnetlink_cttimeout.c | 2 +- net/netfilter/nft_cmp.c | 4 +-- net/netfilter/nft_ct.c | 6 ++-- net/netfilter/nft_fib.c | 2 +- net/netfilter/nft_immediate.c | 4 +-- net/netfilter/nft_payload.c | 2 +- net/netfilter/nft_set_pipapo.c | 4 +-- net/netfilter/utils.c | 8 ++--- net/netfilter/x_tables.c | 2 +- net/netfilter/xt_CONNSECMARK.c | 2 +- net/netfilter/xt_connmark.c | 2 +- net/netfilter/xt_nfacct.c | 2 +- net/netfilter/xt_time.c | 2 +- 35 files changed, 173 insertions(+), 93 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/7 netfilter: nf_tables: Fix a use after free in nft_immediate_destroy()
From: Dan Carpenter <[email protected]>
The nf_tables_rule_release() function frees "rule" so we have to use the _safe() version of list_for_each_entry().
--- net/netfilter/nft_immediate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nft_immediate.c +2 -2
@@ -103,9 +103,9 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx, {const struct nft_immediate_expr *priv =nft_expr_priv (expr);const struct nft_data *data = &priv->data; +struct nft_rule *rule, *n;struct nft_ctx chain_ctx;struct nft_chain *chain; -struct nft_rule *rule;if (priv->dreg !=NFT_REG_VERDICT )return ;
@@ -121,7 +121,7 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx, chain_ctx = *ctx; chain_ctx.chain = chain; -list_for_each_entry (rule, &chain->rules, list) +list_for_each_entry_safe (rule, n, &chain->rules, list)nf_tables_rule_release (&chain_ctx, rule);nf_tables_chain_destroy (&chain_ctx);
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 2/7 ipvs: queue delayed work to expire no destination connections if expire_nodest_conn=1
In reply to Pablo Neira AyusoFrom: Andrew Sy Kim <[email protected]>
When expire_nodest_conn=1 and a destination is deleted, IPVS does not expire the existing connections until the next matching incoming packet. If there are many connection entries from a single client to a single destination, many packets may get dropped before all the connections are expired (more likely with lots of UDP traffic). An optimization can be made where upon deletion of a destination, IPVS queues up delayed work to immediately expire any connections with a deleted destination. This ensures any reused source ports from a client (within the IPVS timeouts) are scheduled to new real servers instead of silently dropped.
--- include/net/ip_vs.h | 29 ++++++++++++++++++++ net/netfilter/ipvs/ip_vs_conn.c | 39 +++++++++++++++++++++++++++ net/netfilter/ipvs/ip_vs_core.c | 47 ++++++++++++++------------------- net/netfilter/ipvs/ip_vs_ctl.c | 22 +++++++++++++++ 4 files changed, 110 insertions(+), 27 deletions(-)
include/net/ip_vs.h +29 -0
@@ -14,6 +14,7 @@#include <linux/spinlock.h> /* for struct rwlock_t */ #include <linux/atomic.h> /* for struct atomic_t */ #include <linux/refcount.h> /* for struct refcount_t */ +#include <linux/workqueue.h> #include <linux/compiler.h> #include <linux/timer.h>
@@ -886,6 +887,8 @@ struct netns_ipvs {atomic_t conn_out_counter;#ifdef CONFIG_SYSCTL +/* delayed work for expiring no dest connections */ +struct delayed_work expire_nodest_conn_work;/* 1/rate drop and drop-entry variables */ struct delayed_work defense_work;/* Work handler */ int drop_rate;
@@ -1051,6 +1054,11 @@ static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)return ipvs->sysctl_conn_reuse_mode; } +static inline int sysctl_expire_nodest_conn (struct netns_ipvs *ipvs) +{ +return ipvs->sysctl_expire_nodest_conn; +} +static inline int sysctl_schedule_icmp (struct netns_ipvs *ipvs) {return ipvs->sysctl_schedule_icmp;
@@ -1138,6 +1146,11 @@ static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)return 1 ; } +static inline int sysctl_expire_nodest_conn (struct netns_ipvs *ipvs) +{ +return 0 ; +} +static inline int sysctl_schedule_icmp (struct netns_ipvs *ipvs) {return 0 ;
@@ -1507,6 +1520,22 @@ static inline int ip_vs_todrop(struct netns_ipvs *ipvs)static inline int ip_vs_todrop (struct netns_ipvs *ipvs) {return 0 ; }#endif +#ifdef CONFIG_SYSCTL +/* Enqueue delayed work for expiring no dest connections +* Only run when sysctl_expire_nodest=1 +*/ +static inline void ip_vs_enqueue_expire_nodest_conns (struct netns_ipvs *ipvs) +{ +if (sysctl_expire_nodest_conn (ipvs)) +queue_delayed_work (system_long_wq, + &ipvs->expire_nodest_conn_work,1 ); +} + +void ip_vs_expire_nodest_conn_flush (struct netns_ipvs *ipvs); +#else +static inline void ip_vs_enqueue_expire_nodest_conns (struct netns_ipvs *ipvs) {} +#endif +#define IP_VS_DFWD_METHOD (dest) (atomic_read(&(dest)->conn_flags) & \ IP_VS_CONN_F_FWD_MASK)
net/netfilter/ipvs/ip_vs_conn.c +39 -0
@@ -1389,6 +1389,45 @@ static void ip_vs_conn_flush(struct netns_ipvs *ipvs) goto flush_again; } } + +#ifdef CONFIG_SYSCTL +void ip_vs_expire_nodest_conn_flush (struct netns_ipvs *ipvs) +{ +int idx; +struct ip_vs_conn *cp, *cp_c; +struct ip_vs_dest *dest; + +rcu_read_lock (); +for (idx =0 ; idx < ip_vs_conn_tab_size; idx++) { +hlist_for_each_entry_rcu (cp, &ip_vs_conn_tab[idx], c_list) { +if (cp->ipvs != ipvs) +continue ; + + dest = cp->dest; +if (!dest || (dest->flags &IP_VS_DEST_F_AVAILABLE )) +continue ; + +if (atomic_read (&cp->n_control)) +continue ; + + cp_c = cp->control; +IP_VS_DBG (4 ,"del connection\n" ); +ip_vs_conn_del (cp); +if (cp_c && !atomic_read (&cp_c->n_control)) { +IP_VS_DBG (4 ,"del controlling connection\n" ); +ip_vs_conn_del (cp_c); + } + } +cond_resched_rcu (); + +/* netns clean up started, abort delayed work */ +if (!ipvs->enable) +break ; + } +rcu_read_unlock (); +} +#endif +/* * per netns init and exit */
net/netfilter/ipvs/ip_vs_core.c +20 -27
72 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_ctl.c +22 -0
@@ -210,6 +210,17 @@ static void update_defense_level(struct netns_ipvs *ipvs)local_bh_enable (); } +/* Handler for delayed work for expiring no +* destination connections +*/ +static void expire_nodest_conn_handler (struct work_struct *work) +{ +struct netns_ipvs *ipvs; + + ipvs = container_of(work, struct netns_ipvs, + expire_nodest_conn_work.work); +ip_vs_expire_nodest_conn_flush (ipvs); +}/* * Timer for checking the defense
@@ -1164,6 +1175,12 @@ static void __ip_vs_del_dest(struct netns_ipvs *ipvs, struct ip_vs_dest *dest,list_add (&dest->t_list, &ipvs->dest_trash); dest->idle_start =0 ;spin_unlock_bh (&ipvs->dest_trash_lock); + +/* Queue up delayed work to expire all no destination connections. +* No-op when CONFIG_SYSCTL is disabled. +*/ +if (!cleanup) +ip_vs_enqueue_expire_nodest_conns (ipvs); }
@@ -4086,6 +4103,10 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)queue_delayed_work (system_long_wq, &ipvs->defense_work,DEFENSE_TIMER_PERIOD ); +/* Init delayed work for expiring no dest conn */ +INIT_DELAYED_WORK (&ipvs->expire_nodest_conn_work, + expire_nodest_conn_handler); +return 0 ; }
@@ -4093,6 +4114,7 @@ static void __net_exit ip_vs_control_net_cleanup_sysctl(struct netns_ipvs *ipvs) {struct net *net = ipvs->net; +cancel_delayed_work_sync (&ipvs->expire_nodest_conn_work);cancel_delayed_work_sync (&ipvs->defense_work);cancel_work_sync (&ipvs->defense_work.work);unregister_net_sysctl_table (ipvs->sysctl_hdr);
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 3/7 netfilter: Use fallthrough pseudo-keyword
In reply to Pablo Neira AyusoFrom: "Gustavo A. R. Silva" <[email protected]>
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case.
--- net/bridge/netfilter/ebtables.c | 2 +- net/netfilter/ipset/ip_set_core.c | 2 +- net/netfilter/nf_conntrack_h323_asn1.c | 6 +++--- net/netfilter/nf_conntrack_proto.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 2 +- net/netfilter/nf_nat_core.c | 12 ++++++------ net/netfilter/nf_synproxy_core.c | 6 ++---- net/netfilter/nf_tables_api.c | 8 ++++---- net/netfilter/nf_tables_core.c | 2 +- net/netfilter/nfnetlink_cttimeout.c | 2 +- net/netfilter/nft_cmp.c | 4 ++-- net/netfilter/nft_ct.c | 6 +++--- net/netfilter/nft_fib.c | 2 +- net/netfilter/nft_payload.c | 2 +- net/netfilter/utils.c | 8 ++++---- net/netfilter/x_tables.c | 2 +- 17 files changed, 34 insertions(+), 36 deletions(-)
net/bridge/netfilter/ebtables.c +1 -1
@@ -1935,7 +1935,7 @@ static int compat_mtw_from_user(const struct compat_ebt_entry_mwt *mwt, size_kern = match_size;module_put (match->me);break ; -case EBT_COMPAT_WATCHER :/* fallthrough */ +case EBT_COMPAT_WATCHER :case EBT_COMPAT_TARGET : wt =xt_request_find_target (NFPROTO_BRIDGE , name, mwt->u.revision);
net/netfilter/ipset/ip_set_core.c +1 -1
@@ -1644,7 +1644,7 @@ ip_set_dump_do(struct sk_buff *skb, struct netlink_callback *cb) goto next_set;if (set->variant->uref) set->variant->uref (set, cb, true); -/* fall through */ + fallthrough;default : ret = set->variant->list (set, skb, cb);if (!cb->args[IPSET_CB_ARG0 ])
net/netfilter/nf_conntrack_h323_asn1.c +3 -3
@@ -257,15 +257,15 @@ static unsigned int get_uint(struct bitstr *bs, int b)case 4 : v |= *bs->cur++; v <<=8 ; -/* fall through */ + fallthrough;case 3 : v |= *bs->cur++; v <<=8 ; -/* fall through */ + fallthrough;case 2 : v |= *bs->cur++; v <<=8 ; -/* fall through */ + fallthrough;case 1 : v |= *bs->cur++;break ;
net/netfilter/nf_conntrack_proto.c +1 -1
@@ -610,7 +610,7 @@ void nf_ct_netns_put(struct net *net, uint8_t nfproto)switch (nfproto) {case NFPROTO_BRIDGE :nf_ct_netns_do_put (net,NFPROTO_BRIDGE ); -/* fall through */ + fallthrough;case NFPROTO_INET :nf_ct_netns_do_put (net,NFPROTO_IPV4 );nf_ct_netns_do_put (net,NFPROTO_IPV6 );
net/netfilter/nf_conntrack_proto_tcp.c +1 -1
@@ -900,7 +900,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,return -NF_REPEAT ;return NF_DROP ; } -/* Fall through */ + fallthrough;case TCP_CONNTRACK_IGNORE :/* Ignored packets: *
net/netfilter/nf_conntrack_standalone.c +1 -1
@@ -60,7 +60,7 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,ntohs (tuple->src.u.tcp.port), ntohs(tuple->dst.u.tcp.port));break ; -case IPPROTO_UDPLITE :/* fallthrough */ +case IPPROTO_UDPLITE :case IPPROTO_UDP : seq_printf(s, "sport=%hu dport=%hu ", ntohs(tuple->src.u.udp.port),
net/netfilter/nf_nat_core.c +6 -6
@@ -408,7 +408,7 @@ static void nf_nat_l4proto_unique_tuple(struct nf_conntrack_tuple *tuple,static const unsigned int max_attempts =128 ;switch (tuple->dst.protonum) { -case IPPROTO_ICMP :/* fallthrough */ +case IPPROTO_ICMP :case IPPROTO_ICMPV6 :/* id is same for either direction... */ keyptr = &tuple->src.u.icmp.id;
@@ -442,11 +442,11 @@ static void nf_nat_l4proto_unique_tuple(struct nf_conntrack_tuple *tuple, } goto find_free_id;#endif -case IPPROTO_UDP :/* fallthrough */ -case IPPROTO_UDPLITE :/* fallthrough */ -case IPPROTO_TCP :/* fallthrough */ -case IPPROTO_SCTP :/* fallthrough */ -case IPPROTO_DCCP :/* fallthrough */ +case IPPROTO_UDP : +case IPPROTO_UDPLITE : +case IPPROTO_TCP : +case IPPROTO_SCTP : +case IPPROTO_DCCP :if (maniptype ==NF_NAT_MANIP_SRC ) keyptr = &tuple->src.u.all;else
net/netfilter/nf_synproxy_core.c +2 -4
@@ -704,8 +704,7 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,nf_ct_seqadj_init (ct, ctinfo,0 ); synproxy->tsoff =0 ;this_cpu_inc (snet->stats->conn_reopened); - -/* fall through */ + fallthrough;case TCP_CONNTRACK_SYN_SENT :if (!synproxy_parse_options (skb, thoff, th, &opts))return NF_DROP ;
@@ -1128,8 +1127,7 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,nf_ct_seqadj_init (ct, ctinfo,0 ); synproxy->tsoff =0 ;this_cpu_inc (snet->stats->conn_reopened); - -/* fall through */ + fallthrough;case TCP_CONNTRACK_SYN_SENT :if (!synproxy_parse_options (skb, thoff, th, &opts))return NF_DROP ;
net/netfilter/nf_tables_api.c +4 -4
@@ -4375,7 +4375,7 @@ void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set,case NFT_TRANS_ABORT :case NFT_TRANS_RELEASE : set->use--; -/* fall through */ + fallthrough;default :nf_tables_unbind_set (ctx, set, binding, phase ==NFT_TRANS_COMMIT );
@@ -6256,7 +6256,7 @@ void nf_tables_deactivate_flowtable(const struct nft_ctx *ctx,case NFT_TRANS_ABORT :case NFT_TRANS_RELEASE : flowtable->use--; -/* fall through */ + fallthrough;default :return ; }
@@ -7262,7 +7262,7 @@ static int nf_tables_validate(struct net *net)break ;case NFT_VALIDATE_NEED :nft_validate_state_update (net,NFT_VALIDATE_DO ); -/* fall through */ + fallthrough;case NFT_VALIDATE_DO :list_for_each_entry (table, &net->nft.tables, list) {if (nft_table_validate (net, table) <0 )
@@ -8336,7 +8336,7 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,default :return -EINVAL ; } -/* fall through */ + fallthrough;case NFT_CONTINUE :case NFT_BREAK :case NFT_RETURN :
net/netfilter/nf_tables_core.c +1 -1
@@ -213,7 +213,7 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv) jumpstack[stackptr].chain = chain; jumpstack[stackptr].rules = rules +1 ; stackptr++; -/* fall through */ + fallthrough;case NFT_GOTO :nft_trace_packet (&info, chain, rule,NFT_TRACETYPE_RULE );
net/netfilter/nfnetlink_cttimeout.c +1 -1
@@ -451,7 +451,7 @@ static int cttimeout_default_get(struct net *net, struct sock *ctnl,case IPPROTO_TCP : timeouts =nf_tcp_pernet (net)->timeouts;break ; -case IPPROTO_UDP :/* fallthrough */ +case IPPROTO_UDP :case IPPROTO_UDPLITE : timeouts =nf_udp_pernet (net)->timeouts;break ;
net/netfilter/nft_cmp.c +2 -2
@@ -43,7 +43,7 @@ void nft_cmp_eval(const struct nft_expr *expr,case NFT_CMP_LT :if (d ==0 ) goto mismatch; -/* fall through */ + fallthrough;case NFT_CMP_LTE :if (d >0 ) goto mismatch;
@@ -51,7 +51,7 @@ void nft_cmp_eval(const struct nft_expr *expr,case NFT_CMP_GT :if (d ==0 ) goto mismatch; -/* fall through */ + fallthrough;case NFT_CMP_GTE :if (d <0 ) goto mismatch;
net/netfilter/nft_ct.c +3 -3
@@ -129,7 +129,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr, return; }#endif -case NFT_CT_BYTES :/* fallthrough */ +case NFT_CT_BYTES :case NFT_CT_PKTS : {const struct nf_conn_acct *acct =nf_conn_acct_find (ct);u64 count =0 ;
@@ -1013,8 +1013,8 @@ static int nft_ct_helper_obj_init(const struct nft_ctx *ctx, help6 =nf_conntrack_helper_try_module_get (name, family, priv->l4proto);break ; -case NFPROTO_NETDEV :/* fallthrough */ -case NFPROTO_BRIDGE :/* same */ +case NFPROTO_NETDEV : +case NFPROTO_BRIDGE :case NFPROTO_INET : help4 =nf_conntrack_helper_try_module_get (name,NFPROTO_IPV4 , priv->l4proto);
net/netfilter/nft_fib.c +1 -1
@@ -32,7 +32,7 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,unsigned int hooks;switch (priv->result) { -case NFT_FIB_RESULT_OIF :/* fallthrough */ +case NFT_FIB_RESULT_OIF :case NFT_FIB_RESULT_OIFNAME : hooks = (1 <<NF_INET_PRE_ROUTING );break ;
net/netfilter/nft_payload.c +1 -1
@@ -467,7 +467,7 @@ static int nft_payload_l4csum_offset(const struct nft_pktinfo *pkt,case IPPROTO_UDP :if (!nft_payload_udp_checksum (skb, pkt->xt.thoff))return -1 ; -/* Fall through. */ + fallthrough;case IPPROTO_UDPLITE : *l4csum_offset = offsetof(struct udphdr , check);break ;
net/netfilter/utils.c +4 -4
@@ -25,7 +25,7 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook, skb->ip_summed =CHECKSUM_UNNECESSARY ;break ; } -/* fall through */ + fallthrough;case CHECKSUM_NONE :if (protocol !=IPPROTO_TCP && protocol !=IPPROTO_UDP ) skb->csum =0 ;
@@ -51,7 +51,7 @@ static __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook,case CHECKSUM_COMPLETE :if (len == skb->len - dataoff)return nf_ip_checksum (skb, hook, dataoff, protocol); -/* fall through */ + fallthrough;case CHECKSUM_NONE : skb->csum =csum_tcpudp_nofold (iph->saddr, iph->daddr, protocol, skb->len - dataoff,0 );
@@ -79,7 +79,7 @@ __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook, skb->ip_summed =CHECKSUM_UNNECESSARY ;break ; } -/* fall through */ + fallthrough;case CHECKSUM_NONE : skb->csum = ~csum_unfold( csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
@@ -106,7 +106,7 @@ static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,case CHECKSUM_COMPLETE :if (len == skb->len - dataoff)return nf_ip6_checksum (skb, hook, dataoff, protocol); -/* fall through */ + fallthrough;case CHECKSUM_NONE : hsum =skb_checksum (skb,0 , dataoff,0 ); skb->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr,
net/netfilter/x_tables.c +1 -1
@@ -1571,7 +1571,7 @@ static void *xt_mttg_seq_next(struct seq_file *seq, void *v, loff_t *ppos, trav->curr = trav->curr->next;if (trav->curr != trav->head)break ; -/* fall through */ + fallthrough;default :return NULL ; }
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 4/7 netfilter: Replace HTTP links with HTTPS ones
In reply to Pablo Neira AyusoFrom: "Alexander A. Klimov" <[email protected]>
Rationale:
Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate.
Deterministic algorithm:
For each file:
If not .svg:
For each line:
If doesn't contain \bxmlns\b:
For each link, \bhttp://[^# \t\r\n]*(?:\w|/):
If neither \bgnu\.org/license, nor \bmozilla\.org/MPL\b:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
Replace HTTP with HTTPS.
--- include/uapi/linux/netfilter/xt_connmark.h | 2 +- net/decnet/netfilter/dn_rtmsg.c | 2 +- net/netfilter/Kconfig | 2 +- net/netfilter/nfnetlink_acct.c | 2 +- net/netfilter/nft_set_pipapo.c | 4 ++-- net/netfilter/xt_CONNSECMARK.c | 2 +- net/netfilter/xt_connmark.c | 2 +- net/netfilter/xt_nfacct.c | 2 +- net/netfilter/xt_time.c | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-)
include/uapi/linux/netfilter/xt_connmark.h +1 -1
@@ -4,7 +4,7 @@#include <linux/types.h> -/* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> +/* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com> * by Henrik Nordstrom <[email protected]> * * This program is free software; you can redistribute it and/or modify
net/decnet/netfilter/dn_rtmsg.c +1 -1
@@ -6,7 +6,7 @@* * DECnet Routing Message Grabulator * -* (C) 2000 ChyGwyn Limited - http://www.chygwyn.com/ +* (C) 2000 ChyGwyn Limited - https://www.chygwyn.com/ * * Author: Steven Whitehouse <[email protected]> */
net/netfilter/Kconfig +1 -1
@@ -447,7 +447,7 @@ config NF_TABLES replace the existing {ip,ip6,arp,eb}_tables infrastructure. It provides a pseudo-state machine with an extensible instruction-set (also known as expressions) that the userspace 'nft' utility - (http://www.netfilter.org/projects/nftables) uses to build the + (https://www.netfilter.org/projects/nftables) uses to build the rule-set. It also comes with the generic set infrastructure that allows you to construct mappings between matchings and actions for performance lookups.
net/netfilter/nfnetlink_acct.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * (C) 2011 Pablo Neira Ayuso <[email protected]> -* (C) 2011 Intra2net AG <http://www.intra2net.com> +* (C) 2011 Intra2net AG <https://www.intra2net.com> */ #include <linux/init.h> #include <linux/module.h>
net/netfilter/nft_set_pipapo.c +2 -2
@@ -312,7 +312,7 @@* Jay Ligatti, Josh Kuhn, and Chris Gage. * Proceedings of the IEEE International Conference on Computer * Communication Networks (ICCCN), August 2010. -* http://www.cse.usf.edu/~ligatti/papers/grouper-conf.pdf +* https://www.cse.usf.edu/~ligatti/papers/grouper-conf.pdf * * [Rottenstreich 2010] * Worst-Case TCAM Rule Expansion
@@ -325,7 +325,7 @@* Kirill Kogan, Sergey Nikolenko, Ori Rottenstreich, William Culhane, * and Patrick Eugster. * Proceedings of the 2014 ACM conference on SIGCOMM, August 2014. -* http://www.sigcomm.org/sites/default/files/ccr/papers/2014/August/2619239-2626294.pdf +* https://www.sigcomm.org/sites/default/files/ccr/papers/2014/August/2619239-2626294.pdf */ #include <linux/kernel.h>
net/netfilter/xt_CONNSECMARK.c +1 -1
@@ -6,7 +6,7 @@* with the SECMARK target and state match. * * Based somewhat on CONNMARK: -* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> +* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com> * by Henrik Nordstrom <[email protected]> * * (C) 2006,2008 Red Hat, Inc., James Morris <[email protected]>
net/netfilter/xt_connmark.c +1 -1
@@ -2,7 +2,7 @@/* * xt_connmark - Netfilter module to operate on connection marks * -* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> +* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com> * by Henrik Nordstrom <[email protected]> * Copyright © CC Computer Consultants GmbH, 2007 - 2008 * Jan Engelhardt <[email protected]>
net/netfilter/xt_nfacct.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * (C) 2011 Pablo Neira Ayuso <[email protected]> -* (C) 2011 Intra2net AG <http://www.intra2net.com> +* (C) 2011 Intra2net AG <https://www.intra2net.com> */ #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt
net/netfilter/xt_time.c +1 -1
@@ -5,7 +5,7 @@* based on ipt_time by Fabrice MARIE <[email protected]> * This is a module which is used for time matching * It is using some modified code from dietlibc (localtime() function) -* that you can find at http://www.fefe.de/dietlibc/ +* that you can find at https://www.fefe.de/dietlibc/ * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from gnu.org/gpl. */
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 5/7 netfilter: ip6tables: Remove redundant null checks
In reply to Pablo Neira AyusoFrom: Gaurav Singh <[email protected]>
Remove superfluous check for NULL pointer to header.
--- net/ipv6/netfilter/ip6t_ah.c | 3 +-- net/ipv6/netfilter/ip6t_frag.c | 3 +-- net/ipv6/netfilter/ip6t_hbh.c | 3 +-- net/ipv6/netfilter/ip6t_rt.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-)
net/ipv6/netfilter/ip6t_ah.c +1 -2
@@ -74,8 +74,7 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par) ahinfo->hdrres, ah->reserved, !(ahinfo->hdrres && ah->reserved)); -return (ah !=NULL ) && -spi_match (ahinfo->spis[0 ], ahinfo->spis[1 ], +return spi_match (ahinfo->spis[0 ], ahinfo->spis[1 ],ntohl (ah->spi), !!(ahinfo->invflags & IP6T_AH_INV_SPI)) && (!ahinfo->hdrlen ||
net/ipv6/netfilter/ip6t_frag.c +1 -2
@@ -85,8 +85,7 @@ frag_mt6(const struct sk_buff *skb, struct xt_action_param *par) !((fraginfo->flags &IP6T_FRAG_NMF ) && (ntohs(fh->frag_off) & IP6_MF))); -return (fh !=NULL ) && -id_match (fraginfo->ids[0 ], fraginfo->ids[1 ], +return id_match (fraginfo->ids[0 ], fraginfo->ids[1 ],ntohl (fh->identification), !!(fraginfo->invflags & IP6T_FRAG_INV_IDS)) && !((fraginfo->flags & IP6T_FRAG_RES) &&
net/ipv6/netfilter/ip6t_hbh.c +1 -2
@@ -86,8 +86,7 @@ hbh_mt6(const struct sk_buff *skb, struct xt_action_param *par) ((optinfo->hdrlen == hdrlen) ^ !!(optinfo->invflags & IP6T_OPTS_INV_LEN)))); - ret = (oh !=NULL ) && - (!(optinfo->flags &IP6T_OPTS_LEN ) || + ret = (!(optinfo->flags &IP6T_OPTS_LEN ) || ((optinfo->hdrlen == hdrlen) ^ !!(optinfo->invflags &IP6T_OPTS_INV_LEN )));
net/ipv6/netfilter/ip6t_rt.c +1 -2
@@ -89,8 +89,7 @@ static bool rt_mt6(const struct sk_buff *skb, struct xt_action_param *par) !((rtinfo->flags &IP6T_RT_RES ) && (((const struct rt0_hdr *)rh)->reserved))); - ret = (rh !=NULL ) && - (segsleft_match (rtinfo->segsleft[0 ], rtinfo->segsleft[1 ], + ret = (segsleft_match (rtinfo->segsleft[0 ], rtinfo->segsleft[1 ], rh->segments_left, !!(rtinfo->invflags & IP6T_RT_INV_SGS))) && (!(rtinfo->flags & IP6T_RT_LEN) ||
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 6/7 netfilter: nf_tables: extended netlink error reporting for expressions
In reply to Pablo Neira AyusoThis patch extends 36dd1bcc07e5 ("netfilter: nf_tables: initial support for extended ACK reporting") to include netlink extended error reporting for expressions. This allows userspace to identify what rule expression is triggering the error.
--- net/netfilter/nf_tables_api.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +6 -1
@@ -2509,6 +2509,7 @@ int nft_expr_dump(struct sk_buff *skb, unsigned int attr,struct nft_expr_info {const struct nft_expr_ops *ops; +const struct nlattr *attr;struct nlattr *tb[NFT_EXPR_MAXATTR +1 ]; };
@@ -2556,7 +2557,9 @@ static int nf_tables_expr_parse(const struct nft_ctx *ctx, }else ops = type->ops; + info->attr = nla; info->ops = ops; +return 0 ; err1:
@@ -3214,8 +3217,10 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk, expr =nft_expr_first (rule);for (i =0 ; i < n; i++) { err =nf_tables_newexpr (&ctx, &info[i], expr); -if (err <0 ) +if (err <0 ) { +NL_SET_BAD_ATTR (extack, info[i].attr); goto err2; + }if (info[i].ops->validate)nft_validate_state_update (net,NFT_VALIDATE_NEED );
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 7/7 netfilter: nf_tables: report EEXIST on overlaps
In reply to Pablo Neira AyusoReplace EBUSY by EEXIST in the following cases:
- If the user adds a chain with a different configuration such as different type, hook and priority.
- If the user adds a non-base chain that clashes with an existing basechain.
- If the user adds a { key : value } mapping element and the key exists but the value differs.
- If the device already belongs to an existing flowtable.
User describe that this error reporting is confusing:
- https://bugzilla.netfilter.org/show_bug.cgi?id=1176
- https://bugzilla.netfilter.org/show_bug.cgi?id=1413
--- net/netfilter/nf_tables_api.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
net/netfilter/nf_tables_api.c +7 -9
@@ -2097,7 +2097,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,if (nla[NFTA_CHAIN_HOOK ]) {if (!nft_is_base_chain (chain)) -return -EBUSY ; +return -EEXIST ; err =nft_chain_parse_hook (ctx->net, nla, &hook, ctx->family, false);
@@ -2107,21 +2107,21 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy, basechain =nft_base_chain (chain);if (basechain->type != hook.type) {nft_chain_release_hook (&hook); -return -EBUSY ; +return -EEXIST ; }if (ctx->family ==NFPROTO_NETDEV ) {if (!nft_hook_list_equal (&basechain->hook_list, &hook.list)) {nft_chain_release_hook (&hook); -return -EBUSY ; +return -EEXIST ; } }else { ops = &basechain->ops;if (ops->hooknum != hook.num || ops->priority != hook.priority) {nft_chain_release_hook (&hook); -return -EBUSY ; +return -EEXIST ; } }nft_chain_release_hook (&hook);
@@ -5262,10 +5262,8 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,if (nft_set_ext_exists (ext,NFT_SET_EXT_DATA ) ^nft_set_ext_exists (ext2,NFT_SET_EXT_DATA ) ||nft_set_ext_exists (ext,NFT_SET_EXT_OBJREF ) ^ -nft_set_ext_exists (ext2,NFT_SET_EXT_OBJREF )) { - err = -EBUSY ; +nft_set_ext_exists (ext2,NFT_SET_EXT_OBJREF )) goto err_element_clash; - } if ((nft_set_ext_exists(ext, NFT_SET_EXT_DATA) && nft_set_ext_exists(ext2, NFT_SET_EXT_DATA) && memcmp(nft_set_ext_data(ext),
@@ -5273,7 +5271,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, (nft_set_ext_exists (ext,NFT_SET_EXT_OBJREF ) &&nft_set_ext_exists (ext2,NFT_SET_EXT_OBJREF ) && *nft_set_ext_obj(ext) != *nft_set_ext_obj(ext2))) - err = -EBUSY; + goto err_element_clash; else if (!(nlmsg_flags & NLM_F_EXCL)) err =0 ; }else if (err == -ENOTEMPTY ) {
@@ -6423,7 +6421,7 @@ static int nft_register_flowtable_net_hooks(struct net *net,list_for_each_entry (hook2, &ft->hook_list, list) {if (hook->ops.dev == hook2->ops.dev && hook->ops.pf == hook2->ops.pf) { - err = -EBUSY ; + err = -EEXIST ; goto err_unregister_net_hooks; } }
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Sun, 2 Aug 2020 20:31:41 +0200
Quoted 12 lines
1) UAF in chain binding support from previous batch, from Dan Carpenter.
2) Queue up delayed work to expire connections with no destination, from Andrew Sy Kim.
3) Use fallthrough pseudo-keyword, from Gustavo A. R. Silva.
4) Replace HTTP links with HTTPS, from Alexander A. Klimov.
5) Remove superfluous null header checks in ip6tables, from Gaurav Singh.
Quoted 8 lines
6) Add extended netlink error reporting for expression.
7) Report EEXIST on overlapping chain, set elements and flowtable devices.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Pulled, thank you.