[PATCH nft v3 6/7] src: ip: switch implicit dependencies to meta l4proto too

2017-05-19 Thread Florian Westphal
after ip6 nexthdr also switch ip to meta l4proto instead of ip protocol. While its needed for ipv6 (due to extension headers) this isn't needed for ip but it has the advantage that tcp dport 22 produces same expressions for ip/ip6/inet families. Signed-off-by: Florian Westphal --- No changes

[PATCH nft 4/7] payload: enforce ip/ip6 protocol depending on icmp or icmpv6

2017-05-19 Thread Florian Westphal
After some discussion with Pablo we agreed to treat icmp/icmpv6 specially. in the case of a rule like 'tcp dport 22' the inet, bridge and netdev families only care about the lower layer protocol. In the icmpv6 case however we'd like to also enforce an ipv6 protocol check (and ipv4 check in icmp c

[PATCH nft v3 5/7] tests: fix up meta l4proto change for ip6 family

2017-05-19 Thread Florian Westphal
After previous commit nft generates meta l4proto for ipv6 dependencies instead of checking the (first) nexthdr value. This fixes up all tests cases accordingly except one which fails with ip6/reject.t: ... 12: 'ip6 nexthdr 6 reject with tcp reset' mismatches 'meta l4proto 6 reject with tcp reset

[PATCH nft v3 3/7] src: ipv6: switch implicit dependencies to meta l4proto

2017-05-19 Thread Florian Westphal
when using rule like ip6 filter input tcp dport 22 nft generates: [ payload load 1b @ network header + 6 => reg 1 ] [ cmp eq reg 1 0x0006 ] [ payload load 2b @ transport header + 2 => reg 1 ] [ cmp eq reg 1 0x1600 ] which is: ip6 filter input ip6 nexthdr tcp dport 22 IOW, such a r

[PATCH nft 1/7] payload: split ll proto dependency into helper

2017-05-19 Thread Florian Westphal
will be re-used in folloup patch for icmp/icmpv6 depenency handling. Signed-off-by: Florian Westphal --- patch was not part of earlier series. src/payload.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/payload.c b/src/payload.c index 5

[PATCH nft v3 0/7] switch l4 dependency to meta l4proto

2017-05-19 Thread Florian Westphal
Currently nft inserts different types of dependencies for l4 protocols, depending on the family. For inet, nft inserts 'meta l4proto' to e.g. check for tcp, for ip, nft uses 'ip protocol'. Both are fine. The ip6 family however uses 'ip6 nexthdr', and thats a problem because e.g. tcp dport 22 will

[PATCH nft v3 2/7] src: allow update of net base w. meta l4proto icmpv6

2017-05-19 Thread Florian Westphal
nft add rule ip6 f i meta l4proto ipv6-icmp icmpv6 type nd-router-advert :1:50-60: Error: conflicting protocols specified: unknown vs. icmpv6 add icmpv6 to nexthdr list so base gets updated correctly. Reported-by: Thomas Woerner Signed-off-by: Florian Westphal --- Change since last version:

[PATCH net-next 2/2] netfilter: nf_tables: make local functions static

2017-05-19 Thread Stephen Hemminger
Resolves warnings: net/netfilter/nft_rt.c:26:6: warning: no previous prototype for ‘nft_rt_get_eval’ [-Wmissing-prototypes] net/netfilter/nft_rt.c:75:5: warning: no previous prototype for ‘nft_rt_get_init’ [-Wmissing-prototypes] net/netfilter/nft_rt.c:106:5: warning: no previous prototype for ‘n

[PATCH net-next 1/2] netfilter: resolve warnings about missing prototypes

