From nobody Sun Dec 14 13:41:10 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9E91D9665 for ; Wed, 11 Dec 2024 15:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733932620; cv=none; b=jgqMlcEqNOqEZi5KDEjG/Ixcy/u/MLUlt9Mbz4dENILpAWLWC00lkZMbcrftgOD3uiupwaWmRS4bYV+2nnsCV4X9Q4egacpXtjytnzGwuGwUZJTWhVjw1TeuAXRRVMSlzKQrVyaPFS777gwZuvHzA6v3Ye6U93RFClXkHCIh+v8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733932620; c=relaxed/simple; bh=Rv+K7hKMlEcxfuBPqiseeoq83C5g31oqxKPW9FfS0H8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=Q8sk4SET8/6IKYFCshIEficqBuykfxkL0ZDaE31xS8Uf/FJQZLDWfwqysw/dY6yH0KyBobpxhu1Q3ICEO0GzR8/QETf4MgCLlSvXvy1ZKE7r4V/U/MagKNQdPzB8XkOQhfrx2dlTSaVjyAjFeHnhY23k0Aw4km2hFzmkvl3oAnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cVqfmndc; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cVqfmndc" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-436202dd730so4284845e9.2 for ; Wed, 11 Dec 2024 07:56:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733932617; x=1734537417; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=nkg3+gqCHZyZ6Sl2qTzJB3+MN185d7FZdzLmb7C7pz0=; b=cVqfmndcU8ORqb/WAs3hyt8lTr4dUf+4XymZz6uPD/WxWt8yHla3SV8YlD0CU6a4Gy 3TpqlHJOfkOj4V3RMYw1FKEtzg1zGBg14Ii7subePb5KL3GWfBuCNVaIOzkJ0ge9xh6a 6yEV9b6z9jRLIEzdSQFx56dn/7bq5KAGWechEwBvG7MW9yPpwhfjdUrcZTE+KWYrg1W0 VY4fHsKfaw89qhDLaXDa3vkCvrkaIXF5DGLvRTtTAqspKxZz/feNwrfL76YlmX84WepO kFi1NUhB6srZ/IuzW+ObeXZ+EGgjerXDDcTEn2DcObGEY1miOIFJ9G6fuuAE183gQ0ry Hz0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733932617; x=1734537417; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nkg3+gqCHZyZ6Sl2qTzJB3+MN185d7FZdzLmb7C7pz0=; b=cFXGJNzbeuRjZtCU0lJZi3mz40EO8AoVJOZL/I1LGrLP707emHgQQhyDchiGkhH+IY XbhAPERsQp0t1p5gnlnP0plpcqmeomI1uzw+cOQxxgBEzJK011eLIV3MLSu4Fxztnwzl /2SzK3Xj8SHnNjzjQPNp9szxmMh3ivu5iPq5kOMg/Cd/C8rt9PBvYHkDC8IJ7yBtBcca hyl42sdEctLLo5OPYrJCEOojBkJxSfO2Qa67kuav5oV5OzeKUJhxdpSXa4yohn1YkCKF haQFYf0sR9aQxtTUW5LZWDT+bgfWorhyZUjwVM8gc5M0p7t2zxjXkfEKHI+OjDosFr1R NFmg== X-Forwarded-Encrypted: i=1; AJvYcCXUAGNLS1qbSxslN+ZxXgrwrOAAYnsgHXJUfS7QB+jukMtaAeNw/BiR3zwCkM0Q8rT1Lo3A0h/YR+cNEvE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+Szs3FsH6r57WLlyzMCqthb462HteHxBi3oPxSXChhmHok62R SwU11WInNog8s96CK6x8DW8TbRVWzJjQZMcsbMaaoGa2qtbni8M6+H6cP49ovuk= X-Gm-Gg: ASbGnctHWCa8h5HJ8udSs8RII+mmuEhL08I3GLndMfrXx7nB9e9/7UxMYXkFmqKcEhd Um49kx4rlXCih3hbyhHT6k8MhdyhBDyExVziQLu0qdnXGp303gu0HwojGe6UjFUkx1UJFiUK6bP 64PVttdeZGX2mC5LoI33yKtER3f5BymrNqghdJ92qDiOdNDc7rPv0Bp1DXPUp4uL6bLNz8U0QtM 2RS7rEFG+YE43s00XySEmXcN1q0PMVvx6hm9ITLdEaADrkmDma6AAr7wkA= X-Google-Smtp-Source: AGHT+IHswNBtDtvurvta3UIe1snbeW4EpMGUksBi4IExyjMEcI6lUxkxBWzCbW9NdBKAwxVrirF4eA== X-Received: by 2002:a05:600c:3541:b0:431:93dd:8e77 with SMTP id 5b1f17b1804b1-4362286bc7bmr2392765e9.31.1733932616850; Wed, 11 Dec 2024 07:56:56 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38782514ec8sm1598464f8f.75.2024.12.11.07.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 07:56:56 -0800 (PST) Date: Wed, 11 Dec 2024 18:56:53 +0300 From: Dan Carpenter To: Julian Anastasov Cc: Simon Horman , Pablo Neira Ayuso , Jozsef Kadlecsik , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , David Laight Subject: [PATCH v2 net] ipvs: Fix clamp() order in ip_vs_conn_init() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We recently added some build time asserts to detect incorrect calls to clamp and it detected this bug which breaks the build. The variable in this clamp is "max_avail" and it should be the first argument. The code currently is the equivalent to max =3D min(max_avail, max). There probably aren't very many systems out there where we actually can hit the minimum value so this doesn't affect runtime for most people. Reported-by: Linux Kernel Functional Testing Closes: https://lore.kernel.org/all/CA+G9fYsT34UkGFKxus63H6UVpYi5GRZkezT9MR= LfAbM3f6ke0g@mail.gmail.com/ Suggested-by: David Laight Fixes: 4f325e26277b ("ipvs: dynamically limit the connection hash table") Signed-off-by: Dan Carpenter Tested-by: Bartosz Golaszewski Reviewed-by: Bartosz Golaszewski --- v2: In the commit message, I said max() but it should have been min(). I added a note that this bug probably doesn't affect too many people in real life. I also added David Laight as a Suggested-by because he did all the work root causing this bug and he already sent a similar patch last week. Added Bartosz's tested by tags. net/netfilter/ipvs/ip_vs_conn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_con= n.c index 98d7dbe3d787..9f75ac801301 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -1495,7 +1495,7 @@ int __init ip_vs_conn_init(void) max_avail -=3D 2; /* ~4 in hash row */ max_avail -=3D 1; /* IPVS up to 1/2 of mem */ max_avail -=3D order_base_2(sizeof(struct ip_vs_conn)); - max =3D clamp(max, min, max_avail); + max =3D clamp(max_avail, min, max); ip_vs_conn_tab_bits =3D clamp_val(ip_vs_conn_tab_bits, min, max); ip_vs_conn_tab_size =3D 1 << ip_vs_conn_tab_bits; ip_vs_conn_tab_mask =3D ip_vs_conn_tab_size - 1; --=20 2.45.2