Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2266006pxb; Fri, 8 Oct 2021 04:32:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLKbHx2a+fB5HOugwtAash/Byo6x17y+ADrcRMDvg9lea/QHrB2HZlni/FwPwYDuCcgPMU X-Received: by 2002:a17:903:24e:b0:13c:49b6:ee98 with SMTP id j14-20020a170903024e00b0013c49b6ee98mr9028988plh.51.1633692739496; Fri, 08 Oct 2021 04:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633692739; cv=none; d=google.com; s=arc-20160816; b=q75nnNsok/VjKylwsvD/b8dWTHP3QWya+W/cYtiTQnEEiZ0JrLfJRBq6ca1wXyADKM nfOA276fNAiO4RbQn91HGqNuyv+OPIrHOZtwl8QFG7rRahYL/TF7utWpth71n9u7abFb J0wd/QOhGHaR5xyMfFsGos1NYSOfJG1Na+PaSVdJ/cFAgQcWvtu25Pgy6D3IXeLvjm0k 6q+qTW/LwuLj2XbZBEi7amDov7un/gvg+w0bU2Ya+0gwZogJbC75/zJsR/4C8ubxa32c UUpm3y5KgUY0w1tHFJnm2As5ZMXU7TfwYbZKVcUO+7CEp45EyV3M0pZYhltTo/xBM2bb 2KXw== 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=TntHnSV6/pZ48Dq6LhUk/A4htmLBIPlZ8fQyIaqIz9A=; b=AHSs+sQWVhTcLrMHL/84vOGGdHZou+VCUQP9nHy8vAZ2p07tID9Ty+z1eqZVUI6hbx rBxHC2Z1WVL9qtq/PBI03aj1mSbN/tFtjI9TMcm8hKuE7FEYusRUHlH1z0hLQvTo240C URuOD454rH1DyWOPV+IAOdpAyOZzCj6Q+YrtEJhso9xhmKX3CS9oC2bBlA75JmvztK5F nSLytuscqWmDfsT8IY7QpB0TLy4prnVi7eq3Ov1Y54kN4FK5zfvHAsBy4dSVnftTaZ45 UgjNrWfPC0Wb/WHalBSw+jiWYJPEE3w/Cq4eHUR66CQmatfBjOi09gFhhQ9WnR5sLyIh j7Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dHgVFmIB; 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 i14si2905997pgk.326.2021.10.08.04.32.07; Fri, 08 Oct 2021 04:32:19 -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=dHgVFmIB; 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 S241428AbhJHLdR (ORCPT + 99 others); Fri, 8 Oct 2021 07:33:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240920AbhJHLba (ORCPT ); Fri, 8 Oct 2021 07:31:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38858610CE; Fri, 8 Oct 2021 11:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633692560; bh=8Dc+tYHawXAr+9oRqHJPFic6Thsbxr2opZw1UiJ7zhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHgVFmIB8rApof+ljd7f5YBnVAbbd9xm/jLanrttoLAyPwByjW02CvFVeqX0n/xLx 93gk0rSwH374AsavfkKx+kQk+Wkh4iK4T7FcBiCZffjli6LcF2GSGp+IUns5zhdm4G nAlVOsUHkFAhkppobMSNGtHogMuVx55ungBKOXb8= 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.14 04/10] ext2: fix sleeping in atomic bugs on error Date: Fri, 8 Oct 2021 13:27:45 +0200 Message-Id: <20211008112714.591344879@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008112714.445637990@linuxfoundation.org> References: <20211008112714.445637990@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 e1b3724bebf2..ccd5a7016c19 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -48,10 +48,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; } @@ -59,10 +58,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