Received: from n169-111.mail.139.com (n169-111.mail.139.com [120.232.169.111]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C43358C1F for ; Tue, 24 Feb 2026 03:36:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=120.232.169.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771904217; cv=none; b=lRGOmY3KrZBa2JjhsPYpqkiSHhcYvqvpaTdy+kghrxXI1fspB2pSJlUAzZ5ua9KP1kS+jYSHMV1MlZM+Q3xw22K6HUOjMqKa5wae66r32jtH1iv+EPpdUqPqX6//euoO6Wu6CJv7VaTUwaJ+TdSV8U0L7qsG3IJH3Ez3rekjRbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771904217; c=relaxed/simple; bh=ErJlm82ImNLhLdSoIgv+QJnE9j/M4ecqEgTTZKHxD6M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=aqd4DYK229x6E9EXF4V7Vc4cC7VD97Pr/RlFldM+CK1B6BGWozlCMOW7PauyNICf7auFm/8FKoLRmo+3MZ0rSbt+C+1W+QSdOQDzPLbTzUorpKLUl8zPcaLNNHFxztvXfAEA0Wb71Myq4MW9n2WdJB7DPmWLf8f1TXGNILPfseM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=139.com; spf=pass smtp.mailfrom=139.com; dkim=pass (1024-bit key) header.d=139.com header.i=@139.com header.b=5JF4KW2J; arc=none smtp.client-ip=120.232.169.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=139.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=139.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=139.com header.i=@139.com header.b="5JF4KW2J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=139.com; s=dkim; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=5JF4KW2JhSfYU2clmoNc5KxQNNMYipPM84lzHrjGqzd8D52WTOiQnx0RtvTqt3bmO6FdmAqjxYOfZ fQb9RD/lHEQz6X1Ysf9er4z+VTgm8YbOBjFhTo1p7IaPKduzkHhDHMo63SMQ6LaQeFOvcTjLV9ahTT 3HusbLnOSjnZ4Ojw= X-RM-TagInfo: emlType=0 X-RM-SPAM: X-RM-SPAM-FLAG:00000000 Received:from ubuntu24.corp.ad.wrs.com (unknown[120.244.194.215]) by rmsmtp-lg-appmail-11-12089 (RichMail) with SMTP id 2f39699d1bcf10f-d95d2; Tue, 24 Feb 2026 11:32:32 +0800 (CST) X-RM-TRANSID:2f39699d1bcf10f-d95d2 From: Bin Lan To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: =?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= , syzbot+d991fea1b4b23b1f6bf8@syzkaller.appspotmail.com, David Sterba , Bin Lan Subject: [PATCH 6.6.y] btrfs: fix NULL dereference on root when tracing inode eviction Date: Tue, 24 Feb 2026 03:32:14 +0000 Message-ID: <20260224033214.4976-1-lanbincn@139.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Miquel Sabaté Solà [ Upstream commit f157dd661339fc6f5f2b574fe2429c43bd309534 ] When evicting an inode the first thing we do is to setup tracing for it, which implies fetching the root's id. But in btrfs_evict_inode() the root might be NULL, as implied in the next check that we do in btrfs_evict_inode(). Hence, we either should set the ->root_objectid to 0 in case the root is NULL, or we move tracing setup after checking that the root is not NULL. Setting the rootid to 0 at least gives us the possibility to trace this call even in the case when the root is NULL, so that's the solution taken here. Fixes: 1abe9b8a138c ("Btrfs: add initial tracepoint support for btrfs") Reported-by: syzbot+d991fea1b4b23b1f6bf8@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=d991fea1b4b23b1f6bf8 Signed-off-by: Miquel Sabaté Solà Reviewed-by: David Sterba Signed-off-by: David Sterba [ Adjust context ] Signed-off-by: Bin Lan --- include/trace/events/btrfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index f759109caeea..eb762cc7bec5 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -225,8 +225,8 @@ DECLARE_EVENT_CLASS(btrfs__inode, __entry->generation = BTRFS_I(inode)->generation; __entry->last_trans = BTRFS_I(inode)->last_trans; __entry->logged_trans = BTRFS_I(inode)->logged_trans; - __entry->root_objectid = - BTRFS_I(inode)->root->root_key.objectid; + __entry->root_objectid = BTRFS_I(inode)->root ? + btrfs_root_id(BTRFS_I(inode)->root) : 0; ), TP_printk_btrfs("root=%llu(%s) gen=%llu ino=%llu blocks=%llu " -- 2.43.0