Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp743325pxu; Fri, 11 Dec 2020 13:13:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMwhacqJ/Es2iP3V4Locr3GWguiT9TRXo3j/gkaTVmf3s47fU45vCKZikw8RaAETinynOr X-Received: by 2002:a50:9ea4:: with SMTP id a33mr13579829edf.70.1607721225254; Fri, 11 Dec 2020 13:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607721225; cv=none; d=google.com; s=arc-20160816; b=Bdfiu0tQtkOCXLxizZrioyeZ196K1646Vj68fpSY8yKbObOFPoIvHYAN+aRUiNx1Jk SI6hR6IHarWHGYBFWi2fRumZfDOvxkarVmVNOne+uSgHlr66WJuVdHJ5EgUBiqhZcyFk uieNEpRGW16oJqRd3DTb/cMj9+x6nya0Mr3Uluawq88y0dq83PWM/eR1P8hm0h8W3J+8 awYQdYtTo9UoT14fYiWS/2fsT1MLIehF2/z2rc7FvbfzevV0iH9/q2U4VuAtTpTp3AmW vk+8BTK8o9FNk9TVCs5Lji9SRFTv3bmEWoJ5Ak40xFlcnN+5agGyfvwCxEdYOPJ8E7Nf Eh3w== 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; bh=E2FQmXUliONPs9YkHarAvXgSrTuM9vN/uX0LR/I39KI=; b=gEzx98qxKSdj+CdFk1X/r9cu3puknNYXh5NG3DzacQolXZsP4wzzifX3UbTzQNt5zM 3etRWUqDdwgI4oqvZ8RvS9DBYtjn243FIXRYX4SUX5HIZbCpo8BzE6fH+daOsVvAn/db jmYUap4ix/7TV3UMv61t7fc2L3PwsTvKgvfYqJv7ek0+9cN7GSb2EE84DuHlx/9gUMgR saGPne+sY+vV32c0I/rMB+Xy1l636Y8P/YdL70kIarb/75rVIl9iPor0wmxoPVeagUA6 dNeOzFPXORii6pcqv/hVQS9PbLIHuWU9y4HqthrN41VwJ6kmdXmjb1l4au6bpEADvc1E 1oow== ARC-Authentication-Results: i=1; mx.google.com; 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 hd40si5141933ejc.265.2020.12.11.13.13.20; Fri, 11 Dec 2020 13:13:45 -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; 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 S2390546AbgLJSrp (ORCPT + 99 others); Thu, 10 Dec 2020 13:47:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:39796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390552AbgLJOcR (ORCPT ); Thu, 10 Dec 2020 09:32:17 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e3f23ce40269a4c9053a@syzkaller.appspotmail.com, Bob Peterson , Andreas Gruenbacher Subject: [PATCH 4.14 28/31] gfs2: check for empty rgrp tree in gfs2_ri_update Date: Thu, 10 Dec 2020 15:27:05 +0100 Message-Id: <20201210142603.508569722@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210142602.099683598@linuxfoundation.org> References: <20201210142602.099683598@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: Bob Peterson commit 778721510e84209f78e31e2ccb296ae36d623f5e upstream. If gfs2 tries to mount a (corrupt) file system that has no resource groups it still tries to set preferences on the first one, which causes a kernel null pointer dereference. This patch adds a check to function gfs2_ri_update so this condition is detected and reported back as an error. Reported-by: syzbot+e3f23ce40269a4c9053a@syzkaller.appspotmail.com Signed-off-by: Bob Peterson Signed-off-by: Andreas Gruenbacher Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/rgrp.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -990,6 +990,10 @@ static int gfs2_ri_update(struct gfs2_in if (error < 0) return error; + if (RB_EMPTY_ROOT(&sdp->sd_rindex_tree)) { + fs_err(sdp, "no resource groups found in the file system.\n"); + return -ENOENT; + } set_rgrp_preferences(sdp); sdp->sd_rindex_uptodate = 1;