Re: [PATCH 2/3] exec: inherit HWCAPs from the parent process
Michal Koutný <[email protected]> Mon, 12 Jan 2026 13:46:44 +0100
| Newsgroups | dev.linux.lists.criu,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <wfl47fj3l4xhffrwuqfn5pgtrrn3s64lxxodnz5forx7d4x443@spsi3sx33lnf> |
On Thu, Jan 08, 2026 at 05:07:47AM +0000, Andrei Vagin <[email protected]> wrote: > @@ -1780,6 +1791,50 @@ static int bprm_execve(struct linux_binprm *bprm) > return retval; > } > > +static void inherit_hwcap(struct linux_binprm *bprm) > +{ > + int i, n; > + > +#ifdef ELF_HWCAP4 > + n = 4; > +#elif defined(ELF_HWCAP3) > + n = 3; > +#elif defined(ELF_HWCAP2) > + n = 2; > +#else > + n = 1; > +#endif Is it guaranteed that HWCAP n+1 exists only when n does? (To make this work.) > + > + for (i = 0; n && i < AT_VECTOR_SIZE; i += 2) { > + long val = current->mm->saved_auxv[i + 1]; > + > + switch (current->mm->saved_auxv[i]) { > + case AT_HWCAP: > + bprm->hwcap = val & ELF_HWCAP; > + break; > +#ifdef ELF_HWCAP2 > + case AT_HWCAP2: > + bprm->hwcap2 = val & ELF_HWCAP2; > + break; > +#endif > +#ifdef ELF_HWCAP3 > + case AT_HWCAP3: > + bprm->hwcap3 = val & ELF_HWCAP3; > + break; > +#endif > +#ifdef ELF_HWCAP4 > + case AT_HWCAP4: > + bprm->hwcap4 = val & ELF_HWCAP4; > + break; > +#endif > + default: > + continue; > + } > + n--; > + } > + mm_flags_set(MMF_USER_HWCAP, bprm->mm); Will this work when mm->saved_auxv isn't set by the prctl (it is zeroes?)? Thanks, Michal
signature.asc
(application/pgp-signature, 265 B)
-----BEGIN PGP SIGNATURE----- iJEEABYKADkWIQRCE24Fn/AcRjnLivR+PQLnlNv4CAUCaWTtMRsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIACgkQfj0C55Tb+AisSAEA3jOw1q2q7fyDcfOoeTcd ydeYIa3MJ59Bw5P1NbVJP0YA/0e1/9IiJ/h7y8JbPASpknLbuJY7oLSlA/zl9MUy MJQF =Iqi6 -----END PGP SIGNATURE-----