From patchwork Fri Mar 15 19:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10855515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED4B513B5 for ; Fri, 15 Mar 2019 19:52:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB6A12AC54 for ; Fri, 15 Mar 2019 19:52:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBEDA2AC57; Fri, 15 Mar 2019 19:52:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A0CB2AC54 for ; Fri, 15 Mar 2019 19:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727548AbfCOTw0 (ORCPT ); Fri, 15 Mar 2019 15:52:26 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:51353 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbfCOTwX (ORCPT ); Fri, 15 Mar 2019 15:52:23 -0400 Received: by mail-yw1-f73.google.com with SMTP id l11so13014301ywl.18 for ; Fri, 15 Mar 2019 12:52:22 -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=UI7aEl8s0mFedqqMgOc8iwA/qQRORzYcgfY9MOX1Q3Q=; b=vfItA5WBR9mxsOR5v/mXd6WRiw4qlJltvNcK03CJ3M5tD9oVwrnLXYPI73iFuFVvAy bStP8xOii4yXjBbLTiAyKSB+txWVCS5HbLg7oCB6RFMjQ5I07jr4SiImmyWLTfMKN0Vo z36zX4CJInXJMuVWsluFJtX4mg9tVYzK2laFJNn9axSKJXusl77n+y3QdI2KYR44uRZK TdwpdeFyx3tJBo/3IPC6BPg3PY4+1i133Q8TRIUuSaS8J+5QIn7rjJkfF42EQR9AUQXB a+dyvkdV6VlmT38t3+1yugNVaOElo8rNqqI8UQ90j7irslaNCh2z5PcCU9Uzw8Cc9GWC No2Q== 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=UI7aEl8s0mFedqqMgOc8iwA/qQRORzYcgfY9MOX1Q3Q=; b=MVEqdj0ADrfBsRhiZEEFW4bwo+byxRPEtVSiSyYFmbiuoU83BRdvDmK7KVlseom0pO oxeFZ1nnHbAjxi9G/ijES7nsyidZxVjcbizciQM9MuHZz6bjCZ1lbs3QtQd3aHSUwH8m S8X6jrJsohZnngxGLcVBDz+DGGyYlA46IrFKtcKYnUak9xY6M+RoSSRvrrtZAXPrGy+9 7b3iksOiOVFyEQQUC2yH+cCQdpcjOHCX6WdmTavmv/ctf3CNcsK8dU42SaHyGdZNcDKj rOLCIS/o6NHs2E0G3vMMuDqH1zBvOTNqnKo5Rg7Ez+MUGoPViQdMSKqBNlH3ZuoAHSqS 5Alg== X-Gm-Message-State: APjAAAXe7/i1qhUkozutc2Rg4Ko63bFe3Kg/+UEOPwqxKirDw4TQf6Qx qXwAKC+Nsv2Yn4rRzIDZDKVqa2R6ZW+iTpZc X-Google-Smtp-Source: APXvYqxeRzK18KUJ10+PDA+W93JZa2qDw/GudrGBEMPcLUXJuZN92dXCZ+z04uJTKknTff4jbLvWVF1Z13ZfBUn3 X-Received: by 2002:a5b:44e:: with SMTP id s14mr2709444ybp.100.1552679541907; Fri, 15 Mar 2019 12:52:21 -0700 (PDT) Date: Fri, 15 Mar 2019 20:51:36 +0100 In-Reply-To: Message-Id: <0e1bd7fbde338061ea54234b3b1bd5ab6102381e.1552679409.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.360.g471c308f928-goog Subject: [PATCH v11 12/14] 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 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 ++++-- p | 45 ------------------------------------------- 2 files changed, 4 insertions(+), 47 deletions(-) delete mode 100644 p 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; } diff --git a/p b/p deleted file mode 100644 index 9d6fa5386e55..000000000000 --- a/p +++ /dev/null @@ -1,45 +0,0 @@ -commit 1fa6fadf644859e8a6a8ecce258444b49be8c7ee -Author: Andrey Konovalov -Date: Mon Mar 4 17:20:32 2019 +0100 - - kasan: fix coccinelle warnings in kasan_p*_table - - kasan_p4d_table, kasan_pmd_table and kasan_pud_table are declared as - returning bool, but return 0 instead of false, which produces a coccinelle - warning. Fix it. - - Fixes: 0207df4fa1a8 ("kernel/memremap, kasan: make ZONE_DEVICE with work with KASAN") - Reported-by: kbuild test robot - Signed-off-by: Andrey Konovalov - -diff --git a/mm/kasan/init.c b/mm/kasan/init.c -index 45a1b5e38e1e..fcaa1ca03175 100644 ---- a/mm/kasan/init.c -+++ b/mm/kasan/init.c -@@ -42,7 +42,7 @@ static inline bool kasan_p4d_table(pgd_t pgd) - #else - static inline bool kasan_p4d_table(pgd_t pgd) - { -- return 0; -+ return false; - } - #endif - #if CONFIG_PGTABLE_LEVELS > 3 -@@ -54,7 +54,7 @@ static inline bool kasan_pud_table(p4d_t p4d) - #else - static inline bool kasan_pud_table(p4d_t p4d) - { -- return 0; -+ return false; - } - #endif - #if CONFIG_PGTABLE_LEVELS > 2 -@@ -66,7 +66,7 @@ static inline bool kasan_pmd_table(pud_t pud) - #else - static inline bool kasan_pmd_table(pud_t pud) - { -- return 0; -+ return false; - } - #endif - pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss;