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 8592FC4743C for ; Wed, 23 Jun 2021 13:05:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54CDC6108E for ; Wed, 23 Jun 2021 13:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230429AbhFWNHS (ORCPT ); Wed, 23 Jun 2021 09:07:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbhFWNHR (ORCPT ); Wed, 23 Jun 2021 09:07:17 -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 00994C061574 for ; Wed, 23 Jun 2021 06:04:56 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw2YR-00BX5y-SA; Wed, 23 Jun 2021 13:04:31 +0000 Date: Wed, 23 Jun 2021 13:04:31 +0000 From: Al Viro To: Catalin Marinas Cc: Xiaoming Ni , Chen Huang , Andrew Morton , Stephen Rothwell , "Matthew Wilcox (Oracle)" , Randy Dunlap , Will Deacon , Linux ARM , linux-mm , open list Subject: Re: [BUG] arm64: an infinite loop in generic_perform_write() Message-ID: References: <92fa298d-9d88-0ca4-40d9-13690dcd42f9@huawei.com> <20210623093220.GA3718@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210623093220.GA3718@arm.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 10:32:21AM +0100, Catalin Marinas wrote: > On arm64, neither memcpy() nor raw_copy_from_user() are expected to work > on Device mappings, we have memcpy_fromio() for this but only for > ioremap(). There's no (easy) way to distinguish in the write() syscall > how the source buffer is mapped. generic_perform_write() does an > iov_iter_fault_in_readable() check but that's not sufficient and it also > breaks the cases where you can get intra-page faults (arm64 MTE or SPARC > ADI). I think in the general case it's racy anyway (another thread doing > an mprotect(PROT_NONE) after the readable check passed). > > So I think generic_perform_write() returning -EFAULT if copied == 0 > would make sense (well, unless it breaks other cases I'm not aware of). It does break the cases of source page eviction under memory pressure. That aside, why the hell is that memory allowed to be mmaped?