* [PATCH net-next 00/10] Netfilter updates for net-next
@ 2021-03-22 23:56 Pablo Neira Ayuso
0 siblings, 0 replies; 15+ messages in thread
From: Pablo Neira Ayuso @ 2021-03-22 23:56 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following batch contains Netfilter updates for net-next:
1) Split flowtable workqueues per events, from Oz Shlomo.
2) fall-through warnings for clang, from Gustavo A. R. Silva
3) Remove unused declaration in conntrack, from YueHaibing.
4) Consolidate skb_try_make_writable() in flowtable datapath,
simplify some of the existing codebase.
5) Call dst_check() to fall back to static classic forwarding path.
6) Update table flags from commit phase.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thanks!
----------------------------------------------------------------
The following changes since commit ebfbc46b35cb70b9fbd88f376d7a33b79f60adff:
openvswitch: Warn over-mtu packets only if iface is UP. (2021-03-16 16:28:30 -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 0ce7cf4127f14078ca598ba9700d813178a59409:
netfilter: nftables: update table flags from the commit phase (2021-03-18 01:35:39 +0100)
----------------------------------------------------------------
Gustavo A. R. Silva (1):
netfilter: Fix fall-through warnings for Clang
Oz Shlomo (1):
netfilter: flowtable: separate replace, destroy and stats to different workqueues
Pablo Neira Ayuso (7):
netfilter: flowtable: consolidate skb_try_make_writable() call
netfilter: flowtable: move skb_try_make_writable() before NAT in IPv4
netfilter: flowtable: move FLOW_OFFLOAD_DIR_MAX away from enumeration
netfilter: flowtable: fast NAT functions never fail
netfilter: flowtable: call dst_check() to fall back to classic forwarding
netfilter: flowtable: refresh timeout after dst and writable checks
netfilter: nftables: update table flags from the commit phase
YueHaibing (1):
netfilter: conntrack: Remove unused variable declaration
include/net/netfilter/ipv6/nf_conntrack_ipv6.h | 3 -
include/net/netfilter/nf_flow_table.h | 14 +-
include/net/netfilter/nf_tables.h | 9 +-
net/netfilter/nf_conntrack_proto_dccp.c | 1 +
net/netfilter/nf_flow_table_core.c | 57 ++----
net/netfilter/nf_flow_table_ip.c | 231 ++++++++++---------------
net/netfilter/nf_flow_table_offload.c | 44 ++++-
net/netfilter/nf_tables_api.c | 32 ++--
net/netfilter/nft_ct.c | 1 +
9 files changed, 174 insertions(+), 218 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 00/10] Netfilter updates for net-next
@ 2021-08-11 8:48 Pablo Neira Ayuso
0 siblings, 0 replies; 15+ messages in thread
From: Pablo Neira Ayuso @ 2021-08-11 8:48 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter updates for net-next:
1) Use nfnetlink_unicast() instead of netlink_unicast() in nft_compat.
2) Remove call to nf_ct_l4proto_find() in flowtable offload timeout
fixup.
3) CLUSTERIP registers ARP hook on demand, from Florian.
4) Use clusterip_net to store pernet warning, also from Florian.
5) Remove struct netns_xt, from Florian Westphal.
6) Enable ebtables hooks in initns on demand, from Florian.
7) Allow to filter conntrack netlink dump per status bits,
from Florian Westphal.
8) Register x_tables hooks in initns on demand, from Florian.
9) Remove queue_handler from per-netns structure, again from Florian.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thanks.
----------------------------------------------------------------
The following changes since commit aae950b189413ed3201354600d44223da0bcf63c:
Merge branch 'clean-devlink-net-namespace-operations' (2021-07-30 13:16:40 -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 8702997074363c294a1f83928cd0c33ca57bf813:
netfilter: nf_queue: move hookfn registration out of struct net (2021-08-10 17:32:00 +0200)
----------------------------------------------------------------
Florian Westphal (8):
netfilter: ipt_CLUSTERIP: only add arp mangle hook when required
netfilter: ipt_CLUSTERIP: use clusterip_net to store pernet warning
netfilter: remove xt pernet data
netfilter: ebtables: do not hook tables by default
netfilter: ctnetlink: add and use a helper for mark parsing
netfilter: ctnetlink: allow to filter dump by status bits
netfilter: x_tables: never register tables by default
netfilter: nf_queue: move hookfn registration out of struct net
Pablo Neira Ayuso (2):
netfilter: nft_compat: use nfnetlink_unicast()
netfilter: flowtable: remove nf_ct_l4proto_find() call
include/linux/netfilter/x_tables.h | 6 +-
include/linux/netfilter_bridge/ebtables.h | 2 +
include/net/net_namespace.h | 2 -
include/net/netfilter/nf_queue.h | 4 +-
include/net/netns/netfilter.h | 1 -
include/net/netns/x_tables.h | 12 ---
include/uapi/linux/netfilter/nfnetlink_conntrack.h | 1 +
net/bridge/netfilter/ebtable_broute.c | 17 +++-
net/bridge/netfilter/ebtable_filter.c | 17 +++-
net/bridge/netfilter/ebtable_nat.c | 17 +++-
net/bridge/netfilter/ebtables.c | 109 ++++++++++++++++++---
net/ipv4/netfilter/arptable_filter.c | 23 +++--
net/ipv4/netfilter/ipt_CLUSTERIP.c | 56 +++++++----
net/ipv4/netfilter/iptable_filter.c | 24 +++--
net/ipv4/netfilter/iptable_mangle.c | 17 ++--
net/ipv4/netfilter/iptable_nat.c | 20 ++--
net/ipv4/netfilter/iptable_raw.c | 21 ++--
net/ipv4/netfilter/iptable_security.c | 23 +++--
net/ipv6/netfilter/ip6table_filter.c | 23 +++--
net/ipv6/netfilter/ip6table_mangle.c | 22 ++---
net/ipv6/netfilter/ip6table_nat.c | 16 +--
net/ipv6/netfilter/ip6table_raw.c | 24 +++--
net/ipv6/netfilter/ip6table_security.c | 22 ++---
net/netfilter/nf_conntrack_netlink.c | 76 +++++++++++---
net/netfilter/nf_flow_table_core.c | 10 --
net/netfilter/nf_queue.c | 19 ++--
net/netfilter/nfnetlink_queue.c | 15 ++-
net/netfilter/nft_compat.c | 8 +-
net/netfilter/x_tables.c | 98 ++++++++++++++----
net/netfilter/xt_CT.c | 11 ---
30 files changed, 468 insertions(+), 248 deletions(-)
delete mode 100644 include/net/netns/x_tables.h
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 00/10] Netfilter updates for net-next
@ 2022-10-26 13:22 Pablo Neira Ayuso
0 siblings, 0 replies; 15+ messages in thread
From: Pablo Neira Ayuso @ 2022-10-26 13:22 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet
Hi,
The following patchset contains Netfilter updates for net-next:
1) Move struct nft_payload_set definition to .c file where it is
only used.
2) Shrink transport and inner header offset fields in the nft_pktinfo
structure to 16-bits, from Florian Westphal.
3) Get rid of nft_objref Kbuild toggle, make it built-in into
nf_tables. This expression is used to instantiate conntrack helpers
in nftables. After removing the conntrack helper auto-assignment
toggle it this feature became more important so move it to the nf_tables
core module. Also from Florian.
4) Extend the existing function to calculate payload inner header offset
to deal with the GRE and IPIP transport protocols.
6) Add inner expression support for nf_tables. This new expression
provides a packet parser for tunneled packets which uses a userspace
description of the expected inner headers. The inner expression
invokes the payload expression (via direct call) to match on the
inner header protocol fields using the inner link, network and
transport header offsets.
An example of the bytecode generated from userspace to match on
IP source encapsulated in a VxLAN packet:
# nft --debug=netlink add rule netdev x y udp dport 4789 vxlan ip saddr 1.2.3.4
netdev x y
[ meta load l4proto => reg 1 ]
[ cmp eq reg 1 0x00000011 ]
[ payload load 2b @ transport header + 2 => reg 1 ]
[ cmp eq reg 1 0x0000b512 ]
[ inner type vxlan hdrsize 8 flags f [ meta load protocol => reg 1 ] ]
[ cmp eq reg 1 0x00000008 ]
[ inner type vxlan hdrsize 8 flags f [ payload load 4b @ network header + 12 => reg 1 ] ]
[ cmp eq reg 1 0x04030201 ]
7) Store inner link, network and transport header offsets in percpu
area to parse inner packet header once only. Matching on a different
tunnel type invalidates existing offsets in the percpu area and it
invokes the inner tunnel parser again.
8) Add support for inner meta matching. This support for
NFTA_META_PROTOCOL, which specifies the inner ethertype, and
NFT_META_L4PROTO, which specifies the inner transport protocol.
9) Extend nft_inner to parse GENEVE optional fields to calculate the
link layer offset.
10) Update inner expression so tunnel offset points to GRE header
to normalize tunnel header handling. This also allows to perform
different interpretations of the GRE header from userspace.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git
Thanks.
----------------------------------------------------------------
The following changes since commit d6dd508080a3cdc0ab34ebf66c3734f2dff907ad:
bnx2: Use kmalloc_size_roundup() to match ksize() usage (2022-10-25 12:59:04 +0200)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git HEAD
for you to fetch changes up to 91619eb60aeccd3181d9b88975add706a9b763c1:
netfilter: nft_inner: set tunnel offset to GRE header offset (2022-10-25 13:48:42 +0200)
----------------------------------------------------------------
Florian Westphal (2):
netfilter: nf_tables: reduce nft_pktinfo by 8 bytes
netfilter: nft_objref: make it builtin
Pablo Neira Ayuso (8):
netfilter: nft_payload: move struct nft_payload_set definition where it belongs
netfilter: nft_payload: access GRE payload via inner offset
netfilter: nft_payload: access ipip payload for inner offset
netfilter: nft_inner: support for inner tunnel header matching
netfilter: nft_inner: add percpu inner context
netfilter: nft_meta: add inner match support
netfilter: nft_inner: add geneve support
netfilter: nft_inner: set tunnel offset to GRE header offset
include/net/netfilter/nf_tables.h | 10 +-
include/net/netfilter/nf_tables_core.h | 36 ++-
include/net/netfilter/nf_tables_ipv4.h | 4 +
include/net/netfilter/nf_tables_ipv6.h | 6 +-
include/net/netfilter/nft_meta.h | 6 +
include/uapi/linux/netfilter/nf_tables.h | 27 +++
net/netfilter/Kconfig | 6 -
net/netfilter/Makefile | 4 +-
net/netfilter/nf_tables_api.c | 37 +++
net/netfilter/nf_tables_core.c | 2 +
net/netfilter/nft_inner.c | 384 +++++++++++++++++++++++++++++++
net/netfilter/nft_meta.c | 62 +++++
net/netfilter/nft_objref.c | 22 +-
net/netfilter/nft_payload.c | 134 ++++++++++-
14 files changed, 695 insertions(+), 45 deletions(-)
create mode 100644 net/netfilter/nft_inner.c
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 00/10] netfilter updates for net-next
@ 2023-08-22 15:43 Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Florian Westphal
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel
Hello,
This batch contains a few updates for your *net-next* tree.
First patch resolves a fortify warning by wrapping the to-be-copied
members via struct_group.
Second patch replaces array[0] with array[] in ebtables uapi.
Both changes from GONG Ruiqi.
The largest chunk is replacement of strncpy with strscpy_pad()
in netfilter, from Justin Stitt.
Last patch, from myself, aborts ruleset validation if a fatal
signal is pending, this speeds up process exit.
The following changes since commit 43c2817225fce05701f062a996255007481935e2:
net: remove unnecessary input parameter 'how' in ifdown function (2023-08-22 13:19:02 +0200)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git tags/nf-next-23-08-22
for you to fetch changes up to 169384fbe8513185499bcbb817d198e6a63eb37e:
netfilter: nf_tables: allow loop termination for pending fatal signal (2023-08-22 15:14:32 +0200)
----------------------------------------------------------------
nf-next pull request 2023-08-22
----------------------------------------------------------------
Florian Westphal (1):
netfilter: nf_tables: allow loop termination for pending fatal signal
GONG, Ruiqi (2):
netfilter: ebtables: fix fortify warnings in size_entry_mwt()
netfilter: ebtables: replace zero-length array members
Justin Stitt (7):
netfilter: ipset: refactor deprecated strncpy
netfilter: nf_tables: refactor deprecated strncpy
netfilter: nf_tables: refactor deprecated strncpy
netfilter: nft_osf: refactor deprecated strncpy
netfilter: nft_meta: refactor deprecated strncpy
netfilter: x_tables: refactor deprecated strncpy
netfilter: xtables: refactor deprecated strncpy
include/uapi/linux/netfilter_bridge/ebtables.h | 22 ++++++++++++----------
net/bridge/netfilter/ebtables.c | 3 +--
net/netfilter/ipset/ip_set_core.c | 10 +++++-----
net/netfilter/nf_tables_api.c | 6 ++++++
net/netfilter/nft_ct.c | 2 +-
net/netfilter/nft_fib.c | 2 +-
net/netfilter/nft_meta.c | 6 +++---
net/netfilter/nft_osf.c | 6 +++---
net/netfilter/x_tables.c | 5 ++---
net/netfilter/xt_repldata.h | 2 +-
10 files changed, 35 insertions(+), 29 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt()
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-23 2:00 ` patchwork-bot+netdevbpf
2023-08-22 15:43 ` [PATCH net-next 02/10] netfilter: ebtables: replace zero-length array members Florian Westphal
` (8 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, GONG, Ruiqi, GONG, Gustavo A . R . Silva,
Kees Cook
From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
When compiling with gcc 13 and CONFIG_FORTIFY_SOURCE=y, the following
warning appears:
In function ‘fortify_memcpy_chk’,
inlined from ‘size_entry_mwt’ at net/bridge/netfilter/ebtables.c:2118:2:
./include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’
declared with attribute warning: detected read beyond size of field (2nd parameter);
maybe use struct_group()? [-Werror=attribute-warning]
592 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The compiler is complaining:
memcpy(&offsets[1], &entry->watchers_offset,
sizeof(offsets) - sizeof(offsets[0]));
where memcpy reads beyong &entry->watchers_offset to copy
{watchers,target,next}_offset altogether into offsets[]. Silence the
warning by wrapping these three up via struct_group().
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/uapi/linux/netfilter_bridge/ebtables.h | 14 ++++++++------
net/bridge/netfilter/ebtables.c | 3 +--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
index a494cf43a755..b0caad82b693 100644
--- a/include/uapi/linux/netfilter_bridge/ebtables.h
+++ b/include/uapi/linux/netfilter_bridge/ebtables.h
@@ -182,12 +182,14 @@ struct ebt_entry {
unsigned char sourcemsk[ETH_ALEN];
unsigned char destmac[ETH_ALEN];
unsigned char destmsk[ETH_ALEN];
- /* sizeof ebt_entry + matches */
- unsigned int watchers_offset;
- /* sizeof ebt_entry + matches + watchers */
- unsigned int target_offset;
- /* sizeof ebt_entry + matches + watchers + target */
- unsigned int next_offset;
+ __struct_group(/* no tag */, offsets, /* no attrs */,
+ /* sizeof ebt_entry + matches */
+ unsigned int watchers_offset;
+ /* sizeof ebt_entry + matches + watchers */
+ unsigned int target_offset;
+ /* sizeof ebt_entry + matches + watchers + target */
+ unsigned int next_offset;
+ );
unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 757ec46fc45a..aa23479b20b2 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -2115,8 +2115,7 @@ static int size_entry_mwt(const struct ebt_entry *entry, const unsigned char *ba
return ret;
offsets[0] = sizeof(struct ebt_entry); /* matches come first */
- memcpy(&offsets[1], &entry->watchers_offset,
- sizeof(offsets) - sizeof(offsets[0]));
+ memcpy(&offsets[1], &entry->offsets, sizeof(entry->offsets));
if (state->buf_kern_start) {
buf_start = state->buf_kern_start + state->buf_kern_offset;
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 02/10] netfilter: ebtables: replace zero-length array members
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 03/10] netfilter: ipset: refactor deprecated strncpy Florian Westphal
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, GONG, Ruiqi, GONG, Kees Cook
From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
As suggested by Kees[1], replace the old-style 0-element array members
of multiple structs in ebtables.h with modern C99 flexible array.
[1]: https://lore.kernel.org/all/5E8E0F9C-EE3F-4B0D-B827-DC47397E2A4A@kernel.org/
[ fw@strlen.de:
keep struct ebt_entry_target as-is, causes compiler warning:
"variable sized type 'struct ebt_entry_target' not at the end of a
struct or class is a GNU extension" ]
Link: https://github.com/KSPP/linux/issues/21
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/uapi/linux/netfilter_bridge/ebtables.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
index b0caad82b693..4ff328f3d339 100644
--- a/include/uapi/linux/netfilter_bridge/ebtables.h
+++ b/include/uapi/linux/netfilter_bridge/ebtables.h
@@ -87,7 +87,7 @@ struct ebt_entries {
/* nr. of entries */
unsigned int nentries;
/* entry list */
- char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+ char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};
/* used for the bitmask of struct ebt_entry */
@@ -129,7 +129,7 @@ struct ebt_entry_match {
} u;
/* size of data */
unsigned int match_size;
- unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+ unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};
struct ebt_entry_watcher {
@@ -142,7 +142,7 @@ struct ebt_entry_watcher {
} u;
/* size of data */
unsigned int watcher_size;
- unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+ unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};
struct ebt_entry_target {
@@ -190,7 +190,7 @@ struct ebt_entry {
/* sizeof ebt_entry + matches + watchers + target */
unsigned int next_offset;
);
- unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+ unsigned char elems[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
};
static __inline__ struct ebt_entry_target *
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 03/10] netfilter: ipset: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 02/10] netfilter: ebtables: replace zero-length array members Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 04/10] netfilter: nf_tables: " Florian Westphal
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt, linux-hardening
From: Justin Stitt <justinstitt@google.com>
Use `strscpy_pad` instead of `strncpy`.
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/ipset/ip_set_core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 0b68e2e2824e..e564b5174261 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -872,7 +872,7 @@ ip_set_name_byindex(struct net *net, ip_set_id_t index, char *name)
BUG_ON(!set);
read_lock_bh(&ip_set_ref_lock);
- strncpy(name, set->name, IPSET_MAXNAMELEN);
+ strscpy_pad(name, set->name, IPSET_MAXNAMELEN);
read_unlock_bh(&ip_set_ref_lock);
}
EXPORT_SYMBOL_GPL(ip_set_name_byindex);
@@ -1326,7 +1326,7 @@ static int ip_set_rename(struct sk_buff *skb, const struct nfnl_info *info,
goto out;
}
}
- strncpy(set->name, name2, IPSET_MAXNAMELEN);
+ strscpy_pad(set->name, name2, IPSET_MAXNAMELEN);
out:
write_unlock_bh(&ip_set_ref_lock);
@@ -1380,9 +1380,9 @@ static int ip_set_swap(struct sk_buff *skb, const struct nfnl_info *info,
return -EBUSY;
}
- strncpy(from_name, from->name, IPSET_MAXNAMELEN);
- strncpy(from->name, to->name, IPSET_MAXNAMELEN);
- strncpy(to->name, from_name, IPSET_MAXNAMELEN);
+ strscpy_pad(from_name, from->name, IPSET_MAXNAMELEN);
+ strscpy_pad(from->name, to->name, IPSET_MAXNAMELEN);
+ strscpy_pad(to->name, from_name, IPSET_MAXNAMELEN);
swap(from->ref, to->ref);
ip_set(inst, from_id) = to;
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 04/10] netfilter: nf_tables: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (2 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 03/10] netfilter: ipset: refactor deprecated strncpy Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 05/10] " Florian Westphal
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt
From: Justin Stitt <justinstitt@google.com>
Prefer `strscpy_pad` over `strncpy`.
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_ct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index e87fd4314c68..86bb9d7797d9 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -108,7 +108,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
helper = rcu_dereference(help->helper);
if (helper == NULL)
goto err;
- strncpy((char *)dest, helper->name, NF_CT_HELPER_NAME_LEN);
+ strscpy_pad((char *)dest, helper->name, NF_CT_HELPER_NAME_LEN);
return;
#ifdef CONFIG_NF_CONNTRACK_LABELS
case NFT_CT_LABELS: {
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 05/10] netfilter: nf_tables: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (3 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 04/10] netfilter: nf_tables: " Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 06/10] netfilter: nft_osf: " Florian Westphal
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt
From: Justin Stitt <justinstitt@google.com>
Prefer `strscpy_pad` over `strncpy`.
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_fib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
index 601c9e09d07a..04b51f285332 100644
--- a/net/netfilter/nft_fib.c
+++ b/net/netfilter/nft_fib.c
@@ -151,7 +151,7 @@ void nft_fib_store_result(void *reg, const struct nft_fib *priv,
if (priv->flags & NFTA_FIB_F_PRESENT)
*dreg = !!dev;
else
- strncpy(reg, dev ? dev->name : "", IFNAMSIZ);
+ strscpy_pad(reg, dev ? dev->name : "", IFNAMSIZ);
break;
default:
WARN_ON_ONCE(1);
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 06/10] netfilter: nft_osf: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (4 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 05/10] " Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 07/10] netfilter: nft_meta: " Florian Westphal
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt
From: Justin Stitt <justinstitt@google.com>
Use `strscpy_pad` over `strncpy` for NUL-terminated strings.
We can also drop the + 1 from `NFT_OSF_MAXGENRELEN + 1` since `strscpy`
will guarantee NUL-termination.
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_osf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/nft_osf.c b/net/netfilter/nft_osf.c
index 70820c66b591..7f61506e5b44 100644
--- a/net/netfilter/nft_osf.c
+++ b/net/netfilter/nft_osf.c
@@ -23,7 +23,7 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
struct nft_osf *priv = nft_expr_priv(expr);
u32 *dest = ®s->data[priv->dreg];
struct sk_buff *skb = pkt->skb;
- char os_match[NFT_OSF_MAXGENRELEN + 1];
+ char os_match[NFT_OSF_MAXGENRELEN];
const struct tcphdr *tcp;
struct nf_osf_data data;
struct tcphdr _tcph;
@@ -45,7 +45,7 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
}
if (!nf_osf_find(skb, nf_osf_fingers, priv->ttl, &data)) {
- strncpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN);
+ strscpy_pad((char *)dest, "unknown", NFT_OSF_MAXGENRELEN);
} else {
if (priv->flags & NFT_OSF_F_VERSION)
snprintf(os_match, NFT_OSF_MAXGENRELEN, "%s:%s",
@@ -53,7 +53,7 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
else
strscpy(os_match, data.genre, NFT_OSF_MAXGENRELEN);
- strncpy((char *)dest, os_match, NFT_OSF_MAXGENRELEN);
+ strscpy_pad((char *)dest, os_match, NFT_OSF_MAXGENRELEN);
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 07/10] netfilter: nft_meta: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (5 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 06/10] netfilter: nft_osf: " Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 08/10] netfilter: x_tables: " Florian Westphal
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt
From: Justin Stitt <justinstitt@google.com>
Prefer `strscpy_pad` to `strncpy`.
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_meta.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 8fdc7318c03c..f7da7c43333b 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -185,12 +185,12 @@ static noinline bool nft_meta_get_eval_kind(enum nft_meta_keys key,
case NFT_META_IIFKIND:
if (!in || !in->rtnl_link_ops)
return false;
- strncpy((char *)dest, in->rtnl_link_ops->kind, IFNAMSIZ);
+ strscpy_pad((char *)dest, in->rtnl_link_ops->kind, IFNAMSIZ);
break;
case NFT_META_OIFKIND:
if (!out || !out->rtnl_link_ops)
return false;
- strncpy((char *)dest, out->rtnl_link_ops->kind, IFNAMSIZ);
+ strscpy_pad((char *)dest, out->rtnl_link_ops->kind, IFNAMSIZ);
break;
default:
return false;
@@ -206,7 +206,7 @@ static void nft_meta_store_ifindex(u32 *dest, const struct net_device *dev)
static void nft_meta_store_ifname(u32 *dest, const struct net_device *dev)
{
- strncpy((char *)dest, dev ? dev->name : "", IFNAMSIZ);
+ strscpy_pad((char *)dest, dev ? dev->name : "", IFNAMSIZ);
}
static bool nft_meta_store_iftype(u32 *dest, const struct net_device *dev)
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 08/10] netfilter: x_tables: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (6 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 07/10] netfilter: nft_meta: " Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 09/10] netfilter: xtables: " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 10/10] netfilter: nf_tables: allow loop termination for pending fatal signal Florian Westphal
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt
From: Justin Stitt <justinstitt@google.com>
Prefer `strscpy_pad` to `strncpy`.
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/x_tables.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 470282cf3fae..21624d68314f 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -768,7 +768,7 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
m->u.user.match_size = msize;
strscpy(name, match->name, sizeof(name));
module_put(match->me);
- strncpy(m->u.user.name, name, sizeof(m->u.user.name));
+ strscpy_pad(m->u.user.name, name, sizeof(m->u.user.name));
*size += off;
*dstptr += msize;
@@ -1148,7 +1148,7 @@ void xt_compat_target_from_user(struct xt_entry_target *t, void **dstptr,
t->u.user.target_size = tsize;
strscpy(name, target->name, sizeof(name));
module_put(target->me);
- strncpy(t->u.user.name, name, sizeof(t->u.user.name));
+ strscpy_pad(t->u.user.name, name, sizeof(t->u.user.name));
*size += off;
*dstptr += tsize;
@@ -2014,4 +2014,3 @@ static void __exit xt_fini(void)
module_init(xt_init);
module_exit(xt_fini);
-
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 09/10] netfilter: xtables: refactor deprecated strncpy
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (7 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 08/10] netfilter: x_tables: " Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 10/10] netfilter: nf_tables: allow loop termination for pending fatal signal Florian Westphal
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel, Justin Stitt
From: Justin Stitt <justinstitt@google.com>
Prefer `strscpy_pad` as it's a more robust interface whilst maintaing
zero-padding behavior.
There may have existed a bug here due to both `tbl->repl.name` and
`info->name` having a size of 32 as defined below:
| #define XT_TABLE_MAXNAMELEN 32
This may lead to buffer overreads in some situations -- `strscpy` solves
this by guaranteeing NUL-termination of the dest buffer.
Signed-off-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/xt_repldata.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/xt_repldata.h b/net/netfilter/xt_repldata.h
index 68ccbe50bb1e..5d1fb7018dba 100644
--- a/net/netfilter/xt_repldata.h
+++ b/net/netfilter/xt_repldata.h
@@ -29,7 +29,7 @@
if (tbl == NULL) \
return NULL; \
term = (struct type##_error *)&(((char *)tbl)[term_offset]); \
- strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
+ strscpy_pad(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
*term = (struct type##_error)typ2##_ERROR_INIT; \
tbl->repl.valid_hooks = hook_mask; \
tbl->repl.num_entries = nhooks + 1; \
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 10/10] netfilter: nf_tables: allow loop termination for pending fatal signal
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
` (8 preceding siblings ...)
2023-08-22 15:43 ` [PATCH net-next 09/10] netfilter: xtables: " Florian Westphal
@ 2023-08-22 15:43 ` Florian Westphal
9 siblings, 0 replies; 15+ messages in thread
From: Florian Westphal @ 2023-08-22 15:43 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
netfilter-devel
abort early so task can exit faster if a fatal signal is pending,
no need to continue validation in that case.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nf_tables_api.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 3e841e45f2c0..f00a1dff85e8 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3675,6 +3675,9 @@ int nft_chain_validate(const struct nft_ctx *ctx, const struct nft_chain *chain)
return -EMLINK;
list_for_each_entry(rule, &chain->rules, list) {
+ if (fatal_signal_pending(current))
+ return -EINTR;
+
if (!nft_is_active_next(ctx->net, rule))
continue;
@@ -10479,6 +10482,9 @@ static int nf_tables_check_loops(const struct nft_ctx *ctx,
if (ctx->chain == chain)
return -ELOOP;
+ if (fatal_signal_pending(current))
+ return -EINTR;
+
list_for_each_entry(rule, &chain->rules, list) {
nft_rule_for_each_expr(expr, last, rule) {
struct nft_immediate_expr *priv;
--
2.41.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt()
2023-08-22 15:43 ` [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Florian Westphal
@ 2023-08-23 2:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 15+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-23 2:00 UTC (permalink / raw)
To: Florian Westphal
Cc: netdev, pabeni, davem, edumazet, kuba, netfilter-devel,
gongruiqi1, GONG, gustavoars, keescook
Hello:
This series was applied to netdev/net-next.git (main)
by Florian Westphal <fw@strlen.de>:
On Tue, 22 Aug 2023 17:43:22 +0200 you wrote:
> From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
>
> When compiling with gcc 13 and CONFIG_FORTIFY_SOURCE=y, the following
> warning appears:
>
> In function ‘fortify_memcpy_chk’,
> inlined from ‘size_entry_mwt’ at net/bridge/netfilter/ebtables.c:2118:2:
> ./include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’
> declared with attribute warning: detected read beyond size of field (2nd parameter);
> maybe use struct_group()? [-Werror=attribute-warning]
> 592 | __read_overflow2_field(q_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> [...]
Here is the summary with links:
- [net-next,01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt()
https://git.kernel.org/netdev/net-next/c/a7ed3465daa2
- [net-next,02/10] netfilter: ebtables: replace zero-length array members
https://git.kernel.org/netdev/net-next/c/a2f02c9920b2
- [net-next,03/10] netfilter: ipset: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/e53314034b23
- [net-next,04/10] netfilter: nf_tables: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/6cdd75a4a66b
- [net-next,05/10] netfilter: nf_tables: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/7457af8bf994
- [net-next,06/10] netfilter: nft_osf: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/6d87a4eae89e
- [net-next,07/10] netfilter: nft_meta: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/ad156c23d65c
- [net-next,08/10] netfilter: x_tables: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/06f7d3c3f82c
- [net-next,09/10] netfilter: xtables: refactor deprecated strncpy
https://git.kernel.org/netdev/net-next/c/aa222dd190d6
- [net-next,10/10] netfilter: nf_tables: allow loop termination for pending fatal signal
https://git.kernel.org/netdev/net-next/c/169384fbe851
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2023-08-23 2:00 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 15:43 [PATCH net-next 00/10] netfilter updates for net-next Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 01/10] netfilter: ebtables: fix fortify warnings in size_entry_mwt() Florian Westphal
2023-08-23 2:00 ` patchwork-bot+netdevbpf
2023-08-22 15:43 ` [PATCH net-next 02/10] netfilter: ebtables: replace zero-length array members Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 03/10] netfilter: ipset: refactor deprecated strncpy Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 04/10] netfilter: nf_tables: " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 05/10] " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 06/10] netfilter: nft_osf: " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 07/10] netfilter: nft_meta: " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 08/10] netfilter: x_tables: " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 09/10] netfilter: xtables: " Florian Westphal
2023-08-22 15:43 ` [PATCH net-next 10/10] netfilter: nf_tables: allow loop termination for pending fatal signal Florian Westphal
-- strict thread matches above, loose matches on Subject: below --
2022-10-26 13:22 [PATCH net-next 00/10] Netfilter updates for net-next Pablo Neira Ayuso
2021-08-11 8:48 Pablo Neira Ayuso
2021-03-22 23:56 Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).