Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3786103pxb; Mon, 4 Oct 2021 09:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiHAm7kxXDFASBsW5Kh9FEpxP07BrZpQkJYTGxCXHZB/RM5hm/XV2fhEFjdTCKkk3RMvWD X-Received: by 2002:aa7:df89:: with SMTP id b9mr15709434edy.137.1633365200235; Mon, 04 Oct 2021 09:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633365200; cv=none; d=google.com; s=arc-20160816; b=yV/IS4TK5kOniH/x1yMUqxSNgLubJN2+pWV5p4uQVBHfnFmu0Kf+m5205sRwJnNwvg JS8LVmJKH3QW4Z3fdd+KDsrCBNfN1SkBM0XATgRcHp5RK4AUh3zwW0Rl/zkPxcveR0vk sbgvNQIjiT2uaDPJ3Wiawyz2lgfh2nxk92i6SJCWfLPGvrOd1jQE1gFM4Cw1W2JNnNY4 In8aQuNzzLUUJkxisxipSN0vdlmlfI+dveRUlStV2gpGooyZQAekcqF9iBFgKqgvgff3 tX2wurG9fHtC+4JKYkDYCAPNjGylLVVJ5uf/Kf7YRePAfwEYA1Y+JBzldW4WJPGE1KRl 2fjg== 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=JljUPQwRM0F0aOti8X5Rwvkp3ILebS1xIz/OVe++0TU=; b=CJR+uZSrNuWRbP0/+Ase3j7G01iOdX074I/fryLvEbznqCNwat7bavimne2t/B6xAK xKe5cBSx9veRkojUaEOvpFFlE+IwgOMFWIU3YjXHTMZlczwJwwmUXRUmFe+GgLL6hFMS azJAKM855Wi5gg7SR9oElcNF4paBuqmvoQVDEY3yucc1AsqQ+UmgvOiti52YW8Sn5kKZ iCXxMpfDN0glgO07jZCmkl30syKMAJsBxjidn/pe1p5vgYo4L1FCz/hWgvsuUPQvH8v2 ccbSNwWZzLXWFHn0CeJsarKljuT9lQm6lxOqs/c9PNYZutlbmhS3rY1xEv9+ncZ12h5l /ETQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BmIvYuI/"; 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 p14si10113091ejr.349.2021.10.04.09.32.38; Mon, 04 Oct 2021 09:33:20 -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="BmIvYuI/"; 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 S237917AbhJDNfo (ORCPT + 99 others); Mon, 4 Oct 2021 09:35:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237863AbhJDNdP (ORCPT ); Mon, 4 Oct 2021 09:33:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5694063229; Mon, 4 Oct 2021 13:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353304; bh=6Fx4jLoQmEwtdDz/vk3Y9llijFeQHQ06JFzmRm6Y6OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmIvYuI/AGrwturBi/7wklH1/KoDQRUMPksq+58ae8UJ667gqaKlzmGUPB/SoU14o YHjuaCKR/v6VbH3YrYCgavWTXkjU2O2LC1cqhjxZsaoT4xk0+3Xy64Sb6Scj3CAYTw +hBJBIXdsgqezNqadRS0m6f0wj3ix+sYT6mjhOxI= 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 5.14 076/172] ipvs: check that ip_vs_conn_tab_bits is between 8 and 20 Date: Mon, 4 Oct 2021 14:52:06 +0200 Message-Id: <20211004125047.453936422@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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 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.33.0