Introduce test 'test_proc_pid_mem' to address the issue in the TODO.
Check if VMsize is 0 to determine whether the process has been unmapped.
The child process cannot signal the parent that it has unmapped itself,
as it no longer exists. This includes unmapping the text segment,
preventing the child from proceeding to the next instruction.
Signed-off-by: Siddharth Menon <simeddon(a)gmail.com>
---
v1->v2: Removed redundant parenthesis, fixed other checkpatch warnings.
Revised commit message based on feedback.
tools/testing/selftests/proc/proc-empty-vm.c | 56 +++++++++++++++++---
1 file changed, 50 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/proc/proc-empty-vm.c b/tools/testing/selftests/proc/proc-empty-vm.c
index b3f898aab4ab..bfb7f8823529 100644
--- a/tools/testing/selftests/proc/proc-empty-vm.c
+++ b/tools/testing/selftests/proc/proc-empty-vm.c
@@ -213,6 +213,53 @@ static void vsyscall(void)
}
#endif
+static int test_proc_pid_mem(pid_t pid)
+{
+ char buf[4096];
+ char *line;
+ int vm_size = -1;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/status", pid);
+ int fd = open(buf, O_RDONLY);
+
+ if (fd == -1) {
+ if (errno == ENOENT)
+ /* Process does not exist */
+ return EXIT_SUCCESS;
+
+ perror("open /proc/[pid]/status");
+ return EXIT_FAILURE;
+ }
+
+ ssize_t rv = read(fd, buf, sizeof(buf) - 1);
+
+ if (rv == -1) {
+ perror("read");
+ close(fd);
+ return EXIT_FAILURE;
+ }
+ buf[rv] = '\0';
+
+ line = strtok(buf, "\n");
+ while (line != NULL) {
+ /* Check for VmSize */
+ if (strncmp(line, "VmSize:", 7) == 0) {
+ if (sscanf(line, "VmSize: %d", &vm_size) == 1)
+ break;
+ perror("Failed to parse VmSize.\n");
+ }
+ line = strtok(NULL, "\n");
+ }
+
+ close(fd);
+
+ /* Check if VmSize is 0 */
+ if (vm_size == 0)
+ return EXIT_SUCCESS;
+
+ return EXIT_FAILURE;
+}
+
static int test_proc_pid_maps(pid_t pid)
{
char buf[4096];
@@ -500,14 +547,11 @@ int main(void)
#endif
return EXIT_FAILURE;
} else {
- /*
- * TODO find reliable way to signal parent that munmap(2) completed.
- * Child can't do it directly because it effectively doesn't exist
- * anymore. Looking at child's VM files isn't 100% reliable either:
- * due to a bug they may not become empty or empty-like.
- */
sleep(1);
+ if (rv == EXIT_SUCCESS)
+ rv = test_proc_pid_mem(pid);
+
if (rv == EXIT_SUCCESS) {
rv = test_proc_pid_maps(pid);
}
--
2.39.5
In this series from Geliang, modifying MPTCP BPF selftests, we have:
- A new MPTCP subflow BPF program setting socket options per subflow: it
looks better to have this old test program in the BPF selftests to
track regressions and to serve as example.
Note: Nicolas is no longer working at Tessares, but he did this work
while working for them, and his email address is no longer available.
- A new hook in the same BPF program to do the verification step.
- A new MPTCP BPF subtest validating the new BPF program added in the
first patch, with the help of the new hook added in the second patch.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe(a)kernel.org>
---
Changes in v7:
- Patch 2/3: use 'can_loop' instead of 'cond_break'. (Martin)
- Patch 3/3: use bpf_program__attach_cgroup(). (Martin)
- Link to v6: https://lore.kernel.org/r/20240911-upstream-bpf-next-20240506-mptcp-subflow…
Changes in v6:
- Patch 3/3: use usleep() instead of sleep()
- Series: rebased on top of bpf-next/net
- Link to v5: https://lore.kernel.org/r/20240910-upstream-bpf-next-20240506-mptcp-subflow…
Changes in v5:
- See the individual changelog for more details about them
- Patch 1/3: set TCP on the 2nd subflow
- Patch 2/3: new
- Patch 3/3: use the BPF program from patch 2/3 to do the validation
instead of using ss.
- Series: rebased on top of bpf-next/net
- Link to v4: https://lore.kernel.org/r/20240805-upstream-bpf-next-20240506-mptcp-subflow…
Changes in v4:
- Drop former patch 2/3: MPTCP's pm_nl_ctl requires a new header file:
- I will check later if it is possible to avoid having duplicated
header files in tools/include/uapi, but no need to block this series
for that. Patch 2/3 can be added later if needed.
- Patch 2/2: skip the test if 'ip mptcp' is not available.
- Link to v3: https://lore.kernel.org/r/20240703-upstream-bpf-next-20240506-mptcp-subflow…
Changes in v3:
- Sorry for the delay between v2 and v3, this series was conflicting
with the "add netns helpers", but it looks like it is on hold:
https://lore.kernel.org/cover.1715821541.git.tanggeliang@kylinos.cn
- Patch 1/3 includes "bpf_tracing_net.h", introduced in between.
- New patch 2/3: "selftests/bpf: Add mptcp pm_nl_ctl link".
- Patch 3/3: use the tool introduced in patch 2/3 + SYS_NOFAIL() helper.
- Link to v2: https://lore.kernel.org/r/20240509-upstream-bpf-next-20240506-mptcp-subflow…
Changes in v2:
- Previous patches 1/4 and 2/4 have been dropped from this series:
- 1/4: "selftests/bpf: Handle SIGINT when creating netns":
- A new version, more generic and no longer specific to MPTCP BPF
selftest will be sent later, as part of a new series. (Alexei)
- 2/4: "selftests/bpf: Add RUN_MPTCP_TEST macro":
- Removed, not to hide helper functions in macros. (Alexei)
- The commit message of patch 1/2 has been clarified to avoid some
possible confusions spot by Alexei.
- Link to v1: https://lore.kernel.org/r/20240507-upstream-bpf-next-20240506-mptcp-subflow…
---
Geliang Tang (2):
selftests/bpf: Add getsockopt to inspect mptcp subflow
selftests/bpf: Add mptcp subflow subtest
Nicolas Rybowski (1):
selftests/bpf: Add mptcp subflow example
MAINTAINERS | 2 +-
tools/testing/selftests/bpf/prog_tests/mptcp.c | 121 ++++++++++++++++++++
tools/testing/selftests/bpf/progs/mptcp_bpf.h | 42 +++++++
tools/testing/selftests/bpf/progs/mptcp_subflow.c | 128 ++++++++++++++++++++++
4 files changed, 292 insertions(+), 1 deletion(-)
---
base-commit: 151ac45348afc5b56baa584c7cd4876addf461ff
change-id: 20240506-upstream-bpf-next-20240506-mptcp-subflow-test-faef6654bfa3
Best regards,
--
Matthieu Baerts (NGI0) <matttbe(a)kernel.org>
From: Jason Xing <kernelxing(a)tencent.com>
When reading through the whole feature, I feel we can do these things to
make it more robust. They are trivial changes, not big ones.
Jason Xing (3):
net-timestamp: add strict check when setting tx flags
net-timestamp: add OPT_ID_TCP test in selftests
net-timestamp: namespacify the sysctl_tstamp_allow_data
include/net/netns/core.h | 1 +
include/net/sock.h | 2 --
net/core/net_namespace.c | 1 +
net/core/skbuff.c | 2 +-
net/core/sock.c | 4 ++++
net/core/sysctl_net_core.c | 18 +++++++++---------
tools/testing/selftests/net/txtimestamp.c | 6 ++++++
7 files changed, 22 insertions(+), 12 deletions(-)
--
2.37.3
There were several attempts to resolve circular include dependency
after the addition of percpu.h: 1c9df907da83 ("random: fix circular
include dependency on arm64 after addition of percpu.h"), c0842fbc1b18
("random32: move the pseudo-random 32-bit definitions to prandom.h") and
finally d9f29deb7fe8 ("prandom: Remove unused include") that completely
removes the inclusion of <linux/percpu.h>.
Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but
with the commit entry remark:
--quote--
A further cleanup step would be to remove this from <linux/random.h>
entirely, and make people who use the prandom infrastructure include
just the new header file. That's a bit of a churn patch, but grepping
for "prandom_" and "next_pseudo_random32" "struct rnd_state" should
catch most users.
But it turns out that that nice cleanup step is fairly painful, because
a _lot_ of code currently seems to depend on the implicit include of
<linux/random.h>, which can currently come in a lot of ways, including
such fairly core headfers as <linux/net.h>.
So the "nice cleanup" part may or may never happen.
--/quote--
We would like to include <linux/percpu.h> in <linux/prandom.h>.
In [1] we would like to repurpose __percpu tag as a named address space
qualifier, where __percpu macro uses defines from <linux/percpu.h>.
The major roadblock to inclusion of <linux/percpu.h> is the above
mentioned legacy inclusion of <linux/prandom.h> in <linux/random.h> that
causes circular include dependency that prevents <linux/percpu.h>
inclusion.
This patch series is the "nice cleanup" part that:
a) Substitutes the inclusion of <linux/random.h> with the
inclusion of <linux/prandom.h> where needed (patches 1 - 17).
b) Removes legacy inclusion of <linux/prandom.h> from
<linux/random.h> (patch 18).
c) Includes <linux/percpu.h> in <linux/prandom.h> (patch 19).
The whole series was tested by compiling the kernel for x86_64 allconfig
and some popular architectures, namely arm64 defconfig, powerpc defconfig
and loongarch defconfig.
[1] https://lore.kernel.org/lkml/20240812115945.484051-4-ubizjak@gmail.com/
Cc: Dave Hansen <dave.hansen(a)linux.intel.com>
Cc: Andy Lutomirski <luto(a)kernel.org>
Cc: Peter Zijlstra <peterz(a)infradead.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Ingo Molnar <mingo(a)redhat.com>
Cc: Borislav Petkov <bp(a)alien8.de>
Cc: "H. Peter Anvin" <hpa(a)zytor.com>
Cc: Jani Nikula <jani.nikula(a)linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen(a)linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi(a)intel.com>
Cc: Tvrtko Ursulin <tursulin(a)ursulin.net>
Cc: David Airlie <airlied(a)gmail.com>
Cc: Daniel Vetter <daniel(a)ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst(a)linux.intel.com>
Cc: Maxime Ripard <mripard(a)kernel.org>
Cc: Thomas Zimmermann <tzimmermann(a)suse.de>
Cc: Hans Verkuil <hverkuil(a)xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab(a)kernel.org>
Cc: Miquel Raynal <miquel.raynal(a)bootlin.com>
Cc: Richard Weinberger <richard(a)nod.at>
Cc: Vignesh Raghavendra <vigneshr(a)ti.com>
Cc: Eric Biggers <ebiggers(a)kernel.org>
Cc: "Theodore Y. Ts'o" <tytso(a)mit.edu>
Cc: Jaegeuk Kim <jaegeuk(a)kernel.org>
Cc: "Jason A. Donenfeld" <Jason(a)zx2c4.com>
Cc: Linus Torvalds <torvalds(a)linux-foundation.org>
Cc: Hannes Reinecke <hare(a)suse.de>
Cc: "James E.J. Bottomley" <James.Bottomley(a)HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen(a)oracle.com>
Cc: Alexei Starovoitov <ast(a)kernel.org>
Cc: Daniel Borkmann <daniel(a)iogearbox.net>
Cc: John Fastabend <john.fastabend(a)gmail.com>
Cc: Andrii Nakryiko <andrii(a)kernel.org>
Cc: Martin KaFai Lau <martin.lau(a)linux.dev>
Cc: Eduard Zingerman <eddyz87(a)gmail.com>
Cc: Song Liu <song(a)kernel.org>
Cc: Yonghong Song <yonghong.song(a)linux.dev>
Cc: KP Singh <kpsingh(a)kernel.org>
Cc: Stanislav Fomichev <sdf(a)fomichev.me>
Cc: Hao Luo <haoluo(a)google.com>
Cc: Jiri Olsa <jolsa(a)kernel.org>
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Brendan Higgins <brendan.higgins(a)linux.dev>
Cc: David Gow <davidgow(a)google.com>
Cc: Rae Moar <rmoar(a)google.com>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: Eric Dumazet <edumazet(a)google.com>
Cc: Jakub Kicinski <kuba(a)kernel.org>
Cc: Paolo Abeni <pabeni(a)redhat.com>
Cc: Jiri Pirko <jiri(a)resnulli.us>
Cc: Petr Mladek <pmladek(a)suse.com>
Cc: Steven Rostedt <rostedt(a)goodmis.org>
Cc: Andy Shevchenko <andriy.shevchenko(a)linux.intel.com>
Cc: Rasmus Villemoes <linux(a)rasmusvillemoes.dk>
Cc: Sergey Senozhatsky <senozhatsky(a)chromium.org>
Cc: Stephen Hemminger <stephen(a)networkplumber.org>
Cc: Jamal Hadi Salim <jhs(a)mojatatu.com>
Cc: Cong Wang <xiyou.wangcong(a)gmail.com>
Cc: Kent Overstreet <kent.overstreet(a)linux.dev>
---
v2: - Reword commit messages to mention the removal of legacy inclusion
of <linux/prandom.h> from <linux/random.h>
- Add missing substitution in crypto/testmgr.c
(reported by kernel test robot)
- Add Acked-by: tags.
v3: - Update to linux 6.12rc1.
- Add more Acked-by: tags.
Uros Bizjak (19):
x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>
crypto: testmgr: Include <linux/prandom.h> instead of <linux/random.h>
drm/i915/selftests: Include <linux/prandom.h> instead of
<linux/random.h>
drm/lib: Include <linux/prandom.h> instead of <linux/random.h>
media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
fscrypt: Include <linux/once.h> in fs/crypto/keyring.c
scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
bpf: Include <linux/prandom.h> instead of <linux/random.h>
lib/interval_tree_test.c: Include <linux/prandom.h> instead of
<linux/random.h>
kunit: string-stream-test: Include <linux/prandom.h>
random32: Include <linux/prandom.h> instead of <linux/random.h>
lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h>
bpf/tests: Include <linux/prandom.h> instead of <linux/random.h>
lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h>
lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
netem: Include <linux/prandom.h> in sch_netem.c
random: Do not include <linux/prandom.h> in <linux/random.h>
prandom: Include <linux/percpu.h> in <linux/prandom.h>
arch/x86/mm/kaslr.c | 2 +-
crypto/testmgr.c | 2 +-
drivers/gpu/drm/i915/selftests/i915_gem.c | 2 +-
drivers/gpu/drm/i915/selftests/i915_random.h | 2 +-
drivers/gpu/drm/i915/selftests/scatterlist.c | 2 +-
drivers/gpu/drm/lib/drm_random.h | 2 +-
drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 +
drivers/mtd/tests/oobtest.c | 2 +-
drivers/mtd/tests/pagetest.c | 2 +-
drivers/mtd/tests/subpagetest.c | 2 +-
fs/crypto/keyring.c | 1 +
include/linux/prandom.h | 1 +
include/linux/random.h | 7 -------
include/scsi/libfcoe.h | 2 +-
kernel/bpf/core.c | 2 +-
lib/interval_tree_test.c | 2 +-
lib/kunit/string-stream-test.c | 1 +
lib/random32.c | 2 +-
lib/rbtree_test.c | 2 +-
lib/test_bpf.c | 2 +-
lib/test_parman.c | 2 +-
lib/test_scanf.c | 2 +-
net/sched/sch_netem.c | 1 +
23 files changed, 22 insertions(+), 24 deletions(-)
--
2.46.2