Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942276AbdDTGkm (ORCPT ); Thu, 20 Apr 2017 02:40:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47654 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S942032AbdDTGkg (ORCPT ); Thu, 20 Apr 2017 02:40:36 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Dave Chinner , Dave Chinner Subject: [PATCH 3.18 102/124] xfs: dont allow di_size with high bit set Date: Thu, 20 Apr 2017 08:36:17 +0200 Message-Id: <20170420063600.981720453@linuxfoundation.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170420063557.021306233@linuxfoundation.org> References: <20170420063557.021306233@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1334 Lines: 41 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Darrick J. Wong commit ef388e2054feedaeb05399ed654bdb06f385d294 upstream. The on-disk field di_size is used to set i_size, which is a signed integer of loff_t. If the high bit of di_size is set, we'll end up with a negative i_size, which will cause all sorts of problems. Since the VFS won't let us create a file with such length, we should catch them here in the verifier too. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_inode_buf.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -304,6 +304,14 @@ xfs_dinode_verify( if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) return false; + /* don't allow invalid i_size */ + if (be64_to_cpu(dip->di_size) & (1ULL << 63)) + return false; + + /* No zero-length symlinks. */ + if (S_ISLNK(be16_to_cpu(dip->di_mode)) && dip->di_size == 0) + return false; + /* only version 3 or greater inodes are extensively verified here */ if (dip->di_version < 3) return true;