Received: by 10.192.165.148 with SMTP id m20csp2528017imm; Sun, 22 Apr 2018 08:55:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vBXZxHsBIkPlUjteXCk+Byddh57yEPp2BSWnTbQ8p754WcGtin8ciaZuIOpNuJXrCBIgP X-Received: by 10.99.119.201 with SMTP id s192mr14474347pgc.51.1524412534325; Sun, 22 Apr 2018 08:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412534; cv=none; d=google.com; s=arc-20160816; b=NJuJDegexHRK8id5AeOJo9/RwtfCjndg2e3Uk8aiqC2Chld0iJWFcYeZ2YceIzw6J+ EhF02+eQ/gg3+hxN5hJ+cM+cjO81XFlr5boD9NyxfiX6TWkUZo09VIxD8VvexqR42oAs q7W5+rjQEPk0gFN/O4GZCvNtXVcvcvzRyAcW2LJzQs9ZDw+NTXy+rSECGm/5S3K0qzBF pClFiLBLJzahq2FXvOeSempmXp7hL2bq2Rpj3qu8SHNAuQ4M/uLzYtj2VKqw/Eqqhhh4 uWR3ynGf8ohHmA6zuxY9C7MErhLqUOt8UEs4cTQlLRhKQznmABkMGLtG3+zWuQihtb75 CJnw== 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=lFxBRI7IDNFcRNQ1iM4NvYcuPinLTWpPoUpHUAjMsPo=; b=N7Z/f1La86eE4R7EfRRm6ye8VwY3l997oudza17wTom9t6rB3MnF1KoipXvYG+UTT1 4+jLzGTQ+H94f566myg/xpjpgJVXbb/i3wEtJqdwM8y2IS6lCWFPHskTtyZjO3f0azFA XP/yHlia6zvPPfupF64Tzr1+bJhiXE+Qa1/wt1fOmSKRMwMHPKiErpdPlK2qxa8/CNbz cf3/PrNc8XTQVoTbj0C9dIBq9u6JIElHZR8AD3+eLbTUhe3XEmrHb7szMeE/QTFrrYdu zUfLjlRXY8AyNq61iJrRlh/BdwKX8dFWI0rvIBAF+utsYcneADgxz7ONeuecoqEx3FAi sbjA== 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 w10si8684773pfi.88.2018.04.22.08.55.20; Sun, 22 Apr 2018 08:55:34 -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 S1754473AbeDVN77 (ORCPT + 99 others); Sun, 22 Apr 2018 09:59:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47122 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754457AbeDVN7y (ORCPT ); Sun, 22 Apr 2018 09:59:54 -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 1E40C9C; Sun, 22 Apr 2018 13:59:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Slaby , Jan Kara , Theodore Tso Subject: [PATCH 4.16 090/196] ext4: fix offset overflow on 32-bit archs in ext4_iomap_begin() Date: Sun, 22 Apr 2018 15:51:50 +0200 Message-Id: <20180422135108.945904552@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: Jiri Slaby commit fe23cb65c2c394ea306f3714a17d46ab2e6a0af1 upstream. ext4_iomap_begin() has a bug where offset returned in the iomap structure will be truncated to unsigned long size. On 64-bit architectures this is fine but on 32-bit architectures obviously not. Not many places actually use the offset stored in the iomap structure but one of visible failures is in SEEK_HOLE / SEEK_DATA implementation. If we create a file like: dd if=/dev/urandom of=file bs=1k seek=8m count=1 then lseek64("file", 0x100000000ULL, SEEK_DATA) wrongly returns 0x100000000 on unfixed kernel while it should return 0x200000000. Avoid the overflow by proper type cast. Fixes: 545052e9e35a ("ext4: Switch to iomap for SEEK_HOLE / SEEK_DATA") Signed-off-by: Jiri Slaby Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org # v4.15 Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3524,7 +3524,7 @@ retry: iomap->flags |= IOMAP_F_DIRTY; iomap->bdev = inode->i_sb->s_bdev; iomap->dax_dev = sbi->s_daxdev; - iomap->offset = first_block << blkbits; + iomap->offset = (u64)first_block << blkbits; iomap->length = (u64)map.m_len << blkbits; if (ret == 0) {