Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3184844pxb; Mon, 9 Nov 2020 05:06:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6ixgZrwaEziBkH7GdpX4pKrSgGkZI55tShqC5J3m4f7DO01exgEJtOt0yjaYFPRfaf9w/ X-Received: by 2002:a17:906:180b:: with SMTP id v11mr14754099eje.466.1604927167966; Mon, 09 Nov 2020 05:06:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604927167; cv=none; d=google.com; s=arc-20160816; b=rOh5IkoWvFufIhVFkz++EcSM1KYjAlzJLBVjTZQb6M2E9MF8QZfbqOLWaQ0fZtfFn+ 0RuE/XFab31g+nWuTlzmuGbM8CuO9WxBmHk/OEmbYjCliH1kYnHLYeEsW6nivo7I5mzH xc5E/mbI86cPscTRcBkgesZiDmAm/hJGprvx4OsTDWSyGDPrMTmldwJa5npsqIFD858g z2KBreRIUhlT3VURAuiBf+OV+lUKSTM09nCrAFzhQjgwZNFEQtfjehIdh105sEymEC0P 1yF5GXz2bWV8g3EpPJpBBbgg857drs6hoLHRyG2nhCotzSULMcL20aeRO7Lb7g3TCeUt Vy8w== 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=7P6RczqyRx6jKKjqZOXjOCH+AfZhqK/0jyGBTqNYKiQ=; b=ty1EggHYHXpcsIL1UShTKEVdUvuwOKvTSmouklolpd7DV2WpW2tzYoiZSCfQx73+L3 wUVJU8uybkBxo41xID5NdRS9B7ub5DAzi2yC1Ecunlv9S5GB374t9gliDt5t3fyhE49e xWhDWXYHIZVI1lSF150PJ73MJq1QEbArwVhL7/DaKl7kZrFnS2ix3uSIIOWCPOptqPSb +tezNCLEn4KUhXEWYX6FX07X0Wp+RBjg1aiVv65bQuhE5Z2TGZoLiq8BRoc3919N77Y2 hgsS0RaGMaUNtE1WnLOGraLGUECaWi+1qQgIoI9/OwdIP6gdaY+CE77woNIVXn95/tDb QNdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2k41koqH; 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=fail (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 z9si7058492eje.29.2020.11.09.05.05.42; Mon, 09 Nov 2020 05:06:07 -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=@kernel.org header.s=default header.b=2k41koqH; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730267AbgKINDw (ORCPT + 99 others); Mon, 9 Nov 2020 08:03:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:55498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730574AbgKINBc (ORCPT ); Mon, 9 Nov 2020 08:01:32 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE8CD20663; Mon, 9 Nov 2020 13:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926891; bh=x2BiHboh21Ky6ukpGo/gzGRBJffoE2cA9D/CqxUe4r4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2k41koqHWgkZnXuRhUDZKvIR1fDOI+lFbrtR8MaOP+Lo/8uiyB233QL1NpfWFWN37 2zqD/hAI3LRu2QBMVPZmoTwWX83aKY2Tlluivfne3lGeUbuZH+LTJ6wdB7qEY0dXby YXrhlJPtc/Ss1qiYJEoO4fd6s2OZHWzWdyuuwJr0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Dilger , Ritesh Harjani , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 4.9 039/117] ext4: Detect already used quota file early Date: Mon, 9 Nov 2020 13:54:25 +0100 Message-Id: <20201109125027.508154460@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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 [ Upstream commit e0770e91424f694b461141cbc99adf6b23006b60 ] When we try to use file already used as a quota file again (for the same or different quota type), strange things can happen. At the very least lockdep annotations may be wrong but also inode flags may be wrongly set / reset. When the file is used for two quota types at once we can even corrupt the file and likely crash the kernel. Catch all these cases by checking whether passed file is already used as quota file and bail early in that case. This fixes occasional generic/219 failure due to lockdep complaint. Reviewed-by: Andreas Dilger Reported-by: Ritesh Harjani Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20201015110330.28716-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/super.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 472fa29c6f604..2527eb3049494 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5412,6 +5412,11 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, /* Quotafile not on the same filesystem? */ if (path->dentry->d_sb != sb) return -EXDEV; + + /* Quota already enabled for this file? */ + if (IS_NOQUOTA(d_inode(path->dentry))) + return -EBUSY; + /* Journaling quota? */ if (EXT4_SB(sb)->s_qf_names[type]) { /* Quotafile not in fs root? */ -- 2.27.0