From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 45A9E3D16EF for ; Wed, 17 Jun 2026 09:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781688986; cv=none; b=E3gIzdptKQmLGAArna734W640hQxTBkr4v/mtqmfx8DvkGu+TkFTfsoc3yV9pD4dKdFSsOcbyNiAtngPwSLnuj9yTpf/iGxtO2DpMn6eZGM94dWE0uc3w6OVcimq6l1KESUFZ/cT90R8VaU+seuPmBq33beADflzdLa6BkS2cXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781688986; c=relaxed/simple; bh=GWPzChxssxZOZZc16sSu79iLhuD8mO4BYO8UX0Bsfzk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QLJDDEmkN0uix5TFmILOnvj1kHwZgjiJ/P1yIifAo/4j5PztdzRnGHUlFPNjU6tawg65pIfumlw82Oy/WccUtZDM2aGdl9ePA9TO0D/Ppl9bfTB+s898Y6K4DxlbE3EfL5oHIec+TBeX3z7E+ghLcWnOKSNQvdzO8DL0U2u8bS4= 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=HQZXW6Qk; arc=none smtp.client-ip=209.85.210.170 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="HQZXW6Qk" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8422f395a4aso557890b3a.0 for ; Wed, 17 Jun 2026 02:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781688983; x=1782293783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Qntz5nm5yQBkXOVak+SMgSBWDeLqTSwFLoQFss37lnc=; b=HQZXW6QkEni9oUS2HrmMWKAVOqywvv4fc05+eN1VjACgPlPM+21udefw+vlzxwWadS JpZUeJH6GYNm2iI0ZxKZT8Z0H/mB6uYleZmNJZ8s1hubC5fQHkHFmXmJEqHA+5K7y0T1 1XGxrRkV3XgaZ79DJDUmieBoLzw1tqwjaoS7E/ALD3bQVDbSQBu1Sl8ssu63TM9qcEo1 H9NOJ6VUzNP4Vuz8E4QW35NnEkKpuJdK+aqLaUIIyXnElDYAR90r8DiONIf7cfVr63Yi tQVrgQa++6TJyEAzJg+LFh23XcTy0tkVFEvptdaI3g66v5bsudelKRFWcP0oYSW9LfvO YtDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781688983; x=1782293783; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Qntz5nm5yQBkXOVak+SMgSBWDeLqTSwFLoQFss37lnc=; b=Zirc1lHJG8KOLCpPotZTDE4ogPbAViTEOfi9jBqj0FVbzLS4+YC78Fn6StsEGU7FSP 0UccCF0UjfG9rC6g6oGaXgrZnXn4STgEfaOfokywhlAEYOAjyPR/S36+NpBokylK1/VL PT3CZmGMP+45UxEmWzAFFNlIqsdShZjD37r53Kuy8tityL9KRIVHXYZWIRmwkBXklYiP FwoVHezWVCpVGbZhjKVZevXygLUDAcER+5Y8FEJcKgMhDMY9rsPg8fQxmyxYj0HpNn+w 3zt+4jX1y8G5CQnx+WSdFTVJ5HPLF3SMNyEjcjxWLR7Cm7mKnWjv6ifnp2OkXVlL64jY JtGA== X-Forwarded-Encrypted: i=1; AFNElJ8W4AF8JPnLDfqKej5tnkhejn10RdyUFvT0ikI4156SjngIlFHwBiKibWg5bTS6kt/RlN5Uen/N9EqSRuw=@vger.kernel.org X-Gm-Message-State: AOJu0YxCKhvRnpBE/paSOGfT1e/9PBx3L8EIx9qoplRGtNcG8RT/wdfA eqFAoAqm95FaWFkRmcrY16dUt1HC38UouD1Nzumy14ObCtxgKtB5XOWL X-Gm-Gg: Acq92OE4qkdzTB2wwGTNV7p0+5rJnZ+k9iOfZmiB/HjE+0FCR8GhdhkKPgxqqhMfysV XHUhWFiuLkKSAHIvAy0WrsJEN9DLyjR8P586NPEAtteSDFOwK1m3EL1L7jF/OnIdMQ840rgrg9k +wCShIN/ufh2x0sIE8EO6aJdMspJoBiBEZxcezxZxwpGMfUR/Yk2D151ebBz7Y+w9yLtn26k6u1 VscsZpFTQleKHjx2BTLrOoYRHHB2Y/gKxrGiGxStuP5XmEcQeR8+euYHJP94rrzkPb55ketxsCB 4gHE3YTSdAahGpyipNLseaJA7ZROsSux4ViAA0h6KpQkA3dYz+ydnUEsPyc0jzVDLWitO4fGcMV BpoT+7WYN4FAx0A9nHUzf0wx2O3irdg5ZNGcG0hSHsuCC3I5MfIZivHpWJvc6i4droCEGPVFbHr 03PXJdKOtnelZASjKucDHBP+/o2d4F9s6/0d3QPLXGja9+JADpjQnE X-Received: by 2002:a05:6a00:a809:b0:837:735b:826f with SMTP id d2e1a72fcca58-84526b9c3cfmr2072767b3a.32.1781688983521; Wed, 17 Jun 2026 02:36:23 -0700 (PDT) Received: from localhost.localdomain ([2a12:a304:100::206b]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8434b0226acsm15521653b3a.48.2026.06.17.02.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 02:36:23 -0700 (PDT) From: Sun Jian To: bpf@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, memxor@gmail.com, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, toke@redhat.com, lorenzo@kernel.org, paul.chaignon@gmail.com, Sun Jian Subject: [PATCH bpf v3 0/2] Fix partial copy of non-linear test_run output Date: Wed, 17 Jun 2026 17:35:55 +0800 Message-ID: <20260617093557.63880-1-sun.jian.kdev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When BPF_PROG_TEST_RUN returns non-linear output and userspace provides a short data_out buffer, bpf_test_finish() can return -ENOSPC before copying the packet prefix or updating data_size_out. Fix this by deriving the linear copy length from the packet layout rather than from the already-clamped copy_size. Add selftest coverage for both non-linear skb and XDP frags paths. Changes in v3: * Keep the fix patch minimal by leaving the existing offset declaration unchanged. * Drop unnecessary memset() calls from the new selftests. * Keep the pass-through TC program and larger test packet for the skb case. pkt_v4 is too small once the short IPv4 input check is accounted for, and the existing packet-access program fails before reaching the partial copy-out path with such a short linear area. Changes in v2: * Fix the Fixes tag to point to the commit that introduced the shared non-linear copy-out logic. * Drop skb-specific wording from the fix commit. * Move the selftest from skb_load_bytes.c to prog_run_opts.c. * Add XDP frags coverage in addition to non-linear skb coverage. v2: https://lore.kernel.org/bpf/20260616093103.471444-1-sun.jian.kdev@gmail.com/ v1: https://lore.kernel.org/bpf/20260615073856.152479-1-sun.jian.kdev@gmail.com/ Tested with: ./test_progs -t prog_run_opts -v ./test_progs -t skb_load_bytes -v ./test_progs -t xdp_pull_data -v Sun Jian (2): bpf: Fix partial copy of non-linear test_run output selftests/bpf: Cover partial copy of non-linear test_run output net/bpf/test_run.c | 8 +-- .../selftests/bpf/prog_tests/prog_run_opts.c | 70 +++++++++++++++++++ .../selftests/bpf/progs/test_pkt_access.c | 12 ++++ 3 files changed, 84 insertions(+), 6 deletions(-) -- 2.43.0