From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 301993A0E93 for ; Thu, 23 Jul 2026 17:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784829483; cv=none; b=CGKs/lOvSbs/zonZB+wdMN+W/kmcKrdRVl5KCCFAKN4qchrdEvEQ/IztsH/6zKG5E+SDqsoGZcQ1SNLoCA8WT66Ct+Z43c1SAlFbLgAhBQB1DmTiRXr0zmATlnK4eisXOgciU2i6eX3n7i46uif45+uuax8ytvvP10gZ95FwHcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784829483; c=relaxed/simple; bh=uhSaHoLoNEt+88qNE9tlgwbWDNke6X5OxSpVGKX1ccs=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=MN1pDOV89N20tTqtx9brHkBFejQqjyb7De7f/EDkx3T2+BsmpxcyAVqAM2jEd3ffhzxHBasAqKdUnBYn+0Mxs3JLQjEH99QA2eEbKZ7oTfHWVaqsxtvtebVHNwGXAilG3SPtXuvie1PrQQfZaYI7Xw4SZyenmsArJYyHeYe8Nc0= 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=JQfHPoeU; arc=none smtp.client-ip=209.85.216.50 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="JQfHPoeU" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-38d489b6b71so886160a91.0 for ; Thu, 23 Jul 2026 10:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784829480; x=1785434280; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=RyhZL1WSIhCm6HgTN87jBbUJ2Vt3tknSGNAZ68PW66g=; b=JQfHPoeUYOt2CFt7bVfp7u1IggAurZ4l0B5QdoN61uPUGCnc4FAb/KFPx7bbDqwiJt 6Ed/Pbx8okaIRMcjXiC6/Ue5YP2G1v8uM/BZo+dIilYK51ZTeT3NR8oxuIholwMpkpCs K/yHbpfJCWyHEm4Je21dlHT1zu1pImOK7vPv0F2Npr3q8jfHNljiZN2FC1gTa5/KIfk/ 1VCv8srYyfn5iI7momEDUq26Khqma6tmuPMb7NetH+vWxvSOFG1L5G8Ik2DI3Zw3xxMZ Eco9XsFtckkR1qt0e8CHnKknBejtsT4+VfI8RC7+X9oYOp3l0sMSvEfMaj3/dhW2odIy DZAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784829480; x=1785434280; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RyhZL1WSIhCm6HgTN87jBbUJ2Vt3tknSGNAZ68PW66g=; b=KFfYrVs/o90bTUXUjkQGl9oExW0yvGx5MdQGMthVQLVwhdlHM+6IYiuVj97IWU7ERT IRUTGg+Dmm425C4y98xIt9gp4A1gHj8he+VHIQ+3c0nDxiRbFZPKfCOeUBHhPeklZ0CL A99SK2EP5vPGMJPSypQaYdq+5Xol0IkWCe/juTK4l+6SksycwMx8WXxJZZc/fy6gxBII tOex7BoxQWFrwOm1iCXgY1HUt01kGLcK2I/UZrlMgPe3K3Pt9Fh6QFk5aJgWw0PDikbm IiH89ir2IAh94FSWjkEYIAPAQT0n9U3nRZ7aHTdp/vSpnlPYUXpQLYeJwEs/vJO42O2B R7eg== X-Forwarded-Encrypted: i=1; AHgh+RqU2OAHNoIYZyrdnBfeuv6IpAAqE10TiLvUxRKKDGM3vKW0rdNPyetHWSFqo098bx3+RIctwZFKElxS5B8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8OO2VBmo4y5yJ6HjfxxsMmp5lBq7pbAktr9wrU7uGPMCAtU1p cFSepkMRY52zviaskv1S6+I7Suqz8R23n7zHsXNsYWnB6yUyuQoug9g3 X-Gm-Gg: AR+sD12HrAD1OEUeNyPPkEoyICkXxnmavwwL6idg0lszsK88oYV3ZhLQ40FRw5LYaC6 EUWrFH/6ZLJ1g8NbJRJR2XSKnhGdDg5hSnlKD7XQf1ReK0TF34g6eiqHz/A8LYWHWIdsu3fpxRG OoZzXlXH3IYX2GEdcEEgvs92zxCMEJ/GStbf1+xtvc3oV8UPQz8amy3wRVnB3giesJjtTIqzC4c 4E1ezw744Z6EvIZloqN9pQ1HQSg1k6oW414vZODlUxbp4pTTNFHMDuP6M/ztkUeEB5fwmMte4aT boDCh/SsxJX6pGZTpTRjJ6IcvY4bwulDyNAeUe+Dv1xfzF/7A2fo2d9/tLofOG+8TZ/BmC71nxX 2suwp/gMux3OaKZRluxRdnhHUCiIv3yXBMKIbPchnYEtMsytjQlI3hCIBMZh1We1VTWpOinVDAO GWpvJDo5fKZcoSQeXRLkv/ia3GkXx2gGcjMswUUzEoRLDrfMFUm+k5/8qVBjc= X-Received: by 2002:a17:90a:c890:b0:38e:dc4:3fbb with SMTP id 98e67ed59e1d1-38ec68982femr3801803a91.43.1784829480429; Thu, 23 Jul 2026 10:58:00 -0700 (PDT) Received: from ?IPv6:2a03:83e0:115c:1:c221:d012:6e37:77f9? ([2620:10d:c090:500::2:8dac]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13d13014d27sm18568791c88.4.2026.07.23.10.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 10:57:59 -0700 (PDT) Message-ID: <22df73ce6c09065672d3a9406ae59c2cb264f96c.camel@gmail.com> Subject: Re: [PATCH bpf-next v3 1/3] bpf: Preserve pointer state for commuted arithmetic From: Eduard Zingerman To: Shung-Hsi Yu , Yiyang Chen Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Kumar Kartikeya Dwivedi , John Fastabend , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Shuah Khan , Emil Tsalapatis , Ihor Solodrai , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 23 Jul 2026 10:57:56 -0700 In-Reply-To: References: <004a83de52a36e9f3acd6c3fa2d0dfd0a013460d.1784696372.git.chenyy23@mails.tsinghua.edu.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.1 (3.60.1-1.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2026-07-23 at 10:35 -0700, Eduard Zingerman wrote: > On Thu, 2026-07-23 at 12:25 +0800, Shung-Hsi Yu wrote: >=20 > ... >=20 > > The sole purpose of having orig_off_reg seem to be for satisfying the > > 'off_reg =3D=3D dst_reg' conditional in sanitize_err(). If that's the c= ase, > > maybe it is better to change sanitize_err to accept an ptr_is_dst_reg > > argument too. > >=20 > > And given now that we are starting to make more use of scratch register > > states, it seems better to get rid the likes of 'off_reg =3D=3D dst_reg= ' all > > together, and simply have ptr_is_dst_reg passed down by > > adjust_scalar_min_max_vals(). > >=20 > >=20 > > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > > index 52be0a118cce..72d49f2a57a3 100644 > > --- a/kernel/bpf/verifier.c > > +++ b/kernel/bpf/verifier.c > > @@ -13505,13 +13505,13 @@ static int sanitize_ptr_alu(struct bpf_verifi= er_env *env, > > const struct bpf_reg_state *off_reg, > > struct bpf_reg_state *dst_reg, > > struct bpf_sanitize_info *info, > > - const bool commit_window) > > + const bool commit_window, > > + const bool ptr_is_dst_reg) >=20 > That's a bit invasive. I think the simplest thing to do is to drop > off_reg and dst_reg parameters from sanitize_err() and re-derive the > information about which one is a pointer. Scratch that, dst type is gone when sanitize_err() called.