History

prctl: add PR_GET_AUXV to copy auxv to userspace

If a library wants to get information from auxv (for instance, AT_HWCAP/AT_HWCAP2), it has a few options, none of them perfectly reliable or ideal: - Be main or the pre-main startup code, and grub through the stack above main. Doesn't work for a library. - Call libc getauxval. Not ideal for libraries that are trying to be libc-independent and/or don't otherwise require anything from other libraries. - Open and read /proc/self/auxv. Doesn't work for libraries that may run in arbitrarily constrained environments that may not have /proc mounted (e.g. libraries that might be used by an init program or a container setup tool). - Assume you're on the main thread and still on the original stack, and try to walk the stack upwards, hoping to find auxv. Extremely bad idea. - Ask the caller to pass auxv in for you. Not ideal for a user-friendly library, and then your caller may have the same problem. Add a prctl that copies current->mm->saved_auxv to a userspace buffer.

Josh Triplett committed 3 years ago

Commit ddc65971 parent 97f7e092 files · +17 −0Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/linux/prctl.h+2−0
@@ -290,4 +290,6 @@ struct prctl_mm_map { · 289 unmodified lines
290#define PR_SET_VMA 0x53564d41290#define PR_SET_VMA 0x53564d41
291# define PR_SET_VMA_ANON_NAME 0291# define PR_SET_VMA_ANON_NAME 0
292 292
293#define PR_GET_AUXV 0x41555856
294
293#endif /* _LINUX_PRCTL_H */295#endif /* _LINUX_PRCTL_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t