From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 255D0C433FF for ; Mon, 5 Aug 2019 13:17:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E26492067D for ; Mon, 5 Aug 2019 13:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011054; bh=4AzKqBZu7cr1F47PxigYcOorqxgFsTkLFRv9XdY+VcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZswXzS+MnOUaNB00LycTuBIkZyjPcmes7J0B6XRTdxSmJ6b9pxJ/IG75Ubiq8lPiK WzTfoU+2g6Xoc52oEwQnEOgUEf7xbBbyAx5vP7pDvArjKZBRrWkfv0ymvRH15wIxKG nNhSTQ0edcACJ94sHWZbbNziPtVN9xuhVgM4HU0A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729587AbfHENRc (ORCPT ); Mon, 5 Aug 2019 09:17:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729263AbfHENFS (ORCPT ); Mon, 5 Aug 2019 09:05:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 50C1A216B7; Mon, 5 Aug 2019 13:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010317; bh=4AzKqBZu7cr1F47PxigYcOorqxgFsTkLFRv9XdY+VcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+0JktuK6uOOnIbu2xEfkvZprYu55af1MQYvctejRhKDfJeBIf5s3aeK3WUyLMNzA 8VsgAgQWOwI9D7IIcbFngWoFMBbDyaLZv4KZE5NIGI9au/BNtk0k85Iwwl4BhzN0zI WJ/NJrU2QMo/BPuu6uVTwvwkVgv+joK5BbiPYuIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell King , Al Viro , Sasha Levin Subject: [PATCH 4.9 09/42] fs/adfs: super: fix use-after-free bug Date: Mon, 5 Aug 2019 15:02:35 +0200 Message-Id: <20190805124925.949843082@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124924.788666484@linuxfoundation.org> References: <20190805124924.788666484@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 [ Upstream commit 5808b14a1f52554de612fee85ef517199855e310 ] Fix a use-after-free bug during filesystem initialisation, where we access the disc record (which is stored in a buffer) after we have released the buffer. Signed-off-by: Russell King Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/adfs/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/adfs/super.c b/fs/adfs/super.c index c9fdfb1129335..e42c300015090 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c @@ -368,6 +368,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) struct buffer_head *bh; struct object_info root_obj; unsigned char *b_data; + unsigned int blocksize; struct adfs_sb_info *asb; struct inode *root; int ret = -EINVAL; @@ -419,8 +420,10 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) goto error_free_bh; } + blocksize = 1 << dr->log2secsize; brelse(bh); - if (sb_set_blocksize(sb, 1 << dr->log2secsize)) { + + if (sb_set_blocksize(sb, blocksize)) { bh = sb_bread(sb, ADFS_DISCRECORD / sb->s_blocksize); if (!bh) { adfs_error(sb, "couldn't read superblock on " -- 2.20.1