Skip to contentSkip to conversation

linux-user: Add AT_SECURE auxval

PATCH Superseded Marco A L Barbosa 3 participants 4 messages Oct 5, 2017 – Jan 8, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Add AT_SECURE auxval

This is necessary to run android ndk applications. Without this patch, the following error is generated:

FATAL: kernel did not supply AT_SECURE

Should AT_SECURE from host be considered or is the ids comparisons enough?

---
 linux-user/elfload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/elfload.c +2 -1
index 79062882ba..177ce30e89 100644
@@ -1354,7 +1354,7 @@ struct exec
                                  ~(abi_ulong)(TARGET_ELF_EXEC_PAGESIZE-1))
 #define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))
 
-#define DLINFO_ITEMS 14
+#define DLINFO_ITEMS 15
 
 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
 {
@@ -1782,6 +1782,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
     NEW_AUX_ENT(AT_HWCAP, (abi_ulong) ELF_HWCAP);
     NEW_AUX_ENT(AT_CLKTCK, (abi_ulong) sysconf(_SC_CLK_TCK));
     NEW_AUX_ENT(AT_RANDOM, (abi_ulong) u_rand_bytes);
+    NEW_AUX_ENT(AT_SECURE, (abi_ulong) (getuid() != geteuid() || getgid() != getegid()));
 
 #ifdef ELF_HWCAP2
     NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2);
Signature · 1 line
2.11.0
#1 lore raw

I'm Cc'ing this to qemu-devel@ for review, since this patch hasn't got any reviews. Please the next time always inclure qemu-devel@ and other addresses according to the output of scripts/get_maintainer.pl

Thanks,

/mjt

Quoted 34 lines · Marco A L Barbosa

This is necessary to run android ndk applications. Without this patch, the following error is generated:

FATAL: kernel did not supply AT_SECURE

Should AT_SECURE from host be considered or is the ids comparisons enough?

---
 linux-user/elfload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/elfload.c +2 -1
index 79062882ba..177ce30e89 100644
@@ -1354,7 +1354,7 @@ struct exec
                                  ~(abi_ulong)(TARGET_ELF_EXEC_PAGESIZE-1))
 #define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))
 
-#define DLINFO_ITEMS 14
+#define DLINFO_ITEMS 15
 
 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
 {
@@ -1782,6 +1782,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
     NEW_AUX_ENT(AT_HWCAP, (abi_ulong) ELF_HWCAP);
     NEW_AUX_ENT(AT_CLKTCK, (abi_ulong) sysconf(_SC_CLK_TCK));
     NEW_AUX_ENT(AT_RANDOM, (abi_ulong) u_rand_bytes);
+    NEW_AUX_ENT(AT_SECURE, (abi_ulong) (getuid() != geteuid() || getgid() != getegid()));
 
 #ifdef ELF_HWCAP2
     NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2);
#2 lore raw
In reply to Marco A L Barbosa

I'm Cc'ing this to qemu-devel@ for review, since this patch hasn't got any reviews. Please the next time always inclure qemu-devel@ and other addresses according to the output of scripts/get_maintainer.pl

Thanks,

/mjt

Quoted 34 lines · Marco A L Barbosa

This is necessary to run android ndk applications. Without this patch, the following error is generated:

FATAL: kernel did not supply AT_SECURE

Should AT_SECURE from host be considered or is the ids comparisons enough?

---
 linux-user/elfload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/elfload.c +2 -1
index 79062882ba..177ce30e89 100644
@@ -1354,7 +1354,7 @@ struct exec
                                  ~(abi_ulong)(TARGET_ELF_EXEC_PAGESIZE-1))
 #define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))
 
-#define DLINFO_ITEMS 14
+#define DLINFO_ITEMS 15
 
 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
 {
@@ -1782,6 +1782,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
     NEW_AUX_ENT(AT_HWCAP, (abi_ulong) ELF_HWCAP);
     NEW_AUX_ENT(AT_CLKTCK, (abi_ulong) sysconf(_SC_CLK_TCK));
     NEW_AUX_ENT(AT_RANDOM, (abi_ulong) u_rand_bytes);
+    NEW_AUX_ENT(AT_SECURE, (abi_ulong) (getuid() != geteuid() || getgid() != getegid()));
 
 #ifdef ELF_HWCAP2
     NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2);
#3 lore raw
Quoted 7 lines · Michael Tokarev
Quoted 6 lines · Marco A L Barbosa

This is necessary to run android ndk applications. Without this patch, the following error is generated:

FATAL: kernel did not supply AT_SECURE

Should AT_SECURE from host be considered or is the ids comparisons enough?

If we just pass through the host AT_SECURE value that would mean we don't need to do the ID comparisons, right? (the host kernel will have done them for us). I think that would be better.

We can do that with qemu_getauxval(AT_SECURE).

thanks
-- PMM