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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 98678C433EF for ; Mon, 29 Nov 2021 13:53:39 +0000 (UTC) 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=xVEzqsziLmEorVKqk4HoLkRAMhWXyx3rWD0Ph6fAKlU=; b=d3DEr3m2a3RuW7 EQfX/aomzWPYsqC6Z59329fmA5A/bHdKIqXJ48t65D8IE20LRthu6n2uBR4mWwlLia5CfZ9aCttQn Tu9Zd3Nf7+5ezDu6o/li3Z2LIYnPYw5nz8gfQkWuK9kjWLOXCGsuP5nQ+lsaBBw/VhdUX1O51ePK2 08FnM2sodNTgZ3E1ambwgssqFGa9UawNamg2rWUsZvEQnJQumdXQNw8j0pvzvsn3l2xKx8OKdBdgn FWFSNVxJsk+bqwq9YZfQ0f3jz/w+QjR6/1A2rvHKe1PLIQ/RSnOF1XyIzDZNMwjtTxn23bR3Qaha3 0Vo2pO0yaQhTCjKBX75w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrh4y-000uW6-3X; Mon, 29 Nov 2021 13:52:24 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrh4t-000uUn-Qv for linux-arm-kernel@lists.infradead.org; Mon, 29 Nov 2021 13:52:21 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 18BBB6152D; Mon, 29 Nov 2021 13:52:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71BD1C004E1; Mon, 29 Nov 2021 13:52:16 +0000 (UTC) Date: Mon, 29 Nov 2021 13:52:12 +0000 From: Catalin Marinas To: Andreas Gruenbacher Cc: Matthew Wilcox , Linus Torvalds , Josef Bacik , David Sterba , Al Viro , Andrew Morton , Will Deacon , linux-fsdevel , LKML , Linux ARM , linux-btrfs Subject: Re: [PATCH 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults Message-ID: References: <20211124192024.2408218-1-catalin.marinas@arm.com> <20211124192024.2408218-4-catalin.marinas@arm.com> <20211127123958.588350-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211129_055219_924442_4CD73A6A X-CRM114-Status: GOOD ( 13.96 ) 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 Sat, Nov 27, 2021 at 07:05:39PM +0100, Andreas Gruenbacher wrote: > Maybe you want to add this though: > > --- a/fs/btrfs/ioctl.c > +++ b/fs/btrfs/ioctl.c > @@ -2202,3 +2202,3 @@ static noinline int search_ioctl(struct inode *inode, > unsigned long sk_offset = 0; > - char __user *fault_in_addr; > + char __user *fault_in_addr, *end; > > @@ -2230,6 +2230,6 @@ static noinline int search_ioctl(struct inode *inode, > fault_in_addr = ubuf; > + end = ubuf + *buf_size; > while (1) { > ret = -EFAULT; > - if (fault_in_writeable(fault_in_addr, > - *buf_size - (fault_in_addr - ubuf))) > + if (fault_in_writeable(fault_in_addr, end - fault_in_addr)) > break; It looks like *buf_size is updated inside copy_to_sk(), so I'll move the end update inside the loop. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel