On 30 August 2013 00:46, Laurent Vivier <laur...@vivier.eu> wrote:
> The binfmt_misc module can calculate the credentials and security
> token according to the binary instead of to the interpreter if the
> 'C' flag is enabled.
>
> To be able to execute non-readable binaries, this flag implies 'O'
> flag. When 'O' flag is enabled, bintfmt_misc opens the file for
> reading and pass the file descriptor to the interpreter.
>
> References:
> linux/Documentation/binfmt_misc.txt          ['O' and 'C' description]
> linux/fs/binfmt_misc.c linux/fs/binfmt_elf.c [ AT_EXECFD usage ]

> +static int get_execfd(char **envp)
> +{
> +    typedef struct {
> +        long a_type;
> +        long a_val;
> +    } auxv_t;
> +    auxv_t *auxv;
> +
> +    while (*envp++ != NULL) {
> +        ;
> +    }
> +
> +    for (auxv = (auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
> +        if (auxv->a_type == AT_EXECFD) {
> +            return auxv->a_val;
> +        }
> +    }
> +    return -1;
> +}

This looks OK in principle, but this is going to clash
with RTH's auxval related patchset
http://patchwork.ozlabs.org/patch/268006/

so some coordination might be a good idea.

thanks
-- PMM

Reply via email to