All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks
@ 2026-10-02 13:05 Wake Liu via ltp
  2026-10-02 13:42 ` [LTP] " linuxtestproject.agent
  2026-10-05 13:27 ` [LTP] [PATCH] " Andrea Cervesato via ltp
  0 siblings, 2 replies; 3+ messages in thread
From: Wake Liu via ltp @ 2026-10-02 13:05 UTC (permalink / raw)
  To: ltp

Bionic's <sys/procfs.h> provides elf_gregset_t and struct elf_siginfo,
but not struct elf_prstatus or struct elf_prpsinfo, so coredump02
fails to build on Android:

    error: incomplete definition of type 'const struct elf_prstatus'

Add configure checks and fallback definitions which follow
include/linux/elfcore.h. The timevals and pr_uid/pr_gid use the kernel
types, so the layout matches the native core dump format, e.g. 16-bit
pr_uid on 32-bit x86 and arm. Use the new header in coredump02.

Fixes: 72a170823fb0 ("coredump02: Verify ELF structure and notes")
Signed-off-by: Wake Liu <wakel@google.com>
---
 configure.ac                           |  1 +
 include/lapi/procfs.h                  | 56 ++++++++++++++++++++++++++
 testcases/kernel/coredump/coredump02.c |  2 +-
 3 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 include/lapi/procfs.h

diff --git a/configure.ac b/configure.ac
index e979de0e7..370c2e74f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,6 +201,7 @@ AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>])
 AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>])
 AC_CHECK_TYPES([struct clone_args],,,[#include <sched.h>])
 AC_CHECK_TYPES([struct sched_attr],,,[#include <sched.h>])
+AC_CHECK_TYPES([struct elf_prpsinfo, struct elf_prstatus],,,[#include <sys/procfs.h>])
 AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error,
 		struct fanotify_event_info_header, struct fanotify_event_info_pidfd,
 		struct fanotify_event_info_range],,,[#include <sys/fanotify.h>])
diff --git a/include/lapi/procfs.h b/include/lapi/procfs.h
new file mode 100644
index 000000000..598d91bf1
--- /dev/null
+++ b/include/lapi/procfs.h
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Google LLC
+ */
+
+#ifndef LAPI_PROCFS_H__
+#define LAPI_PROCFS_H__
+
+#include "config.h"
+#include <sys/types.h>
+#include <sys/procfs.h>
+#include "lapi/posix_types.h"
+
+/*
+ * Bionic does not provide the core dump note descriptors. The fallbacks
+ * follow include/linux/elfcore.h, using the kernel types so that the layout
+ * matches the native ABI on every architecture.
+ */
+#ifndef HAVE_STRUCT_ELF_PRSTATUS
+struct elf_prstatus {
+	struct elf_siginfo pr_info;
+	short pr_cursig;
+	unsigned long pr_sigpend;
+	unsigned long pr_sighold;
+	pid_t pr_pid;
+	pid_t pr_ppid;
+	pid_t pr_pgrp;
+	pid_t pr_sid;
+	struct {
+		__kernel_long_t tv_sec;
+		__kernel_long_t tv_usec;
+	} pr_utime, pr_stime, pr_cutime, pr_cstime;
+	elf_gregset_t pr_reg;
+	int pr_fpvalid;
+};
+#endif
+
+#ifndef HAVE_STRUCT_ELF_PRPSINFO
+struct elf_prpsinfo {
+	char pr_state;
+	char pr_sname;
+	char pr_zomb;
+	char pr_nice;
+	unsigned long pr_flag;
+	__kernel_uid_t pr_uid;
+	__kernel_gid_t pr_gid;
+	pid_t pr_pid;
+	pid_t pr_ppid;
+	pid_t pr_pgrp;
+	pid_t pr_sid;
+	char pr_fname[16];
+	char pr_psargs[ELF_PRARGSZ];
+};
+#endif
+
+#endif /* LAPI_PROCFS_H__ */
diff --git a/testcases/kernel/coredump/coredump02.c b/testcases/kernel/coredump/coredump02.c
index 7b0b4c43e..6657a3d71 100644
--- a/testcases/kernel/coredump/coredump02.c
+++ b/testcases/kernel/coredump/coredump02.c
@@ -40,9 +40,9 @@
  */
 
 #include <link.h>
-#include <sys/procfs.h>
 
 #include "coredump_common.h"
+#include "lapi/procfs.h"
 
 #define NOTE_ALIGN(x) (((x) + 3) & ~3U)
 
-- 
2.56.0.rc1.315.gc6ed9934b7-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks
  2026-10-02 13:05 [LTP] [PATCH] lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks Wake Liu via ltp
@ 2026-10-02 13:42 ` linuxtestproject.agent
  2026-10-05 13:27 ` [LTP] [PATCH] " Andrea Cervesato via ltp
  1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-10-02 13:42 UTC (permalink / raw)
  To: Wake Liu; +Cc: ltp

Hi Wake,

On 2026-10-02, Wake Liu wrote:
> lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks

Verdict - Reviewed

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks
  2026-10-02 13:05 [LTP] [PATCH] lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks Wake Liu via ltp
  2026-10-02 13:42 ` [LTP] " linuxtestproject.agent
@ 2026-10-05 13:27 ` Andrea Cervesato via ltp
  1 sibling, 0 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2026-10-05 13:27 UTC (permalink / raw)
  To: Wake Liu; +Cc: ltp

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-05 13:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 13:05 [LTP] [PATCH] lapi/procfs.h: Add elf_prstatus and elf_prpsinfo fallbacks Wake Liu via ltp
2026-10-02 13:42 ` [LTP] " linuxtestproject.agent
2026-10-05 13:27 ` [LTP] [PATCH] " Andrea Cervesato via ltp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.