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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 95E4CC49EA5 for ; Thu, 24 Jun 2021 16:40:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 03188613CC for ; Thu, 24 Jun 2021 16:40:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03188613CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 04C186B006C; Thu, 24 Jun 2021 12:40:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 023066B0070; Thu, 24 Jun 2021 12:40:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2CFD6B0071; Thu, 24 Jun 2021 12:40:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id B3B276B006C for ; Thu, 24 Jun 2021 12:40:09 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5980122020 for ; Thu, 24 Jun 2021 16:40:08 +0000 (UTC) X-FDA: 78289179696.13.5C52467 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [142.44.231.140]) by imf23.hostedemail.com (Postfix) with ESMTP id 033CDA000276 for ; Thu, 24 Jun 2021 16:40:07 +0000 (UTC) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwSOK-00BrRG-Mi; Thu, 24 Jun 2021 16:39:48 +0000 Date: Thu, 24 Jun 2021 16:39:48 +0000 From: Al Viro To: Robin Murphy Cc: Matthew Wilcox , Christoph Hellwig , Chen Huang , Mark Rutland , Andrew Morton , Stephen Rothwell , Randy Dunlap , Catalin Marinas , Will Deacon , Linux ARM , linux-mm , open list Subject: Re: [BUG] arm64: an infinite loop in generic_perform_write() Message-ID: References: <20210623132223.GA96264@C02TD0UTHF1T.local> <1c635945-fb25-8871-7b34-f475f75b2caf@huawei.com> <27fbb8c1-2a65-738f-6bec-13f450395ab7@arm.com> <7896a3c7-2e14-d0f4-dbb9-286b6f7181b5@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7896a3c7-2e14-d0f4-dbb9-286b6f7181b5@arm.com> Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=none; spf=none (imf23.hostedemail.com: domain of viro@ftp.linux.org.uk has no SPF policy when checking 142.44.231.140) smtp.mailfrom=viro@ftp.linux.org.uk X-Rspamd-Server: rspam02 X-Stat-Signature: xae5631zpi5w1o7q5j6ok3nfo4bi674q X-Rspamd-Queue-Id: 033CDA000276 X-HE-Tag: 1624552807-285903 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 Thu, Jun 24, 2021 at 05:38:35PM +0100, Robin Murphy wrote: > On 2021-06-24 17:27, Al Viro wrote: > > On Thu, Jun 24, 2021 at 02:22:27PM +0100, Robin Murphy wrote: > > > > > FWIW I think the only way to make the kernel behaviour any more robust here > > > would be to make the whole uaccess API more expressive, such that rather > > > than simply saying "I only got this far" it could actually differentiate > > > between stopping due to a fault which may be recoverable and worth retrying, > > > and one which definitely isn't. > > > > ... and propagate that "more expressive" information through what, 3 or 4 > > levels in the call chain? > > > > From include/linux/uaccess.h: > > > > * If raw_copy_{to,from}_user(to, from, size) returns N, size - N bytes starting > > * at to must become equal to the bytes fetched from the corresponding area > > * starting at from. All data past to + size - N must be left unmodified. > > * > > * If copying succeeds, the return value must be 0. If some data cannot be > > * fetched, it is permitted to copy less than had been fetched; the only > > * hard requirement is that not storing anything at all (i.e. returning size) > > * should happen only when nothing could be copied. In other words, you don't > > * have to squeeze as much as possible - it is allowed, but not necessary. > > > > arm64 instances violate the aforementioned hard requirement. Please, fix > > it there; it's not hard. All you need is an exception handler in .Ltiny15 > > that would fall back to (short) byte-by-byte copy if the faulting address > > happened to be unaligned. Or just do one-byte copy, not that it had been > > considerably cheaper than a loop. Will be cheaper than propagating that extra > > information up the call chain, let alone paying for extra ->write_begin() > > and ->write_end() for single byte in generic_perform_write(). > > And what do we do if we then continue to fault with an external abort > because whatever it is that warranted being mapped as Device-type memory in > the first place doesn't support byte accesses? If it does not support byte access, it would've failed on fault-in.