netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org
Subject: [PATCH net 1/7] netfilter: flowtable: fix NAT IPv6 offload mangling
Date: Tue, 13 Apr 2021 00:30:53 +0200	[thread overview]
Message-ID: <20210412223059.20841-2-pablo@netfilter.org> (raw)
In-Reply-To: <20210412223059.20841-1-pablo@netfilter.org>

Fix out-of-bound access in the address array.

Fixes: 5c27d8d76ce8 ("netfilter: nf_flow_table_offload: add IPv6 support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_flow_table_offload.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
index 2a6993fa40d7..1c5460e7bce8 100644
--- a/net/netfilter/nf_flow_table_offload.c
+++ b/net/netfilter/nf_flow_table_offload.c
@@ -305,12 +305,12 @@ static void flow_offload_ipv6_mangle(struct nf_flow_rule *flow_rule,
 				     const __be32 *addr, const __be32 *mask)
 {
 	struct flow_action_entry *entry;
-	int i;
+	int i, j;
 
-	for (i = 0; i < sizeof(struct in6_addr) / sizeof(u32); i += sizeof(u32)) {
+	for (i = 0, j = 0; i < sizeof(struct in6_addr) / sizeof(u32); i += sizeof(u32), j++) {
 		entry = flow_action_entry_next(flow_rule);
 		flow_offload_mangle(entry, FLOW_ACT_MANGLE_HDR_TYPE_IP6,
-				    offset + i, &addr[i], mask);
+				    offset + i, &addr[j], mask);
 	}
 }
 
-- 
2.20.1


  reply	other threads:[~2021-04-12 22:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 22:30 [PATCH net 0/7] Netfilter fixes for net Pablo Neira Ayuso
2021-04-12 22:30 ` Pablo Neira Ayuso [this message]
2021-04-12 23:20   ` [PATCH net 1/7] netfilter: flowtable: fix NAT IPv6 offload mangling patchwork-bot+netdevbpf
2021-04-12 22:30 ` [PATCH net 2/7] netfilter: conntrack: do not print icmpv6 as unknown via /proc Pablo Neira Ayuso
2021-04-12 22:30 ` [PATCH net 3/7] netfilter: nft_limit: avoid possible divide error in nft_limit_init Pablo Neira Ayuso
2021-04-12 22:30 ` [PATCH net 4/7] netfilter: bridge: add pre_exit hooks for ebtable unregistration Pablo Neira Ayuso
2021-04-12 22:30 ` [PATCH net 5/7] netfilter: arp_tables: add pre_exit hook for table unregister Pablo Neira Ayuso
2021-04-12 22:30 ` [PATCH net 6/7] netfilter: x_tables: fix compat match/target pad out-of-bound write Pablo Neira Ayuso
2021-04-12 22:30 ` [PATCH net 7/7] netfilter: nftables: clone set element expression template Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412223059.20841-2-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).