Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021AbaGCAB1 (ORCPT ); Wed, 2 Jul 2014 20:01:27 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:59745 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbaGCABZ (ORCPT ); Wed, 2 Jul 2014 20:01:25 -0400 MIME-Version: 1.0 In-Reply-To: References: <1403913966-4927-1-git-send-email-ast@plumgrid.com> <1403913966-4927-9-git-send-email-ast@plumgrid.com> Date: Wed, 2 Jul 2014 17:01:24 -0700 Message-ID: Subject: Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier From: Alexei Starovoitov To: Chema Gonzalez Cc: "David S. Miller" , Ingo Molnar , Linus Torvalds , Steven Rostedt , Daniel Borkmann , Eric Dumazet , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Thomas Gleixner , "H. Peter Anvin" , Andrew Morton , Kees Cook , Linux API , Network Development , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 2, 2014 at 4:35 PM, Chema Gonzalez wrote: > On Wed, Jul 2, 2014 at 4:04 PM, Alexei Starovoitov wrote: >>>> + reg = regs + BPF_REG_1; /* 1st arg to a function */ >>>> + reg->ptr = PTR_TO_CTX; >>> Wait, doesn't this depend on doing "BPF_MOV64_REG(BPF_REG_CTX, >>> BPF_REG_ARG1)" (the bpf-to-ebpf prologue), which is only enforced on >>> filters converted from bpf? In fact, shouldn't this set >>> regs[BPF_REG_CTX] instead of regs[BPF_REG_1] ? >> >> nope. it's REG_1. >> as you said r6=r1 is only emitted by converted classic filters. >> Verifier will see this 'r6=r1' assignment and will copy the r1 type into r6. > You're right. I read BPF_MOV64_REG() AT&T-syntax-style. > > BTW, check_stack_write() in kernel/bpf/verifier.c has a couple of > assignments of a slot->ptr to 0 (instead of INVALID_PTR). I assume > this is unintended. yes. good catch. Will fix it. Too bad C compiler silently casts integers to enums -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/