Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3923528pxb; Mon, 4 Oct 2021 12:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3yGtcPZW/wkIydwcgiZ8zOK4nOHjTg+bMJmJbX0jYUB6SxTtSlr6S4Ql80nB5hNMCnpnn X-Received: by 2002:a17:906:4e4a:: with SMTP id g10mr261435ejw.524.1633376718583; Mon, 04 Oct 2021 12:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376718; cv=none; d=google.com; s=arc-20160816; b=U8gY3anpKcT9372bhpGbpuL0qGMuFyCEjSzL8NKklC9drOs7EPI7Amb8AZnX1+GGRR liT8XGmxd+UOKHFMm2YgyVop7qaPpnctOgXQLCNkeQihvwfbGWPv2rOM+3yx9RmWQvGN NJzXVs3bQ2Ihh85DLJ2+rcSqnjN82Pj5LnUPcFZUnhT2ne/QMVbIyuP9aisgHFdpWEP8 GVM9HL5FfLfx1cGbfNC3fAVQaEsDYspLuLsbEV55wnh3NVyif4dRIbqFBNFGems+s1XH 3i+aKhcB0CDx6GBfmVjOuFtntWkDK6kxEk38MXCzn3yc4fT9kgmN2TYf3fsTNhrWPieL 6Cng== 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=zr1eAJznbu/tEbdbfgkfj+NXCiz6EU6PWUHnjZJ7Wyo=; b=a6ESXmWc8+x2YlGs9MQvm2EI6ySjcXlqwhVEiWIjAsDo1zwfYBrxsOJlPA0/dmozzx VWGjmrz5guvkh4zYMGkPfJrotP6FuKQTRNnkDHBeboR0J46rD6ZpIFPLNgmjrveiuput 0J2E0lQODFXYjeeHJIFA5qOYBy5rY2uwDvC26+r7eukFxJRWJ4TdwyA/jsGtrJXzNYJ1 EC13ixl9lfkGOZCqKdktLkqsL0iXYsc8RLO9TdHLy7yuFcSon+kx9dRpkRb/EWipiLrn giWfL/IOhbWvd3RmCiiTMpVsOpdiPTbGra/TiKyyqDi1FXrAr+DVZVK2r/pVWLxoYtWI DaeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qMd5OaF7; 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 f25si958663ejz.15.2021.10.04.12.44.54; Mon, 04 Oct 2021 12:45:18 -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=qMd5OaF7; 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 S234238AbhJDNPh (ORCPT + 99 others); Mon, 4 Oct 2021 09:15:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:47394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236188AbhJDNNd (ORCPT ); Mon, 4 Oct 2021 09:13:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B064D61B74; Mon, 4 Oct 2021 13:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352719; bh=btchl0DR4ajugpku7C1Va3oggK8PguAEAjFscJpsi7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMd5OaF7a3qd0hPQYDh+cv6YGDUXNb7XG6plPWafGPXvvjrwI6PlmfxSyS6tPKb7X DiO/9jgdsZ8XUYGVc1uLo+s9nPyqGqT2ED550nmzSnSTTzb08q9bf5c5+0e0SJnoF5 8z0TjUOlZpifkOo6+H7pb8vfpGm8qHu0zD9Yc/V4= 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.19 62/95] ipvs: check that ip_vs_conn_tab_bits is between 8 and 20 Date: Mon, 4 Oct 2021 14:52:32 +0200 Message-Id: <20211004125035.599313418@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125033.572932188@linuxfoundation.org> References: <20211004125033.572932188@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 5b2b17867cb1..2780a847701e 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -1399,6 +1399,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