Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp353695img; Mon, 18 Mar 2019 04:49:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5TvgvWD20oYumtKwl0TMX6U+R1jVSqxfIJy5cAd28nsQ8lfkrQ/8WRVOCsRyF0RcDEK8D X-Received: by 2002:a63:7c07:: with SMTP id x7mr17518595pgc.284.1552909748472; Mon, 18 Mar 2019 04:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552909748; cv=none; d=google.com; s=arc-20160816; b=Dsjp4GdeAjgfLExkXLQ1gWyx/OmWi1nauEv1Et7AYTzCS98HuOu5XHehqhIe4TWlXR 9lKXKjiD1qfFsgbqVpNN9cCG2DOiF2bR49o3MBXAJkI+BMH7Obko0/B/4QfWx916zW1+ gZ4Ze9ujpy+biJuJAvCgIJQAhBe+zxdvvd9D8BEjnHxahpuoCaRCcs0Vt1E8rNMRAwut TUQQLR4a8utQyyJSuh6SFvBLn/HiqoE3meRhmhXy3eSi+r2Olthpzg0CHmzmNWZFMbZn 100/z+oJScvsbKYu5xSvkZY2lVpEZqDHw76MLIQexHy271puhuIixKs7jHuwZPluxCgu V/Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=cAjTK3lSVPrV3KWiYH4fM9uStQ4aYws3H7LOYwr+AhA=; b=Iv2PzGyEA1GEUdXhJQOoN2EQrrEnvCsyvLNoPMcXYL9nPoHmPb0X2g1Ppvw7YSllEH SULrFmnc9TlVbB9RQivWHeFWXA0mJFNNV/s5yYCSVOfAPj0tNNqWcZrfMfPYnD6LI89B UfvYG4Lq/Lp3OJxvc9KYRfJqbQGTMve61odpTBB0vRvBkxXpLCXEKiDiqlo6OBQ9pqqI sVVOzPXPVUAxL0qNNRN/g24tZz+cUXDdp5j2M0kMdwBwSdIqNsQ5MGsawyc0cY2XDs5S wzDOMhHycAXTjkn6PFVvRw9IZXIr2Y2k5DjnI/fTKMVKMBPGFaFWTQMwn8Dkbwi1M4oB 8/wQ== 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 m15si9071911pls.433.2019.03.18.04.48.53; Mon, 18 Mar 2019 04:49:08 -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; 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 S1727503AbfCRLrZ (ORCPT + 99 others); Mon, 18 Mar 2019 07:47:25 -0400 Received: from foss.arm.com ([217.140.101.70]:60942 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbfCRLrY (ORCPT ); Mon, 18 Mar 2019 07:47:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 02AC81650; Mon, 18 Mar 2019 04:47:24 -0700 (PDT) Received: from [10.1.199.35] (e107154-lin.cambridge.arm.com [10.1.199.35]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D824F3F614; Mon, 18 Mar 2019 04:47:17 -0700 (PDT) Subject: Re: [PATCH v11 09/14] kernel, arm64: untag user pointers in prctl_set_mm* To: Andrey Konovalov , 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 , Szabolcs Nagy References: From: Kevin Brodsky Message-ID: <96675b72-d325-0682-4864-b6a96f63f8fd@arm.com> Date: Mon, 18 Mar 2019 11:47:15 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/03/2019 19:51, Andrey Konovalov wrote: > 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. > > prctl_set_mm() and prctl_set_mm_map() use provided user pointers for vma > lookups, which can only by done with untagged pointers. > > Untag user pointers in these functions. > > Signed-off-by: Andrey Konovalov > --- > kernel/sys.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/kernel/sys.c b/kernel/sys.c > index 12df0e5434b8..8e56d87cc6db 100644 > --- a/kernel/sys.c > +++ b/kernel/sys.c > @@ -1993,6 +1993,18 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data > if (copy_from_user(&prctl_map, addr, sizeof(prctl_map))) > return -EFAULT; > > + prctl_map->start_code = untagged_addr(prctl_map.start_code); > + prctl_map->end_code = untagged_addr(prctl_map.end_code); > + prctl_map->start_data = untagged_addr(prctl_map.start_data); > + prctl_map->end_data = untagged_addr(prctl_map.end_data); > + prctl_map->start_brk = untagged_addr(prctl_map.start_brk); > + prctl_map->brk = untagged_addr(prctl_map.brk); > + prctl_map->start_stack = untagged_addr(prctl_map.start_stack); > + prctl_map->arg_start = untagged_addr(prctl_map.arg_start); > + prctl_map->arg_end = untagged_addr(prctl_map.arg_end); > + prctl_map->env_start = untagged_addr(prctl_map.env_start); > + prctl_map->env_end = untagged_addr(prctl_map.env_end); As the buildbot suggests, those -> should be . instead :) You might want to check your local build with CONFIG_CHECKPOINT_RESTORE=y. > + > error = validate_prctl_map(&prctl_map); > if (error) > return error; > @@ -2106,6 +2118,8 @@ static int prctl_set_mm(int opt, unsigned long addr, > opt != PR_SET_MM_MAP_SIZE))) > return -EINVAL; > > + addr = untagged_addr(addr); This is a bit too coarse, addr is indeed used for find_vma() later on, but it is also used to access memory, by prctl_set_mm_mmap() and prctl_set_auxv(). Kevin > + > #ifdef CONFIG_CHECKPOINT_RESTORE > if (opt == PR_SET_MM_MAP || opt == PR_SET_MM_MAP_SIZE) > return prctl_set_mm_map(opt, (const void __user *)addr, arg4);