Re: [btrfs?] general protection fault in getname_kernel (2)

From: Edward Adam Davis
Date: Wed Oct 09 2024 - 10:40:53 EST


The origin fc's source is NULL

#syz test

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 692f81f1e23e..06bdf0cf7b88 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2148,6 +2148,8 @@ static int btrfs_dup_fs_context(struct fs_context *fc, struct fs_context *src_fc
* mounting, and then once we free the dup it'll free ->source, so we
* need to make sure we're only pointing to it in one fc.
*/
+ if (!src_fc->source)
+ return -EINVAL;
refcount_inc(&ctx->refs);
fc->fs_private = ctx;
fc->source = src_fc->source;