Re: [PATCH bpf-next 1/2] bpf: Add bpf_lsm_set_bprm_opts helper
From: Alexei Starovoitov
Date: Mon Nov 16 2020 - 18:00:30 EST
On Mon, Nov 16, 2020 at 2:48 PM KP Singh <kpsingh@xxxxxxxxxxxx> wrote:
>
> [...]
>
> > >
> > > +BPF_CALL_2(bpf_lsm_set_bprm_opts, struct linux_binprm *, bprm, u64, flags)
> > > +{
> >
> > This should also reject invalid flags. I'd rather change this helper from RET_VOID
> > to RET_INTEGER and throw -EINVAL for everything other than BPF_LSM_F_BPRM_SECUREEXEC
> > passed in here including zero so it can be extended in future.
>
> Sounds good, I added:
>
> enum {
> BPF_LSM_F_BPRM_SECUREEXEC = (1ULL << 0),
> + /* Mask for all the currently supported BPRM options */
> + BPF_LSM_F_BRPM_OPTS_MASK = 0x1ULL,
> };
No need to add it to uapi.
Keep it next to the helper in .c file like it's done with other flags.