Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Su Yue <l@damenly.su>
To: linux-btrfs@vger.kernel.org
Cc: l@damenly.su
Subject: [PATCH v2 1/2] btrfs: prevent NULL pointer dereference in extent_io_tree_panic()
Date: Sun,  3 Jan 2021 17:28:03 +0800	[thread overview]
Message-ID: <20210103092804.756-2-l@damenly.su> (raw)
In-Reply-To: <20210103092804.756-1-l@damenly.su>

Some extent io trees are initialized with NULL private member(e.g., btrfs_devi
ce::alloc_state and btrfs_fs_info::excluded_extents). Dereference of a NULL
@tree->private as struct inode * will cause kernel panic.

Just pass @tree->fs_info as parameter to extent_io_tree_panic() directly.
Let it panic as expected at least.

Fixes: 05912a3c04eb ("btrfs: drop extent_io_ops::tree_fs_info callback")
Signed-off-by: Su Yue <l@damenly.su>
---
 fs/btrfs/extent_io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 6e3b72e63e42..c9cee458e001 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -676,9 +676,7 @@ alloc_extent_state_atomic(struct extent_state *prealloc)
 
 static void extent_io_tree_panic(struct extent_io_tree *tree, int err)
 {
-	struct inode *inode = tree->private_data;
-
-	btrfs_panic(btrfs_sb(inode->i_sb), err,
+	btrfs_panic(tree->fs_info, err,
 	"locking error: extent tree was modified by another thread while locked");
 }
 
-- 
2.29.2


  reply	other threads:[~2021-01-03  9:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-03  9:28 [PATCH v2 0/2] btrfs: fix issues when mouting the poc image Su Yue
2021-01-03  9:28 ` Su Yue [this message]
2021-01-04  7:33   ` [PATCH v2 1/2] btrfs: prevent NULL pointer dereference in extent_io_tree_panic() Anand Jain
2021-01-03  9:28 ` [PATCH v2 2/2] btrfs: tree-checker: check if chunk item end oveflows Su Yue
2021-01-04  8:31   ` Anand Jain
2021-01-04  9:15     ` Su Yue
2021-01-05  3:31       ` Anand Jain
2021-01-04 15:59   ` David Sterba
2021-01-04 15:58 ` [PATCH v2 0/2] btrfs: fix issues when mouting the poc image David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210103092804.756-2-l@damenly.su \
    --to=l@damenly.su \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox