Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp463546lqp; Sat, 13 Apr 2024 05:05:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvnaJq95Q2Y24j0ucBDw3hPR12i4ukbHDBFqeGoABBn6REUtm8n1/NUN9x0DsAlK3iaXreOKxK+HW0YoVcq4m9LPcJdF1XVPIbuMpA0g== X-Google-Smtp-Source: AGHT+IF6EMFXAumaym454OmuNIkntkbzUuhCyS3dmEuFKd9v4DcWxfmTGx55Ps+6em12vbNFfrG3 X-Received: by 2002:a05:6a21:3283:b0:1a9:68c6:c0a7 with SMTP id yt3-20020a056a21328300b001a968c6c0a7mr6632458pzb.9.1713009937400; Sat, 13 Apr 2024 05:05:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713009937; cv=pass; d=google.com; s=arc-20160816; b=Vg9bysrHzoxnnW0y7qfC4uU9qRTPf6yBbEf0gBpLiQ3FsOUDLM0blX7G7qZA+2TmDi btoX9amFaDRpeorSCDLzRjk4LyujYjcfmhJTpw2EWtBYED3pLRKE70mKLRZ7rq84DzY7 z6SGRVY5hgw8/IXxJpCSNurIPahfNCbFYHIfUAGWhqsRVrikR30d3uPdAzzUs/7XMHdI 0N+hnnF8WF8kR52e21y8eaUKoQzlZcK+EchMDlE41CYDnwoQkGWEQP00d+DgUAfODsV0 Wc64wNYHxGQV2B3sm7kdyUI8mlTYsoPYmV7SRpKYyHd79tjBkrq82y8fzjrYQXHPH+Zf Hzbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zQ1FGgNIg0k+I4UahvT89tNdkIK7R2oXFwHH5kRe97k=; fh=oXHpO6PJ50PAEDWmayfyiFGkUuo1Ulw1QcT+04Wa164=; b=zmLVO+e+jb9s3QbXUPHSUgd/PQtuUsFzIx5kYBG9If6B9URHJdhLhLLcBjMJN20eeh tzWK4XP//QJBw7fP4av39MvTm+3L4+kfnpsFyDVb8gMvFX64NZDzC0+cPE/ct4qwtMh0 rA8kKlEwqbtbMaj3qIc7nDuZxmrUxaGU9lOi3ifZ4yQG3UCcqFz/syMWEwM2aMJPGVwu jiYJRH6uCEC6jS11PwZjoj3xaBTfTLutt+WoPgkf7L+yJLoxHool4hnDhUlbjk7uSzIE 7aNKwNHNH7KLFyKvwzUPnptjBthQRp7bU7GuvmJURqDSNLLss7WYzspP2O8wSK2MP+Sv DJBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-143726-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143726-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bs64-20020a632843000000b005e42b4c97f2si4706333pgb.289.2024.04.13.05.05.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 05:05:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143726-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-143726-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143726-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5C0FDB217BF for ; Sat, 13 Apr 2024 12:05:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A95F4087B; Sat, 13 Apr 2024 12:05:24 +0000 (UTC) Received: from mail115-63.sinamail.sina.com.cn (mail115-63.sinamail.sina.com.cn [218.30.115.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 575A9381B9 for ; Sat, 13 Apr 2024 12:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.63 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713009923; cv=none; b=kR5JZznxWfS2lTWs3E49ohaefe2k8Ww9kW+QjyGyfpaZC74wkansoMs4RXJlw2lzhAH8R/65bXwDR46qQRuw584tpfzE6F1vXszjTdK87FMJW/G5r0pVP/kJOHqd0ROZjs1EC8CpOjrpoZDpqjkz98euDj8HoFqMYDq1MbUHc7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713009923; c=relaxed/simple; bh=ZwDuFROcMYHb63Lc+jpXgLARAMWwJuw+kBamNEgQdPk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JkS6Y5ZECVoUR6PyIKOPyoDKyO+I4RAOVsU5C0EM/BxOO5HiooVdbONMy9Y59sEz2CqzZq5JV7+dHn4UoKawCGv46NcA+b16WEs5ljUZj4T0t+xcpELnZsHC8SuJTNvesp+qxVWVjhNhwwXcTUe0p4sy/A56qse0oM3dbKYxsn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.88.51.22]) by sina.com (10.75.12.45) with ESMTP id 661A74CE000057DC; Sat, 13 Apr 2024 20:04:32 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 82145831457969 X-SMAIL-UIID: 86D990D479B54C46B1D514ADBD1C56AF-20240413-200432-1 From: Hillf Danton To: Amir Goldstein Cc: Jan Kara , syzbot , syzkaller-bugs@googlegroups.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [syzbot] [ext4?] KASAN: slab-use-after-free Read in fsnotify Date: Sat, 13 Apr 2024 20:04:26 +0800 Message-Id: <20240413120426.1889-1-hdanton@sina.com> In-Reply-To: References: <00000000000095bb400615f4b0ed@google.com> <20240413084519.1774-1-hdanton@sina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sat, 13 Apr 2024 12:32:32 +0300 Amir Goldstein > On Sat, Apr 13, 2024 at 11:45=E2=80=AFAM Hillf Danton wrote: > > > > If you composed fix based on SB_ACTIVE that is cleared in > > generic_shutdown_super() with &sb->s_umount held for write, > > I wonder what simpler serialization than srcu you could > > find/create in fsnotify. > > As far as I can tell there is no need for serialisation. > > The problem is that fsnotify_sb_error() can be called from the > context of ->put_super() call from generic_shutdown_super(). > > It's true that in the repro the thread calling fsnotify_sb_error() > in the worker thread running quota deferred work from put_super() > but I think there are sufficient barriers for this worker thread to > observer the cleared SB_ACTIVE flag. > do_exit quota_release_workfn --- --- cleanup_mnt() ext4_release_dquot() __super_lock_excl(s); __ext4_error() deactivate_locked_super(s); fsnotify_sb_error() ext4_kill_sb() kill_block_super() generic_shutdown_super() if (!(sb->s_flags & SB_ACTIVE)) return; sb->s_flags &= ~SB_ACTIVE; fsnotify_sb_delete() fsnotify() Because of no sync like taking &sb->s_umount in the worker context, checking SB_ACTIVE added in your fix is unable to close the race. > Anyway, according to syzbot, repro does not trigger the UAF > with my last fix. > Note: testing is done by a robot and is best-effort only.