Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3700573ybv; Mon, 10 Feb 2020 04:58:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwzSufCL/H+PH4IMEewU67qMh7Qhdyucl+OtAN+HcRqJi6tvWcPIzpiR/UBoS3GpImQ7rSE X-Received: by 2002:aca:1903:: with SMTP id l3mr751660oii.16.1581339533847; Mon, 10 Feb 2020 04:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339533; cv=none; d=google.com; s=arc-20160816; b=OxHn04N4Ie90z7D/kQDevvS+SN6cD7sfVKpddAsCrWECtDF7saUe3j6kilRtoNQXfa El0nZ1nQmd0cMTt/O+HURk6/MD10juNmedJeHhept2JqyySYGSVwkmKOnMdRy495Xwu3 LTEpul9gKm94uJNhK4ZuMznmmBSXlVSCkvCcbtdRwgwN63oETT4+noILIDfkDu/LAT5q kqTjxH3RgsczEQb400PlsIyIxR4qhNn2vNU08z8Kw+KO9THxuo1I+kqX/UTp9jdTOVsp uBAb6CnBoqAWxZU/kcQgXdNOB1WDj9sC+qCmeiHPBuJ/K1vCaFauiQyjY4B2/OdvjFQ6 OhPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dEdOoYNgruUbKCzmEPZ1J0T7uGfeKrktsoZ4hXbzSj4=; b=jIDF0E4Pml7K/O+GXmUkR7kAiuI7425MJ+J0o2CAHBRrQOviRlthSVkBq1etzeo0n4 eOAo49uNLsWDMxKcTTama7xiyBgu+zzAu2vvJCtKFcLanimuMqOWGoDikc2QfUxMzT41 ikU46D+36LQREFUACbBmHQUVZ2zB0O/fzDLtdTGNF3ON9l4oUS60Z1jEj6jAqdCu9k3E L8o/+3IRPi6RvjWlfF4JSuQhWcQmoJ/E72wcft9kZSa4BmJNU101n/L0Nn1Wr4jf+tuS ESDQtpupP8VyH7ShsQ1ruI5G6TR5OPAumVR3sGukAYx8P/YzmASzg2KOj+cCH4AQWZj4 +4IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UBzUzKdh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si133742oth.158.2020.02.10.04.58.42; Mon, 10 Feb 2020 04:58:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UBzUzKdh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727973AbgBJM6j (ORCPT + 99 others); Mon, 10 Feb 2020 07:58:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:43130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729174AbgBJMlR (ORCPT ); Mon, 10 Feb 2020 07:41:17 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 673312080C; Mon, 10 Feb 2020 12:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338477; bh=FwxRVwrf3HtPEl8NyRFM30eRNOqp7VploIS1YQCsNBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBzUzKdhffdpKWiX8aylm9BrUoiwO/lhp4nz2K+o5rgshrmRN+BEPX4cgzgPbqu4y daYAA2NK0tofkwsq+YBxn5z72DpIVzHx7s623wv+WbOtSIzUPYPkAFGQdN9ZSjt/Od My0y2Fc+mVa0wLvCVyw9NqyFcO7MtNv8WNPHG3dg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Abhi Das , Andreas Gruenbacher Subject: [PATCH 5.5 209/367] gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0 Date: Mon, 10 Feb 2020 04:32:02 -0800 Message-Id: <20200210122443.669979204@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Abhi Das commit 7582026f6f3588ecebd281965c8a71aff6fb6158 upstream. When the first log header in a journal happens to have a sequence number of 0, a bug in gfs2_find_jhead() causes it to prematurely exit, and return an uninitialized jhead with seq 0. This can cause failures in the caller. For instance, a mount fails in one test case. The correct behavior is for it to continue searching through the journal to find the correct journal head with the highest sequence number. Fixes: f4686c26ecc3 ("gfs2: read journal in large chunks") Cc: stable@vger.kernel.org # v5.2+ Signed-off-by: Abhi Das Signed-off-by: Andreas Gruenbacher Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/lops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -422,7 +422,7 @@ static bool gfs2_jhead_pg_srch(struct gf for (offset = 0; offset < PAGE_SIZE; offset += sdp->sd_sb.sb_bsize) { if (!__get_log_header(sdp, kaddr + offset, 0, &lh)) { - if (lh.lh_sequence > head->lh_sequence) + if (lh.lh_sequence >= head->lh_sequence) *head = lh; else { ret = true;