Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1692347pxb; Mon, 12 Apr 2021 04:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9Bt75jv1g0WTYzhJuvC45bxoEUGRq1WIZVZcWW16K2BZ0C+yz8SM9IvFRraPdWgRPxMQC X-Received: by 2002:aa7:dcc7:: with SMTP id w7mr28379156edu.255.1618227278805; Mon, 12 Apr 2021 04:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618227278; cv=none; d=google.com; s=arc-20160816; b=ycI8MiUW+2Mb5z/9F+5u3O08i6S1wLv2RKRXVnIzCcQMz0omNyil1wJwsHoLsEAQwh XrpyyPGsquCJIBEEYXjckIZpgDSRS9CsRPu8jRl/NxZlVrRRC4PGYynkhjBxwwDif2tu JezXuiATmLrLJyUVYzAqK7dtG29nRB1VO5lShUUDyis9n+OKxB3i/FZhgNdYOM+11lhx jPtMwDNxFsBgvc5ggTZQnKI/UYvXd0X1+X9JlalrxtlgS8qPDNm0HOms49HmlMaJovex NXVJTeFH4OpoR7s/F9JmNg23Q/TWdkhuR63H9WdP6SnbyTbRmbxwpuRR+lPBOf/iPp0b xYDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kWQ0c8ucYe9UV0ATqeFAnzRMY2iAE51PlhKV5u1lmgA=; b=nK6LQ1L151yhjln4dQUUaRo+LOkozG11MdN7w2+7pk7RNjIo9Z9ddUuZgRbjolrliY 80hBLacHmH3+K3eDTCKOjo0xScuElC7LJKKzTneoohHCmW7R+3c765rCTlI8xBOnmm6M swHz0M48m4irEsLDRf9G4zDoHQ19wsegrZB67cP5OSPCyPPbIir3pZ7klXN3zf/gCA3L 0j0zZW8bl1yingQclHrclW/zuVL4uuPDQLHkkX3uZscUSm1YItp6o0BTnmp4+bkSQDEM FqxdfxfzBS+zm7B5ETkIYN2mAEstJIeaVHElnru3hBx+T9cAp5k2KjXxF+WDR3cCc/BU 6TfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cUlG6NlY; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si7964574ejc.571.2021.04.12.04.34.10; Mon, 12 Apr 2021 04:34:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cUlG6NlY; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240422AbhDLLbL (ORCPT + 99 others); Mon, 12 Apr 2021 07:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240413AbhDLLbL (ORCPT ); Mon, 12 Apr 2021 07:31:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C456C06138C; Mon, 12 Apr 2021 04:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kWQ0c8ucYe9UV0ATqeFAnzRMY2iAE51PlhKV5u1lmgA=; b=cUlG6NlYie3LJa9ROPnR/w8KN2 JCdeSfOVfIeml1p84gNnsCv7tp+9EaP/qi6AjJ9B9nZGmaLGGKWPjHTdIvaWcevxZqaAkVyH2zIYp YpK1Vp4IdlP++IDrzLyQJenh0Z9PQiQc5EmbthkHVGgJYwguPfIaBbOh+NnGPEke9NwJew87h0P4l V7bgqTmOzaNfOfdXMhCBPWNLGUefhossu8yUlPa9K5YVUlircfzjRegGT3hQYhaUB86Eo/A+q8Lh9 FyKa4e0if+oxWZxVJ/gYi8OJ+vHclbw/A6CDRpuHpMycMwJB4pNR6QVEd0Gvi7jbQGTdY01NUVmYY Rk6/snpw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lVumD-004Fyn-9X; Mon, 12 Apr 2021 11:30:49 +0000 Date: Mon, 12 Apr 2021 12:30:45 +0100 From: Matthew Wilcox To: Jan Kara Cc: Ted Tso , linux-ext4@vger.kernel.org, Eric Whitney , linux-fsdevel@vger.kernel.org, "Darrick J . Wong" Subject: Re: [PATCH 3/3] ext4: Fix overflow in ext4_iomap_alloc() Message-ID: <20210412113045.GI2531743@casper.infradead.org> References: <20210412102333.2676-1-jack@suse.cz> <20210412102333.2676-4-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210412102333.2676-4-jack@suse.cz> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Apr 12, 2021 at 12:23:33PM +0200, Jan Kara wrote: > A code in iomap alloc may overblock block number when converting it to "overflow"? > byte offset. Luckily this is mostly harmless as we will just use more > expensive method of writing using unwritten extents even though we are > writing beyond i_size. > > Fixes: 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure") > Signed-off-by: Jan Kara > --- > fs/ext4/inode.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 0948a43f1b3d..7cebbb2d2e34 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3420,7 +3420,7 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map, > * i_disksize out to i_size. This could be beyond where direct I/O is > * happening and thus expose allocated blocks to direct I/O reads. > */ > - else if ((map->m_lblk * (1 << blkbits)) >= i_size_read(inode)) > + else if (((loff_t)map->m_lblk << blkbits) >= i_size_read(inode)) > m_flags = EXT4_GET_BLOCKS_CREATE; > else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) > m_flags = EXT4_GET_BLOCKS_IO_CREATE_EXT; > -- > 2.26.2 >