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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04F68C433F5 for ; Fri, 22 Oct 2021 09:34:22 +0000 (UTC) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 93C9B610CB for ; Fri, 22 Oct 2021 09:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 93C9B610CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=oss.oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M8qCXb019206; Fri, 22 Oct 2021 09:34:21 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3but5xg6au-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Oct 2021 09:34:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M9Ff6J174874; Fri, 22 Oct 2021 09:34:13 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 3br8gxng9j-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Fri, 22 Oct 2021 09:34:12 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1mdqwF-0004Ji-Ra; Fri, 22 Oct 2021 02:34:11 -0700 Received: from aserp3020.oracle.com ([141.146.126.70]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1mdqwC-0004JJ-PE for ocfs2-devel@oss.oracle.com; Fri, 22 Oct 2021 02:34:08 -0700 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19M9FIJF159349 for ; Fri, 22 Oct 2021 09:34:08 GMT Received: from mx0a-00069f01.pphosted.com (mx0a-00069f01.pphosted.com [205.220.165.26]) by aserp3020.oracle.com with ESMTP id 3bqpjac01h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 22 Oct 2021 09:34:08 +0000 Received: from pps.filterd (m0246575.ppops.net [127.0.0.1]) by mx0b-00069f01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M6ZkEn019378 for ; Fri, 22 Oct 2021 09:34:07 GMT Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx0b-00069f01.pphosted.com with ESMTP id 3bur5vhwdg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 22 Oct 2021 09:34:07 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4BE761163; Fri, 22 Oct 2021 09:34:03 +0000 (UTC) Date: Fri, 22 Oct 2021 10:34:00 +0100 From: Catalin Marinas To: Linus Torvalds Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Source-IP: 198.145.29.99 X-ServerName: mail.kernel.org X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 mx include:_spf.kernel.org ~all X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Reason: safe X-Spam: OrgSafeList X-SpamRule: orgsafelist Cc: cluster-devel , Jan Kara , Andreas Gruenbacher , Linux Kernel Mailing List , Josef Bacik , Christoph Hellwig , Al Viro , linux-fsdevel , Will Deacon , "ocfs2-devel@oss.oracle.com" Subject: Re: [Ocfs2-devel] [RFC][arm64] possible infinite loop in btrfs search_ioctl() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 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: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10144 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110220051 X-Proofpoint-ORIG-GUID: LZb_p1EG7Xp3LTZGIH8lre7HGcHtrhJS X-Proofpoint-GUID: LZb_p1EG7Xp3LTZGIH8lre7HGcHtrhJS On Thu, Oct 21, 2021 at 04:30:30PM -1000, Linus Torvalds wrote: > On Thu, Oct 21, 2021 at 4:42 AM Andreas Gruenbacher wrote: > > But probing the entire memory range in fault domain granularity in the > > page fault-in functions still doesn't actually make sense. Those > > functions really only need to guarantee that we'll be able to make > > progress eventually. From that point of view, it should be enough to > > probe the first byte of the requested memory range > > That's probably fine. > > Although it should be more than one byte - "copy_from_user()" might do > word-at-a-time optimizations, so you could have an infinite loop of > > (a) copy_from_user() fails because the chunk it tried to get failed partly > > (b) fault_in() probing succeeds, because the beginning part is fine > > so I agree that the fault-in code doesn't need to do the whole area, > but it needs to at least do some thing, to > handle the situation where the copy_to/from_user requires more than a > single byte. >>From a discussion with Al some months ago, if there are bytes still accessible, copy_from_user() is not allowed to fail fully (i.e. return the requested copy size) even when it uses word-at-a-time. In the worst case, it should return size - 1. If the fault_in() then continues probing from uaddr + 1, it should eventually hit the faulty address. The problem appears when fault_in() restarts from uaddr rather than where copy_from_user() stopped. That's what the btrfs search_ioctl() does. I also need to check the direct I/O cases that Andreas mentioned, maybe they can be changed not to attempt the fault_in() from the beginning of the block. -- Catalin _______________________________________________ Ocfs2-devel mailing list Ocfs2-devel@oss.oracle.com https://oss.oracle.com/mailman/listinfo/ocfs2-devel