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=-17.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 81818C4707F for ; Thu, 27 May 2021 09:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EE2860249 for ; Thu, 27 May 2021 09:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235921AbhE0Jx0 (ORCPT ); Thu, 27 May 2021 05:53:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25978 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbhE0JxX (ORCPT ); Thu, 27 May 2021 05:53:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622109110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u9Cxtk2CGDavcxRvdG5xqMXG/D6DQ86Gj3Jra0Du2iA=; b=GEyDwZi8Wo5GrE6ocnn/fhfXN8atBfKm+G4GrDeRi+jNCsoIpxVWj5qqT5DbpNZxRLYfHe HGcpu0MFGADdg1nhq7nav+5EFZbf1nVoV5LB1XsRuqXRAYbHTBSpMtiDU3OEeEDCeiq0pu D0yHIlrOMGpu6gPAtUC9N8jZvCwEOFo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-H_O0Ks53PH6uw7WYjNETzA-1; Thu, 27 May 2021 05:51:46 -0400 X-MC-Unique: H_O0Ks53PH6uw7WYjNETzA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28388101371B; Thu, 27 May 2021 09:51:45 +0000 (UTC) Received: from dresden.str.redhat.com (ovpn-114-232.ams2.redhat.com [10.36.114.232]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 873B3687D7; Thu, 27 May 2021 09:51:39 +0000 (UTC) Subject: Re: [Virtio-fs] [PATCH 1/4] fuse: Fix crash in fuse_dentry_automount() error path To: Greg Kurz , Miklos Szeredi Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, virtio-fs@redhat.com, linux-fsdevel@vger.kernel.org, Vivek Goyal References: <20210525150230.157586-1-groug@kaod.org> <20210525150230.157586-2-groug@kaod.org> From: Max Reitz Message-ID: Date: Thu, 27 May 2021 11:51:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210525150230.157586-2-groug@kaod.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.05.21 17:02, Greg Kurz wrote: > If fuse_fill_super_submount() returns an error, the error path > triggers a crash: > > [ 26.206673] BUG: kernel NULL pointer dereference, address: 0000000000000000 > [...] > [ 26.226362] RIP: 0010:__list_del_entry_valid+0x25/0x90 > [...] > [ 26.247938] Call Trace: > [ 26.248300] fuse_mount_remove+0x2c/0x70 [fuse] > [ 26.248892] virtio_kill_sb+0x22/0x160 [virtiofs] > [ 26.249487] deactivate_locked_super+0x36/0xa0 > [ 26.250077] fuse_dentry_automount+0x178/0x1a0 [fuse] > > The crash happens because fuse_mount_remove() assumes that the FUSE > mount was already added to list under the FUSE connection, but this > only done after fuse_fill_super_submount() has returned success. > > This means that until fuse_fill_super_submount() has returned success, > the FUSE mount isn't actually owned by the superblock. We should thus > reclaim ownership by clearing sb->s_fs_info, which will skip the call > to fuse_mount_remove(), and perform rollback, like virtio_fs_get_tree() > already does for the root sb. > > Fixes: bf109c64040f ("fuse: implement crossmounts") > Cc: mreitz@redhat.com > Cc: stable@vger.kernel.org # v5.10+ > Signed-off-by: Greg Kurz > --- > fs/fuse/dir.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) Reviewed-by: Max Reitz