Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2265656pxb; Fri, 8 Oct 2021 04:31:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIsZlzJaXXzDaNBwulXz7vV1h6UwuahwrlJbnMHm8a4XAe6CmuUUXAOR4AlI46ljkZ/XVq X-Received: by 2002:a63:4b4c:: with SMTP id k12mr4238991pgl.172.1633692712509; Fri, 08 Oct 2021 04:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692712; cv=none; d=google.com; s=arc-20160816; b=puaUlaTqDSOyAnrI+fpHTt83cQYOUqM+0okyPVKDMGnDOwUK1iwM6vM3tuDwu0k+nv YHX9OOj9ir2nw/f/oJKmA3SKN9vPlyykXji9070+Dq/dFj2eK0efwDuOt9itjXRWcH/M BXpwnyxlpHJrUIwujpvzI1OFQTyweFkuBZ8nF48BlbLWZ1DFMLLZtDHafiAsj2SyWp1H t+LTejSlmM8WUPj5Qos/HvQRueD7k3zeLfSTqRyr87pcL9cgZtSMMf7WzB2soS4CUnUf UEyyT7oo8UO9F991Ybj1rbVZQUFxbw8ubk4fdu+jZRs9xQHMSj4Pyou/h44TVds2vICu 89RQ== 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=v5NVLzXVaO/67kJVKoKGQQGBv1nf/drxi73cVOCO2JQ=; b=ujPM0lIP08yIKvEZadeWueFTLYcgbvdJe2sBF9wL4b76Fcj+4eywzpxmf8xUEIxKvJ HpAePHqiyfZCvi++gH0BP5tKY5j1O959CTZAHxarhB0Mb7btvPh3WebBFdnIAwf5vXaV mKGsm+bm1/xNPCJNMD1Mz5Zb8xoay9nWTIBQrb0RPdDnNHzIGKNEZq7IzDFLNPsYkHzx I6tVQpQVBAdfY/KOnzEU+s7Rv7GEEyKkuVgGRmq9I6MpZD10yr6E4AQMWlUr5wNQSfnD 52o7jzgyt8QgYg9hlNqaBa82EiZu4rB3UzLxUGA7B3yyyyKIV92KexFn8mFwIRHBdydk RKqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JL7mbFTf; 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 2si2114073pll.95.2021.10.08.04.31.39; Fri, 08 Oct 2021 04:31:52 -0700 (PDT) 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=JL7mbFTf; 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 S240454AbhJHLb1 (ORCPT + 99 others); Fri, 8 Oct 2021 07:31:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:58246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240374AbhJHLar (ORCPT ); Fri, 8 Oct 2021 07:30:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1CAD61029; Fri, 8 Oct 2021 11:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692532; bh=DiC/iphoatt/a+XEjILF60jpiyxJAzAikHTj84ook+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JL7mbFTfq8fSGPu+qQaNGu6CEoY0f3itYP7ycp98jmDM/eoxpiVoRx7/If7Z5BbN7 bCDhmvKoeWm5CuIJynQYAOEMp+PiWPPrsuHdIcf3LNMHWli5+z/LIE5vUNlp99GUMR B3PWGbSh2o6OF/eB3xUG+mOGlGyknuVbV40cNqPE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jan Kara , Sasha Levin Subject: [PATCH 4.4 4/7] ext2: fix sleeping in atomic bugs on error Date: Fri, 8 Oct 2021 13:27:36 +0200 Message-Id: <20211008112713.656328777@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112713.515980393@linuxfoundation.org> References: <20211008112713.515980393@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: Dan Carpenter [ Upstream commit 372d1f3e1bfede719864d0d1fbf3146b1e638c88 ] The ext2_error() function syncs the filesystem so it sleeps. The caller is holding a spinlock so it's not allowed to sleep. ext2_statfs() <- disables preempt -> ext2_count_free_blocks() -> ext2_get_group_desc() Fix this by using WARN() to print an error message and a stack trace instead of using ext2_error(). Link: https://lore.kernel.org/r/20210921203233.GA16529@kili Signed-off-by: Dan Carpenter Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/ext2/balloc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 9f9992b37924..2e4747e0aaf0 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -46,10 +46,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, struct ext2_sb_info *sbi = EXT2_SB(sb); if (block_group >= sbi->s_groups_count) { - ext2_error (sb, "ext2_get_group_desc", - "block_group >= groups_count - " - "block_group = %d, groups_count = %lu", - block_group, sbi->s_groups_count); + WARN(1, "block_group >= groups_count - " + "block_group = %d, groups_count = %lu", + block_group, sbi->s_groups_count); return NULL; } @@ -57,10 +56,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb); offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1); if (!sbi->s_group_desc[group_desc]) { - ext2_error (sb, "ext2_get_group_desc", - "Group descriptor not loaded - " - "block_group = %d, group_desc = %lu, desc = %lu", - block_group, group_desc, offset); + WARN(1, "Group descriptor not loaded - " + "block_group = %d, group_desc = %lu, desc = %lu", + block_group, group_desc, offset); return NULL; } -- 2.33.0