From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (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 41E3F3B3894 for ; Fri, 10 Jul 2026 07:25:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.171 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783668352; cv=pass; b=eS31YUCXFeMDk73cZs87ImzNH3Z+QJTwffNqOzGXzxWzQukOXzNJtgzg8QYVMUYt6dW+RHwJuXHKRJRO9QMhiJKgY4H9TzQzokLk+Akt8dOMvy6+7MdGbLi8yyt1E9A/q2w8XzEsZw2UpLXGbtrPMOjsW9OElgCEJ2G3H2o2nAM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783668352; c=relaxed/simple; bh=mh9wE6hVtejwpqaCnWH4G3lR/r6ymmL6RvQu7O86Nl4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fUvhf8jFakMrds7bvgikrvopO0A/xnmByoe/j2OGMqac8LJSo2peSETB6Gz8hrrDUr2Nu2+CUdFtTHQazgl6S+Tr/umhH16irq7lXlOiGb7y+34yiocBcUZQJ3syxgFnto/MrVmtSM/Sa8+kaeIgBxxWyd+kT0v+HxanNzWKzFY= ARC-Authentication-Results:i=2; 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=YBik+sEs; arc=pass smtp.client-ip=209.85.128.171 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="YBik+sEs" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-7dbcb505578so6641567b3.3 for ; Fri, 10 Jul 2026 00:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783668350; cv=none; d=google.com; s=arc-20260327; b=Ql3FtvshH4KPU41uvsf50Bx5Li461n3VaS88C3c4LjL8QOSbMO7KeylUt30/EUZh0m POAyVnhjr1D8982qcX+rBmTYvJwsuC/TONfqTvY09qgIDU8v5d9pYygGqvz6YDcK7sqa GycejqqSXPP1TbfzLIXLkBRWZAf0ssFQG6q0SFo3FVQz1KSQJuxgXfcKxxc8f0VgxGLu udeLHGj/bMPPR6Tn1ye6miMcIu/SaqayocoLJL00f+Xz2/NbpQ9oPYlqo7c7qPjGSSrW A2heXC/6Bx5TTVRgEu11KWKdSzT6H+12LyQkf2k2q1SDz63wFfRWhKC/9mIThK64wdqf GNmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mh9wE6hVtejwpqaCnWH4G3lR/r6ymmL6RvQu7O86Nl4=; fh=mT4+B6Zb0T+2VjKC8zqXWSwuAeYiPYoNHajqNJBoJO8=; b=gSdxfjkTJh8c1bDIr8kkS7oO5muHq0Nq/8A2ZW5l1k/qowzkjKLc8G2Pw/162DzUGk q/S1xbsO7pPz0OD0DhjkZlcF7AGi1FNLyF4WQciKMGoB2rCIorVkAGGUOATEgchoyaiI /1TA9JJ3rWFJh+1qyLFgNoim6K6b1/oPB7QcOrrNlvHd6yV3mcL3uD0Dv3HS0X68fAya bY4LIai1p3l0TvLZTB5BiH9QDRvcq/Inx9WBbok39HtRQHWIlrxJ5yRjLlSmr0jXQkBk FzVsMYHeUJ5aBWFJwSlmL+h9q0SFRQQPE01kMjU+YQEpiNHhBOboy+x+RSFSwlCaDTas ZJBA==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783668350; x=1784273150; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=mh9wE6hVtejwpqaCnWH4G3lR/r6ymmL6RvQu7O86Nl4=; b=YBik+sEsrE3WCU+KxB991u6zQ72Ve6Fdhzdj0CsaZBArzOQfDRclZo3wYYRE8NyAmD pMFP5wxMO38WJaI+XeVlta3Wj0axrJ97Rq02PXGobb2Rp6qNY/pJZQtNg++JaqiUZE0y 7lerNZCc/aDCDfntKC3xLOeEFojhfBscH9+5c2RhAD+QN/Ba9LgblK8sQx0AL9AMqoQ7 g2xEc8jnr4tbrsDvMG4ns2Qw3l0io2xZ4AZQgZ/xRRIgXvRXrz2jHA9EE1i2UdhbXWVS arQIsZhmwOYEnCOuvWXF00xcXcFbI0+3q+/F9GtN2MqwqbsTKZ7xrU1j2sY/jNb4ggvK Muxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783668350; x=1784273150; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mh9wE6hVtejwpqaCnWH4G3lR/r6ymmL6RvQu7O86Nl4=; b=D/ysCSXCUV96HlBYhohlxI7F0T7fQl/jnJXjK0mXRDe37Hj/kDXhsTRL4zLSMn5yRd qYMgw9aQ+pV3MFLUEc2Y4+BJfgx9XtzslQJHl13YX7TxV+1nKgxfjofp6yM0sPlChBCe VF80E6M31pwbg5QlJkC6a2tYN34niF/ga5ti/F6uvVO3IbcAGP0c7mRhZoV3W0zc7L3O 9sXGRSh7JLF2kmO0+m5K0gnU7NmGzTr2T25FrsI6EYzDTZQE/+vxO9GwPYnkvICvTYx1 m/0lUAS1D4ruR1LMlkFsDSmM+xzmuuFkeVxJ/d+nMr0bmqySo7itgncXW0cqktqaEEme 8aKw== X-Forwarded-Encrypted: i=1; AHgh+RpvtFgsZQW/TVx49vPrtSOlAMiJBtuoGcj60VmwXvTpd/6v9HzVPjRPPk4GSgsxupIdtwnfLX8AORorsA4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2uJAZuP5udmAm8r6+sH+o7knb0K4DT7EY8Rj9at7lmNNyfX7b hf8MkK+mL+dtHhXKws3CQm8uvUSnCL0436y3sJzPCPL5pvQExh26V4cTPzkTruMkkv/htz4Jj7P Uixfm645cO+EGOBrmyn2BPD6qPxRmRfM= X-Gm-Gg: AfdE7clereWNmy9ggbp7YfgTbL/wN9Ox0uqgZ0iQGtWCzejBbpqN8wSZ6w6wyY0lxLh oKX4GKIKw7j9yNRCBpqy5++5qYAd1un8Gll7sSY1YjZISaSRcETlzQJNTn+9y2jQXQJcgh/UQWh FWYcLVyuSha3VtvIt3UVN5ZRdG0pKXzuny+emH2By7/MBpTuXMLQrF2BOrFXyzckBlsCaZQR45S F9IIAF34w88woqykyuVbK6/QqEd1rOqgakyAz2t9faMJ0EiH8x9SjgSvQyXrHlPKrVh73LlIZCr 5uEw1puOQrcSQTbWt56Tm7IYxG75iVLHcy0U+d4x X-Received: by 2002:a05:690c:650e:b0:81e:7034:2ec7 with SMTP id 00721157ae682-81e70343a1bmr37581077b3.50.1783668350063; Fri, 10 Jul 2026 00:25:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260708090151.151729-1-sun.jian.kdev@gmail.com> <20260708090151.151729-2-sun.jian.kdev@gmail.com> <1f8aad47f61fbf85eb55276e4bb01bfcff61393e.camel@gmail.com> <4349d987d34f9426bdbb09a5d02de61da8f3e746.camel@gmail.com> In-Reply-To: <4349d987d34f9426bdbb09a5d02de61da8f3e746.camel@gmail.com> From: sun jian Date: Fri, 10 Jul 2026 15:25:38 +0800 X-Gm-Features: AVVi8CdDId0qAQuJjxIMlDaRDt9TMr1o0P2SW2pz0fSqjQyJjET2634wzxh5uAc Message-ID: Subject: Re: [PATCH bpf v4 1/2] bpf: Reject negative const offsets for buffer pointers To: Eduard Zingerman Cc: Shung-Hsi Yu , bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, andrii@kernel.org, memxor@gmail.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, shuah@kernel.org, mmullins@fb.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jul 10, 2026 at 2:23=E2=80=AFPM Eduard Zingerman wrote: > > On Fri, 2026-07-10 at 13:52 +0800, sun jian wrote: > > [...] > > > There is an observable effect on the target bpf base. I tested it with = a > > temporary raw_tp writable test_run reproducer, not part of the series. = It > > attaches a raw_tp writable program to bpf_test_finish and triggers it > > through BPF_PROG_TEST_RUN. The program does: > > > > r6 =3D *(u64 *)(r1 + 0) > > r6 +=3D -8 > > *(u64 *)(r6 + 0) =3D 0 > > > > With KASAN enabled and the BPF JIT disabled, on the bpf base without th= e > > verifier fix, the program loads, attaches, executes, and KASAN reports: > > Could you please identify why the behaviour differs between bpf and bpf-n= ext? I checked the current bpf-next, but I could not reproduce the difference. Both the public cgit page and my local bpf-next/master and bpf-next/for-nex= t point to: a4553044d1af ("Merge branch 'bpf-bound-rdonly-rdwr_buf_size-kfunc-return-si= ze'") I tested that tree with only the selftest patch applied. The staged diff only contains: tools/testing/selftests/bpf/prog_tests/raw_tp_writable_reject_nbd_invalid.c tools/testing/selftests/bpf/progs/verifier_raw_tp_writable.c The negative const-offset case is still accepted at load time: #637/2 verifier_raw_tp_writable/raw_tracepoint_writable: reject negative const offset:FAIL run_subtest:FAIL:unexpected_load_success unexpected success: 0 and the verifier log only shows: processed 4 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 The current __check_buffer_access() in that tree still only rejects a negative instruction offset and a non-constant var_off. It does not check the folded effective offset, so this case still has off=3D0 and var_off=3D-= 8 and is accepted. So, at least on a4553044d1af, I do not see bpf-next rejecting this case. If you have a bpf-next commit or verifier log where this case is rejected, I'd be glad to take a look and reconcile; I may well be missing something in my setup. Thanks, Sun Jian > > [...]