Skip to contentSkip to conversation

Fix AT_EXECFN auxv for no-MMU fdpic

PATCH New Mark Salter 1 participant 2 messages Feb 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Fix AT_EXECFN auxv for no-MMU fdpic

In the no-MMU case, the FDPIC loader was passing an offset as the value for the AT_EXECFN auxv. This patch translates that offset into an actual user address.

---
 fs/binfmt_elf_fdpic.c | 1 +
 1 file changed, 1 insertion(+)
fs/binfmt_elf_fdpic.c +1 -0
index cb240dd..af4c9a4 100644
@@ -496,6 +496,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
 	sp = arch_align_stack(bprm->p);
 #else
 	sp = mm->start_stack;
+	bprm->exec = sp - (MAX_ARG_PAGES * PAGE_SIZE - bprm->exec);
 
 	/* stack the program arguments and environment */
 	if (elf_fdpic_transfer_args_to_stack(bprm, &sp) < 0)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 Fix /proc/<pid>/auxv for FDPIC binaries

The FDPIC loader is not storing aux vector info in mm->saved_aux so the aux vectors were not being exposed through /proc/<pid>/auxv. This patch copies the aux vectors stored on the user stack into mm->saved_aux so that they may be available through procfs.

---
 fs/binfmt_elf_fdpic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/binfmt_elf_fdpic.c +6 -1
index af4c9a4..9651918 100644
@@ -478,7 +478,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
 				   struct elf_fdpic_params *interp_params)
 {
 	const struct cred *cred = current_cred();
-	unsigned long sp, csp, nitems;
+	unsigned long sp, csp, nitems, auxv_end;
 	elf_caddr_t __user *argv, *envp;
 	size_t platform_len = 0, len;
 	char *k_platform, *k_base_platform;
@@ -594,6 +594,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
 	} while (0)
 
 	nr = 0;
+	auxv_end = csp;
 	csp -= 2 * sizeof(unsigned long);
 	NEW_AUX_ENT(AT_NULL, 0);
 	if (k_platform) {
@@ -645,6 +646,10 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
 #endif
 #undef NEW_AUX_ENT
 
+	if (copy_from_user(current->mm->saved_auxv,
+			   (const char __user *) csp, auxv_end - csp))
+		return -EFAULT;
+
 	/* allocate room for argv[] and envv[] */
 	csp -= (bprm->envc + 1) * sizeof(elf_caddr_t);
 	envp = (elf_caddr_t __user *) csp;
Signature · 1 line
1.8.1.2