Received: by 10.223.185.111 with SMTP id b44csp906070wrg; Fri, 9 Mar 2018 16:31:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvVXIgZgPLwRwNW5NY9i8RDJLUpfL8lNZ4ztDIz4AEl3svNZMmtC3+3MDQcM7vCh2qdwi+T X-Received: by 2002:a17:902:7404:: with SMTP id g4-v6mr327604pll.235.1520641883285; Fri, 09 Mar 2018 16:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520641883; cv=none; d=google.com; s=arc-20160816; b=VepRl9+4bTCle9Zwqi/DzMtvHWjksaqVTYZZIMaXGP4WF1KoxGUzli+YN3iVMbYnci 6hTpXOOB1sN8Y+X+KzVOdwbqV2AatNSyGFcsbPb00c/xCdKRZRKqzJ1V/Dv7Wqnit6+m MmSNXPPjqf0G2LsYIb3KQgfLQuMNH7quAwq/QirprONlSwBuJcy8EHGZ3nYK+VJO5nPD Q821m/OsiNNeBOT8zd0gaT0tsCkW1tJoEJYyMtKWUX0ptSIcQCuFhOdnf2ZP+AaPx4Ug nTTUnqoqHaRMw3+qokl8bNGnjPP7IyKeXGxIsEMUdPHuoodZHXhEhUdIamrG5Gerfsj4 6faA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rOlN72Wrqt3iRvO/8cjcePeqTabflSSFFTo9eohfR+Q=; b=sz3pSJuv0WxId1eExauqljQUHjhSN+jIJEeKsttUZuXgKCMrxSGLJ+DsuTCsC5TM9G Sy5dFDgzHuZM6mpX11EY+Hj0uBjIeM3RgxDp3IaTQ1IvgBhUntrUIriHxRPQetitwvkT p4ukCyxofZpbsXHEhsiYn1LvomVJxcLnJ6fZYtOczmZWRgdz8eewUgeH5VnvCY/o3AIu jSlOQiV5Mf6WfBC5qI/F2AZixkGfMJeRRzZgbEHeYKpPK1HGRSCoDBObY4uT4q4veCz+ XGjHfGiTbF9/Jsdf0qjqUb987LlMqyu8qYTgkwj8OWkSS7WS/FkKQ36CrBHLuNBouObP /Mkg== 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 37-v6si1777814ple.599.2018.03.09.16.31.08; Fri, 09 Mar 2018 16:31:23 -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 S934009AbeCJAXB (ORCPT + 99 others); Fri, 9 Mar 2018 19:23:01 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40286 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933647AbeCJAW6 (ORCPT ); Fri, 9 Mar 2018 19:22:58 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 51CBB119A; Sat, 10 Mar 2018 00:22:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, "David S . Miller" , Jarno Rajahalme Subject: [PATCH 4.9 59/65] bpf: fix wrong exposure of map_flags into fdinfo for lpm Date: Fri, 9 Mar 2018 16:18:59 -0800 Message-Id: <20180310001830.032356503@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann [ upstream commit a316338cb71a3260201490e615f2f6d5c0d8fb2c ] trie_alloc() always needs to have BPF_F_NO_PREALLOC passed in via attr->map_flags, since it does not support preallocation yet. We check the flag, but we never copy the flag into trie->map.map_flags, which is later on exposed into fdinfo and used by loaders such as iproute2. Latter uses this in bpf_map_selfcheck_pinned() to test whether a pinned map has the same spec as the one from the BPF obj file and if not, bails out, which is currently the case for lpm since it exposes always 0 as flags. Also copy over flags in array_map_alloc() and stack_map_alloc(). They always have to be 0 right now, but we should make sure to not miss to copy them over at a later point in time when we add actual flags for them to use. Fixes: b95a5c4db09b ("bpf: add a longest prefix match trie map implementation") Reported-by: Jarno Rajahalme Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov Signed-off-by: David S. Miller Signed-off-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/arraymap.c | 1 + kernel/bpf/stackmap.c | 1 + 2 files changed, 2 insertions(+) --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -107,6 +107,7 @@ static struct bpf_map *array_map_alloc(u array->map.key_size = attr->key_size; array->map.value_size = attr->value_size; array->map.max_entries = attr->max_entries; + array->map.map_flags = attr->map_flags; array->elem_size = elem_size; if (!percpu) --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c @@ -88,6 +88,7 @@ static struct bpf_map *stack_map_alloc(u smap->map.key_size = attr->key_size; smap->map.value_size = value_size; smap->map.max_entries = attr->max_entries; + smap->map.map_flags = attr->map_flags; smap->n_buckets = n_buckets; smap->map.pages = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT;