512                         args->dat_prot |= PROT_READ;
 513                 if (dataphdrp->p_flags & PF_W)
 514                         args->dat_prot |= PROT_WRITE;
 515                 if (dataphdrp->p_flags & PF_X)
 516                         args->dat_prot |= PROT_EXEC;
 517         }
 518 
 519         /*
 520          * If a auxvector will be required - reserve the space for
 521          * it now.  This may be increased by exec_args if there are
 522          * ISA-specific types (included in __KERN_NAUXV_IMPL).
 523          */
 524         if (hasauxv) {
 525                 /*
 526                  * If a AUX vector is being built - the base AUX
 527                  * entries are:
 528                  *
 529                  *      AT_BASE
 530                  *      AT_FLAGS
 531                  *      AT_PAGESZ
 532                  *      AT_RANDOM       (added in stk_copyout)
 533                  *      AT_SUN_AUXFLAGS
 534                  *      AT_SUN_HWCAP
 535                  *      AT_SUN_HWCAP2
 536                  *      AT_SUN_PLATFORM (added in stk_copyout)
 537                  *      AT_SUN_EXECNAME (added in stk_copyout)
 538                  *      AT_NULL
 539                  *
 540                  * total == 10
 541                  */
 542                 if (hasdy && hasu) {
 543                         /*
 544                          * Has PT_INTERP & PT_PHDR - the auxvectors that
 545                          * will be built are:
 546                          *
 547                          *      AT_PHDR
 548                          *      AT_PHENT
 549                          *      AT_PHNUM
 550                          *      AT_ENTRY
 551                          *      AT_LDDATA
 552                          *
 
 626                 if ((error = vn_rdwr(UIO_READ, vp, (caddr_t)cap,
 627                     capsize, (offset_t)capphdr->p_offset,
 628                     UIO_SYSSPACE, 0, (rlim64_t)0, CRED(), &resid)) != 0) {
 629                         uprintf("%s: Cannot read capabilities section\n",
 630                             exec_file);
 631                         goto out;
 632                 }
 633                 for (cp = cap; cp < cap + ncaps; cp++) {
 634                         if (cp->c_tag == CA_SUNW_SF_1 &&
 635                             (cp->c_un.c_val & SF1_SUNW_ADDR32)) {
 636                                 if (args->to_model == DATAMODEL_LP64)
 637                                         args->addr32 = 1;
 638                                 break;
 639                         }
 640                 }
 641         }
 642 
 643         aux = bigwad->elfargs;
 644         /*
 645          * Move args to the user's stack.
 646          * This can fill in the AT_SUN_PLATFORM, AT_SUN_EXECNAME and AT_RANDOM
 647          * aux entries.
 648          */
 649         if ((error = exec_args(uap, args, idatap, (void **)&aux)) != 0) {
 650                 if (error == -1) {
 651                         error = ENOEXEC;
 652                         goto bad;
 653                 }
 654                 goto out;
 655         }
 656         /* we're single threaded after this point */
 657 
 658         /*
 659          * If this is an ET_DYN executable (shared object),
 660          * determine its memory size so that mapelfexec() can load it.
 661          */
 662         if (ehdrp->e_type == ET_DYN)
 663                 len = elfsize(ehdrp, nphdrs, phdrbase, NULL);
 664         else
 665                 len = 0;
 666 
 667         dtrphdr = NULL;
 
 868                  * architecture-specific user per-LWP location. The dtrace
 869                  * fasttrap provider requires ready access to per-LWP scratch
 870                  * space. We assume that there is only one such program header
 871                  * in the interpreter.
 872                  */
 873                 if (dtrphdr != NULL &&
 874                     dtrace_safe_phdr(dtrphdr, args, voffset) != 0) {
 875                         VN_RELE(nvp);
 876                         uprintf("%s: Bad DTrace phdr in %s\n", exec_file, dlnp);
 877                         goto bad;
 878                 }
 879 
 880                 VN_RELE(nvp);
 881                 ADDAUX(aux, AT_SUN_LDDATA, voffset + lddata)
 882         }
 883 
 884         if (hasauxv) {
 885                 int auxf = AF_SUN_HWCAPVERIFY;
 886 
 887                 /*
 888                  * Note: AT_SUN_PLATFORM, AT_SUN_EXECNAME and AT_RANDOM were
 889                  * filled in via exec_args()
 890                  */
 891                 ADDAUX(aux, AT_BASE, voffset)
 892                 ADDAUX(aux, AT_FLAGS, at_flags)
 893                 ADDAUX(aux, AT_PAGESZ, PAGESIZE)
 894                 /*
 895                  * Linker flags. (security)
 896                  * p_flag not yet set at this time.
 897                  * We rely on gexec() to provide us with the information.
 898                  * If the application is set-uid but this is not reflected
 899                  * in a mismatch between real/effective uids/gids, then
 900                  * don't treat this as a set-uid exec.  So we care about
 901                  * the EXECSETID_UGIDS flag but not the ...SETID flag.
 902                  */
 903                 if ((setid &= ~EXECSETID_SETID) != 0)
 904                         auxf |= AF_SUN_SETUGID;
 905 
 906                 /*
 907                  * If we're running a native process from within a branded
 908                  * zone under pfexec then we clear the AF_SUN_SETUGID flag so
 909                  * that the native ld.so.1 is able to link with the native
 
 | 
 
 
 512                         args->dat_prot |= PROT_READ;
 513                 if (dataphdrp->p_flags & PF_W)
 514                         args->dat_prot |= PROT_WRITE;
 515                 if (dataphdrp->p_flags & PF_X)
 516                         args->dat_prot |= PROT_EXEC;
 517         }
 518 
 519         /*
 520          * If a auxvector will be required - reserve the space for
 521          * it now.  This may be increased by exec_args if there are
 522          * ISA-specific types (included in __KERN_NAUXV_IMPL).
 523          */
 524         if (hasauxv) {
 525                 /*
 526                  * If a AUX vector is being built - the base AUX
 527                  * entries are:
 528                  *
 529                  *      AT_BASE
 530                  *      AT_FLAGS
 531                  *      AT_PAGESZ
 532                  *      AT_RANDOM
 533                  *      AT_SUN_AUXFLAGS
 534                  *      AT_SUN_HWCAP
 535                  *      AT_SUN_HWCAP2
 536                  *      AT_SUN_PLATFORM (added in stk_copyout)
 537                  *      AT_SUN_EXECNAME (added in stk_copyout)
 538                  *      AT_NULL
 539                  *
 540                  * total == 10
 541                  */
 542                 if (hasdy && hasu) {
 543                         /*
 544                          * Has PT_INTERP & PT_PHDR - the auxvectors that
 545                          * will be built are:
 546                          *
 547                          *      AT_PHDR
 548                          *      AT_PHENT
 549                          *      AT_PHNUM
 550                          *      AT_ENTRY
 551                          *      AT_LDDATA
 552                          *
 
 626                 if ((error = vn_rdwr(UIO_READ, vp, (caddr_t)cap,
 627                     capsize, (offset_t)capphdr->p_offset,
 628                     UIO_SYSSPACE, 0, (rlim64_t)0, CRED(), &resid)) != 0) {
 629                         uprintf("%s: Cannot read capabilities section\n",
 630                             exec_file);
 631                         goto out;
 632                 }
 633                 for (cp = cap; cp < cap + ncaps; cp++) {
 634                         if (cp->c_tag == CA_SUNW_SF_1 &&
 635                             (cp->c_un.c_val & SF1_SUNW_ADDR32)) {
 636                                 if (args->to_model == DATAMODEL_LP64)
 637                                         args->addr32 = 1;
 638                                 break;
 639                         }
 640                 }
 641         }
 642 
 643         aux = bigwad->elfargs;
 644         /*
 645          * Move args to the user's stack.
 646          * This can fill in the AT_SUN_PLATFORM and AT_SUN_EXECNAME aux entries.
 647          */
 648         if ((error = exec_args(uap, args, idatap, (void **)&aux)) != 0) {
 649                 if (error == -1) {
 650                         error = ENOEXEC;
 651                         goto bad;
 652                 }
 653                 goto out;
 654         }
 655         /* we're single threaded after this point */
 656 
 657         /*
 658          * If this is an ET_DYN executable (shared object),
 659          * determine its memory size so that mapelfexec() can load it.
 660          */
 661         if (ehdrp->e_type == ET_DYN)
 662                 len = elfsize(ehdrp, nphdrs, phdrbase, NULL);
 663         else
 664                 len = 0;
 665 
 666         dtrphdr = NULL;
 
 867                  * architecture-specific user per-LWP location. The dtrace
 868                  * fasttrap provider requires ready access to per-LWP scratch
 869                  * space. We assume that there is only one such program header
 870                  * in the interpreter.
 871                  */
 872                 if (dtrphdr != NULL &&
 873                     dtrace_safe_phdr(dtrphdr, args, voffset) != 0) {
 874                         VN_RELE(nvp);
 875                         uprintf("%s: Bad DTrace phdr in %s\n", exec_file, dlnp);
 876                         goto bad;
 877                 }
 878 
 879                 VN_RELE(nvp);
 880                 ADDAUX(aux, AT_SUN_LDDATA, voffset + lddata)
 881         }
 882 
 883         if (hasauxv) {
 884                 int auxf = AF_SUN_HWCAPVERIFY;
 885 
 886                 /*
 887                  * Note: AT_SUN_PLATFORM and AT_RANDOM were filled in via
 888                  * exec_args()
 889                  */
 890                 ADDAUX(aux, AT_BASE, voffset)
 891                 ADDAUX(aux, AT_FLAGS, at_flags)
 892                 ADDAUX(aux, AT_PAGESZ, PAGESIZE)
 893                 /*
 894                  * Linker flags. (security)
 895                  * p_flag not yet set at this time.
 896                  * We rely on gexec() to provide us with the information.
 897                  * If the application is set-uid but this is not reflected
 898                  * in a mismatch between real/effective uids/gids, then
 899                  * don't treat this as a set-uid exec.  So we care about
 900                  * the EXECSETID_UGIDS flag but not the ...SETID flag.
 901                  */
 902                 if ((setid &= ~EXECSETID_SETID) != 0)
 903                         auxf |= AF_SUN_SETUGID;
 904 
 905                 /*
 906                  * If we're running a native process from within a branded
 907                  * zone under pfexec then we clear the AF_SUN_SETUGID flag so
 908                  * that the native ld.so.1 is able to link with the native
 
 |