From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (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 E4C902F6910 for ; Wed, 15 Apr 2026 18:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776276779; cv=none; b=C9FqTa4P5AiPSe9nfCPDo37luUmlzyAiyTOazKFMVm0AE7+G/dhoDJgSu+FWSi7IVC65ttDTa+2FxZ9xZyIuyOU/gUJGztG6k7ydjgM7qFL0d9zt6b7uk91nWmgQNRsZdfC71Y0ouB1k2EbhSHms6VlTzC0sc5maUL2Xkv0tg0I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776276779; c=relaxed/simple; bh=xuBugwAPRWxTp/rGLYw2T3rsOVKCDWNhWWPbUlOApb4=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=UZEU25KsDV8Z2eo2zwsCIJHvrE5uAs/0VWiq7SUNpBtavKAbNn9qbvR5VbVrCEMyTvQ3jZh0+zVXzzZqdHobZQ/FeGoKa6V9NRp8ua3Q/bWk6oQ0OpgX/xx6xhCnRl6fFK0HHkFmnBQKmD+3fueWQUYrmQa/jfnY9BnS9m4sWvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NO8LwNh2; arc=none smtp.client-ip=74.125.82.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NO8LwNh2" Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-12732165d1eso18203846c88.1 for ; Wed, 15 Apr 2026 11:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776276777; x=1776881577; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=IJGjylw6DdMpKyotHh1RaXqArO8pofJ71mbPiDBvte8=; b=NO8LwNh2ZsQFdsw04/zOkxa86S9TnRixiRC6wlen/1/gFVCsToQW5re+6BRkjL4vWn QoW434n7Ho+dmV0rQ0ygiBAkQA7BW3SObDK0bFKkd1kXQCqBtaysZmiIvgNd7LUIwyqf g7XlPPFuLPbIG0NSYlWMYcvIdBXVI8Xgp9cH967iIQPirueBpWTPgbXV04eZAMDM3b3F vGCVwwqcr39hBEE4Qby96hDdh2El5skcuJsUWvz2Gspi11w82vWEu5tyYPPROkRaKdOU 8wh5N2iE8qtSc+j5YRu6CYpCTq1tAFc0ZGMwL827s0GcGFqed5Ny3zl2/Dk5CQXC2kUG iPPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776276777; x=1776881577; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IJGjylw6DdMpKyotHh1RaXqArO8pofJ71mbPiDBvte8=; b=cWbRf+vFWoorrj/tMFuDH0ckqhpgQI2YYf86/ITvy+Ckn+T2JHSnFkvVcxJGn7ZZdb 334TbdGijCFGdlIXv+ZO9cyjOVAeCQ2VARhYuYRD5/tSRitFjt8zwzYo5vtMwjp+s8FZ /7S9guY4FidWHUpkPEIDkj9icpbSTNg0swr3tO4Z4UYUbUomgRT0R1YYhuXlKvSzSGQW BrOWSbdKnxWLU48NpJhnrMFOt+nKzGLx79A/tLdXlVZu9Cu83lQxgtHeXC3wSJsrw+/6 UcvRVs6tIIdDDewji/BIN2yIS0VGBpl/a/LC235eEgyDpr/MdeY6tap2aIfV6aojx4lA aIHw== X-Forwarded-Encrypted: i=1; AFNElJ+xc8Ps/Xy6dWduEU2Bojo9mHHSfgtPSFurJWWn0OGilfQGkBSZVRWHWbjjLfjdAxLjFNWEaCjKrAZebK8=@vger.kernel.org X-Gm-Message-State: AOJu0YxQc/98s2547Xw5PsLQ4crsG4CJ355gYvChswFqB4QFT4aiLXDZ z4mNyNBFuF8va4zSPVBQ7ASdRe+TuhXy/B8XAZzeuU9Yf76ev19SE2wX X-Gm-Gg: AeBDiev6k0+18sI8gJ7LzfjStdD4WKYPp53WZotb0fSuICO9mSLMUu5Xlwq0tOCOLTc bEIuN8lBrB+PBK1yiB8j92lz3AuORPRjrymJdT/hO90X+MvokRx0l6n7Bcsl+jVbsDcJ7rlfrXv cKSPdfeu0tGSid/bemJH+EmePO/j2peGLnfUroFbl7P5bKqVL7Q9b0nvG7Wdrv1bKg0QonRceMB sNQeYUdG+ooPG/Ru2WWKXW2/J7tvPN3e71VexVMEjdPLTFYZmF15djVNEkbUAI1zelRvBhqkUG8 qJw8Sozhrd1OvHQzpU025hWtEPJ+Wt06XODdVm4hemc3wxqgB9F0yXCkR3hpy/QzO3aKBgn/+M6 RyzNJqaCzL+W/o/r3Z0VwGpaxsN2nNopkrAvv3DO+wAmmdXnvv+QAfTrn0j6wRmucdC3V+eNfDx GiZatYajhLxWjHODN2PKagMMRBIMjIRdy/E6ZM5OJTsg6vk9/4WkfE7WzYZL6gcpxW6OM4g2uTg HkC2Q== X-Received: by 2002:a05:7022:790:b0:119:e56b:98b9 with SMTP id a92af1059eb24-12c34eeae15mr12703540c88.32.1776276776885; Wed, 15 Apr 2026 11:12:56 -0700 (PDT) Received: from ?IPv6:2a03:83e0:115c:1:21dc:2944:7f23:f4d7? ([2620:10d:c090:500::cdb0]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2de8c606925sm4601940eec.12.2026.04.15.11.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 11:12:56 -0700 (PDT) Message-ID: Subject: Re: [PATCH 1/2] bpf: deduce_bounds_64_from_32 tightening with circular range logic From: Eduard Zingerman To: Helen Koike , andrii@kernel.org, shung-hsi.yu@suse.com, yonghong.song@linux.dev, ast@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com Date: Wed, 15 Apr 2026 11:12:55 -0700 In-Reply-To: <20260410124035.297632-1-koike@igalia.com> References: <20260410124035.297632-1-koike@igalia.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-04-10 at 09:40 -0300, Helen Koike wrote: > Unify handling of signed and unsigned using circular range logic. >=20 > Signed and unsigned numbers follows the same order in bit > representation. We can think of it as a clock, were 12h is > 0x0000_0000 and 11h is 0xFFFF_FFFF, regardless of its sign. >=20 > Then, instead of dealing with max and min, we deal with a base and len, > where len =3D max - min. >=20 > Example: > range [-1, 3] is represented by base=3D0xFFFF_FFFF len=3D4 > since (u32)3 - (u32)-1 is 4. >=20 > And we can verify if a value v is in range if: > (u32)(v - base) <=3D len > which is true if v is signed -1 or v is unsigned 0xFFFF_FFFF. >=20 > This automatically handles the wrapping case, discarding the need to > check if it crosses the signed range or not and handle each case. >=20 > It also fixes the following current issues: > * [(u32)umin, (u32)umax] falling outside of [u32_min_value, u32_max_value= ] > * [(u32)umin, (u32)umax] falling in the gap [(u32)s32_max_value, (u32)s32= _min_value] >=20 > Fixes: c51d5ad6543c ("bpf: improve deduction of 64-bit bounds from 32-bit= bounds") > [Circular representation] > Suggested-by: Eduard Zingerman > Signed-off-by: Helen Koike >=20 > --- Acked-by: Eduard Zingerman [...]