Netfilter fixes for net
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi,
The following patchset contains Netfilter fixes for net:
1) Incorrect output device in nf_egress hook, from Phill Sutter.
2) Preserve liberal flag in TCP conntrack state, reported by Sven Auhagen.
3) Use GFP_KERNEL_ACCOUNT flag for nf_tables objects, from Vasily Averin.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit f92fcb5c00dc924a4661d5bf68de7937040f26b8:
Merge branch 'ice-avoid-sleeping-scheduling-in-atomic-contexts' (2022-03-23 10:40:44 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git HEAD
for you to fetch changes up to 33758c891479ea1c736abfee64b5225925875557:
memcg: enable accounting for nft objects (2022-03-28 10:11:23 +0200)
----------------------------------------------------------------
Pablo Neira Ayuso (1):
netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options
Phil Sutter (1):
netfilter: egress: Report interface as outgoing
Vasily Averin (1):
memcg: enable accounting for nft objects
include/linux/netfilter_netdev.h | 2 +- net/netfilter/core.c | 2 +- net/netfilter/nf_conntrack_proto_tcp.c | 17 +++++++++---- net/netfilter/nf_tables_api.c | 44 +++++++++++++++++----------------- 4 files changed, 37 insertions(+), 28 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/3 netfilter: egress: Report interface as outgoing
From: Phil Sutter <[email protected]>
Otherwise packets in egress chains seem like they are being received by the interface, not sent out via it.
--- include/linux/netfilter_netdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/netfilter_netdev.h +1 -1
@@ -99,7 +99,7 @@ static inline struct sk_buff *nf_hook_egress(struct sk_buff *skb, int *rc,return skb;nf_hook_state_init (&state,NF_NETDEV_EGRESS , -NFPROTO_NETDEV , dev,NULL ,NULL , +NFPROTO_NETDEV ,NULL , dev,NULL ,dev_net (dev),NULL );/* nf assumes rcu_read_lock, not just read_lock_bh */
Signature · 1 line
2.30.2
Re: [PATCH net 1/3] netfilter: egress: Report interface as outgoing
This series was applied to netdev/net.git (master) by Pablo Neira Ayuso <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Pablo Neira Ayuso <[email protected]>:
Quoted 10 lines · On Mon, 28 Mar 2022 10:20:20 +0200 you wrote:
From: Phil Sutter <[email protected]>
Otherwise packets in egress chains seem like they are being received by the interface, not sent out via it.
Fixes 42df6e1d221dd ("netfilter: Introduce egress hook")Signed-off-by Phil Sutter <[email protected]>Signed-off-by Florian Westphal <[email protected]>[...]
Here is the summary with links:
- [net,1/3] netfilter: egress: Report interface as outgoing
https://git.kernel.org/netdev/net/c/d645552e9bd9 - [net,2/3] netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options https://git.kernel.org/netdev/net/c/f2dd495a8d58 - [net,3/3] memcg: enable accounting for nft objects https://git.kernel.org/netdev/net/c/33758c891479
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerPATCH 2/3 netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options
In reply to Pablo Neira AyusoDo not reset IP_CT_TCP_FLAG_BE_LIBERAL flag in out-of-sync scenarios coming before the TCP window tracking, otherwise such connections will fail in the window check.
Update tcp_options() to leave this flag in place and add a new helper function to reset the tcp window state.
Based on patch from Sven Auhagen.
--- net/netfilter/nf_conntrack_proto_tcp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +13 -4
@@ -341,8 +341,8 @@ static void tcp_options(const struct sk_buff *skb,if (!ptr)return ; - state->td_scale = - state->flags =0 ; + state->td_scale =0 ; + state->flags &=IP_CT_TCP_FLAG_BE_LIBERAL ;while (length >0 ) {int opcode=*ptr++;
@@ -862,6 +862,16 @@ static bool tcp_can_early_drop(const struct nf_conn *ct)return false; } +static void nf_ct_tcp_state_reset (struct ip_ct_tcp_state *state) +{ + state->td_end =0 ; + state->td_maxend =0 ; + state->td_maxwin =0 ; + state->td_maxack =0 ; + state->td_scale =0 ; + state->flags &=IP_CT_TCP_FLAG_BE_LIBERAL ; +} +/* Returns verdict for packet, or -1 for invalid. */ int nf_conntrack_tcp_packet(struct nf_conn *ct, struct sk_buff *skb,
@@ -968,8 +978,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct, ct->proto.tcp.last_flags &= ~IP_CT_EXP_CHALLENGE_ACK ; ct->proto.tcp.seen[ct->proto.tcp.last_dir].flags = ct->proto.tcp.last_flags; -memset (&ct->proto.tcp.seen[dir],0 , -sizeof (struct ip_ct_tcp_state )); +nf_ct_tcp_state_reset (&ct->proto.tcp.seen[dir]);break ; } ct->proto.tcp.last_index = index;
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 3/3 memcg: enable accounting for nft objects
In reply to Pablo Neira AyusoFrom: Vasily Averin <[email protected]>
nftables replaces iptables, but it lacks memcg accounting.
This patch account most of the memory allocation associated with nft and should protect the host from misusing nft inside a memcg restricted container.
--- net/netfilter/core.c | 2 +- net/netfilter/nf_tables_api.c | 44 +++++++++++++++++------------------ 2 files changed, 23 insertions(+), 23 deletions(-)
net/netfilter/core.c +1 -1
@@ -58,7 +58,7 @@ static struct nf_hook_entries *allocate_hook_entries_size(u16 num)if (num ==0 )return NULL ; - e =kvzalloc (alloc,GFP_KERNEL ); + e =kvzalloc (alloc,GFP_KERNEL_ACCOUNT );if (e) e->num_hook_entries = num;return e;
net/netfilter/nf_tables_api.c +22 -22
168 lines not on this page · raw message
Signature · 1 line
2.30.2