From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f51.google.com (mail-yx1-f51.google.com [74.125.224.51]) (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 168092FFFBF for ; Thu, 4 Dec 2025 07:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764834421; cv=none; b=HMrza8rr0iL/EJusL0+p+GZEc5RJpAxORVe9m49aRHo4wN5zcGBeFnGFE72naX/LqHrkdiaGuSMrNkJbat4QsqNXQiiF8RzvbXWJfD2pctIIJECZB2arVY4ugiuoIcz7v4Nehs1YQJrtX0nBfOjIVZDvzL5kyBxWJr+XkX/DZUc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764834421; c=relaxed/simple; bh=80SRJuOgcTTOlotUZtwxNq10fJ7vLgfVquViWgwDO0w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D9zYylL+rTEpX55RczgFcTE8ZGCt/bPqf/V0m36FMdNwoKKe3HjqA6SvSxp5up0UE8OI+wx4QX7/i09HVeuAcnrjiMbk07khhIrRiWYO8icnQrSgtOHKsCFSxHpsIMz7ddzXEdu0yb7/HL36HzOS7sawBm45LRTNgUSiH2195Ec= 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=VYGpd9Gi; arc=none smtp.client-ip=74.125.224.51 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="VYGpd9Gi" Received: by mail-yx1-f51.google.com with SMTP id 956f58d0204a3-640e065991dso436356d50.3 for ; Wed, 03 Dec 2025 23:46:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764834418; x=1765439218; 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=64al5XjBckKJlAGYWOzuZ9pNtheivLV4ZpzNmU/B6No=; b=VYGpd9Gi9+XUN1o1QF1ftGMaiBlY7c8AWMnkdyCUt+KEXYy/h+27pTSr5l/VBQ9P9K BL4LQP2mxLgWUNAAtxZj2ad+cVfRCXs5aYOhBuoVcd9wIFPzJvt4DoikNjyFDjKwqq/u TBTtJKolDpVgyWgTXONv2CUme93uYgj1MArdB4nUAtwWG6vCyGgIEidQ+9wBRveKHxEd lTSjmX9vHn/zWdkCqUsZxyimK+6i1PIz9Xv3Sf0q8x58XPd13++e0gYtX1jZjGsKdGcN sPTGyK0QfroDBZhZm4gSG6BHL0h1wrpTTQKHuEKCAmNu13Osne2oplw1cXSA0fzIfDbI w/Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764834418; x=1765439218; 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=64al5XjBckKJlAGYWOzuZ9pNtheivLV4ZpzNmU/B6No=; b=Oge2lIkesFlEOSIe/MMGwTFqd27Hw6OejuyP8pM2FXy9LPK6+Z27tKWO+iEMLnONo0 NYG7byZ8OA446bRt0C83UXXsoS9ro1J0uey9+rxsAMTWDVeHfzWvj5XTiFLrOTFBwYxr 26/gKU1JIfXtoCGeP10x0zJ4TAGm8rguE7KevrLK3Fe5p2bko5J/MQSpIqHmkQeAbcGH imE6NPPkpEXYqHz4NUWyjq+5DQE1J8M2UMbEAUWsHIriFVNcHzjurAfrsA7wJbMsGv3H 0b0Y9z/trC99XFAYz1QSrOqn/C82vWIoXndkRJ8Zn5pNWyp0/IqEHEsKsxZX6c7EJIWB AJDA== X-Forwarded-Encrypted: i=1; AJvYcCUlINmXYJZv6P3Rf0lAcN1WyXJSUIIxpW7Q6X6jfIdpx3Q5CVmDnK2edRUpExDHDVhNlpM12U+v13Fg+Xo=@vger.kernel.org X-Gm-Message-State: AOJu0YyzGM8UNiMO9eJg3I26w3xHm5tx5bcYeDG+/8UPIRh/wQ7mjTeX kncpmmC9so+y6bxWjBRlIEFksAdl75/FkWybKkCUTdtcKe5Ty3TrpiPk X-Gm-Gg: ASbGncubKxJJhYRFwOnvbX5EIxF+XcQi7NAs8ghiaF1lGRYRGHo+jzwQHDycC4k/qFT J/aLmKkuO1way8Mm1i/Do9XQN23nFkNpXx6Yu2v1jIhCCZo4A3zfBGpAao8cL9vUyJoaPLPTM9D DLikhu1AiYE4G1OIVRjhykYrQsf9J+SzsxKTp3Gnue4PZCnDATYy5ufojXBXB4hx6q635AoNQI2 Xz4wlkX+exgzbrJxMm6+zdkrcR77dmHOJKJ5sTk0zgj39LXC8usuOCHT4Io4C7YGvEIBOU5QAyr OnGmVVzTiDW6EFz8fjFU9JHQmAmEC8wuf2nkZoQmX3DSzGocwBt9PGR/zcWGgtQ5clYd/B8Xd8w h4Qm3kP5sH2xCZ1YPOqvHCBIrhDa9NeHigiid5GmcHtaGmSSwGgMhqWob8jvjfJWS2YPPyHVzl9 r9J3Wyoxpes309L5B4ojDVZR2VvsTZ2d1gooGanm7ValNzeiTeB6Y= X-Google-Smtp-Source: AGHT+IH9QdNew3zKd3MAg8XQ76QMKfr9y+L0i90gdPpGFMiV8Q8w/KZTKg3m0AoyZ7lPvAh4HwpkBg== X-Received: by 2002:a05:690e:4101:b0:641:f5bc:6981 with SMTP id 956f58d0204a3-6443704bc86mr3412127d50.77.1764834417911; Wed, 03 Dec 2025 23:46:57 -0800 (PST) Received: from localhost.localdomain (45.62.117.175.16clouds.com. [45.62.117.175]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6443f5bcbbesm364495d50.23.2025.12.03.23.46.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Dec 2025 23:46:57 -0800 (PST) From: Shuran Liu To: song@kernel.org, mattbobrowski@google.com, bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, dxu@dxuuu.xyz, linux-kselftest@vger.kernel.org, shuah@kernel.org, electronlsr@gmail.com Subject: [PATCH bpf v4 0/2] bpf: fix bpf_d_path() helper prototype Date: Thu, 4 Dec 2025 15:46:30 +0800 Message-ID: <20251204074632.8562-1-electronlsr@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, This series fixes a verifier issue with bpf_d_path() and adds a regression test to cover its use within a hook function. Patch 1 updates the bpf_d_path() helper prototype so that the second argument is marked as MEM_WRITE. This makes it explicit to the verifier that the helper writes into the provided buffer. Patch 2 extends the existing d_path selftest to cover incorrect verifier assumptions caused by an incorrect function prototype. The test program calls bpf_d_path() and checks if the first character of the path is '/'. It ensures the verifier does not assume the buffer remains unwritten. Changelog ========= v4: - Use the fallocate hook instead of an LSM hook to simplify the selftest, as suggested by Matt and Alexei. - Add a utility function in test_d_path.c to load the BPF program, improving code reuse. v3: - Switch the pathname prefix loop to use bpf_for() instead of #pragma unroll, as suggested by Matt. - Remove /tmp/bpf_d_path_test in the test cleanup path. - Add the missing Reviewed-by tags. v2: - Merge the new test into the existing d_path selftest rather than creating new files. - Add PID filtering in the LSM program to avoid nondeterministic failures due to unrelated processes triggering bprm_check_security. - Synchronize child execution using a pipe to ensure deterministic updates to the PID. Thanks for your time and reviews. Shuran Liu (2): bpf: mark bpf_d_path() buffer as writeable selftests/bpf: add regression test for bpf_d_path() kernel/trace/bpf_trace.c | 2 +- .../testing/selftests/bpf/prog_tests/d_path.c | 90 +++++++++++++++---- .../testing/selftests/bpf/progs/test_d_path.c | 23 +++++ 3 files changed, 96 insertions(+), 19 deletions(-) -- 2.52.0