Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1517179imp; Fri, 22 Feb 2019 05:16:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IbWFEajfTZbgxPln4g+rleGiBgYsbESxYXDxRvDFwYTXq1lAliT4Qmf/FJn0yYF0O49kTbu X-Received: by 2002:a17:902:147:: with SMTP id 65mr4209329plb.116.1550841394140; Fri, 22 Feb 2019 05:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550841394; cv=none; d=google.com; s=arc-20160816; b=aXXVd4EW77dN8TceHtOfPMCUBua97zcVRoXeWpWwneqt/d7AkD8YpxM0jUJHLydyUB Uw3MGhXOmyZQjAhwgJrFQT1xAECUCAMHopO6QJsSWqP9WIhV1HgiS2EH2f8RyvHZtTD6 Imj4dsKs4YjLXvWjL4MetciGGc+tbFuYZzJwTuhkPmmpx5tmXa56G3CA9ByjXkKJkiyL QadQhxVZWge7xTXZs6za3fOq2/8mEGY/beGKJyI4T9+TY1RvMJ9+JyrFStMqdJ3dLW/2 IuBTYhPkbZ+aa9kg1BeghR5BJQMQuULTT0u+dEF5LwEII885TFLS91fyRn0R5vn1MjLl l8NQ== 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=fRfkbToKv+b7yDFcB+4r6684B7I+gtcuiYdWKbyseiM=; b=S91p3p7YHB1IU3x8gPwq55+bm6o4BghuFbKeej6cC++pojiQ/2n+uKjGrgw0O5eH2e lVwLmzvCCjhI+oo3R+iHDcMFyw7CN4jaG5TWZp3+HKl4uYIYx2LdM8OdZrbQENQtNyFn KSJUly+2w4eZJtODjHHbO8greiVZTfgB5mjchkk70agzB3GiSM0uAcvI+ZgDmFIAuPTn svR4AEpghZsFggiNm/P7g2I290nEyCqqGAYQr4g/BfqF8i2IiSSCfy3+Aa+Tu8X5aBvy LoYEkEhxY0p3NtI8GrFTEAQIHjSsh2BvU6IPC3FPl0Nj9iignCTAxo0ZbiThXv5oirtX 1EaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kinvolk.io header.s=google header.b=O8MC509q; 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 64si1398478plk.172.2019.02.22.05.16.18; Fri, 22 Feb 2019 05:16:34 -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=@kinvolk.io header.s=google header.b=O8MC509q; 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 S1726977AbfBVNPI (ORCPT + 99 others); Fri, 22 Feb 2019 08:15:08 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:42504 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbfBVNPH (ORCPT ); Fri, 22 Feb 2019 08:15:07 -0500 Received: by mail-oi1-f194.google.com with SMTP id s16so1641257oih.9 for ; Fri, 22 Feb 2019 05:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kinvolk.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fRfkbToKv+b7yDFcB+4r6684B7I+gtcuiYdWKbyseiM=; b=O8MC509qWJMK4qfCKuMSO9wyIuCSCnJSwt3nmg7XZOhNrHFPPmwUkSagEUx19tP5i6 hUoh6MRJv9MJ3dfCEMa/p9HjuDXSMx/tAzW1+NF1Yfezcu7itnx72iEjNnwGU78wT2OY AGK1ZsHRQPA/jNb/bypt7G+EVBuCQDeNuJz7o= 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=fRfkbToKv+b7yDFcB+4r6684B7I+gtcuiYdWKbyseiM=; b=kX4YIlbm2QvLFu+NxlvB93zAgDpjSrLteAQEZGtloMzs2XLIPIub8sT1sxy0OTBbNK IMYqyptf4FF2BgZmDkalQsvu0VhRa+hVDliok9DKQ7cfl7+3KPLrb0Cld00p9Cvh5zVN rBHyiES+SVSLhTPrloPIfdCaJK37eh27g5jC6uUz5ZCYSdAWkfLmOzv9w1euG5QXJyGe ibjFHeXb+WjkUpnovS+7SWgO9HHiQcqE5/tKjpMdtqp9/huKo7AN3LidieMy3hwje7q8 rrbCna2waorcb2R2dvB7nF9QUmUv4Hq0v65GXaPWHRhDAUzKy7Dsev+vwUq88jGTtYq6 Xu5A== X-Gm-Message-State: AHQUAuZzGmhx/jz+Z2jP3uGfIBpomJJm+KP9xJqcc8qq74nOVZiGjAVy D9aOtOWugVrSbJhXbjxAD2nPEU6KqbbXqmS61mnnqA== X-Received: by 2002:aca:4c58:: with SMTP id z85mr2403275oia.140.1550841306522; Fri, 22 Feb 2019 05:15:06 -0800 (PST) MIME-Version: 1.0 References: <20190221163926.15221-1-alban@kinvolk.io> <20190221222350.6u2jbtias2c3mgyy@kafai-mbp.dhcp.thefacebook.com> In-Reply-To: <20190221222350.6u2jbtias2c3mgyy@kafai-mbp.dhcp.thefacebook.com> From: Alban Crequy Date: Fri, 22 Feb 2019 14:14:55 +0100 Message-ID: Subject: Re: [PATCH bpf-next v1] bpf, lpm: fix lookup bug in map_delete_elem To: Martin Lau Cc: Alban Crequy , "ast@kernel.org" , "daniel@iogearbox.net" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "iago@kinvolk.io" , Craig Gallek 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 Thu, Feb 21, 2019 at 11:24 PM Martin Lau wrote: > > On Thu, Feb 21, 2019 at 05:39:26PM +0100, 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 > The change makes sense to me. Can you add this reproducer to > tools/testing/selftests/bpf/test_lpm_map.c? > > Bug fix should be for the "bpf" tree instead of "bpf-next" > Fixes tag is also required, like > > Fixes: e454cf595853 ("bpf: Implement map_delete_elem for BPF_MAP_TYPE_LPM_TRIE") > Cc: Craig Gallek Thanks! I'll send a v2 shortly with the selftest and the tags, based on "bpf" tree. Cheers, Alban > > Signed-off-by: Alban Crequy > > --- > > kernel/bpf/lpm_trie.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c > > index abf1002080df..93a5cbbde421 100644 > > --- a/kernel/bpf/lpm_trie.c > > +++ b/kernel/bpf/lpm_trie.c > > @@ -471,6 +471,7 @@ static int trie_delete_elem(struct bpf_map *map, void *_key) > > } > > > > if (!node || node->prefixlen != key->prefixlen || > > + node->prefixlen != matchlen || > > (node->flags & LPM_TREE_NODE_FLAG_IM)) { > > ret = -ENOENT; > > goto out; > > -- > > 2.20.1 > >