Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3578826pxb; Mon, 24 Jan 2022 12:41:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSJwnZ2YSXnJdOOBZOcQLiR8jthA5cazjxTcSSeZdBHT++ICHff5+MJzBDcST8pMXNfFtH X-Received: by 2002:a17:902:a404:b0:148:b897:c658 with SMTP id p4-20020a170902a40400b00148b897c658mr16001357plq.71.1643056869093; Mon, 24 Jan 2022 12:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056869; cv=none; d=google.com; s=arc-20160816; b=TfqI8kte1Fypmeg7fSjD5GvHr+BYUkzaG3gn2c06IyGKidZOlaJTJnzBMQGNBl+wyW oHSIRd+eYD2uMjGRImtEFIbAbb3EzsNH7L5ElYpZN5k7Zwl4if9xOWjO2zC3+OnZIrDU DTecsKsFesYotzyUdG4zIXVOuDAPOOmsYpadhkI7oxDeYf1CQm7k1hKYGWJWBCNNh43u SZmRSTlIBilNj8BEDUq3MoGS2o8bUYVSAp8n5HcKzIT9AgCxKKcPu1eDqeL4skyvQ/Yb lwoUV4iG5348c2lBlLKBqUqETi6oSVT/KqTVmsFX2LdPhWTw6yQj2Xs73kd2xAKZoAxz m+jA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3O4+N+p4VUR3smIsfR07hJNuUdBc1k98O7znrhqi0MA=; b=St+aZlbfS1VVbeeDKmD6FdN44FM9aU1LHSEp71MFS+F64jS77wf6Ld0KXy9MnpVL16 PraA6s8YcwSZy8RBdLAUuUqopwc03j1igH30NinYCHJjjjIW4t/xH5n+2BS3fgwxT19T OhShO8Dbm1DjaMNAIGrZp3Zy8HjYu4V2gCQrhsWM/OYMPE8tdI7BPxgyl5PwYfXz/WVo 7zpYghh+nilTra6g3YYE6YeuMmvw17LDBhwZGdSmQU6AY2jwu/DdRKgX0Jy095cqHetk aO3TuqLwpQYPLbXCj1bcdMTo+cCLpVJzBUWQBWInmnx30aGUnJ7wmG01BfamqLkN/dfA 7Pgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fGT5tB+z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v19si16962629pfu.27.2022.01.24.12.40.54; Mon, 24 Jan 2022 12:41:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fGT5tB+z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358878AbiAXTz6 (ORCPT + 99 others); Mon, 24 Jan 2022 14:55:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355862AbiAXToE (ORCPT ); Mon, 24 Jan 2022 14:44:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F2AC02B8C5; Mon, 24 Jan 2022 11:22:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9FFAC6131E; Mon, 24 Jan 2022 19:22:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6482EC340E5; Mon, 24 Jan 2022 19:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052142; bh=TqIHgv56NEhzscdSjyNbYIuSq5WGNXRyGvRmEURN6lE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGT5tB+zFiIQZIzZptdoasTEjCFsQboTuvhS6z7LWzOdCFT0s0bhlAsIPE4RG+SoS CAxLyglp4bE8yUzfu3NsZbK9qzrYZVLjwnK728I0zd94sxnr+xkbhHycowY1j1GPW9 5LPUjko8WlYe2WfPDOcjBZaMHJjmvJAfnsAwzKRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , stable@kernel.org, Theodore Tso , syzbot+3b6f9218b1301ddda3e2@syzkaller.appspotmail.com Subject: [PATCH 4.19 202/239] ext4: make sure to reset inode lockdep class when quota enabling fails Date: Mon, 24 Jan 2022 19:44:00 +0100 Message-Id: <20220124183949.531077186@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit 4013d47a5307fdb5c13370b5392498b00fedd274 upstream. When we succeed in enabling some quota type but fail to enable another one with quota feature, we correctly disable all enabled quota types. However we forget to reset i_data_sem lockdep class. When the inode gets freed and reused, it will inherit this lockdep class (i_data_sem is initialized only when a slab is created) and thus eventually lockdep barfs about possible deadlocks. Reported-and-tested-by: syzbot+3b6f9218b1301ddda3e2@syzkaller.appspotmail.com Signed-off-by: Jan Kara Cc: stable@kernel.org Link: https://lore.kernel.org/r/20211007155336.12493-3-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5883,8 +5883,19 @@ static int ext4_enable_quotas(struct sup "Failed to enable quota tracking " "(type=%d, err=%d). Please run " "e2fsck to fix.", type, err); - for (type--; type >= 0; type--) + for (type--; type >= 0; type--) { + struct inode *inode; + + inode = sb_dqopt(sb)->files[type]; + if (inode) + inode = igrab(inode); dquot_quota_off(sb, type); + if (inode) { + lockdep_set_quota_inode(inode, + I_DATA_SEM_NORMAL); + iput(inode); + } + } return err; }