Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp372610pxv; Thu, 24 Jun 2021 09:42:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMjjulYTTbsfIn6L6YdlvVlkFVIQWm7gWhE+CEf+QZIP7hPAsl/LP3msZW4nj72TX/TkZD X-Received: by 2002:a92:da88:: with SMTP id u8mr4360893iln.185.1624552948917; Thu, 24 Jun 2021 09:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624552948; cv=none; d=google.com; s=arc-20160816; b=MHQWQz1TMhMJHfrEfb/CL8UhkK4Qr2RyiQUSbE/giCEnjNOAq5lsthRLIX8/oFX8Co wUALJV31XlPvBg3UgbIraQXp4Af2aGeZQ77wt07gsaZB93l7U8rCWbq0b4EGdqnRT/XD NWMsAvwHhZyeMJkSRIxORRXuRK5Pz6FJSgWTSQhdkS7xUFOJeFwbThhIv/BE48FjF8lp lSdhwJ4PNEeJNFu9fqeCj8q0LGStw0+7HK69w5DTJZ3sGrWcvQVHpc5eI4UmobAkMW5k 5owh5607zjZ9sJCcJlAfgR4ZoS0/LJx9ZvRNLgP4I8qSedrXpgLhMTzXkX/etZl41mqW gGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=5PWjLZLT4ptvpPwc6qAzr8fOFPNgriuMk1HmNtJjhvM=; b=EMHeJhlWqIsZJcJ+kcIEjIQ0yiZ14b/9xcaJxoCa88dWYEQ21HMZMMf6hcR50bu22Q K5qOScysSFf9vEMpLHuHWRyeiBVPzXatJOKE7c1mwBqVlf55ZdHTpM5j+15JysInU6Sf a0ynbNOOUu3pd541J28L59cGFLKFJU3aivKtU6c1ABkVPoQRa+Cobl/ol6HwBfQrc/x9 p8c0/eAgGEFt/mZw9fnfIkW4pjzXaMmoIekR2OTvNCWTP1xDTE3NA22MVgTDDRqt42nB wf5O/4k+1Xh0yGnEplX3qVo6mSApm1K5uBJdYuCTKj4812M+niEvetkwUWgZWlev6ovQ NEAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si2536681iom.77.2021.06.24.09.42.16; Thu, 24 Jun 2021 09:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbhFXQmc (ORCPT + 99 others); Thu, 24 Jun 2021 12:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbhFXQmb (ORCPT ); Thu, 24 Jun 2021 12:42:31 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE62C061574 for ; Thu, 24 Jun 2021 09:40:11 -0700 (PDT) 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> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.