From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D0B0C43613 for ; Mon, 24 Jun 2019 14:22:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00830208E4 for ; Mon, 24 Jun 2019 14:22:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Fw5Izn08"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="km7JeQ3v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00830208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BD3VT0ATRgn1mGxR8QsNGI+7GXV6MmMCcEaRjGbLJ1w=; b=Fw5Izn08JUIx+s mPKu1rbqUrTZ0zHHAPl2o807WUQiUV/L5kkNNj+oOSIQOV51xjy1/Vdi2Hlozwyc7fN7diVlj7PJy 5PRIM9FXSO1fW3f5LW5+sAdi+c2dxfvpLD4YANPpkGmPAPF0tYsuKG9xeQNJEYKIidwvkPqcHbSwY sGPcbYPGAVP/MdIIabujjyzCPXkV04sV7CuJ/Q+2jIAuhkStAqdW6kx+N8jK6m/CO/J4ji87pD7Wp TIlZApvPpajli+jbJUnyYB1+3CBOjA0KCc/WDMjbAEttj4+PCXyOsyoLkpIbsfr65v9/uhiw4Z1eB OEAL5C5v44WqY+oTQRxA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hfPrv-0006vK-Qz; Mon, 24 Jun 2019 14:22:51 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hfPrs-0006tj-UM for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2019 14:22:50 +0000 Received: by mail-pl1-x643.google.com with SMTP id e5so6965305pls.13 for ; Mon, 24 Jun 2019 07:22:46 -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=gAszyd6Rkh0AyBVnY2MGQeafDGFV/B/Xjwc7nOHGBTU=; b=km7JeQ3vyTD2UtwSHCAAp4q4at1sY/ltJPO5wzrrkqMzNLeQZPjXSnOQ7VtkWA81dl HEFVLO9l5VlkdkocDhA+ezC7dKtBn4IeaF4UZLWnOmGq0Ok4r2E9GR7Hoa79HLNOGJVe 0AHZ3EJWZEjcDwF6xOVW5nBJXR6vOtRMH7oBaouWSEKGFrWAIrbWb9kQA+Hlo7SIhUEB uGLPh5fQQfh1ibByxQrZM4UE+cDk+UJmRIBMFqrJwcIDdYtIIT+tU41CsIi86+tplFna 0qMXAZhS5viMtSm5pwtZ6YrDben3dB8l27s4Hd+Xtz7mclZlxhwdWOJHEC5Ft/EzKQyl VZSQ== 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=gAszyd6Rkh0AyBVnY2MGQeafDGFV/B/Xjwc7nOHGBTU=; b=l0IuipTWDMmT9qWnMDgwusuNFWps29MPd6Ourc5Q1fLV/qtky2F0BLsaPSM0PPKJ3W t380CW2I+1PZl9lshZIMLxEiWBTK9rTs6nvn3inPflY4ZZwbNmL0dink5eWDFXlwwFvU 2Z584iPZiJ394EqFKrR6t4Ugvq6ZVQLzYwfXxKSCgBMwl5iUlDPS7lgp4vKDPx4f7nYj LqZCp+wPGqMXmHcYv+ukGihMyOti12DYUmzeOTXYzNwSiEa5IjVyysAT4ofneO47Y2V9 UNWIVkMyuxgUYBSschy19euhf/TE6ZBO07fI6hUIMSt75/0WL09g8TbipFEx5BtXxODe F5eA== X-Gm-Message-State: APjAAAUU2qH+1PZBOlffzNKJSnRNwppGMNwuVk9mRK7mdU+pzCzXdhnb Axh5Fxlhhisxgh9gMijw5iCCcEuZ8K15RaSLbwDv5A== X-Google-Smtp-Source: APXvYqx/7NbeFZuwI48tclTUh11xegUV5UsdKc2ldTOnN03zOVYnpDOwlkZEMuzBYRoM7kFvSzXnjLxRZwjrOwVDnPw= X-Received: by 2002:a17:902:4183:: with SMTP id f3mr32179784pld.336.1561386165165; Mon, 24 Jun 2019 07:22:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Mon, 24 Jun 2019 16:22:34 +0200 Message-ID: Subject: Re: [PATCH v17 04/15] mm, arm64: untag user pointers passed to memory syscalls To: Khalid Aziz X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190624_072248_987020_67238FC4 X-CRM114-Status: GOOD ( 24.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Szabolcs Nagy , Catalin Marinas , Will Deacon , dri-devel@lists.freedesktop.org, Linux Memory Management List , "open list:KERNEL SELFTEST FRAMEWORK" , Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Jason Gunthorpe , Dmitry Vyukov , Dave Martin , Evgeniy Stepanov , linux-media@vger.kernel.org, Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , Linux ARM , Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , LKML , Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 19, 2019 at 6:46 PM Khalid Aziz wrote: > > On 6/19/19 9:55 AM, Khalid Aziz wrote: > > On 6/12/19 5:43 AM, 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. > >> > >> This patch allows tagged pointers to be passed to the following memory > >> syscalls: get_mempolicy, madvise, mbind, mincore, mlock, mlock2, mprotect, > >> mremap, msync, munlock, move_pages. > >> > >> The mmap and mremap syscalls do not currently accept tagged addresses. > >> Architectures may interpret the tag as a background colour for the > >> corresponding vma. > >> > >> Reviewed-by: Catalin Marinas > >> Reviewed-by: Kees Cook > >> Signed-off-by: Andrey Konovalov > >> --- > > > > Reviewed-by: Khalid Aziz > > > > > > I would also recommend updating commit log for all the patches in this > series that are changing files under mm/ as opposed to arch/arm64 to not > reference arm64 kernel ABI since the change applies to every > architecture. So something along the lines of "This patch is part of a > series that extends kernel ABI to allow......." Sure, will do in v18, thanks! > > -- > Khalid > > > >> mm/madvise.c | 2 ++ > >> mm/mempolicy.c | 3 +++ > >> mm/migrate.c | 2 +- > >> mm/mincore.c | 2 ++ > >> mm/mlock.c | 4 ++++ > >> mm/mprotect.c | 2 ++ > >> mm/mremap.c | 7 +++++++ > >> mm/msync.c | 2 ++ > >> 8 files changed, 23 insertions(+), 1 deletion(-) > >> > >> diff --git a/mm/madvise.c b/mm/madvise.c > >> index 628022e674a7..39b82f8a698f 100644 > >> --- a/mm/madvise.c > >> +++ b/mm/madvise.c > >> @@ -810,6 +810,8 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior) > >> size_t len; > >> struct blk_plug plug; > >> > >> + start = untagged_addr(start); > >> + > >> if (!madvise_behavior_valid(behavior)) > >> return error; > >> > >> diff --git a/mm/mempolicy.c b/mm/mempolicy.c > >> index 01600d80ae01..78e0a88b2680 100644 > >> --- a/mm/mempolicy.c > >> +++ b/mm/mempolicy.c > >> @@ -1360,6 +1360,7 @@ static long kernel_mbind(unsigned long start, unsigned long len, > >> int err; > >> unsigned short mode_flags; > >> > >> + start = untagged_addr(start); > >> mode_flags = mode & MPOL_MODE_FLAGS; > >> mode &= ~MPOL_MODE_FLAGS; > >> if (mode >= MPOL_MAX) > >> @@ -1517,6 +1518,8 @@ static int kernel_get_mempolicy(int __user *policy, > >> int uninitialized_var(pval); > >> nodemask_t nodes; > >> > >> + addr = untagged_addr(addr); > >> + > >> if (nmask != NULL && maxnode < nr_node_ids) > >> return -EINVAL; > >> > >> diff --git a/mm/migrate.c b/mm/migrate.c > >> index f2ecc2855a12..d22c45cf36b2 100644 > >> --- a/mm/migrate.c > >> +++ b/mm/migrate.c > >> @@ -1616,7 +1616,7 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, > >> goto out_flush; > >> if (get_user(node, nodes + i)) > >> goto out_flush; > >> - addr = (unsigned long)p; > >> + addr = (unsigned long)untagged_addr(p); > >> > >> err = -ENODEV; > >> if (node < 0 || node >= MAX_NUMNODES) > >> diff --git a/mm/mincore.c b/mm/mincore.c > >> index c3f058bd0faf..64c322ed845c 100644 > >> --- a/mm/mincore.c > >> +++ b/mm/mincore.c > >> @@ -249,6 +249,8 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len, > >> unsigned long pages; > >> unsigned char *tmp; > >> > >> + start = untagged_addr(start); > >> + > >> /* Check the start address: needs to be page-aligned.. */ > >> if (start & ~PAGE_MASK) > >> return -EINVAL;fixup_user_fault > >> diff --git a/mm/mlock.c b/mm/mlock.c > >> index 080f3b36415b..e82609eaa428 100644 > >> --- a/mm/mlock.c > >> +++ b/mm/mlock.c > >> @@ -674,6 +674,8 @@ static __must_check int do_mlock(unsigned long start, size_t len, vm_flags_t fla > >> unsigned long lock_limit; > >> int error = -ENOMEM; > >> > >> + start = untagged_addr(start); > >> + > >> if (!can_do_mlock()) > >> return -EPERM; > >> > >> @@ -735,6 +737,8 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) > >> { > >> int ret; > >> > >> + start = untagged_addr(start); > >> + > >> len = PAGE_ALIGN(len + (offset_in_page(start))); > >> start &= PAGE_MASK; > >> > >> diff --git a/mm/mprotect.c b/mm/mprotect.c > >> index bf38dfbbb4b4..19f981b733bc 100644 > >> --- a/mm/mprotect.c > >> +++ b/mm/mprotect.c > >> @@ -465,6 +465,8 @@ static int do_mprotect_pkey(unsigned long start, size_t len, > >> const bool rier = (current->personality & READ_IMPLIES_EXEC) && > >> (prot & PROT_READ); > >> > >> + start = untagged_addr(start); > >> + > >> prot &= ~(PROT_GROWSDOWN|PROT_GROWSUP); > >> if (grows == (PROT_GROWSDOWN|PROT_GROWSUP)) /* can't be both */ > >> return -EINVAL; > >> diff --git a/mm/mremap.c b/mm/mremap.c > >> index fc241d23cd97..64c9a3b8be0a 100644 > >> --- a/mm/mremap.c > >> +++ b/mm/mremap.c > >> @@ -606,6 +606,13 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, > >> LIST_HEAD(uf_unmap_early); > >> LIST_HEAD(uf_unmap); > >> > >> + /* > >> + * Architectures may interpret the tag passed to mmap as a background > >> + * colour for the corresponding vma. For mremap we don't allow tagged > >> + * new_addr to preserve similar behaviour to mmap. > >> + */ > >> + addr = untagged_addr(addr); > >> + > >> if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE)) > >> return ret; > >> > >> diff --git a/mm/msync.c b/mm/msync.c > >> index ef30a429623a..c3bd3e75f687 100644 > >> --- a/mm/msync.c > >> +++ b/mm/msync.c > >> @@ -37,6 +37,8 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags) > >> int unmapped_error = 0; > >> int error = -EINVAL; > >> > >> + start = untagged_addr(start); > >> + > >> if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC)) > >> goto out; > >> if (offset_in_page(start)) > >> > > > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel