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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 EE801C07E95 for ; Tue, 13 Jul 2021 17:22:24 +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 B7E78610D1 for ; Tue, 13 Jul 2021 17:22:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7E78610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Cqr5mBzo0QjUd6pM/8Df6bivHcH4aybN5OtVjehKRfs=; b=pZcdNGfqfZuPk7 bIDMnEyEsdaN6vpd70VuB+Hueyu172/qWpu6C9eMJYWjXzhE/mE63SkHTdce9c1GYxxAyrv67g3Js iwP6TpWKUmmTpx6acnfO9jieugfX19ubaYSyOj3LlEdY5jLbuUC5Dia/VoPxbpoTNxkkDpkVHWX2N 6k2Lbd3YxYUXw7Dyxi0CmrMtStfmG1WfVfZycGNo8lFVoFUVrlV/z//mj7L26194/Hcc5EiJled0X Q/EYdDK6fum5XuiObbxy4kr+fAmNodSTn+qFEIsHLC5ObNGGP9QdJkDq07s09GyHfIYicqBCmkEy7 4o9ZamohpdS/BhAEQEqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3M5c-00B2IH-F5; Tue, 13 Jul 2021 17:21:00 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3M5X-00B2HY-Vh for linux-arm-kernel@lists.infradead.org; Tue, 13 Jul 2021 17:20:57 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E778661183; Tue, 13 Jul 2021 17:20:53 +0000 (UTC) Date: Tue, 13 Jul 2021 18:20:46 +0100 From: Catalin Marinas To: Will Deacon Cc: Robin Murphy , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Chen Huang , Al Viro Subject: Re: [PATCH] arm64: Avoid premature usercopy failure Message-ID: <20210713172045.GD13181@arm.com> References: <20210713165957.GA30304@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210713165957.GA30304@willie-the-truck> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210713_102056_078673_6DFD0912 X-CRM114-Status: GOOD ( 27.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jul 13, 2021 at 05:59:58PM +0100, Will Deacon wrote: > On Mon, Jul 12, 2021 at 03:27:46PM +0100, Robin Murphy wrote: > > Al reminds us that the usercopy API must only return complete failure > > if absolutely nothing could be copied. Currently, if userspace does > > something silly like giving us an unaligned pointer to Device memory, > > or a size which overruns MTE tag bounds, we may fail to honour that > > requirement when faulting on a multi-byte access even though a smaller > > access could have succeeded. > > > > Add a mitigation to the fixup routines to fall back to a single-byte > > copy if we faulted on a larger access before anything has been written > > to the destination, to guarantee making *some* forward progress. We > > needn't be too concerned about the overall performance since this should > > only occur when callers are doing something a bit dodgy in the first > > place. Particularly broken userspace might still be able to trick > > generic_perform_write() into an infinite loop by targeting write() at > > an mmap() of some read-only device register where the fault-in load > > succeeds but any store synchronously aborts such that copy_to_user() is > > genuinely unable to make progress, but, well, don't do that... > > > > CC: stable@vger.kernel.org > > Reported-by: Chen Huang > > Suggested-by: Al Viro > > Reviewed-by: Catalin Marinas > > Signed-off-by: Robin Murphy > > --- > > > > I've started trying the "replay" approach for figuring out more precise > > remainders in general, but that quickly got more complicated with > > rebasing the fault address passing stuff, so I'm resending this now as > > a point fix and will continue to explore that as an improvement on top. > > Is it possible to add/extend a selftest for this, please? I think Catalin > mentioned that before, but not sure if he got anywhere with it. It's on my to-do list but going on holiday soon. If Robin is keen on this, I don't really mind ;). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel