Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp159607imm; Tue, 31 Jul 2018 15:52:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfTi66UkLWoygp4oBXJX++94ayfrZphCSmZI6pE8bOUsIaschsH17OlU29O6QmZ/0A0VTDN X-Received: by 2002:a62:4695:: with SMTP id o21-v6mr24051943pfi.176.1533077559558; Tue, 31 Jul 2018 15:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533077559; cv=none; d=google.com; s=arc-20160816; b=scBYq0Zmm15tYxjZfbwCBuvhmkyL+DGXlEzUrrMTqTLAFmb/UFiGle+qqF+cC8mJrZ jSJ48SE+vvg6HYhuz+UdIfLZ8DDh3i+BN4wUrchPV+QcYF76I35ekJVpxJMdIXD3Fprx rBtdvTYwT+JjB+TwIT1WrPmPZRzhkIUbvxOzW4mEikNnwoS6gCHG5OVMNpOsUDhFQF2T gtdSdFbdrgOz8cDP6SadGvjwrffS5QB9FT/LiGdSp5/xq5AvvmqJJC/4IBjglHZfqF4e 3U5X6MH5YJKgLzROVMNsopb5cG+DbL+UEIX5WkVMdVQXBKWkgva7M3RUYw51GB1a912F Aihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=QZ31D2DQVWbyflBOjIlEEkydjgR3/B2Jb/qxdWk8QSQ=; b=XoVggZWvxqBNljAI/+/P8e1nVyUHVhkb/iJb9iGWqmGG8p6qYFfqNmXLIImB5wlQej CENZ1PT57onEsUbcntbh3YECeyu0J2END79uN97A9LVEmPAwHF/2DnpBaUBOsfbudn9v +am5tSsA61GSc35DB2NWwAn6W5M1deeR+Efec0l3HfgOuaY5yT5Vz5D9AQdoQkDzXCfS IhJ7vdtpMnibXFbjkwcpoqhLK6cy9wxyBw/4Es3CDMnuV+GAGO6/DhN94vRNuG8FOVez fkwryI5FH46mEaip7Mq7AWaK5tUtAooKqV1MREf2hzehS7DTkjZ+Fe6/Xd3VKf3hC5U+ XxcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1-v6si10184388plc.168.2018.07.31.15.52.21; Tue, 31 Jul 2018 15:52:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732775AbeHAAc6 (ORCPT + 99 others); Tue, 31 Jul 2018 20:32:58 -0400 Received: from www62.your-server.de ([213.133.104.62]:38536 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731637AbeHAAc6 (ORCPT ); Tue, 31 Jul 2018 20:32:58 -0400 Received: from [78.46.172.2] (helo=sslproxy05.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1fkdTD-0002Y5-Np; Wed, 01 Aug 2018 00:50:23 +0200 Received: from [62.203.87.61] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1fkdTD-000UsI-Ax; Wed, 01 Aug 2018 00:50:23 +0200 Subject: Re: [PATCH v4 bpf-next 08/14] bpf: introduce the bpf_get_local_storage() helper function To: Roman Gushchin , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, Alexei Starovoitov References: <20180727215243.3850-1-guro@fb.com> <20180727215243.3850-9-guro@fb.com> From: Daniel Borkmann Message-ID: Date: Wed, 1 Aug 2018 00:50:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180727215243.3850-9-guro@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.0/24800/Tue Jul 31 18:43:36 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/27/2018 11:52 PM, Roman Gushchin wrote: [...] > @@ -2533,6 +2541,16 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn > } > > regs = cur_regs(env); > + > + /* check that flags argument in get_local_storage(map, flags) is 0, > + * this is required because get_local_storage() can't return an error. > + */ > + if (func_id == BPF_FUNC_get_local_storage && > + !tnum_equals_const(regs[BPF_REG_2].var_off, 0)) { > + verbose(env, "get_local_storage() doesn't support non-zero flags\n"); > + return -EINVAL; > + } Hmm, this check is actually not correct. You will still be able to pass non-zero values in there. arg2_type from the helper is ARG_ANYTHING, so the register type could for example be one of the pointer types and it will still pass the verifier. The correct way to check would be to use register_is_null(). > + > /* reset caller saved regs */ > for (i = 0; i < CALLER_SAVED_REGS; i++) { > mark_reg_not_init(env, regs, caller_saved[i]);