Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2266214pxb; Fri, 8 Oct 2021 04:32:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQkrAKoe+e8iwX7Wa3CqTdTfyY0tInmlJm9siFehnRAkUP1J8bF47iVWePlSxkfHZ5geYE X-Received: by 2002:a63:2b8c:: with SMTP id r134mr4181120pgr.420.1633692755534; Fri, 08 Oct 2021 04:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692755; cv=none; d=google.com; s=arc-20160816; b=yQ/pgW6yHRK9DWMPuWZnNoMbtOZV42DlQ/IOLd5Dzh45INLanEjm8alZi6+cqx2QXQ NgXs8ZquRHt/K5CBGKlm47zpJf/x4YUtPbSRSPXxFEF1w4vrZwgRbm+5OYMSRmiKEYnG QdzYYi4mDP4mRGzc1FnJiYEJ+RbGz7sXdknEcjaxkUwkqDBWG7WjOjJt9pcB5uk3NOzY sRf5SpoHsNIaFvxDBDdq7VgSGw88Z45j7D1zuFflTdRscutRxC4N13DRk0txAwoSQ51a a51Wb2cFPbMXfCMFm6H0YikFUPlY/lffeMpHy6DCc63fIXeIEgU4MImjAmybUBbdX6O1 fcPA== 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=QHfbA8CFQNqxDrnHxGi6g8gF1nuqAhmA732R5WKKdmY=; b=d5DzxxTa10KpaMaAk9IzMHwqdQdN2E6Gdc/bJTLbUg1tLuxFJOmqdBTZz0CgHNj4CF z5tVCRh20MdYGUMyvkIgc6gXMzm8ULcA19DYGNkN70qxMuat1C8uBmgakrQUxHW2ENRu fVy4USUH9s1HQ1TXwfdQqTdyd5RNn+rxsowiqzrXcCJd+baTgrjJNrX7sn0XL/rUSIFr gOjfGmzlHG+eGHDbx1g2MwlPkaM8fhgppbtPaPEVGULLi3Ts9O6G2meGmEddsJUizM8T WFbW75/GsvMXN/n+1OjiDxnrzQgZRj1En4L4gkD/QF1XEC0btaEoEuZKhB6B5T1oG6gk PAqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V3jr3Svz; 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 hk6si4044839pjb.125.2021.10.08.04.32.22; Fri, 08 Oct 2021 04:32:35 -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=V3jr3Svz; 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 S241051AbhJHLbp (ORCPT + 99 others); Fri, 8 Oct 2021 07:31:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:58556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240522AbhJHLbA (ORCPT ); Fri, 8 Oct 2021 07:31:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C172661039; Fri, 8 Oct 2021 11:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692543; bh=27whueOksSIGYwWBQXzhOYss4ziLaN09BDh/OORgVbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V3jr3SvzrHXRe9FvLFrZ0GL/JbVOvIoNJJdgPtQHUNuv42N7qPpIwvqjDBNn9iLuk +kCy4R0ypPMz6159GOo2drVT6XTT1Rgs1DTHuzB8zMZ+aZ3g4ufd7ugFzKct3EQK4F AdGz17PNVsQ688veWjVj73n4UopEzPb4HuCFCtak= 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.9 5/8] ext2: fix sleeping in atomic bugs on error Date: Fri, 8 Oct 2021 13:27:42 +0200 Message-Id: <20211008112714.126049100@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112713.941269121@linuxfoundation.org> References: <20211008112713.941269121@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 4c40c0786e16..bd32140bdfee 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