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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 AA7EAC34026 for ; Tue, 18 Feb 2020 13:07:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5A79D20801 for ; Tue, 18 Feb 2020 13:07:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="p03h2q2o" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A79D20801 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0C41F6B0006; Tue, 18 Feb 2020 08:07:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09AE36B0007; Tue, 18 Feb 2020 08:07:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1AA66B0008; Tue, 18 Feb 2020 08:07:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id DB4536B0006 for ; Tue, 18 Feb 2020 08:07:51 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8AE608248047 for ; Tue, 18 Feb 2020 13:07:51 +0000 (UTC) X-FDA: 76503275142.22.shoe72_277004fe4533d X-HE-Tag: shoe72_277004fe4533d X-Filterd-Recvd-Size: 6034 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Feb 2020 13:07:50 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id e9so983842pjr.4 for ; Tue, 18 Feb 2020 05:07:50 -0800 (PST) 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=Qo1YUJb/RWYJFwig6pzp9B2Ejd28xQg9RZwtPeZ5+II=; b=p03h2q2oFzCsylq8kredNKQ01XRdkwUMvCYPUjYq/RzqX/imqMmY01sPPA/6euPoSQ /SbxLVv6e4NoTFbPLgkLRPRI1KA45cBN1ZQJIoLvOFFvLUxu5UMliCWWJD5YcQmEQXoq gvHQpy/ZirgJsF3bY2AUh3/wfYE8URE1jzed8uET9PCFvOILmWjwiLf2kX8GB/uYFMkP Cwow0Bey0I1KTKj9wZzOxDbD3vGr2ocyengclQureo05E3vUAmkhndqvsPHXx86eqwAi eE7TDhVdPVum9RjBB0m2fpmxWwjDQTG95fRdbomskE5PaoXSZLVwlfh+KDKqYBijROPU JI5Q== 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=Qo1YUJb/RWYJFwig6pzp9B2Ejd28xQg9RZwtPeZ5+II=; b=Ndetd1tsrfm6Upp4/HZmghNko30Bl+8mz+COJK142F8HNFXHCQGkzxmsuRpJfe0gVz R4WH+AKz87TgbxUFRwL6b4AfwFMn6CH7wW6X8pY8S54eBbiplj2R8byuWNJGQUEIr+9v hW38+qwfM4vOEzoWSly/E2imsetEpmzXhU/I/X7B/2gKpdnLxyfUi6Jfdj7PI7C937fP 3mSrY8XN8un0/T7LOQE6cBH17peADkxNgYala2/sPCRLMM5Qf8vr4FFgp1DkG3y1rWd0 U1+8OYrKURwB99YB2Q1iZ5FHAi7zQF56YMOUPB9AGQyLPCguQ296UJlk8doZCzp1dUQe wRJg== X-Gm-Message-State: APjAAAXhAcoZsaOaDMzr3sAoDm9zJeAf3UJXRw2Tud7keNqpgoeB7xRn qTbnf/2M1Idyf0MtznStj5+V4hfdM5TNb1uK59x6/w== X-Google-Smtp-Source: APXvYqxMy8oB1NG4dNDB1Xm/PatBGPZPL8iCKwCorX+nNCE6VB2xnOZH5zfiPiC11rVcY7hOuYQID9xq80Oo7TSvY5Q= X-Received: by 2002:a17:902:8682:: with SMTP id g2mr20241607plo.336.1582031269417; Tue, 18 Feb 2020 05:07:49 -0800 (PST) MIME-Version: 1.0 References: <20200218122310.72710-1-catalin.marinas@arm.com> <20200218123426.GA19776@willie-the-truck> In-Reply-To: <20200218123426.GA19776@willie-the-truck> From: Andrey Konovalov Date: Tue, 18 Feb 2020 14:07:38 +0100 Message-ID: Subject: Re: [PATCH] mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() To: Evgenii Stepanov Cc: Catalin Marinas , Linux Memory Management List , Linux ARM , Szabolcs Nagy , Andrew Morton , Florian Weimer , Victor Stinner , Will Deacon Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Feb 18, 2020 at 1:34 PM Will Deacon wrote: > > On Tue, Feb 18, 2020 at 12:23:10PM +0000, Catalin Marinas wrote: > > Currently the arm64 kernel ignores the top address byte passed to brk(), > > mmap() and mremap(). When the user is not aware of the 56-bit address > > limit or relies on the kernel to return an error, untagging such > > pointers has the potential to create address aliases in user-space. > > Passing a tagged address to munmap(), madvise() is permitted since the > > tagged pointer is expected to be inside an existing mapping. > > Might be worth mentioning that this is causing real issues for existing > userspace: > > https://bugzilla.redhat.com/show_bug.cgi?id=1797052 > > and so should be merged as a fix. > > > Remove untagging in the above functions by partially reverting commit > > ce18d171cb73 ("mm: untag user pointers in mmap/munmap/mremap/brk"). In > > addition, update the arm64 tagged-address-abi.rst document accordingly. Evgenii, do you know if this will cause any issues for HWASAN? > > > > Fixes: ce18d171cb73 ("mm: untag user pointers in mmap/munmap/mremap/brk") > > Cc: # 5.4.x- > > Cc: Andrey Konovalov > > Cc: Will Deacon > > Cc: Andrew Morton > > Cc: Florian Weimer > > Reported-by: Victor Stinner > > Signed-off-by: Catalin Marinas > > --- > > Documentation/arm64/tagged-address-abi.rst | 7 +++++-- > > mm/mmap.c | 4 ---- > > mm/mremap.c | 1 - > > 3 files changed, 5 insertions(+), 7 deletions(-) > > > > diff --git a/Documentation/arm64/tagged-address-abi.rst b/Documentation/arm64/tagged-address-abi.rst > > index d4a85d535bf9..1771a8b5712e 100644 > > --- a/Documentation/arm64/tagged-address-abi.rst > > +++ b/Documentation/arm64/tagged-address-abi.rst > > @@ -44,8 +44,11 @@ The AArch64 Tagged Address ABI has two stages of relaxation depending > > how the user addresses are used by the kernel: > > > > 1. User addresses not accessed by the kernel but used for address space > > - management (e.g. ``mmap()``, ``mprotect()``, ``madvise()``). The use > > - of valid tagged pointers in this context is always allowed. > > + management (e.g. ``mprotect()``, ``madvise()``). The use of valid > > + tagged pointers in this context is allowed with the exception of > > + ``brk()``, ``mmap()`` and the ``new_address`` argument to > > + ``mremap()`` as these have the potential of aliasing with existing > > + user addresses. > > Given that we're backporting this to stable kernels, perhaps it's worth > a note here along the lines of: > > NOTE: This behaviour changed in v5.6 and so some earlier kernels may > incorrectly accept valid tagged pointers for these system calls. > > With that: > > Acked-by: Will Deacon > > Happy to take this as an arm64 fix for 5.6, unless Andrew would prefer > to route it via his tree. > > Will