Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp616700img; Mon, 18 Mar 2019 10:19:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrmbsVFq/NVV7k2hlQQKdOUGeBqc19/iaPfUGUjhcdDGk0awrxcf5nb7QlmOKvIRVFSK0z X-Received: by 2002:aa7:8d43:: with SMTP id s3mr19919969pfe.118.1552929584996; Mon, 18 Mar 2019 10:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552929584; cv=none; d=google.com; s=arc-20160816; b=guKaHI4c6JJBZ+LVEDze+qPkyv/swqJ9scHnvzloZYlhHzmL2rJnFLaoMKPZsnsiGJ kAv137AvGrh+pqEMS3qc7+XgPyl9d3whm/EUfX/qJ7NKf4EMIoEM3Rbzh+uLyqtXTppz VABw76Mn4TWWr/fS6Wx+AP84L7HFa7/sZxXMfjRCzakpcrSutlAXfWvWSxN7vDjkhJB+ /LTapyd9umTQTn6HWAzMVBHdGim+O5gt17AlHXkZq+DgyHZXQQ8DBpjBqAM8WQ6KkMRT SMVHa1CRxyIZ3H2bPWkE9AIwfTDXS/CSqEYgiI7G7TWtWM813ifEcaBG+x7OXC4BA8Tw GJzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=hfuKek+o8vy+53O51p2MPtj2JUyumu3LZdujtPFxXko=; b=TQSID3/S52wRdmKq3N96HFU13ulSSYgdjKLufdsNPuyd9UkV6zoxcd6mYWstErRdp8 f+CWbreRM1qTebzUPG0szwL5BbDvFLHmFgF7xATSK5Fa5rcaD4IzWMFvA0gTnN0N/TMj KOABlJcdc9/JXfR+mx0ikp3rBYJpFKwSymClqO90AOeslaphVim7BYcCau6KACgTYbvT +9k6e+kBuQQYaVvZFLemvFLJ1Dj2SckmC1NLrngnKJIzD/FTixBheVhz3MClZNFcO0zv hQ+gz6SCc8AH33C9gW4NhbVHULJk1t1CFrc1JYXiplYDUIG/yPFrQ5SdAwT2fVHLzKtI BdOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OVRG0jDx; 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 x9si618582pgf.237.2019.03.18.10.19.29; Mon, 18 Mar 2019 10:19:44 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=OVRG0jDx; 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 S1728063AbfCRRS3 (ORCPT + 99 others); Mon, 18 Mar 2019 13:18:29 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:40712 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728035AbfCRRS1 (ORCPT ); Mon, 18 Mar 2019 13:18:27 -0400 Received: by mail-yw1-f73.google.com with SMTP id x2so3173757ywc.7 for ; Mon, 18 Mar 2019 10:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=hfuKek+o8vy+53O51p2MPtj2JUyumu3LZdujtPFxXko=; b=OVRG0jDx+a4bA2Xe0x2W0QLSaeWfLl/IABe0xhS3IFP8diCvylSVwKQWoIigEjNHVc yxjFs3rDXFN+YQZXXdBXqzoVuEhq+g8HP9vfnj/K/jnMV093FMqmv6YIj0itG5FlZbO1 ke03j95r0/PkzmDHuCN3H9fGFOQlTbWpbvmuT2QemWXQk/lZDOT0fPG1qeBd7bYvwCAL AE3Z9++g1iD+M29C/0LdG7U5gglyxyekWqwWKO87UeLRgDFAy26KL+NKf1x9Z+3nMGJh HWwxBBm2ki5StK4NVq41umliE7Ge0hSfeTd7JwuOJHWr+3LKBGyWEd26Ba9MwuaG3MTr +/EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hfuKek+o8vy+53O51p2MPtj2JUyumu3LZdujtPFxXko=; b=e1KZNpt9//t/EARekqt+SYrAtWZET71/83sS1Qmb6MzwXqWbNN2ATzSSTTHeuSr6qJ LhoUd7lIdPCSwRoqyMg9dy6pq3yA4QfLmVbmT0+g+WC6EtLmXcvD0854pwATASySruub xGVa1QlBGRb1Bi6e/JbwJWE4UsCyWDDaEJX+YvLe44y9cSHHRO3XygDr2hNTWrL0l8Ck 98gc/3OpoNOG2iIUgcMHFhsE6w9YxrhIayO4mH+eP6F1eFjCYq2FGA39KavWRhG8jiiA +heiVZ+I4I/B6GCFnBrKJl6NOGHmvS0wBWtVkMwy/KQCBgdYZwo5F5ZTfVHJ7LqB2xv8 GvTg== X-Gm-Message-State: APjAAAWedK5+3dMdJkbUun1xcs/HnzOGGWjnqlGo86eKcgDj2XjoYycO /vSUN5FZqAGl1ufaR3+9C7c+Kbur7hnS0qKT X-Received: by 2002:a25:e648:: with SMTP id d69mr9320791ybh.95.1552929506037; Mon, 18 Mar 2019 10:18:26 -0700 (PDT) Date: Mon, 18 Mar 2019 18:17:44 +0100 In-Reply-To: Message-Id: <7883ff7cbe2e8075c3a0f450eade08587f49f3bc.1552929301.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v12 12/13] bpf, arm64: untag user pointers in stack_map_get_build_id_offset From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , Vincenzo Frascino , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy , Andrey Konovalov 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 This patch is a part of a series that extends arm64 kernel ABI to allow to pass tagged user pointers (with the top byte set to something else other than 0x00) as syscall arguments. stack_map_get_build_id_offset() uses provided user pointers for vma lookups, which can only by done with untagged pointers. Untag the user pointer in this function for doing the lookup and calculating the offset, but save as is into the bpf_stack_build_id struct. Signed-off-by: Andrey Konovalov --- kernel/bpf/stackmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c index 950ab2f28922..bb89341d3faf 100644 --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c @@ -320,7 +320,9 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, } for (i = 0; i < trace_nr; i++) { - vma = find_vma(current->mm, ips[i]); + u64 untagged_ip = untagged_addr(ips[i]); + + vma = find_vma(current->mm, untagged_ip); if (!vma || stack_map_get_build_id(vma, id_offs[i].build_id)) { /* per entry fall back to ips */ id_offs[i].status = BPF_STACK_BUILD_ID_IP; @@ -328,7 +330,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, memset(id_offs[i].build_id, 0, BPF_BUILD_ID_SIZE); continue; } - id_offs[i].offset = (vma->vm_pgoff << PAGE_SHIFT) + ips[i] + id_offs[i].offset = (vma->vm_pgoff << PAGE_SHIFT) + untagged_ip - vma->vm_start; id_offs[i].status = BPF_STACK_BUILD_ID_VALID; } -- 2.21.0.225.g810b269d1ac-goog