Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp49363pxh; Thu, 7 Apr 2022 13:37:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAICATPMXaZkd+5C4xJoHbkMcbyRcFSrq9lgI0tb/ZOo4eA1ifZXvgP3MCfAxQiIeh3XyS X-Received: by 2002:a17:902:788b:b0:157:a9c:6fb6 with SMTP id q11-20020a170902788b00b001570a9c6fb6mr4409419pll.110.1649363854349; Thu, 07 Apr 2022 13:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363854; cv=none; d=google.com; s=arc-20160816; b=z+SThRBJ4O3XF57fTXcoSi8fMkE+Dmn5Yj0x1+AwgD3acktGFcblSA6eXnZny/YTYQ PIwQmrLrDAK7sg4qqq7dXowKtiIZGWO1HfquPs8j4oY6aavaU663GBFag+SVJ/CccbuA LbnxISAf3LpZ8JuWoTHI6Ny8oAiZViUG+DMevEQ7HxlZXfTrWbzVmrSb8Sz2QXfRKkQx qLINglFfWXphhjvYWUgQiGeg8LBnNRQGKQRui+0c4NvDwTpR/YFW9uuvHL0l19OkIiVk 8ofPPHnTnSkPmHhHPpKUAhHpJkBLGgQAyRghAz23i3Zs2nlAYwNyymrmI0bsGUDP7BHG 1tzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=98548563aIgFxuTbEGhuFrrjF0oRxSf7O8rE+4waoDU=; b=jHHqf1g271nTKNnFglZ0dA326IWdxEprDnhwj1nvcy9g1xJGwvUHNPCiZ08Ow3u7+c SayQJ/XA75ZYOIhJB8eHBqfyRjkuI9zfj7FWvtqfeGCamw7IF7AddjPEmOOiZYvcSk+g O/6P6Z0EDhxFJRLEGdgDaUdIBjREPpgoE1eLRr1DF6hfSbOF4EMB8nDTerHCq2XI7UMF VLQsKFXQ3NRvDbyPM0MZ8VNAepYpCOnBh4/MpoiVTuLy77vJjr/oMHqr1UGqEz6EJjFP ET7HHbVwJ7ZvTTBAVmwmUc2qVvSsRnCV9Y54akaR7IqEzJRKKQIIIg64u62TQ/LJ5n5W gxeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="g4l9K/uv"; dkim=neutral (no key) header.i=@suse.cz header.b=LI5tM34l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v11-20020a63f84b000000b003816043f026si17666792pgj.539.2022.04.07.13.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="g4l9K/uv"; dkim=neutral (no key) header.i=@suse.cz header.b=LI5tM34l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A1CC3858E6; Thu, 7 Apr 2022 12:48:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240657AbiDGLLZ (ORCPT + 99 others); Thu, 7 Apr 2022 07:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233754AbiDGLLV (ORCPT ); Thu, 7 Apr 2022 07:11:21 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56F1183BD; Thu, 7 Apr 2022 04:09:21 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5DCE721117; Thu, 7 Apr 2022 11:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1649329760; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=98548563aIgFxuTbEGhuFrrjF0oRxSf7O8rE+4waoDU=; b=g4l9K/uvaXiqTrh3Weo9re3njIkaiqWsHhVzlu2BUyNo8+Kh97Oe45WKq1IDepkLQ+TCXq DWZCwJ6llV/96zFlTJlkAQsQx4ls9hq9WD2RvRBSCuqRBeaTM2glq5AusAaLjUIyrHa8sw Gci42F79V2a/ZAc58R5BDeZFhJPA1GM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1649329760; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=98548563aIgFxuTbEGhuFrrjF0oRxSf7O8rE+4waoDU=; b=LI5tM34lmFPs2XvK0D3ZAkCwGn99zxxeFnUMWJtRtT3TH/8rccyWZ9R4XYqXWwEnLrQoGV +Yxxp19aOb7tPGDQ== Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 47FA2A3B88; Thu, 7 Apr 2022 11:09:20 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 314E5DA80E; Thu, 7 Apr 2022 13:05:18 +0200 (CEST) Date: Thu, 7 Apr 2022 13:05:18 +0200 From: David Sterba To: Catalin Marinas Cc: Linus Torvalds , Andreas Gruenbacher , Josef Bacik , Al Viro , Andrew Morton , Chris Mason , David Sterba , Will Deacon , linux-fsdevel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] btrfs: Avoid live-lock in search_ioctl() on hardware with sub-page faults Message-ID: <20220407110518.GE15609@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Catalin Marinas , Linus Torvalds , Andreas Gruenbacher , Josef Bacik , Al Viro , Andrew Morton , Chris Mason , David Sterba , Will Deacon , linux-fsdevel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220406180922.1522433-1-catalin.marinas@arm.com> <20220406180922.1522433-4-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220406180922.1522433-4-catalin.marinas@arm.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 06, 2022 at 07:09:22PM +0100, Catalin Marinas wrote: > Commit a48b73eca4ce ("btrfs: fix potential deadlock in the search > ioctl") addressed a lockdep warning by pre-faulting the user pages and > attempting the copy_to_user_nofault() in an infinite loop. On > architectures like arm64 with MTE, an access may fault within a page at > a location different from what fault_in_writeable() probed. Since the > sk_offset is rewound to the previous struct btrfs_ioctl_search_header > boundary, there is no guaranteed forward progress and search_ioctl() may > live-lock. > > Use fault_in_subpage_writeable() instead of fault_in_writeable() to > ensure the permission is checked at the right granularity (smaller than > PAGE_SIZE). > > Signed-off-by: Catalin Marinas > Fixes: a48b73eca4ce ("btrfs: fix potential deadlock in the search ioctl") > Reported-by: Al Viro Acked-by: David Sterba