Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4610433rwb; Tue, 8 Aug 2023 10:56:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHWiUmWmGYE8LibK4+bd6XbiEungBYjVAJlHRBvdAqwt8+a38y5Dnq3aqUVPxweDnJnbhr X-Received: by 2002:a05:6a20:1611:b0:134:149e:7b74 with SMTP id l17-20020a056a20161100b00134149e7b74mr233160pzj.61.1691517386285; Tue, 08 Aug 2023 10:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691517386; cv=none; d=google.com; s=arc-20160816; b=laBcAKNYfZNUPVF2Vk3kVC/2fmmfrpVlW0wQDN21E6pPn7igXzAe68NJzOnQSOKvAl AsP338GvXAg9I/aLe8wfcCXW8EbOwWsmjpEIyiwhHO3F/Ugb+kwV6cndpa6U8t3Yq4vT 0eJ5exuG3vVZV6SRiudSk+JJ0B92jfpwzGKjcHMbAI90zPfy/EjBeJmgaJm8Iuwz8xc4 3PMlW33KZgChC+G0F4zTqPvj0Y/QWbUallP4YLhX6SCeSHC7daSb/UiXgXN+JGF/W+4Q DKfJqtPfaXrtnOn161VHN0qDQLSgDAi1NfbLs1TUauu3jbZ0bkZ7GMGGyDLbKWGS25Fc cOvQ== 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:message-id:subject:cc:to:from:date; bh=mNrIAiQso5/sdKuObGWm5afCW+UJUXYfIwiB5JlKbkY=; fh=PqIvRlgNc+6IBlhb5Qquov7fUuV5lEzdZJqUSvDaC5I=; b=uyvrGly9vuoi/286knGXpY/5UqT/NJfzLVayVoS1Ieo5sEOnTYBmhNiipoeK+tNsR+ AT4P2MIbGtimsSjs5BOKD3HpGymg+xsDfahlJwRW88HNHsk4OAzT9tEfC0ss9IiccGnU MCJTaYuuabqPZKQwNbjANBVyg8EXPoHIwCD0jOEqfNhAbb2k9jASwCgaacc+Ah/eWHcD KIbvIPpko7UM8NbasGl/n/ll0njM5WK5jS9+94VeIrXjaIvZxgbcbcu1D+Wsbhq3u6MD qxftZ/iXl98KmPCi1P1lL+XEC2jLrGIbfa3Kbt28ZujJwUCm/QXTY9wtgtyVPDP9Fica b6vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a633f0e000000b00557531eafb0si5429002pga.559.2023.08.08.10.56.11; Tue, 08 Aug 2023 10:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbjHHRHa (ORCPT + 99 others); Tue, 8 Aug 2023 13:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233977AbjHHRGb (ORCPT ); Tue, 8 Aug 2023 13:06:31 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 430085F860; Tue, 8 Aug 2023 09:02:44 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id CBBB967373; Tue, 8 Aug 2023 18:01:41 +0200 (CEST) Date: Tue, 8 Aug 2023 18:01:41 +0200 From: Christoph Hellwig To: Christian Brauner Cc: hch@lst.de, clm@fb.com, dsterba@suse.com, josef@toxicpanda.com, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot Subject: Re: [syzbot] [btrfs?] KASAN: slab-use-after-free Read in btrfs_open_devices Message-ID: <20230808160141.GA15875@lst.de> References: <0000000000007921d606025b6ad6@google.com> <000000000000094846060260e710@google.com> <20230808-zentimeter-kappen-5da1e70c5535@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230808-zentimeter-kappen-5da1e70c5535@brauner> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,GB_FAKE_RF_SHORT, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 Yes, probably. The lifetimes looked fishy to me to start with, but this might have made things worse. On Tue, Aug 08, 2023 at 05:50:02PM +0200, Christian Brauner wrote: > On Mon, Aug 07, 2023 at 08:24:36PM -0700, syzbot wrote: > > syzbot has bisected this issue to: > > > > commit 066d64b26a21a5b5c500a30f27f3e4b1959aac9e > > Author: Christoph Hellwig > > Date: Wed Aug 2 15:41:23 2023 +0000 > > > > btrfs: open block devices after superblock creation > > > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15493371a80000 > > start commit: f7dc24b34138 Add linux-next specific files for 20230807 > > git tree: linux-next > > final oops: https://syzkaller.appspot.com/x/report.txt?x=17493371a80000 > > console output: https://syzkaller.appspot.com/x/log.txt?x=13493371a80000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=d7847c9dca13d6c5 > > dashboard link: https://syzkaller.appspot.com/bug?extid=26860029a4d562566231 > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=179704c9a80000 > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17868ba9a80000 > > > > Reported-by: syzbot+26860029a4d562566231@syzkaller.appspotmail.com > > Fixes: 066d64b26a21 ("btrfs: open block devices after superblock creation") > > > > For information about bisection process see: https://goo.gl/tpsmEJ#bisection > > I think the issue might be that before your patch the lifetime of: > @device was aligned with @device->s_fs_info but now that you're dropping > the uuid mutex after btrfs_scan_one_device() that isn't true anymore. So > it feels like: > > P1 P2 > lock_uuid_mutex; > device = btrfs_scan_one_device(); > fs_devices = device->fs_devices; > unlock_uuid_mutex; > // earlier mount that gets cleaned up > lock_uuid_mutex; > btrfs_close_devices(fs_devices); > unlock_uuid_mutex; > > lock_uuid_mutex; > btrfs_open_devices(fs_devices); // UAF > unlock_uuid_mutex; > > But I'm not entirely sure. ---end quoted text---