Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1607111imp; Fri, 22 Feb 2019 07:05:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IbAtp1uUAXZzTt4eFt/hGI03nJE/MqpNTYbOyr0HLJKcZDC7wIRz1p8lDRw2dArDPgCCFR8 X-Received: by 2002:a17:902:7590:: with SMTP id j16mr4647508pll.304.1550847901321; Fri, 22 Feb 2019 07:05:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550847901; cv=none; d=google.com; s=arc-20160816; b=qBt2wRXKQpFzS7o/2QFmUm56LPoN3bI/8KPRGgpQEx5L2LZBPnaEBT4KhHnzHWZ6l5 UD+d3WqlfApMYVDMdXadmqpoWDThfuWzt27lVhB5j1A4PxuD/eRa4evU2O7TCKU4xLQ8 S4TZXrpIBbAq0dkkPEdCEpwPcly0Sw1LnLs+hLh36bIJplveD4pmFhTBu2jBj9kvTKR9 1ONg/wDFQSUiFshVjiq0/jpBHL4spweeyBsogH65v6hlgFPqklZ7Gxem0yZBgbMnEJoB uxbonVGgyUWCrBPJHNi5XUPrm6jtYu1Pc9vl92DJsvOlEdU1ZdhYdXulKUgX+1CZDGW+ ezwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Bejm64Z0NlM1ZDVFnZXR7yBhoaJ/IR36fFRkAXegVm0=; b=Foe6RQw/2PZHYsKEKtHcGq/6iJ+92nfXdMhgf9q4VgmJxrhqsCQ93llIIpcC81jX8p BT0j1FsTj/RLsqjghBShitEuc+zWPQA0cNs7ug5mUuu3BcCj1H/LtGblZg9xd90WVD12 lL54MvVWXw8PINhzR+/tr1PhvbYr0NZTIgiHLl0o5JEecjRR4LEPEWlxjuuPArfGBwGs g70htDPs3j48fj02DQsTBqqGmJ9Y4PeBOzTMD1E9CvpNxyu/AtZumxdZtnTO61k5UlV3 iVcIltGM2CtEwhr+dnz5ZSU6zhR7yK5RkSBXyFLT0K0u73mJbxtgoo/WXowPDynC4Hi7 mQQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d8HbxDgj; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si1571273pfi.247.2019.02.22.07.04.44; Fri, 22 Feb 2019 07:05:01 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=d8HbxDgj; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbfBVPDw (ORCPT + 99 others); Fri, 22 Feb 2019 10:03:52 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:34631 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbfBVPDw (ORCPT ); Fri, 22 Feb 2019 10:03:52 -0500 Received: by mail-qt1-f193.google.com with SMTP id w4so2827946qtc.1 for ; Fri, 22 Feb 2019 07:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Bejm64Z0NlM1ZDVFnZXR7yBhoaJ/IR36fFRkAXegVm0=; b=d8HbxDgjp4yF/OlAcZED4bdka/TzPrWmRJnxRgTaeMZnhIAs6bQYcFVex9aNuieYbz ljaMTku8TACvmHGOe94dMdlDx2Hs4IYZBMlWHn9UOX3DZxmNzHp6S8vltaLFAg+co7Pj f+cJMgcg5MO+Wr/wno/nSDJHM68nGavspMiKOgc/zPedU0u3awiLTceQ48k/r+9wLgKX JYC3vBR00c+gm+vRXbKyWfueuQO13bG9eCXxaGOwvSw6u6uNVocD+oBcluIYMU8kTepA vT6W2MscXsBVaWF+ENAUEIUBvED0tRXqL3BA+dhQ6PFaYmTHOWnomtEZYOsBfArtR7p8 lFag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Bejm64Z0NlM1ZDVFnZXR7yBhoaJ/IR36fFRkAXegVm0=; b=PG/MoQVdCIX4pDo8DU/9YWYt1BxmUJm2+wrsjTNUbDmNgFRbhb45y/Kn6YlI34t+PU xBoyWbOZBpV0hGZgTrpGyq4f9XftdBLVSXoqT+9RLrIzj9/rzrI5GAE3oV2gloeEcSux aSzwh4F9xft/r3tmP469kuxzx4mRjuBmCrb8qY4T8keRLGsm40LwhioNMNLK9H6x7qCN P2YjE7QZ+NV2GbWXzNy+G4/wsD9vdLvtsd7gUGupuIuDEJhSQFv6rl65u76VwcTGeN/g ntZzyNk9shpsCLueY1Fx05PD0eg9H1mVRI9viC32ifj6IX8pNB7s5R0RXq8juhUKdc3q 8x6w== X-Gm-Message-State: AHQUAuY+GL0KnThrL/qbYmXl7U9/evqonSgzvG8cBQUsABZ/tFginWoi aT2a0XTKYx8o8UODFGuFsOcarXElqtBu4KckMzXM69qj5UQ= X-Received: by 2002:aed:37e7:: with SMTP id j94mr3463043qtb.282.1550847831182; Fri, 22 Feb 2019 07:03:51 -0800 (PST) MIME-Version: 1.0 References: <20190222131908.6207-1-alban@kinvolk.io> In-Reply-To: <20190222131908.6207-1-alban@kinvolk.io> From: Craig Gallek Date: Fri, 22 Feb 2019 10:03:40 -0500 Message-ID: Subject: Re: [PATCH bpf v2] bpf, lpm: fix lookup bug in map_delete_elem To: Alban Crequy Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , netdev , LKML , alban@kinvolk.io, iago@kinvolk.io Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 22, 2019 at 8:19 AM 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 > > --- Acked-by: Craig Gallek Good catch, thanks for the fix!