Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp672302pxk; Thu, 17 Sep 2020 13:00:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxV1x0tRWbE4LE1tr3wG2lbJ+OSf7k7KAj+OOw/jdLysN/j3EG4dWBq6xmNyfEG1/g0jZHd X-Received: by 2002:a17:906:7013:: with SMTP id n19mr32166495ejj.388.1600372803140; Thu, 17 Sep 2020 13:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600372803; cv=none; d=google.com; s=arc-20160816; b=LpB3ALIXwbL0qtjXCY4R0TmXTHfCWjxA6Wc0wkhlKU/5UssdqYw8Hng9ZhddcIghcM 0IDIs/MXJaCjHUkX1yeZkx+vIoRR4JEoznPxRL41K4qgHqjEsBr7NJGHK2iQMDZdZiXu eQpowe5zv20NWO3ByPu5gCbfs7lzbHbMGEfo/vVLMS/KuqQyetU6oC58LtP6QDlbXs/6 hKG41VKiZqTaaPEAp2732pNxpXCBPrWBVCvOIGp7ZwKXMACA7FKki0yz2+lbulajhynO GLKdE7aHBEgm+dez3dcKRyP8Eah08xWQ9GOouUB2SfkkyYlL3BOfs0ca94eUmFOsWPJy 2lRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OObP7ESagVMm2FaJ6Rme03cmL60WVXPH94+AaCixnHo=; b=yWn23HcosckWxzbfSlBVTg8yAv0n7bGP40MAFq+FFvsq/tAokTkudO0lg1nncTrOIm vNg2BurVJ+umaL2OJOeIcbJfnKCFWg/tcPdIMFJ5ZBuijI2tntliJ8UxrC0se7VcMwBo 0QG5OW18g6mxOFkIDEJPeTb6MQHq1/LSg5IoyC/H9lRnZNwy4LMJ3BnkFYVgRmgLHgTq 3FSVl8aYT98aDv6hzhEgsEwsxdYH65vVW3h3TiSkJVnEsXGOenMakYrwm1pN0W2tkoLy tY+mr0fV8ULZhRRRJc9Cy+vA77u8YyPOPJdrqCuLb46Q7keJ21aqNuJQSESb1/YJ4IIM KJvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GFoqH90o; 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 u18si619660edf.140.2020.09.17.12.59.39; Thu, 17 Sep 2020 13:00:03 -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=@kernel.org header.s=default header.b=GFoqH90o; 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 S1726847AbgIQT4c (ORCPT + 99 others); Thu, 17 Sep 2020 15:56:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:43278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727512AbgIQOpj (ORCPT ); Thu, 17 Sep 2020 10:45:39 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0325C21582; Thu, 17 Sep 2020 14:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600353902; bh=PebSWXQKwXVcYAUHxdRQaN64t6YAf60XzC+pP27srAY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GFoqH90oTcBu9apcTAJzYnF+qJnUghZfdBsfz+bu3MF8YN5/FJc1akTVS43BtbyMA 9XMPgoHHVIUS/s95Oyl1ioYtUJ6f7hmyCuvzylcrWW1Ad5TBT92IEqDJXgOKqdhl95 mgQ91bWRGGx4I4tPpkmUAxvPv+UMJ6K0R6iq6bu4= Date: Thu, 17 Sep 2020 16:45:29 +0200 From: Greg Kroah-Hartman To: Bob Peterson Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Andreas Gruenbacher , Sasha Levin , Daniel Craig , Nicolas Courtel , Salvatore Bonaccorso Subject: Re: [PATCH 4.19 142/206] gfs2: fix use-after-free on transaction ail lists Message-ID: <20200917144529.GJ3941575@kroah.com> References: <20200623195316.864547658@linuxfoundation.org> <20200623195323.968867013@linuxfoundation.org> <20200910194319.GA131386@eldamar.local> <20200911115816.GB3717176@kroah.com> <942693093.16771250.1599826115915.JavaMail.zimbra@redhat.com> <20200911122024.GA3758477@kroah.com> <1542145456.16781948.1599828554609.JavaMail.zimbra@redhat.com> <20200912064713.GA291675@eldamar.local> <1934025224.17237499.1600188721184.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1934025224.17237499.1600188721184.JavaMail.zimbra@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 12:52:01PM -0400, Bob Peterson wrote: > ----- Original Message ----- > > Hi Bob, hi Greg, > > > > On Fri, Sep 11, 2020 at 08:49:14AM -0400, Bob Peterson wrote: > > > ----- Original Message ----- > > > > On Fri, Sep 11, 2020 at 08:08:35AM -0400, Bob Peterson wrote: > > > > > ----- Original Message ----- > > > > > > On Thu, Sep 10, 2020 at 09:43:19PM +0200, Salvatore Bonaccorso wrote: > > > > > > > Hi, > > > > > > > > > > > > > > On Tue, Jun 23, 2020 at 09:57:50PM +0200, Greg Kroah-Hartman wrote: > > > > > > > > From: Bob Peterson > > > > > > > > > > > > > > > > [ Upstream commit 83d060ca8d90fa1e3feac227f995c013100862d3 ] > > > > > > > > > > > > > > > > Before this patch, transactions could be merged into the system > > > > > > > > transaction by function gfs2_merge_trans(), but the transaction > > > > > > > > ail > > > > > > > > lists were never merged. Because the ail flushing mechanism can > > > > > > > > run > > > > > > > > separately, bd elements can be attached to the transaction's > > > > > > > > buffer > > > > > > > > list during the transaction (trans_add_meta, etc) but quickly > > > > > > > > moved > > > > > > > > to its ail lists. Later, in function gfs2_trans_end, the > > > > > > > > transaction > > > > > > > > can be freed (by gfs2_trans_end) while it still has bd elements > > > > > > > > queued to its ail lists, which can cause it to either lose track > > > > > > > > of > > > > > > > > the bd elements altogether (memory leak) or worse, reference the > > > > > > > > bd > > > > > > > > elements after the parent transaction has been freed. > > > > > > > > > > > > > > > > Although I've not seen any serious consequences, the problem > > > > > > > > becomes > > > > > > > > apparent with the previous patch's addition of: > > > > > > > > > > > > > > > > gfs2_assert_warn(sdp, list_empty(&tr->tr_ail1_list)); > > > > > > > > > > > > > > > > to function gfs2_trans_free(). > > > > > > > > > > > > > > > > This patch adds logic into gfs2_merge_trans() to move the merged > > > > > > > > transaction's ail lists to the sdp transaction. This prevents the > > > > > > > > use-after-free. To do this properly, we need to hold the ail > > > > > > > > lock, > > > > > > > > so we pass sdp into the function instead of the transaction > > > > > > > > itself. > > > > > > > > > > > > > > > > Signed-off-by: Bob Peterson > > > > > > > > Signed-off-by: Andreas Gruenbacher > > > > > > > > Signed-off-by: Sasha Levin > > > > > (snip) > > > > > > > > > > > > > > In Debian two user confirmed issues on writing on a GFS2 partition > > > > > > > with this commit applied. The initial Debian report is at > > > > > > > https://bugs.debian.org/968567 and Daniel Craig reported it into > > > > > > > Bugzilla at https://bugzilla.kernel.org/show_bug.cgi?id=209217 . > > > > > > > > > > > > > > Writing to a gfs2 filesystem fails and results in a soft lookup of > > > > > > > the > > > > > > > machine for kernels with that commit applied. I cannot reporduce > > > > > > > the > > > > > > > issue myself due not having a respective setup available, but > > > > > > > Daniel > > > > > > > described a minimal serieos of steps to reproduce the issue. > > > > > > > > > > > > > > This might affect as well other stable series where this commit was > > > > > > > applied, as there was a similar report for someone running 5.4.58 > > > > > > > in > > > > > > > https://www.redhat.com/archives/linux-cluster/2020-August/msg00000.html > > > > > > > > > > > > Can you report this to the gfs2 developers? > > > > > > > > > > > > thanks, > > > > > > > > > > > > greg k-h > > > > > > > > > > Hi Greg, > > > > > > > > > > No need. The patch came from the gfs2 developers. I think he just wants > > > > > it added to a stable release. > > > > > > > > What commit needs to be added to a stable release? > > > > > > > > confused, > > > > > > > > greg k-h > > > > > > Sorry Greg, > > > > > > It's pretty early here and the caffeine hadn't quite hit my system. > > > The problem is most likely that 4.19.132 is missing this upstream patch: > > > > > > cbcc89b630447ec7836aa2b9242d9bb1725f5a61 > > > > > > I'm not sure how or why 83d060ca8d90fa1e3feac227f995c013100862d3 got > > > put into stable without a stable CC but cbcc89b6304 is definitely > > > required. > > > > > > I'd like to suggest Salvatore try cherry-picking this patch to see if > > > it fixes the problem, and if so, perhaps Greg can add it to stable. > > > > I can confirm (Daniel was able to test): Applying cbcc89b63044 ("gfs2: > > initialize transaction tr_ailX_lists earlier") fixes the issue. So > > would be great if you can pick that up for stable for those series > > which had 83d060ca8d90 ("gfs2: fix use-after-free on transaction ail > > lists") as well. > > > > Regards, > > Salvatore > > > > > > Hi Greg, > > As per Salvatore's email above, can you please cherry-pick GFS2 patch > cbcc89b630447ec7836aa2b9242d9bb1725f5a61 to the stable releases like > 4.19 to which ("gfs2: fix use-after-free on transaction ail lists") > (83d060ca8d90fa1e3feac227f995c013100862d3) was applied? Thanks. Now queued up, thanks. greg k-h