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 D71CAC34026 for ; Tue, 18 Feb 2020 13:06:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8FC2220801 for ; Tue, 18 Feb 2020 13:06:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FyAUPeWq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FC2220801 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 382B76B0003; Tue, 18 Feb 2020 08:06:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 332F16B0006; Tue, 18 Feb 2020 08:06:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 221B36B0007; Tue, 18 Feb 2020 08:06:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id 0B7496B0003 for ; Tue, 18 Feb 2020 08:06:49 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BBFB91269 for ; Tue, 18 Feb 2020 13:06:48 +0000 (UTC) X-FDA: 76503272496.15.walk92_1e4da4cff9c3e X-HE-Tag: walk92_1e4da4cff9c3e X-Filterd-Recvd-Size: 5969 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Feb 2020 13:06:48 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id k29so10623414pfp.13 for ; Tue, 18 Feb 2020 05:06:48 -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=rO0+HTudurHIpLNnL3eo7xZsjczyqgXMhw0p9F9AXKc=; b=FyAUPeWqlKqhvKzz50Pl1H3asxCWMNFKyGG1j3jfNHVHYFIOgvFKGISZQexIv1+XGp ei9zxbs7N+5ZWUnshBLfVXE1wKDbqQGUHrH/Pw6sMPM/p/GQd8CAk5UF+OxXw9Qu9iJ7 4TpPCRAeCknN3qZMR4mVm90q94RPFr1PCVlGCP2rFdF8YupEqxxMsARHSFUgej3kfGlE 73ilkhIP6KK0N4GKYQrV3rYsyItGeDSCK7vjHLmgO3QunUSdBlKH0DeA1YYCrpRumBE2 LgkNT6TGRtDPiTNkgjprUmKKKPFTj7iP0c//M6+XWT4s0UC92E2ShFQSDN8RGN735dU0 UehA== 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=rO0+HTudurHIpLNnL3eo7xZsjczyqgXMhw0p9F9AXKc=; b=MtRM92q0/Beaz0YLgtmhlDxe1ufgdzLQffHJ8nVqRqvdumC7VhNEFy6mV8RAqg2fWL IFZM/TOM4a1WDXwa3cfcSQbgmQcfUkgTjSNuEmUFqGv/kSRiH1eyCLBtTrBLKSmgrqSQ BfnmpODW9tVN9XRloslN7qbrOpyMg8QiEQysbLLiFMYC3tWOYxSi+x8hR2Q0QPLn1r6m WZG6wOeiB8cxV+I7FnqHCsaIRF06SA9Vdf7Ri8NCIK188BnOkHMZ5O8f7OaS+nOW9w/O u27+MAF4Mm3zgT0Qvq4CTe2edH7R7beK4t2SO+vChLq6FFbxnjF4fcqq2f0f6ITvGRMe hcVw== X-Gm-Message-State: APjAAAVRk5k9NlB8BzoKl8EVEvwefjJvJHG9pPO2s8PFPqbwFkGQkRnX BZba4vZZsSZhHUjMU7AwmVG0rk2gdK85t8pT7MuWFQ== X-Google-Smtp-Source: APXvYqx7HjbGglI6atITptUtHzHTlpn1BWPSVcbuHwx6KPRMS807SnR+1xfpZUOdmOzCQnJPqmgdkM50qiEcOY/S4oo= X-Received: by 2002:a63:615:: with SMTP id 21mr22865082pgg.440.1582031206806; Tue, 18 Feb 2020 05:06:46 -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:06:35 +0100 Message-ID: Subject: Re: [PATCH] mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() To: Evgenii Stepanov Cc: Linux Memory Management List , Linux ARM , Szabolcs Nagy , Andrew Morton , Florian Weimer , Victor Stinner , Will Deacon , Catalin Marinas 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. > > > > 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