Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp27527imm; Fri, 21 Sep 2018 17:22:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV62WPR4IfhGsV0x0oGHXulbZkury7YPaWgUNcVtswct/tm4rACVn6hp+zFQ6HVp6V4ZZszW/ X-Received: by 2002:a63:b507:: with SMTP id y7-v6mr98246pge.425.1537575738312; Fri, 21 Sep 2018 17:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575738; cv=none; d=google.com; s=arc-20160816; b=hAKjmE0EdwnbdgIS6x1s1tnzeX1XmJKH6gZadOqHGqxya87EB5N5L8K+lZMU68SPpe iThyQV/bboqqKvc2Sj+VxI4u7uBNsSZM/+DqkYBB9b0SpXgBW3789b7SnMrMrRPOi7iL ePfSi0a4JCCzDrj0HNQPOOHEzJAaERkJM9L8yjdfreBbKeCDVcPw6wNwmo3/iP1hZ4we 3CaZ4dUOTUxXB1xeNu1RAndehT589Kwjs/Wepyr8QFKY66pgpVgGHbVMcv3atWimqRwf GdElk5PiXXGTtHHV+fCWjl32PA77t/HQgEvDrSIppVFdDS5wFbz71pi7gOfHoBDcaeWh nYvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=aKVsCOj0qAEhGv+bromE53g9tTsNiPAxILJGom/xD5c=; b=EqFgIkIoqYKO17XA4rTWOYo6DuGZDgQ/I4CmgunvNLjrD3TPjjs105yYgyXDABuFVi +dMGuA+1b7xzXj9erdWCYhPAXdUeytaVHVQYlgtnZs8mg8LF30xOdAu21CeRmlNMMvxW zV48DEjpg5thy2qIZJvXwWDI2ExcV63diFYnxE3JKY8Ss63SLx5If8ROG0qk/MwXTMJn /m+pvhTN879PqTdwSkom80P/O2sc1Gh1ff+TxbOLRaTIAUy72vz3chLDGyDsUCHPMiTD fR1rcjOUEJ+8oEiu1Ai2a0+4pDiyNXiwzVwtiN/KDMNsDJ+/xrmitCazqfzEC4v6Wwq8 A2uA== ARC-Authentication-Results: i=1; mx.google.com; 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 x6-v6si26756230pgb.469.2018.09.21.17.22.01; Fri, 21 Sep 2018 17:22:18 -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; 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 S2391776AbeIVGMh (ORCPT + 99 others); Sat, 22 Sep 2018 02:12:37 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44256 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392014AbeIVGKt (ORCPT ); Sat, 22 Sep 2018 02:10:49 -0400 Received: from [2a02:8011:400e:2:cbab:f00:c93f:614] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1g3Vdy-0008BX-6b; Sat, 22 Sep 2018 01:19:30 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdo-0000sH-6O; Sat, 22 Sep 2018 01:19:20 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Andreas Dilger" , "Theodore Ts'o" Date: Sat, 22 Sep 2018 01:15:42 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 32/63] ext4: always verify the magic number in xattr blocks In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:cbab:f00:c93f:614 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.58-rc1 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 [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/ext4/xattr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -213,12 +213,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 -EIO; + if (buffer_verified(bh)) + return 0; + if (!ext4_xattr_block_csum_verify(inode, bh)) return -EIO; error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,