Commit ec23847d6cfe445ba9a1a5ec513297f4cc0ada53

Authored by Paul Mundt
Committed by Linus Torvalds
1 parent 758222f842

binfmt_elf_fdpic: support auxvec base platform string

Commit 483fad1c3fa1060d7e6710e84a065ad514571739 ("ELF loader support for
auxvec base platform string") introduced AT_BASE_PLATFORM, but only
implemented it for binfmt_elf.

Given that AT_VECTOR_SIZE_BASE is unconditionally enlarged for us, and
it's only optionally added in for the platforms that set
ELF_BASE_PLATFORM, wire it up for binfmt_elf_fdpic, too.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 43 additions and 7 deletions Side-by-side Diff

fs/binfmt_elf_fdpic.c
... ... @@ -455,7 +455,17 @@
455 455 }
456 456  
457 457 /*****************************************************************************/
  458 +
  459 +#ifndef ELF_BASE_PLATFORM
458 460 /*
  461 + * AT_BASE_PLATFORM indicates the "real" hardware/microarchitecture.
  462 + * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value
  463 + * will be copied to the user stack in the same manner as AT_PLATFORM.
  464 + */
  465 +#define ELF_BASE_PLATFORM NULL
  466 +#endif
  467 +
  468 +/*
459 469 * present useful information to the program
460 470 */
461 471 static int create_elf_fdpic_tables(struct linux_binprm *bprm,
... ... @@ -466,8 +476,8 @@
466 476 unsigned long sp, csp, nitems;
467 477 elf_caddr_t __user *argv, *envp;
468 478 size_t platform_len = 0, len;
469   - char *k_platform;
470   - char __user *u_platform, *p;
  479 + char *k_platform, *k_base_platform;
  480 + char __user *u_platform, *u_base_platform, *p;
471 481 long hwcap;
472 482 int loop;
473 483 int nr; /* reset for each csp adjustment */
474 484  
... ... @@ -483,11 +493,14 @@
483 493 return -EFAULT;
484 494 #endif
485 495  
486   - /* get hold of platform and hardware capabilities masks for the machine
487   - * we are running on. In some cases (Sparc), this info is impossible
488   - * to get, in others (i386) it is merely difficult.
489   - */
490 496 hwcap = ELF_HWCAP;
  497 +
  498 + /*
  499 + * If this architecture has a platform capability string, copy it
  500 + * to userspace. In some cases (Sparc), this info is impossible
  501 + * for userspace to get any other way, in others (i386) it is
  502 + * merely difficult.
  503 + */
491 504 k_platform = ELF_PLATFORM;
492 505 u_platform = NULL;
493 506  
... ... @@ -499,6 +512,21 @@
499 512 return -EFAULT;
500 513 }
501 514  
  515 + /*
  516 + * If this architecture has a "base" platform capability
  517 + * string, copy it to userspace.
  518 + */
  519 + k_base_platform = ELF_BASE_PLATFORM;
  520 + u_base_platform = NULL;
  521 +
  522 + if (k_base_platform) {
  523 + platform_len = strlen(k_base_platform) + 1;
  524 + sp -= platform_len;
  525 + u_base_platform = (char __user *) sp;
  526 + if (__copy_to_user(u_base_platform, k_base_platform, platform_len) != 0)
  527 + return -EFAULT;
  528 + }
  529 +
502 530 #if defined(__i386__) && defined(CONFIG_SMP)
503 531 /* in some cases (e.g. Hyper-Threading), we want to avoid L1 evictions
504 532 * by the processes running on the same package. One thing we can do is
... ... @@ -543,7 +571,8 @@
543 571 /* force 16 byte _final_ alignment here for generality */
544 572 #define DLINFO_ITEMS 13
545 573  
546   - nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;
  574 + nitems = 1 + DLINFO_ITEMS + (k_platform ? 1 : 0) +
  575 + (k_base_platform ? 1 : 0) + AT_VECTOR_SIZE_ARCH;
547 576  
548 577 csp = sp;
549 578 sp -= nitems * 2 * sizeof(unsigned long);
... ... @@ -573,6 +602,13 @@
573 602 csp -= 2 * sizeof(unsigned long);
574 603 NEW_AUX_ENT(AT_PLATFORM,
575 604 (elf_addr_t) (unsigned long) u_platform);
  605 + }
  606 +
  607 + if (k_base_platform) {
  608 + nr = 0;
  609 + csp -= 2 * sizeof(unsigned long);
  610 + NEW_AUX_ENT(AT_BASE_PLATFORM,
  611 + (elf_addr_t) (unsigned long) u_base_platform);
576 612 }
577 613  
578 614 nr = 0;