[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181130.143537.2241990550018683260.davem@davemloft.net>
Date: Fri, 30 Nov 2018 14:35:37 -0800 (PST)
From: David Miller <davem@...emloft.net>
To: alexei.starovoitov@...il.com
Cc: daniel@...earbox.net, ast@...nel.org, netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next 1/4] bpf: Add BPF_F_ANY_ALIGNMENT.
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
Date: Fri, 30 Nov 2018 13:58:20 -0800
> On Thu, Nov 29, 2018 at 07:32:41PM -0800, David Miller wrote:
>> +/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
>> + * verifier will allow any alignment whatsoever. This bypasses
>> + * what CONFIG_EFFICIENT_UNALIGNED_ACCESS would cause it to do.
>
> I think majority of user space folks who read uapi/bpf.h have no idea
> what that kernel config does.
> Could you reword the comment here to say that this flag is only
> effective on architectures and like sparc and mips that don't
> have efficient unaligned access and ignored on x86/arm64 ?
Ok.
>> + if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) &&
>> + (attr->prog_flags & BPF_F_ANY_ALIGNMENT) &&
>> + !capable(CAP_SYS_ADMIN))
>> + return -EPERM;
>
> I guess we don't want to add:
> if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) &&
> (attr->prog_flags & BPF_F_ANY_ALIGNMENT))
> return -EINVAL;
>
> so that test_verifier.c can just unconditionally pass this flag
> on all archs ?
Right.
>> @@ -247,7 +249,11 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns,
>> attr.log_level = log_level;
>> log_buf[0] = 0;
>> attr.kern_version = kern_version;
>> - attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0;
>> + if (strict_alignment)
>> + prog_flags |= BPF_F_STRICT_ALIGNMENT;
>> + if (any_alignment)
>> + prog_flags |= BPF_F_ANY_ALIGNMENT;
>> + attr.prog_flags = prog_flags;
>
> instead of adding another argument may be replace 'int strict_alignment'
> with '__u32 prog_flags' ?
> and future flags won't need tweaks to bpf_verify_program() api.
Yeah the number of arguments are getting out of control, I'll do that.
Powered by blists - more mailing lists