Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2336483imm; Thu, 11 Oct 2018 08:42:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV63H4wDdcVx6OyWpLaKS9UmltDs/1UBQG6SeyyhEWS2PbUuDaGviTh89vpg5op0nvwVBI/dK X-Received: by 2002:a63:4f20:: with SMTP id d32-v6mr1756747pgb.231.1539272578166; Thu, 11 Oct 2018 08:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539272578; cv=none; d=google.com; s=arc-20160816; b=UIjAW+2F0II2rnZoaNAAuF94oMdQaZMBR7XBiMiKulgpYhZjknyCz9hsxhCrp2JKIJ 5/cg8vMjrny0tCr8Lvwaj5FILzcWoDcsfsui7cOXzxWiKIsQ+B/7V6jEm45CrDltAloE 47Rdz89TiW+t0T8I73gTqlJiC0tWbGtbLbEi4WPtwFI7RxLM+9y9QAq7+WogclGXLvAZ P6+c80psLriTaymIvJ8sLbU/jnmsX7wzjvEeWklHI0XzDJmc8XT8kxV5OL0h1ibrBJ7+ cygUhWO3yCiUa/zrXugP0Ex1K4lfBuRdYIjxHZ8fbtw7gDhi9AIdxKDpdzSqpMCVGSQ9 /j9Q== 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=KlowIHgvOOWUTN1+8sRWkzm6BiVjF59lcTyTceEjBJY=; b=yiPLqRXUy8S3QkKnbTbaAllt7wEetbRX96ZGUqa6AMBvejbY9hzxF6qSPMISL9CNp2 FWPoedVrBmE6Cki3l8u+SPPtBiMxHgFRxFsKD2r5GFGbrCbc1jzOY4SVVNm6tajRA4Dx GIvYW8a3CL3q7g+/F2wjOhg5L2zhxI8rTLCEAvxw9VR9AjlkqpHyanDCZ50ElDSKBTEf xrNgRIplLM9KyvzBFXrKPXaosmZmTtmt74trctGrAucKd3MimaoNx4kajOcN5ZppsmBM UtZ1TBvD2T0S+8Kvo+jOv/Zj90VWDq00bB1jf4fNHrj8nyOpZMdh48Vp4t5Nd+PhJxAG NOog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GsySxIlv; 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 ce19-v6si18732163plb.162.2018.10.11.08.42.42; Thu, 11 Oct 2018 08:42:58 -0700 (PDT) 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=GsySxIlv; 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 S1730526AbeJKXJa (ORCPT + 99 others); Thu, 11 Oct 2018 19:09:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:40320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726700AbeJKXJ3 (ORCPT ); Thu, 11 Oct 2018 19:09:29 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 0C6AB21477; Thu, 11 Oct 2018 15:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539272505; bh=GDZIEQO0AkS4egdHwau+Kyxl/2rEbEAD3HtjjO8EOmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GsySxIlvztk+T80gKuavRx5V5G6ZAaPm/F7j9WDQ3hYAUKeC5xE5M7QS91WZKpkOS t51qQChCNl8MF1Ji2S+8WJoiMD31uC9313w6DdQaLk+btbOvNdh4syoR2qTE4DnKeN NdMU1CGMubekj2IOi9e+WkxxchUWrGDX0ncUa+Is= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , Andreas Dilger , Daniel Rosenberg Subject: [PATCH 4.4 13/27] ext4: always verify the magic number in xattr blocks Date: Thu, 11 Oct 2018 17:35:00 +0200 Message-Id: <20181011152534.660729148@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181011152534.014964888@linuxfoundation.org> References: <20181011152534.014964888@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: Theodore Ts'o commit 513f86d73855ce556ea9522b6bfd79f87356dc3a upstream. If there an inode points to a block which is also some other type of metadata block (such as a block allocation bitmap), the buffer_verified flag can be set when it was validated as that other metadata block type; however, it would make a really terrible external attribute block. The reason why we use the verified flag is to avoid constantly reverifying the block. However, it doesn't take much overhead to make sure the magic number of the xattr block is correct, and this will avoid potential crashes. This addresses CVE-2018-10879. https://bugzilla.kernel.org/show_bug.cgi?id=200001 Signed-off-by: Theodore Ts'o Reviewed-by: Andreas Dilger [Backported to 4.4: adjust context] Signed-off-by: Daniel Rosenberg Signed-off-by: Greg Kroah-Hartman --- fs/ext4/xattr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -220,12 +220,12 @@ ext4_xattr_check_block(struct inode *ino { int error; - if (buffer_verified(bh)) - return 0; - if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) || BHDR(bh)->h_blocks != cpu_to_le32(1)) return -EFSCORRUPTED; + if (buffer_verified(bh)) + return 0; + if (!ext4_xattr_block_csum_verify(inode, bh->b_blocknr, BHDR(bh))) return -EFSBADCRC; error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,