[apparmor] [patch] regression tests: more ptrace adjustments for arm64 upstream changes

Steve Beattie steve at nxnw.org
Tue Jul 14 16:20:23 UTC 2015


In the commit "Rev 3169: regression tests: have
ptrace use PTRACE_GETREGSET by default", I created
some ifdef magic to use the per arch general purpose
register data structures for various architectures,
including arm64.  Unfortunately, in the upstream glibc commit
<bits/ptrace.h> is no longer included in the arm64 specific user.h,
which defined the structure as 'struct user_pt_regs'; instead user.h
was converted to define 'struct user_regs_struct'. Because of this, the
ptrace test fails to compile on arm64 when glibc is 2.20 or newer.

This patch adjusts the ptrace test to use the newer structure on arm64
if it's detected that a newer glibc is detected and reverts to using
the older one for older glibcs. It also adds an error when compiling
on architectures that haven't been incorporated yet (I don't have
access to most of the other glibc architectures, patches welcome.).

This patch is for both 2.10 and 2.9.

Signed-off-by: Steve Beattie <steve at nxnw.org>
 tests/regression/apparmor/ptrace.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: b/tests/regression/apparmor/ptrace.c
--- a/tests/regression/apparmor/ptrace.c
+++ b/tests/regression/apparmor/ptrace.c
@@ -40,9 +40,15 @@ int interp_status(int status)
 #  if defined(__x86_64__) || defined(__i386__)
 #    define ARCH_REGS_STRUCT struct user_regs_struct
 #  elif defined(__aarch64__)
-#    define ARCH_REGS_STRUCT struct user_pt_regs
+#    if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 20))
+#      define ARCH_REGS_STRUCT struct user_regs_struct
+#    else
+#      define ARCH_REGS_STRUCT struct user_pt_regs
+#    endif
 #  elif defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)
 #    define ARCH_REGS_STRUCT struct pt_regs
+#  else
+#    error "Need to define ARCH_REGS_STRUCT for this architecture"
 #  endif
 int read_ptrace_registers(pid_t pid)

Steve Beattie
<sbeattie at ubuntu.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150714/464b4b24/attachment.pgp>

More information about the AppArmor mailing list