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 02/15] ipvs: check that ip_vs_conn_tab_bits is between 8 and 20
Date: Sat, 25 Sep 2021 00:11:00 +0200	[thread overview]
Message-ID: <20210924221113.348767-3-pablo@netfilter.org> (raw)
In-Reply-To: <20210924221113.348767-1-pablo@netfilter.org>

From: Andrea Claudi <aclaudi@redhat.com>

ip_vs_conn_tab_bits may be provided by the user through the
conn_tab_bits module parameter. If this value is greater than 31, or
less than 0, the shift operator used to derive tab_size causes undefined
behaviour.

Fix this checking ip_vs_conn_tab_bits value to be in the range specified
in ipvs Kconfig. If not, simply use default value.

Fixes: 6f7edb4881bf ("IPVS: Allow boot time change of hash size")
Reported-by: Yi Chen <yiche@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/ipvs/ip_vs_conn.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index c100c6b112c8..2c467c422dc6 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1468,6 +1468,10 @@ int __init ip_vs_conn_init(void)
 	int idx;
 
 	/* Compute size and mask */
+	if (ip_vs_conn_tab_bits < 8 || ip_vs_conn_tab_bits > 20) {
+		pr_info("conn_tab_bits not in [8, 20]. Using default value\n");
+		ip_vs_conn_tab_bits = CONFIG_IP_VS_TAB_BITS;
+	}
 	ip_vs_conn_tab_size = 1 << ip_vs_conn_tab_bits;
 	ip_vs_conn_tab_mask = ip_vs_conn_tab_size - 1;
 
-- 
2.30.2


  parent reply	other threads:[~2021-09-24 22:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 22:10 [PATCH net 00/15] Netfilter/IPVS fixes for net Pablo Neira Ayuso
2021-09-24 22:10 ` [PATCH net 01/15] netfilter: ipset: Fix oversized kvmalloc() calls Pablo Neira Ayuso
2021-09-25  3:40   ` patchwork-bot+netdevbpf
2021-09-24 22:11 ` Pablo Neira Ayuso [this message]
2021-09-24 22:11 ` [PATCH net 03/15] netfilter: ip6_tables: zero-initialize fragment offset Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 04/15] netfilter: conntrack: make max chain length random Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 05/15] netfilter: conntrack: include zone id in tuple hash again Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 06/15] netfilter: nat: include zone id in nat table " Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 07/15] selftests: netfilter: add selftest for directional zone support Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 08/15] selftests: netfilter: add zone stress test with colliding tuples Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 09/15] netfilter: nf_tables: unlink table before deleting it Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 10/15] netfilter: nf_tables: Fix oversized kvmalloc() calls Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 11/15] netfilter: nf_nat_masquerade: make async masq_inet6_event handling generic Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 12/15] netfilter: nf_nat_masquerade: defer conntrack walk to work queue Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 13/15] netfilter: iptable_raw: drop bogus net_init annotation Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 14/15] netfilter: log: work around missing softdep backend module Pablo Neira Ayuso
2021-09-24 22:11 ` [PATCH net 15/15] netfilter: conntrack: serialize hash resizes and cleanups 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=20210924221113.348767-3-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).