* [PATCH v3] test: account for member name change in mm_struct
@ 2026-02-10 17:35 Kris Van Hees
2026-02-10 18:39 ` [DTrace-devel] " Eugene Loh
0 siblings, 1 reply; 2+ messages in thread
From: Kris Van Hees @ 2026-02-10 17:35 UTC (permalink / raw)
To: dtrace, dtrace-devel
The flexible array at the end of the mm_struct has changed name in newer
kernels. Rather than depending on a particular name, we can simply get
the name of the last member (since that is there the flexible array is
always found) and try to use that.
The testsuite gains a dependency on bpftool for this test.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
dtrace.spec | 2 +-
.../arrays/tst.ctf-dynsized-bounds-runtime.d | 25 -----------
.../arrays/tst.ctf-dynsized-bounds-runtime.sh | 43 +++++++++++++++++++
3 files changed, 44 insertions(+), 26 deletions(-)
delete mode 100644 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
create mode 100755 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
diff --git a/dtrace.spec b/dtrace.spec
index d6af5a80..e0d832ac 100644
--- a/dtrace.spec
+++ b/dtrace.spec
@@ -115,7 +115,7 @@ Requires: %{name}-devel = %{version}-%{release} perl gcc java
Requires: java-devel perl-IO-Socket-IP perl-Net-Ping xfsprogs
Requires: exportfs vim-minimal %{name}%{?_isa} = %{version}-%{release}
Requires: coreutils wireshark %{glibc32}
-Requires: time bc nfs-utils
+Requires: time bc nfs-utils bpftool
Suggests: kernel-uek-tools
Autoreq: 0
Group: Development/System
diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
deleted file mode 100644
index f3801454..00000000
--- a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
- * Licensed under the Universal Permissive License v 1.0 as shown at
- * http://oss.oracle.com/licenses/upl.
- */
-
-/*
- * ASSERTION: Array accesses work for CTF-declared arrays of dynamic size
- * (ensuring the bounds checking is also bypassed at runtime).
- *
- * SECTION: Pointers and Arrays/Array Declarations and Storage
- */
-
-BEGIN
-{
- i = pid - pid; /* Non-constant 0 value. */
- trace(curthread->mm->cpu_bitmap[i]);
- exit(0);
-}
-
-ERROR
-{
- exit(1);
-}
diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
new file mode 100755
index 00000000..60fe6afc
--- /dev/null
+++ b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# ASSERTION: Array accesses work for CTF-declared arrays of dynamic size
+# (ensuring the bounds checking is also bypassed at runtime).
+#
+# SECTION: Pointers and Arrays/Array Declarations and Storage
+
+dtrace=$1
+
+# The mm_struct 'cpu_bitmap' was renamed to 'flexible_array', so we need to
+# see which member name the current kernel uses. Since it is always the last
+# member of mm_struct, we just use that member name, and hope for the best.
+# If mm_struct ever gets changed to not have a flesible array at its end, this
+# test will need a new structure to work with.
+# are out of luck.
+
+# Determine the member name we should use.
+member=`bpftool btf dump id 1 | \
+ awk '/^\[[0-9]+\] STRUCT \047mm_struct\047/ { in_mm = 1; next; }
+ /^\t/ && in_mm { fld = $1; gsub(/\047/, "", fld); next }
+ /^\[[0-9]+\] [A-Z]+ \047/ && in_mm { print fld; exit; }'`
+
+
+# Try to access the flexible array.
+$dtrace $dt_flags -qn "
+BEGIN
+{
+ i = pid - pid; /* non-constant 0 value */
+ v = curthread->mm->$member[i];
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}"
+
+echo $?
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [DTrace-devel] [PATCH v3] test: account for member name change in mm_struct
2026-02-10 17:35 [PATCH v3] test: account for member name change in mm_struct Kris Van Hees
@ 2026-02-10 18:39 ` Eugene Loh
0 siblings, 0 replies; 2+ messages in thread
From: Eugene Loh @ 2026-02-10 18:39 UTC (permalink / raw)
To: Kris Van Hees, dtrace, dtrace-devel
A few minor comments:
On 2/10/26 12:35, Kris Van Hees via DTrace-devel wrote:
> The flexible array at the end of the mm_struct has changed name in newer
> kernels. Rather than depending on a particular name, we can simply get
> the name of the last member (since that is there the flexible array is
> always found) and try to use that.
>
> The testsuite gains a dependency on bpftool for this test.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> dtrace.spec | 2 +-
> .../arrays/tst.ctf-dynsized-bounds-runtime.d | 25 -----------
> .../arrays/tst.ctf-dynsized-bounds-runtime.sh | 43 +++++++++++++++++++
> 3 files changed, 44 insertions(+), 26 deletions(-)
> delete mode 100644 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
> create mode 100755 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
>
> diff --git a/dtrace.spec b/dtrace.spec
> index d6af5a80..e0d832ac 100644
> --- a/dtrace.spec
> +++ b/dtrace.spec
> @@ -115,7 +115,7 @@ Requires: %{name}-devel = %{version}-%{release} perl gcc java
> Requires: java-devel perl-IO-Socket-IP perl-Net-Ping xfsprogs
> Requires: exportfs vim-minimal %{name}%{?_isa} = %{version}-%{release}
> Requires: coreutils wireshark %{glibc32}
> -Requires: time bc nfs-utils
> +Requires: time bc nfs-utils bpftool
> Suggests: kernel-uek-tools
> Autoreq: 0
> Group: Development/System
> diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
> deleted file mode 100644
> index f3801454..00000000
> --- a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -/*
> - * Oracle Linux DTrace.
> - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
> - * Licensed under the Universal Permissive License v 1.0 as shown at
> - * http://oss.oracle.com/licenses/upl.
> - */
> -
> -/*
> - * ASSERTION: Array accesses work for CTF-declared arrays of dynamic size
> - * (ensuring the bounds checking is also bypassed at runtime).
> - *
> - * SECTION: Pointers and Arrays/Array Declarations and Storage
> - */
> -
> -BEGIN
> -{
> - i = pid - pid; /* Non-constant 0 value. */
> - trace(curthread->mm->cpu_bitmap[i]);
> - exit(0);
> -}
> -
> -ERROR
> -{
> - exit(1);
> -}
> diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
> new file mode 100755
> index 00000000..60fe6afc
> --- /dev/null
> +++ b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.sh
> @@ -0,0 +1,43 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +
> +# ASSERTION: Array accesses work for CTF-declared arrays of dynamic size
> +# (ensuring the bounds checking is also bypassed at runtime).
> +#
> +# SECTION: Pointers and Arrays/Array Declarations and Storage
> +
> +dtrace=$1
> +
> +# The mm_struct 'cpu_bitmap' was renamed to 'flexible_array', so we need to
> +# see which member name the current kernel uses. Since it is always the last
> +# member of mm_struct, we just use that member name, and hope for the best.
> +# If mm_struct ever gets changed to not have a flesible array at its end, this
s/flesible/flexible/
> +# test will need a new structure to work with.
> +# are out of luck.
/are out of luck/d
> +
> +# Determine the member name we should use.
> +member=`bpftool btf dump id 1 | \
> + awk '/^\[[0-9]+\] STRUCT \047mm_struct\047/ { in_mm = 1; next; }
> + /^\t/ && in_mm { fld = $1; gsub(/\047/, "", fld); next }
> + /^\[[0-9]+\] [A-Z]+ \047/ && in_mm { print fld; exit; }'`
The search for the end of STRUCT looks for [A-Z]+, but could there be a
'_' in there? E.g., for "FUNC_PROTO"?
> +
> +
> +# Try to access the flexible array.
> +$dtrace $dt_flags -qn "
> +BEGIN
> +{
> + i = pid - pid; /* non-constant 0 value */
> + v = curthread->mm->$member[i];
> + exit(0);
> +}
> +
> +ERROR
> +{
> + exit(1);
> +}"
> +
> +echo $?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-10 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 17:35 [PATCH v3] test: account for member name change in mm_struct Kris Van Hees
2026-02-10 18:39 ` [DTrace-devel] " Eugene Loh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox