From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 695E84734D4 for ; Thu, 23 Jul 2026 17:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784828130; cv=none; b=R5FHBK+iyBGlu9KY/CllWknJ75aRfMYeVwY0MdDe/0To4ybttGAGvPFf9m8me1vKUYLZeVwO8oi2S1opq2eMHE97RNn7iWAvRBsTZet8NBu0Cv678iyEH3JpUIYcUJYQozh05HbLWeIF5t6DUcsTJH/3clmfquUPOc8C5bqmvuQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784828130; c=relaxed/simple; bh=SQ7DJ0PfgPG+lfGBSOJGXKcBKPHLY+ziIZ5lLkxF/RM=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=ns0NR67UdvR/z6wIUC0jURPYthNahVgqkICrJXaGDyV7tR7fnR37Ewf4uZmwr0ax1NSr0W21tXMMJC0rAFNlGZNKT7N+xRguGHz4SRqah9cIN+ErxnparctcyiocML4UdXfQqo6RluNGmqa5hYSmO8MWNb2DPU0soAMmC2y+lF8= 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=H7GhoN32; arc=none smtp.client-ip=209.85.214.179 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="H7GhoN32" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2caced6038eso9961995ad.0 for ; Thu, 23 Jul 2026 10:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784828129; x=1785432929; 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=3+C2/eQx85hIDTRoY5V0ZRlv5zniHV47faqIMelZ0cg=; b=H7GhoN32KR/vp95vgwYtVkssJ7SlB3JRz3Zot3Hc/5hOmQ+9cIUQGfLhhqw6GCV8o7 UkvKSLG5a576ThIKc187pvJIkMsMwsKDQz7cCFBcTb9EuO1tG+/TIgBlC8KncTSVdQC+ O/vIECUTCYhVH0nmI8ZypbHImZpGCNEXKy2fVfSkzWK4BU29qYElgzH1bT+DT70B7WdZ 1n+zjZnIJsaP0I8InwKNbKWdXISV7w08vLbkWnZb3vcRhXsDD7nt66JSZNMtb+2fVp6F 2XTCNnt82SeOjft2Ef78yYr1VoNIwHBF1oZXzDUtSFVUObLo0dzBFOIPzZkjHMCzz+my 01zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784828129; x=1785432929; 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=3+C2/eQx85hIDTRoY5V0ZRlv5zniHV47faqIMelZ0cg=; b=K/VfQy+u981W+klLDRaTHfB4Imx8M7NJ1dJkMQnolliRQ0HxVJQ4SFFXDofR7uM0nj u4h71J0z2OCn8HcJc55MtxAICIMVhCGt7XqDE80osZ+UWfFPNRi8zJp22k40NHJ/0/x+ aH46khyNJK3h1oZ5uDVo3bVnx+8XOjS4WoGre7bV6ArWuIIuWyIQutII7XyFp8Tr2L88 JrOMhtC6qhNme/HPSbl//M4iJAm218hbpqKuH/ewec32sP71I4sz7t0/fE1GYC9tC2Ln iv2nI0pIjIVOZVLO6T5icVCTHZaDMhScoB5ZnWyAhzQerSfrSECSEsR+ZHFwnB+x8siO zQsw== X-Forwarded-Encrypted: i=1; AHgh+Ro0Thsoc+5Z4zJi0+ZSdnsvp4To/zvEqQUV3FxYQkMeYyG801RXVHKisevA9qmCpJiX8WlQD1prLTujj/Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5SW0zPDkViCW9fUzJtQE8n+85OQR/5Am4V04ZF9O7n8PiJ9w5 GCAi5d4+2CZud7KHTPZxSkwj5OzWaw4icHgUe5tWC8btPrQ6Om549bzv X-Gm-Gg: AR+sD10l7Frh7rUMNgIFf8atYNQEm0Lh1xCyiwXD4PmCze8FbnzdTsp9qNf/8p5y6e8 LktPNi7MM2ADR14WH3bhsOcNoCUrmAWN/BzNYadh6zqUtohqk3KtftkzzsbobDNi0Cs4gI2aRBa 2iLaoqAHkXNnsjkjYrqTSHg2LjlNUsysFq6bfR2RSF4ENfAhFHKdhb/36MZz0aGzI5dZ8DFgQox poMN26JTdIWkDSNyvUZUaEU3Im+X0tzyezyOe6dekGZVybTcnwm4berY8oesO9OVigqbCbfgTxT szrx4SGxCc+psI0sJymEzXtG6Y+Obw0bUA3FYmPqJrLhHud52scblTZPmIPAGsHNcK/3AZAxGek tP5QWjaDUlq/Hnp5nhnmO4zIoMVxVNt9O7egSSzs2LFuJWQ0bv2ISSTKiweeQA5Rx4Qmx+zHZgO ypaODe7MSLegBYiNeYig1uFHd1u6RRCj5OmIpRQJ7qiJERuugPBJgbbFE19P0= X-Received: by 2002:a17:903:1c1:b0:2cf:18e5:1d18 with SMTP id d9443c01a7336-2cfa958568amr41353275ad.29.1784828128485; Thu, 23 Jul 2026 10:35:28 -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 5a478bee46e88-3147e1bc886sm21822514eec.26.2026.07.23.10.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 10:35:27 -0700 (PDT) Message-ID: 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:35:25 -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 12:25 +0800, Shung-Hsi Yu wrote: ... > 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 cas= e, > 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_verifier= _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) 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. ...