From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933485AbdKBR6x (ORCPT ); Thu, 2 Nov 2017 13:58:53 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:43295 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932383AbdKBR6u (ORCPT ); Thu, 2 Nov 2017 13:58:50 -0400 X-Google-Smtp-Source: ABhQp+Q3fHGJ1Q/gvL7jUEpe+/3BlzWbhC4OlTymoIpo2M6Zf+STozKCMmvtnerdFtMM//Euwt5VyQ== Date: Thu, 2 Nov 2017 10:58:46 -0700 From: Jakub Kicinski To: Arnd Bergmann Cc: Alexei Starovoitov , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Edward Cree , John Fastabend , Networking , Linux Kernel Mailing List Subject: Re: [PATCH 2/2] [net-next] bpf: fix out-of-bounds access warning in bpf_check Message-ID: <20171102105846.2609f1ec@cakuba.netronome.com> In-Reply-To: References: <20171102110558.2746221-1-arnd@arndb.de> <20171102110558.2746221-2-arnd@arndb.de> <20171102155945.vvrrugvhrgdvvkso@ast-mbp> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Nov 2017 17:14:00 +0100, Arnd Bergmann wrote: > On Thu, Nov 2, 2017 at 4:59 PM, Alexei Starovoitov wrote: > > On Thu, Nov 02, 2017 at 12:05:52PM +0100, Arnd Bergmann wrote: > >> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > >> index 750aff880ecb..debb60ad08ee 100644 > >> --- a/kernel/bpf/verifier.c > >> +++ b/kernel/bpf/verifier.c > >> @@ -4447,6 +4447,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr) > >> struct bpf_verifer_log *log; > >> int ret = -EINVAL; > >> > >> + /* no program is valid */ > >> + if (ARRAY_SIZE(bpf_verifier_ops) == 0) > >> + return -EINVAL; > > > > sorry I don't see how bpf_verifier_ops can be empty. > > Did you mix it up with your previous patch when you made bpf_analyzer_ops empty? > > I confused the two a couple of times while creating the patches, but > I'm still fairly > sure I got it right in the end: > > bpf_verifier_ops is an array that gets generated by including linux/bpf_types.h. > That file has two kinds of entries: > > - BPF_MAP_TYPE() entries are left out, as that macro is defined to an > empty string > here. > > - BPF_PROG_TYPE() entries are conditional depending on CONFIG_NET and > CONFIG_BPF_EVENTS. In the configuration that produces the warning, > both are disabled. Right. My preferred fix was to add a NULL entry to the table so it's never empty, but this is OK too. Thanks!