Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1625109imp; Fri, 22 Feb 2019 07:24:18 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia6G0cpc619R+AXh+Rmqf0vjrWqN6HCf1kWjkpKfy2wn994b1j1wpuJclsa38T3QTGZbe/x X-Received: by 2002:a62:d10b:: with SMTP id z11mr4763572pfg.84.1550849058110; Fri, 22 Feb 2019 07:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550849058; cv=none; d=google.com; s=arc-20160816; b=0EpaADy+BxfocVjbTptndJdrSyPXnCzNOhYhYJnpSQBfDIlEEDBE3sPEdRRr/akAKp kXjwFhIeLHJ7hrTnmwY3GOWmij3oR9XKUPOdmm83IVf4MYcPIalobDlYy7HPonrZDaub jUydtL0ZCTQchm3mG9ZJhgynFZLRl0LSmCC55yHUjJ/OqDgXxpmJCQ5NfzX/uw0hhheG 3yZTJSQSvre5plksIvgz7//QwnGFcik+lAzOZ5brP/VU+kXnxjy8NWdcGAiGSJdLKgXA jxIdxIjV14wZQzixkQ4mg4Sv8Dw09aO1fK6LevEn4SPNwRhekf08PhtZDVDpaCCfHehJ Uuww== 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; bh=jqFo+YjjluleqvQMt1xPIESn5QRfGq/XfaWRqtrd7XE=; b=DsH8QB5Dg/SBKCFouvJbNdSYUK4+zTZ220rJL2MJ5QjqSGVDhXIHUGJqi7p8PzBD4q dzw92z1GqAsYiG3HYO5Utdmn84/0vN1j8vSjjoC6LwaYu5NqgFgusndNBjZbyA5u4icG ohjvuBUuTz8O0azu8uthourKMFoQtJ8CEJgsgaZx+EeY+nRgTXdV6G22mm+JFeva4Tc3 PZKlURuFrzQQ2B8kic1tyPHeyI2+WDBE8BAhSwIYDQDypKAmhfeyuqTq0ZcpynkvTicU hNMKvloVqaryr5ZDtpMDHIfzTc/gLa+Gy+K2aNYDn4ZzCjGJyVG7V+TT5Mt/Fbb35flI L0fA== 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 b98si1644913plb.230.2019.02.22.07.24.02; Fri, 22 Feb 2019 07:24:18 -0800 (PST) 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 S1727039AbfBVPW6 (ORCPT + 99 others); Fri, 22 Feb 2019 10:22:58 -0500 Received: from www62.your-server.de ([213.133.104.62]:55458 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbfBVPW6 (ORCPT ); Fri, 22 Feb 2019 10:22:58 -0500 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1gxCf7-00060o-9Z; Fri, 22 Feb 2019 16:22:53 +0100 Received: from [178.197.248.36] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gxCf7-0005kY-1O; Fri, 22 Feb 2019 16:22:53 +0100 Subject: Re: [PATCH bpf v2] bpf, lpm: fix lookup bug in map_delete_elem To: Alban Crequy , ast@kernel.org Cc: kafai@fb.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alban@kinvolk.io, iago@kinvolk.io References: <20190222131908.6207-1-alban@kinvolk.io> From: Daniel Borkmann Message-ID: <3ee7ff6a-116b-efea-bf81-045b882f28d1@iogearbox.net> Date: Fri, 22 Feb 2019 16:22:51 +0100 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: <20190222131908.6207-1-alban@kinvolk.io> 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.2/25368/Fri Feb 22 11:32:58 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/22/2019 02:19 PM, Alban Crequy wrote: > From: Alban Crequy > > trie_delete_elem() was deleting an entry even though it was not matching > if the prefixlen was correct. This patch adds a check on matchlen. > > Reproducer: > > $ sudo bpftool map create /sys/fs/bpf/mylpm type lpm_trie key 8 value 1 entries 128 name mylpm flags 1 > $ sudo bpftool map update pinned /sys/fs/bpf/mylpm key hex 10 00 00 00 aa bb cc dd value hex 01 > $ sudo bpftool map dump pinned /sys/fs/bpf/mylpm > key: 10 00 00 00 aa bb cc dd value: 01 > Found 1 element > $ sudo bpftool map delete pinned /sys/fs/bpf/mylpm key hex 10 00 00 00 ff ff ff ff > $ echo $? > 0 > $ sudo bpftool map dump pinned /sys/fs/bpf/mylpm > Found 0 elements > > A similar reproducer is added in the selftests. > > Without the patch: > > $ sudo ./tools/testing/selftests/bpf/test_lpm_map > test_lpm_map: test_lpm_map.c:485: test_lpm_delete: Assertion `bpf_map_delete_elem(map_fd, key) == -1 && errno == ENOENT' failed. > Aborted > > With the patch: test_lpm_map runs without errors. > > Fixes: e454cf595853 ("bpf: Implement map_delete_elem for BPF_MAP_TYPE_LPM_TRIE") > Cc: Craig Gallek > Signed-off-by: Alban Crequy Applied, thanks!