2017-05-19 Thread Stephen Hemminger
Missing include file causes: net/netfilter/nf_dup_netdev.c:26:6: warning: no previous prototype for ‘nf_fwd_netdev_egress’ [-Wmissing-prototypes] net/netfilter/nf_dup_netdev.c:40:6: warning: no previous prototype for ‘nf_dup_netdev_egress’ [-Wmissing-prototypes] Signed-off-by: Stephen Hemminger

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
On Fri, May 19, 2017 at 12:36 PM, Florian Westphal wrote: > Oliver Ford wrote: >> On Fri, May 19, 2017 at 11:38 AM, Florian Westphal wrote: >> > Oliver Ford wrote: >> >> On Fri, May 19, 2017 at 11:04 AM, Florian Westphal wrote: >> >> > Oliver Ford wrote: >> >> >> Filter a beginning '--t'. Bec

[PATCH v5 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
Fixes the crash reported in Bugzilla #1131 where a malformed parameter that specifies the table option during a restore can create an invalid pointer. It was discovered during fuzz testing that options like '-ftf' can cause a segfault. A parameter that includes a 't' is not currently filtered corre

[nft PATCH v3] List handles of added rules if requested

2017-05-19 Thread Phil Sutter
Being able to retrieve an added rule's handle atomically is a crucial feature for scripts invoking nft command: Without it, there is no way to be sure a handle extracted from 'nft list ruleset' command actually refers to the rule one has added before or that of another process which ran in between.

Re: [PATCH nf] netfilter: conntrack: fix false CRC32c mismatch using paged skb

2017-05-19 Thread Davide Caratti
hello Pablo, thank you for looking at this! On Fri, 2017-05-19 at 10:41 +0200, Pablo Neira Ayuso wrote: > On Thu, May 18, 2017 at 06:01:43PM +0200, Davide Caratti wrote: > > sctp_compute_cksum() implementation assumes that at least the SCTP header > > is in the linear part of skb: modify conntrack

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Florian Westphal
Oliver Ford wrote: > On Fri, May 19, 2017 at 11:38 AM, Florian Westphal wrote: > > Oliver Ford wrote: > >> On Fri, May 19, 2017 at 11:04 AM, Florian Westphal wrote: > >> > Oliver Ford wrote: > >> >> Filter a beginning '--t'. Because the getopt_long function allows > >> >> abbreviations, > >>

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
On Fri, May 19, 2017 at 11:38 AM, Florian Westphal wrote: > Oliver Ford wrote: >> On Fri, May 19, 2017 at 11:04 AM, Florian Westphal wrote: >> > Oliver Ford wrote: >> >> Filter a beginning '--t'. Because the getopt_long function allows >> >> abbreviations, >> >> any parameter beginning with '-

[PATCH v4 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
Fixes the crash reported in Bugzilla #1131 where a malformed parameter that specifies the table option during a restore can create an invalid pointer. It was discovered during fuzz testing that options like '-ftf' can cause a segfault. A parameter that includes a 't' is not currently filtered corre

Re: [nf-next PATCH] netfilter: nf_tables: Report transactions' process info to user space

2017-05-19 Thread Phil Sutter
On Mon, May 15, 2017 at 07:54:44PM +0200, Pablo Neira Ayuso wrote: > On Mon, May 15, 2017 at 06:44:32PM +0200, Phil Sutter wrote: > > On Mon, May 15, 2017 at 05:53:31PM +0200, Pablo Neira Ayuso wrote: > > > On Mon, May 15, 2017 at 04:51:49PM +0200, Phil Sutter wrote: > > > > When committing a trans

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
On Fri, May 19, 2017 at 11:38 AM, Florian Westphal wrote: > Oliver Ford wrote: >> On Fri, May 19, 2017 at 11:04 AM, Florian Westphal wrote: >> > Oliver Ford wrote: >> >> Filter a beginning '--t'. Because the getopt_long function allows >> >> abbreviations, >> >> any parameter beginning with '-

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Florian Westphal
Oliver Ford wrote: > On Fri, May 19, 2017 at 11:04 AM, Florian Westphal wrote: > > Oliver Ford wrote: > >> Filter a beginning '--t'. Because the getopt_long function allows > >> abbreviations, > >> any parameter beginning with '--t' will be treated as '--table'. > > > > No, thats not correct: >

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
On Fri, May 19, 2017 at 11:04 AM, Florian Westphal wrote: > Oliver Ford wrote: >> Filter a beginning '--t'. Because the getopt_long function allows >> abbreviations, >> any parameter beginning with '--t' will be treated as '--table'. > > No, thats not correct: > --t is treated as --table. > --tf

Re: [PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Florian Westphal
Oliver Ford wrote: > Filter a beginning '--t'. Because the getopt_long function allows > abbreviations, > any parameter beginning with '--t' will be treated as '--table'. No, thats not correct: --t is treated as --table. --tfoo is an invalid option. --ttl is ttl. So this: > +

Re: [PATCH v2 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
On Thu, May 18, 2017 at 4:29 PM, Oliver Ford wrote: > On Thu, May 18, 2017 at 4:20 PM, Florian Westphal wrote: >> Oliver Ford wrote: >>> On Thu, May 18, 2017 at 3:42 PM, Florian Westphal wrote: >>> > Oliver Ford wrote: >>> >> --- a/iptables/ip6tables-restore.c >>> >> +++ b/iptables/ip6tables-r

[PATCH v3 1/1] iptables: Fix crash on malformed iptables-restore

2017-05-19 Thread Oliver Ford
Fixes the crash reported in Bugzilla #1131 where a malformed parameter that specifies the table option during a restore can create an invalid pointer. It was discovered during fuzz testing that options like '-ftf' can cause a segfault. A parameter that includes a 't' is not currently filtered corre

Re: [PATCH nf] netfilter: conntrack: fix false CRC32c mismatch using paged skb

2017-05-19 Thread Pablo Neira Ayuso
Hi Davide, On Thu, May 18, 2017 at 06:01:43PM +0200, Davide Caratti wrote: > sctp_compute_cksum() implementation assumes that at least the SCTP header > is in the linear part of skb: modify conntrack error callback to avoid > false CRC32c mismatch, if the transport header is partially/entirely pag

[PATCH 02/12] netfilter: ctnetlink: Make some parameters integer to avoid enum mismatch

2017-05-19 Thread Pablo Neira Ayuso
From: Matthias Kaehlcke Not all parameters passed to ctnetlink_parse_tuple() and ctnetlink_exp_dump_tuple() match the enum type in the signatures of these functions. Since this is intended change the argument type of to be an unsigned integer value. Signed-off-by: Matthias Kaehlcke Signed-off-b

[PATCH 00/12] Netfilter/IPVS fixes for net

2017-05-19 Thread Pablo Neira Ayuso
Hi David, The following patchset contains Netfilter/IPVS fixes for your net tree, they are: 1) When using IPVS in direct-routing mode, normal traffic from the LVS host to a back-end server is sometimes incorrectly NATed on the way back into the LVS host. Patch to fix this from Julian Anasta

[PATCH 01/12] ipvs: SNAT packet replies only for NATed connections

2017-05-19 Thread Pablo Neira Ayuso
From: Julian Anastasov We do not check if packet from real server is for NAT connection before performing SNAT. This causes problems for setups that use DR/TUN and allow local clients to access the real server directly, for example: - local client in director creates IPVS-DR/TUN connection CIP->

[PATCH 04/12] netfilter: introduce nf_conntrack_helper_put helper function

2017-05-19 Thread Pablo Neira Ayuso
From: Liping Zhang And convert module_put invocation to nf_conntrack_helper_put, this is prepared for the followup patch, which will add a refcnt for cthelper, so we can reject the deleting request when cthelper is in use. Signed-off-by: Liping Zhang Signed-off-by: Pablo Neira Ayuso --- inclu

[PATCH 06/12] netfilter: xtables: zero padding in data_to_user

2017-05-19 Thread Pablo Neira Ayuso
From: Willem de Bruijn When looking up an iptables rule, the iptables binary compares the aligned match and target data (XT_ALIGN). In some cases this can exceed the actual data size to include padding bytes. Before commit f77bc5b23fb1 ("iptables: use match, target and data copy_to_user helpers"

[PATCH 11/12] ebtables: arpreply: Add the standard target sanity check

2017-05-19 Thread Pablo Neira Ayuso
From: Gao Feng The info->target comes from userspace and it would be used directly. So we need to add the sanity check to make sure it is a valid standard target, although the ebtables tool has already checked it. Kernel needs to validate anything coming from userspace. If the target is set as a

[PATCH 05/12] netfilter: nfnl_cthelper: reject del request if helper obj is in use

2017-05-19 Thread Pablo Neira Ayuso
From: Liping Zhang We can still delete the ct helper even if it is in use, this will cause a use-after-free error. In more detail, I mean: # nfct helper add ssdp inet udp # iptables -t raw -A OUTPUT -p udp -j CT --helper ssdp # nfct helper delete ssdp //--> oops, succeed! BUG: unable to h

[PATCH 08/12] netfilter: nf_tables: can't assume lock is acquired when dumping set elems

2017-05-19 Thread Pablo Neira Ayuso
From: Liping Zhang When dumping the elements related to a specified set, we may invoke the nf_tables_dump_set with the NFNL_SUBSYS_NFTABLES lock not acquired. So we should use the proper rcu operation to avoid race condition, just like other nft dump operations. Signed-off-by: Liping Zhang Sign

[PATCH 09/12] netfilter: nf_tables: missing sanitization in data from userspace

2017-05-19 Thread Pablo Neira Ayuso
Do not assume userspace always sends us NFT_DATA_VALUE for bitwise and cmp expressions. Although NFT_DATA_VERDICT does not make any sense, it is still possible to handcraft a netlink message using this incorrect data type. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nft_bitwise.c | 19 +++

[PATCH 10/12] netfilter: nf_tables: revisit chain/object refcounting from elements

2017-05-19 Thread Pablo Neira Ayuso
Andreas reports that the following incremental update using our commit protocol doesn't work. # nft -f incremental-update.nft delete element ip filter client_to_any { 10.180.86.22 : goto CIn_1 } delete chain ip filter CIn_1 ... Error: Could not process rule: Device or resource busy The existi

[PATCH 07/12] netfilter: synproxy: fix conntrackd interaction

2017-05-19 Thread Pablo Neira Ayuso
From: Eric Leblond This patch fixes the creation of connection tracking entry from netlink when synproxy is used. It was missing the addition of the synproxy extension. This was causing kernel crashes when a conntrack entry created by conntrackd was used after the switch of traffic from active n

[PATCH 12/12] netfilter: xtables: fix build failure from COMPAT_XT_ALIGN outside CONFIG_COMPAT

2017-05-19 Thread Pablo Neira Ayuso
From: Willem de Bruijn The patch in the Fixes references COMPAT_XT_ALIGN in the definition of XT_DATA_TO_USER, outside an #ifdef CONFIG_COMPAT block. Split XT_DATA_TO_USER into separate compat and non compat variants and define the first inside an CONFIG_COMPAT block. This simplifies both varia

[PATCH 03/12] netfilter: don't setup nat info for confirmed ct

2017-05-19 Thread Pablo Neira Ayuso
From: Liping Zhang We cannot setup nat info if the ct has been confirmed already, else, different cpu may race to handle the same ct. In extreme situation, we may hit the "BUG_ON(nf_nat_initialized(ct, maniptype))" in the nf_nat_setup_info. Also running the following commands will easily hit NF_

Re: [PATCH iptables] iptables: support insisting that the lock is held

2017-05-19 Thread Lorenzo Colitti
On Thu, May 4, 2017 at 12:57 AM, Lorenzo Colitti wrote: > > I would like to skip this compile time switch, if the existing > > behaviour is broken, we should just fix it. What is the scenario that > > can indeed have an impact in terms of backward compatibility breakage? > > Does it really make se

[PATCH] iptables: insist that the lock is held.

2017-05-19 Thread Lorenzo Colitti
Currently, iptables programs will exit with an error if the iptables lock cannot be acquired, but will silently continue if the lock cannot be opened at all. This can cause unexpected failures (with unhelpful error messages) in the presence of concurrent updates, which can be very difficult to find