Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922582pxb; Mon, 4 Oct 2021 12:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzz6kI+JqrAljO8Db3PeWz2RljHcR/xXpYbrUor8QKRH8WBDu3o+wQPbaCd59xFfooFCrN+ X-Received: by 2002:a05:6402:1011:: with SMTP id c17mr20562730edu.144.1633376616188; Mon, 04 Oct 2021 12:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376616; cv=none; d=google.com; s=arc-20160816; b=tgYXMCJpRYXAvLTqxkP7s7NSwBHjQZ3ZknIhaEDAVfzf+Wy8pp+GGt+oQYfB6UCA2c YQA6/8qGR9PA27sjzx8byk3P+d8JKJC1PBNpOLv7v4KuqXSlkg0+bk51RNUVKV3cvjDy quoXvjvEqRbVH2icGRO/7k5p51kA4VJ/TthDAR+qxQGo/O4YrqCCeZGVp5repTR9VWNw rFms8WtBYYsV2nu34XiGj2iCHPmvBrCjPjWlkBYYvxr7DblAmqz92z3KDlmh4VFjXFNe LY9mE5DIfkK1lKllXPJv2QIjWXRKjWgrbwlJ839kNfygqoODFOk3uBmy6lGJpNKP9LD9 pLMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5Q1BQ0VLFWEKPJtS0uapXaG1GKkGrNRno7UHDk3Qfe4=; b=sAkSTqYEY5+fANpD29FJDadN7wZmXRO5TXWDZBIKoye5l4KTlFvOM/D57MrRXFtZF+ c8STiz5k2tJOdPksigxsU6BPcfQaU94GT1dEPbCzExU7/W0JR9qyqOkWm0aZFuV+aui5 NZcsxC55nGxIficdyddBDzYKDlxn3LRs1ZIRys5c0MDOk/uI2HGWbR/YApynmPfDrHxt IETVT29vSXZ3yfTwnoEtC48tkmyYOWqsHV4pT9xBIV3QNIIytSUMRRV8fsDIaT/Ck9ZV Owd/W+OTxpwJ+aZCKBV9ih1T/T9Clkj2/ptzVAXIU9C8IuLeA05xA7MWyz6YP0PVdJIH Kl+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RaruXftQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ne20si24418815ejc.429.2021.10.04.12.43.09; Mon, 04 Oct 2021 12:43:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RaruXftQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234885AbhJDNFQ (ORCPT + 99 others); Mon, 4 Oct 2021 09:05:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235025AbhJDNDi (ORCPT ); Mon, 4 Oct 2021 09:03:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AEA6060E0C; Mon, 4 Oct 2021 12:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352397; bh=1Ook0az1oK0+KVyFFdhJhRziO7F/Wuv81VPLFCDn7Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RaruXftQkadXOS3sD6o5+55878vcUC7GE8izEM62Di50g9o80zl3wS49bYhJNqAGF jTndKLyhPfnsay34MvWINQPv/SML0C6BK+ruSf1rp2tMXOCBgiqJpFTIF7aTuYzdnK YHKu2f6tOh+PkcBBJzIBrBcA7U6rONDsTZYN3nCI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Chen , Andrea Claudi , Julian Anastasov , Simon Horman , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.14 46/75] ipvs: check that ip_vs_conn_tab_bits is between 8 and 20 Date: Mon, 4 Oct 2021 14:52:21 +0200 Message-Id: <20211004125033.074210545@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125031.530773667@linuxfoundation.org> References: <20211004125031.530773667@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrea Claudi [ Upstream commit 69e73dbfda14fbfe748d3812da1244cce2928dcb ] 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 Signed-off-by: Andrea Claudi Acked-by: Julian Anastasov Acked-by: Simon Horman Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- 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 3d2ac71a83ec..620c865c230b 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -1406,6 +1406,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.33.0