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=ham 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 B8C92C433FF for ; Mon, 5 Aug 2019 13:04:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79A9320880 for ; Mon, 5 Aug 2019 13:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010280; bh=3KBRVhRDiu83YjpGhGpXMuxxGlTDGVg54CdmRe86b0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lht4cImOU+Sdy5c4vDYCXAAhhn2oGMwrA3+Vp8JEB3mUtigl2JMOttJhXDmnSlcxU KI8FcWjWYvU03I5tMzxzbTzCcPBRAiNn0TWA3kT6K+8KCD4ERXH2RRe4eQXEtBBPEN Ezx+p9Lcmv16qC/hbaIpTMzZlKdc8kaey8UqV4JQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729098AbfHENEj (ORCPT ); Mon, 5 Aug 2019 09:04:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:40352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729053AbfHENEh (ORCPT ); Mon, 5 Aug 2019 09:04:37 -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 D3FC02087B; Mon, 5 Aug 2019 13:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010276; bh=3KBRVhRDiu83YjpGhGpXMuxxGlTDGVg54CdmRe86b0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqJZIMATUFyBhf7yDHucu30loioRGjQ1s3FobowuSdYF2dFeFSzBE5SgquZexQesv MjOWXplPiZLBpOOii7JHO/1G7kRsonYzSxnqpoVdo/ISKYoEVNdCgsS/5ikpJCvkTx s2CriieStcm9/G/cMGKEsL2wsMCCmo+UtrznnC7c= 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.4 06/22] fs/adfs: super: fix use-after-free bug Date: Mon, 5 Aug 2019 15:02:43 +0200 Message-Id: <20190805124920.027806904@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124918.070468681@linuxfoundation.org> References: <20190805124918.070468681@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 4d4a0df8344fe..b00ae922ece27 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