Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp596304img; Mon, 18 Mar 2019 09:55:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVK4LsH0LbFjlc6NT2+KINwyZD9kuDLNaNNiqu6AdwyGx28lQAT0bdKZjv1vv2TO9SQ1Mb X-Received: by 2002:a63:4815:: with SMTP id v21mr18606262pga.412.1552928126085; Mon, 18 Mar 2019 09:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552928126; cv=none; d=google.com; s=arc-20160816; b=QYsXPxW7n4H0PG/P8kfXc0PFZXoo5XJM/+JuRET3qhd+64d2rG8VFQK66z9iQAaqYA zFyzEsEj7cZbdGkdfzxPZ25YWKf9tH/fWacvBFUDjBAGhNK89oE93d7eyjidxGEUu1Gv JfgjWdKuDc5x2UB50rCkxSQF0LV0PtPlM/yUFzMoVrQCRIIbuT/0KltjxNJEEP7DByKE 7QakH/1FLZMlliBb1i2m+6LD5lP95lm1CPBmRdAbz9VX+gRRHXijL5mwvRbioEGNpmbq 7+/5cSHLt57+HfSlKxAFoihAEjkFcJc5lLMk/tXUkpbnrgnfB2Si6VeE5/RoO/AKGbcX cYHw== 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=oTTTDsmzZRxE0P4UD+1ikNPbtlS4Dyc6/3yBg27ixDQ=; b=RfrcSLene7u9ehFV8flH7N4/yuz8T3m990h7xKr+vl929Mgg15iWpNmhWLRXdRlBEz Y0V1JbFWqOEJhRcjWizEpc5hskWyUuK6WB3WFHBlYlEBTASpClFrdxH4Hk68qQztLJVa mspAJaAVixirkoX6nXdSkR/lIiykOF1A/O6Nvb2AK5nauHuskfkUdQz+hlK9VF8d+tRY cQtH+Q4SMcVgeTWMHospDTQdqGoM/Z5rc6HO8ASITRYV2mLYoW3J8+l620N1Rq9DhQvF yODyIE5dvAQG5dHPNUPkW6lQR5PyKem5MjU3t1GcElpTY7SLpEBLJ7zWXJxSS/iqRm3K iemQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qL2sbyGF; 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 n3si9087400pgv.458.2019.03.18.09.55.10; Mon, 18 Mar 2019 09:55:26 -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=qL2sbyGF; 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 S1727528AbfCRQyJ (ORCPT + 99 others); Mon, 18 Mar 2019 12:54:09 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32880 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726922AbfCRQyI (ORCPT ); Mon, 18 Mar 2019 12:54:08 -0400 Received: by mail-pf1-f194.google.com with SMTP id i19so11679046pfd.0 for ; Mon, 18 Mar 2019 09:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oTTTDsmzZRxE0P4UD+1ikNPbtlS4Dyc6/3yBg27ixDQ=; b=qL2sbyGFEclrtQPUA6LVmMhwOgE9ZrDgMW6Yf0szQXcjCN8uVFclD6Agav2oG/HaIH tt+Y2mHDCoddFKSu8Zy4+3UpfZZ7SmbEpgE0cwANONzfIFjpTwwIM+e92N9XMSRRWHoH PxF+RlzsqmGVQHybjhaImaimN17+872PGPB3vCwmBpKws2yHzSmXHY74ILhBEtFUAPZC ZvI5cWjIE/Xp9Y+h7052jpM79vanjEebGQOinpddGY5fyw7tCnhdUPSnrMHlG9O0r3NS 7j+QGp+4xtUxFT/lBj7jefQ9mZPAHUuw6v1QjZFT5Vjqdwgm4b+IedSWlUu5f+FbiQK2 9n2w== 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=oTTTDsmzZRxE0P4UD+1ikNPbtlS4Dyc6/3yBg27ixDQ=; b=fc8/TQSMpgD5E2GBX6lPgMmG5vZyw0wyLbXJXTGDvJrn3Ge+8LVwMs6vNVeYk+DIxq vCNjKRDQHm5AVjyOTVTtoGiEDGDqrM1Hz94fQk87wsWoHgb6mrASBPr8nJmzUuhbMZuu ITKVzv+e+oQXIyKh7InthlOZrsc/al0Yopft9EYFydAc44p1RP2pbSVwKoyEQFuFGkXK SkQlRTcF6nowERKzNa0zt+0lxwqp6UiDFhW6QttMab0Frp7rAhOedQshmMrh0H9RCwaw rO7KbTsz3mWUph10wbi/1k1jfTrwlXkgiX67UoPUhKi2tavrqFuRCLw4gbTPy9kRi4VA ha/A== X-Gm-Message-State: APjAAAUuFxUj4cz930w2ExEi0wTFTkCylR2+6PkLz4yaYLKz2jUGVUXk Keue0KxLGTvpC8epMl3L+AFyZkjK+W5pyj+zCbwjrw== X-Received: by 2002:a17:902:d24:: with SMTP id 33mr13090976plu.246.1552928047514; Mon, 18 Mar 2019 09:54:07 -0700 (PDT) MIME-Version: 1.0 References: <96675b72-d325-0682-4864-b6a96f63f8fd@arm.com> In-Reply-To: <96675b72-d325-0682-4864-b6a96f63f8fd@arm.com> From: Andrey Konovalov Date: Mon, 18 Mar 2019 17:53:56 +0100 Message-ID: Subject: Re: [PATCH v11 09/14] kernel, arm64: untag user pointers in prctl_set_mm* To: Kevin Brodsky Cc: 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 , "open list:DOCUMENTATION" , Linux Memory Management List , linux-arch , netdev , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya , Luc Van Oostenryck , Dave Martin , Szabolcs Nagy 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 Mon, Mar 18, 2019 at 12:47 PM Kevin Brodsky wrote: > > 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. Oops :) > > > + > > 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(). Yes, I wrote this patch before our Friday discussion and forgot about it. I'll fix it in v12, thanks! > > 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); >