Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2521000imu; Thu, 29 Nov 2018 06:20:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/UPgBSwA7kYXTYCwmVJK8U26NKXpdK/QRjjTfBhC6uey/MVeMygVGdbwFyrbEP5yww/8vVW X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr1661804plk.291.1543501258558; Thu, 29 Nov 2018 06:20:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501258; cv=none; d=google.com; s=arc-20160816; b=xhBGeaQHVQ5Jx+BtyCt5it/SC0+Ww1UQG5SoYH8BSm99KUFh7RP6oxm3mKwx5cwu7Q re+NsINY9dfxmp16QWTTJbOulY8rcWvb7NgrW+G/j95qPj0T3e6CRKU7AfbY/+Ws/h67 3pr1pkNCBpKBlzQMO9BeWdfw3BsR/yD6NQF7D+S9DIi+oUql0nhTQ/bixAaRfU/e8cpw 2k5UkcJBtzmNXTmDMczi5iWGEEQ01r9Evv34FsO4NOiEmSzOz38shazbhfr1aVOj2rho YjDN6wuD+x/ZamAXF3WG6RfifPPbziIZdw2FBmyNu0vb4jARM0dWiu7nZIJB8N4HvoFD EzmA== 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=TH0pJ9QPdu0C+My8/Y4dELd5urA0cJgZZEEwZUj/RXE=; b=b8HxPHOAdlku9KSnUfqXoXEjL5Dl3QLUyATISW51WgB9hqVde1T+aq0IdElzKM/yM8 YUI6hBJErRTA1nX2G0Fbg4DfFvC2KOgHa6pl6wwDXawImAtwPu9NAPLx7sI007xPJY2X Akz9CaYGKasUODczJNBSsJY26bW1ThQelD0Rn/XngBMBecvEmVqBMWyMy9bgb8WrOdaw BgeoODQAti9aZ208oNybClsPEmbGExrjEJlxxnWeGK+VtITUvTK1zz89sJqLCRrkAMFO WQTw+j9W2LseUg4n8D+lusXm97rADmkkmOBTxL5uVNYzFZUPT7bEYDm38uNBtDc7XFWV 7D9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Dy/XfgdD"; 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 s27si1969173pgm.501.2018.11.29.06.20.42; Thu, 29 Nov 2018 06:20:58 -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="Dy/XfgdD"; 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 S1730669AbeK3BXk (ORCPT + 99 others); Thu, 29 Nov 2018 20:23:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:45962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729763AbeK3BXj (ORCPT ); Thu, 29 Nov 2018 20:23:39 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 178C921104; Thu, 29 Nov 2018 14:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501089; bh=722+Mc2wdFKzhAWu9DnMKMKI+R5ZRkwo+RZ+W1H/NNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dy/XfgdDaqdw1v1vwZ8X2LJC+smIhnkVxkDXDYAeGH8+FoIw8QA1czxsXKeJE+lCN 31txpg9UdbMFwaO5kABhHOout7CzeHeeHN/XHGXxdoVN7HWcR5RVil+wvqrus4qF6T gL072xjSX9W30nLLGf6ocNHGavWYUMJBZM2nbEyg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+dcb8b3587445007f5808@syzkaller.appspotmail.com, Andrew Price , Bob Peterson Subject: [PATCH 4.4 08/86] gfs2: Dont leave s_fs_info pointing to freed memory in init_sbd Date: Thu, 29 Nov 2018 15:11:33 +0100 Message-Id: <20181129140110.611829640@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrew Price commit 4c62bd9cea7bcf10292f7e4c57a2bca332942697 upstream. When alloc_percpu() fails, sdp gets freed but sb->s_fs_info still points to the same address. Move the assignment after that error check so that s_fs_info can only point to a valid sdp or NULL, which is checked for later in the error path, in gfs2_kill_super(). Reported-by: syzbot+dcb8b3587445007f5808@syzkaller.appspotmail.com Signed-off-by: Andrew Price Signed-off-by: Bob Peterson Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/ops_fstype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -71,13 +71,13 @@ static struct gfs2_sbd *init_sbd(struct if (!sdp) return NULL; - sb->s_fs_info = sdp; sdp->sd_vfs = sb; sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats); if (!sdp->sd_lkstats) { kfree(sdp); return NULL; } + sb->s_fs_info = sdp; set_bit(SDF_NOJOURNALID, &sdp->sd_flags); gfs2_tune_init(&sdp->sd_tune);