Received: by 10.192.165.148 with SMTP id m20csp2431456imm; Sun, 22 Apr 2018 07:01:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/TpbQf6Pz6e4HX87FHPUU8i9EFM3fqg97UrGlL0fGpJtH7YNVx1lTxXuji6mxPwGqM45NZ X-Received: by 2002:a17:902:bc8b:: with SMTP id bb11-v6mr13937799plb.285.1524405674772; Sun, 22 Apr 2018 07:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405674; cv=none; d=google.com; s=arc-20160816; b=pLtNdvuJpNQ+XmfyrOfMzxZGaVnaS2f9y7uOrZIryY1ubOeWo23tiogSxOpcza1E0/ e0JpBN6X5+1yHA0jj0HZKg4ot3xR9jAHVtwRHgQ3UM7ewjgA8V30Rid4M+RQlJefe+ja z+lnHeGeWA1u2Az55WKkFGu5AjracaecAF0mXeA+Vh1h+6b0/MTHTaaTpz1QBfAxWzJ/ BktAotpXzU8weI1ld998UnrxeAAHDvn8sIBoyobVnWIXF8CSN2LRK/PS00Pp/DjIG5JS wr/FwZASeapDfVwzLayEsUI3qdIn+5Qq1PLrGSVOxYI56Cd9JxLpISPnmNWvNFjiS5dK bTVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=WLn3kjtOvwRmPu6jGwKDhLD8Wl7vN1RHEKiOAGANfLY=; b=oRVXTTHwjWRss1CHSH2POJE5IuNSRfDQNXuYbMuwq4hd0d/xsjaopkwPGcgGo3DIpG E81c1CT5nwGV0OtkjIs25/Z6sZ1hA6gvcBcG2CO9+8Kt8QQYzmPSIaWUCnjy/LLuismB Frq0zG+DDEopyRwEVImpR9PFNMQqPtTqaPlA2a0bWhpQJnd479tNOxtVoYZJneQa87l8 6CTk2M47SvjyXL5rtDSGFcOYsZyez3WWy3p8GBC+PJO9qv1rcON5mjLME2N/TYTfvH/V Tjt2CTl79UjuxbRYZodNu1NXuKyiN4B35TuVMvTjlISvnxwD28neR5UNzHGBM88yWz+4 3YUg== 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 a6-v6si10041241plz.211.2018.04.22.07.01.00; Sun, 22 Apr 2018 07:01:14 -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 S1754173AbeDVN6b (ORCPT + 99 others); Sun, 22 Apr 2018 09:58:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46226 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754148AbeDVN6Z (ORCPT ); Sun, 22 Apr 2018 09:58:25 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E10D6CE3; Sun, 22 Apr 2018 13:58:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Xu , Eric Biggers , Theodore Tso Subject: [PATCH 4.16 092/196] ext4: limit xattr size to INT_MAX Date: Sun, 22 Apr 2018 15:51:52 +0200 Message-Id: <20180422135109.046443853@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit ce3fd194fcc6fbdc00ce095a852f22df97baa401 upstream. ext4 isn't validating the sizes of xattrs where the value of the xattr is stored in an external inode. This is problematic because ->e_value_size is a u32, but ext4_xattr_get() returns an int. A very large size is misinterpreted as an error code, which ext4_get_acl() translates into a bogus ERR_PTR() for which IS_ERR() returns false, causing a crash. Fix this by validating that all xattrs are <= INT_MAX bytes. This issue has been assigned CVE-2018-1095. https://bugzilla.kernel.org/show_bug.cgi?id=199185 https://bugzilla.redhat.com/show_bug.cgi?id=1560793 Reported-by: Wen Xu Signed-off-by: Eric Biggers Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Fixes: e50e5129f384 ("ext4: xattr-in-inode support") Signed-off-by: Greg Kroah-Hartman --- fs/ext4/xattr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -195,10 +195,13 @@ ext4_xattr_check_entries(struct ext4_xat /* Check the values */ while (!IS_LAST_ENTRY(entry)) { - if (entry->e_value_size != 0 && - entry->e_value_inum == 0) { + u32 size = le32_to_cpu(entry->e_value_size); + + if (size > INT_MAX) + return -EFSCORRUPTED; + + if (size != 0 && entry->e_value_inum == 0) { u16 offs = le16_to_cpu(entry->e_value_offs); - u32 size = le32_to_cpu(entry->e_value_size); void *value; /*