Re: [PATCH bpf-next v3 2/2] bpf: Add tests for bpf_lsm_set_bprm_opts

From: Martin KaFai Lau
Date: Tue Nov 17 2020 - 01:18:43 EST


On Tue, Nov 17, 2020 at 02:13:07AM +0000, KP Singh wrote:
> From: KP Singh <kpsingh@xxxxxxxxxx>
>
> The test forks a child process, updates the local storage to set/unset
> the securexec bit.
>
> The BPF program in the test attaches to bprm_creds_for_exec which checks
> the local storage of the current task to set the secureexec bit on the
> binary parameters (bprm).
>
> The child then execs a bash command with the environment variable
> TMPDIR set in the envp. The bash command returns a different exit code
> based on its observed value of the TMPDIR variable.
>
> Since TMPDIR is one of the variables that is ignored by the dynamic
> loader when the secureexec bit is set, one should expect the
> child execution to not see this value when the secureexec bit is set.
>
> Signed-off-by: KP Singh <kpsingh@xxxxxxxxxx>
Acked-by: Martin KaFai Lau <kafai@xxxxxx>