Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp162142pxu; Thu, 10 Dec 2020 22:10:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjMS8H7SnF6F3Y8ZRPeGTcR97yQOl52LdHkNn61yugCtLQa1bDp3ZpcFKPgNuOv/zvzX0C X-Received: by 2002:a50:9f4e:: with SMTP id b72mr10282849edf.200.1607667043857; Thu, 10 Dec 2020 22:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607667043; cv=none; d=google.com; s=arc-20160816; b=zczzLvjwGpmdMdUjOy85vB1V2/oL5lp8ct/JeEoNcgdiBxdcZLrnB/T7M+bi8RRJHt kWvuvW/jChPMyHbDL8NvgKFWHIDkf6nXFneM4bfGNvEmwSVLS8CoIr5bZQnPh/tag2QS WEQD34+7GuCM4TQk9SDQn9VRFMu2Sx1rDTuu33d21+IJ9nbBJVoSuHaSxKUA1vpJdMdr t5bQux3sHFWiP9FggvE9dFFBaKSDPW9J2ntsJwrj2prte+hbWxoQuexgCpmY0r7Glx3f /tGVqjnz/nRB228DavKT+e+aoWWi+2bjYMurbZ0akXDgfTQEPYnwW1kvbd0P5k+9VfPM ZCQw== 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=IcBVvAT9iFAJYl3ox32zIvppZVrFnVAVl7lRb6bpQCs=; b=MoQpvXiLgbSWp2n4MHFm6xFDQ2sKqpJJB6ho8ivTr8MC23EjSoliCNIqlFYhIhZXZL c3+cup/8CC9J7KfUHYV30bgyhx/MV1b1yUl6ERJH20bPBPo92t3iqGRbTI7/SsgwTmKP siYUbeQuggcsD1nnfdZ2c1bE/gB5+ZNCLSEZIMOjo13mGp9DPfb5KIYxANVPEn3xl/gJ V1ouZ/DCm3ydn+I4qECr2KJ7xot7DB5xTzRuqq1Y8Ifpq74OYLVAkUMt+Z7TW/5WJsTj jHASXRImwG6HLCSqSpl52GiAGNsGABkpOWQTAI1k7zMXn4+UGtRY5E89GKquhVjAr3NZ kdqA== 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 e12si3926697eje.644.2020.12.10.22.10.19; Thu, 10 Dec 2020 22:10:43 -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 S2391055AbgLJOgu (ORCPT + 99 others); Thu, 10 Dec 2020 09:36:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:42204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389517AbgLJOeE (ORCPT ); Thu, 10 Dec 2020 09:34:04 -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.19 34/39] gfs2: check for empty rgrp tree in gfs2_ri_update Date: Thu, 10 Dec 2020 15:27:13 +0100 Message-Id: <20201210142603.961444296@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210142602.272595094@linuxfoundation.org> References: <20201210142602.272595094@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 @@ -1009,6 +1009,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;