Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3728090pxb; Mon, 24 Jan 2022 16:30:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzelQLH6u0NkhrHJAtHlJIGNSkdBFt0orMti/u1ll2Zw2lDRSSYEIFtRIszq0CVBTUS0o+ X-Received: by 2002:a17:90a:e601:: with SMTP id j1mr781613pjy.69.1643070616787; Mon, 24 Jan 2022 16:30:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643070616; cv=none; d=google.com; s=arc-20160816; b=iOTUpKBNtzPspcS0TJvXvMOcAypPDmDD2XLrsW0xmWRr/toH7PCqoCOF2Be2qZHOI8 XdAmH9zKn6TjSHK9u527830EWg0bi8+Jys8+e6J1ZPv/LpCnkK1bLdmBp/NXqk4f+DM+ NPXQ7eQ1mSgQv3+LIKo6AKo9Mf7KSNG5EkGI0LnkrlUUFIuTpxl+QglH0A0L0eyQaDj3 +ipYCv2BkmuKfknTtOQwb+pHJqw8gddJ/hJ8NNShuATbSb4jU+7nYaa+vgeYlPMfbtY6 TxgkKyR2xGuG7CidNCvxI5SYlmIG5zi/HyMZSCasld55ZkOjyYhcrk05PIWTpfFq8Gzt Zj5Q== 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=/pJK7X+5/z8J63hqwV+7toohknU+8Y5oMJyNraYd4vE=; b=yTqQ7/R4TSL9MxqrYXa5rCulptz+U7rSo1U0ogVEeM7p/WhMO1Ez2G1OzO3jEcHXjY dbwHMWgT/eFjiTf4Mw5Oc8B9a3oCLrdc71WPCJd4XutTAz13KByx67iCDyLC8BrJG++Q L6Hn4bOB4R0TS+twf8mX+moarvfUkio9h8m8qLSsPOK9tjVi0z1fL4+C3L/jLm9eICOf 8R/ibQvObVIfn+x/Ik1PubB62fwz2bqvl9cB052tjkXrU74aFElFm0xmtMpSJ5iEWmTR re7r35pQduT9Yrx5Cbbpd9NVne3gRCsyntaNMNsYUdX8KQIJKHWK53tsk2c0goIaTsyY Os2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LTnhflvF; 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 s6si10552868plg.590.2022.01.24.16.30.04; Mon, 24 Jan 2022 16:30:16 -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=LTnhflvF; 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 S3408169AbiAYAVw (ORCPT + 99 others); Mon, 24 Jan 2022 19:21:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2360379AbiAXXgk (ORCPT ); Mon, 24 Jan 2022 18:36:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 921E9C0ADFD7; Mon, 24 Jan 2022 13:37:38 -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 ams.source.kernel.org (Postfix) with ESMTPS id 5BF4DB81188; Mon, 24 Jan 2022 21:37:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9303BC340E4; Mon, 24 Jan 2022 21:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060256; bh=0/1uQfnW40fQCtD/TrAwPiBVSZy/dooJp7W8kuvZi2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LTnhflvFVp5yUNAwUtJ3hmckzTjRuISdfT5/DOiE13nJy+R+uwzGcJRWJ4gGE8pKE SMsiLa92k4SgUD+FDrefAq9r7ozvSlGdqY9z0Ji5Zqny2SE0EcknGNG37gcpgMs/eH AdLZoeiNrKC2P6YKArIshDXXdxz3jEnzJ+yeuJGM= 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 5.16 0889/1039] ext4: make sure to reset inode lockdep class when quota enabling fails Date: Mon, 24 Jan 2022 19:44:38 +0100 Message-Id: <20220124184155.174086253@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 @@ -6361,8 +6361,19 @@ int ext4_enable_quotas(struct super_bloc "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; }