[v6,2/2] btrfs: qgroup: fix sleep from invalid context bug in update_qgroup_limit_item()
Message ID | 20221116142354.1228954-3-chenxiaosong2@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp139887wru; Wed, 16 Nov 2022 05:31:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UacF9KFhhtOBbfR8VPIQz6xcIGtfuishyanNQUe8T2AJEd+u8He6SrWwZcq/v+0+UBw3x X-Received: by 2002:a17:903:26c1:b0:186:9852:b9e4 with SMTP id jg1-20020a17090326c100b001869852b9e4mr9236043plb.52.1668605470318; Wed, 16 Nov 2022 05:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668605470; cv=none; d=google.com; s=arc-20160816; b=CPEsMbK49XdQzTzHl1Yxrzn+YULZRnsgc1R2y4cTKHSeJR9PuV904eE1pL2ouVfAWE fKCyHi0gTHFEFO+kasmQqNpU+p80gPHQ6hWZOOnmWZQiWNGGSNQv7jguxA2Lb/H78uzM wI7cVHK74crwWezVpRL2Wb1NVkd8Y0TdMADqquFGYslC21sqtgjrFxyqA+XqblIlPrEK 1dwbZ0+6cJAZVa9XZc3WLqLS1+WJFh2hGrVj/o9kayMFywynRNRMSVJ6L2WdBv5Go4CQ yLd2JJYF5PWGC4PEV3zqMhSntB0p+6p/9OBjY6XeIgMr49XbMiEH+7Ij4F3h31m32mJn 32NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NG2zCvmrXdUxEt+Oqj5MJN9L1C+XD6fPgNt3J3KypZY=; b=Cu78gyCvVO0lDTXMcRxNQycuBpvpJSVNOKZ2XedF+YARgsNPgSGyBIG5AN9jjHmCnU j0++RYIF92PYZo4JtCZRlXnYdRsrbGJQbPoaDQ4Y3i2ohRPB1KV4OTIUxFSlwfAXD01n AslaJAd+kzBpjiUFXVVGlA4AYkTK5X2dgD9z1sxsWMtdq2kpTLoKK99tjbMJzymGXjRs w1rEydUnkjhmbz1gaoG7BiLkbQ/UxsAWTadAfT7CBPHNOmvkRe59R/brK/jbPbXUo23d u0NFpMr2dUuRg4Ci08GOMVqt8kNCoqsQY2l/GobokGTED/KmUMerEr0CXo2OZzai8yw/ GthA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a634c11000000b00460c07c5542si16277027pga.407.2022.11.16.05.30.54; Wed, 16 Nov 2022 05:31:10 -0800 (PST) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233966AbiKPNTj (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 08:19:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbiKPNTg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 08:19:36 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74CB220F73; Wed, 16 Nov 2022 05:19:35 -0800 (PST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NC3Xk660QzHvpW; Wed, 16 Nov 2022 21:19:02 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 21:19:33 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 21:19:32 +0800 From: ChenXiaoSong <chenxiaosong2@huawei.com> To: <clm@fb.com>, <josef@toxicpanda.com>, <dsterba@suse.com> CC: <linux-btrfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <chenxiaosong2@huawei.com>, <zhangxiaoxu5@huawei.com>, <yanaijie@huawei.com>, <quwenruo.btrfs@gmx.com>, <wqu@suse.com> Subject: [PATCH v6 2/2] btrfs: qgroup: fix sleep from invalid context bug in update_qgroup_limit_item() Date: Wed, 16 Nov 2022 22:23:54 +0800 Message-ID: <20221116142354.1228954-3-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116142354.1228954-1-chenxiaosong2@huawei.com> References: <20221116142354.1228954-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749659649703458491?= X-GMAIL-MSGID: =?utf-8?q?1749659649703458491?= |
Series |
btrfs: fix sleep from invalid context bug in update_qgroup_limit_item()
|
|
Commit Message
ChenXiaoSong
Nov. 16, 2022, 2:23 p.m. UTC
Syzkaller reported BUG as follows:
BUG: sleeping function called from invalid context at
include/linux/sched/mm.h:274
Call Trace:
<TASK>
dump_stack_lvl+0xcd/0x134
__might_resched.cold+0x222/0x26b
kmem_cache_alloc+0x2e7/0x3c0
update_qgroup_limit_item+0xe1/0x390
btrfs_qgroup_inherit+0x147b/0x1ee0
create_subvol+0x4eb/0x1710
btrfs_mksubvol+0xfe5/0x13f0
__btrfs_ioctl_snap_create+0x2b0/0x430
btrfs_ioctl_snap_create_v2+0x25a/0x520
btrfs_ioctl+0x2a1c/0x5ce0
__x64_sys_ioctl+0x193/0x200
do_syscall_64+0x35/0x80
Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in
btrfs_run_qgroups() later.
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
---
fs/btrfs/qgroup.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
Comments
On 2022/11/16 22:23, ChenXiaoSong wrote: > Syzkaller reported BUG as follows: > > BUG: sleeping function called from invalid context at > include/linux/sched/mm.h:274 > Call Trace: > <TASK> > dump_stack_lvl+0xcd/0x134 > __might_resched.cold+0x222/0x26b > kmem_cache_alloc+0x2e7/0x3c0 > update_qgroup_limit_item+0xe1/0x390 > btrfs_qgroup_inherit+0x147b/0x1ee0 > create_subvol+0x4eb/0x1710 > btrfs_mksubvol+0xfe5/0x13f0 > __btrfs_ioctl_snap_create+0x2b0/0x430 > btrfs_ioctl_snap_create_v2+0x25a/0x520 > btrfs_ioctl+0x2a1c/0x5ce0 > __x64_sys_ioctl+0x193/0x200 > do_syscall_64+0x35/0x80 > > Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in > btrfs_run_qgroups() later. > > Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/qgroup.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index 9334c3157c22..b74105a10f16 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -2951,14 +2951,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, > dstgroup->rsv_rfer = inherit->lim.rsv_rfer; > dstgroup->rsv_excl = inherit->lim.rsv_excl; > > - ret = update_qgroup_limit_item(trans, dstgroup); > - if (ret) { > - qgroup_mark_inconsistent(fs_info); > - btrfs_info(fs_info, > - "unable to update quota limit for %llu", > - dstgroup->qgroupid); > - goto unlock; > - } > + qgroup_dirty(fs_info, dstgroup); > } > > if (srcid) {
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 9334c3157c22..b74105a10f16 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -2951,14 +2951,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, dstgroup->rsv_rfer = inherit->lim.rsv_rfer; dstgroup->rsv_excl = inherit->lim.rsv_excl; - ret = update_qgroup_limit_item(trans, dstgroup); - if (ret) { - qgroup_mark_inconsistent(fs_info); - btrfs_info(fs_info, - "unable to update quota limit for %llu", - dstgroup->qgroupid); - goto unlock; - } + qgroup_dirty(fs_info, dstgroup); } if (srcid) {