Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5019466ybf; Wed, 4 Mar 2020 15:40:07 -0800 (PST) X-Google-Smtp-Source: ADFU+vu+51JJ81dc/8dE62AK87ANKpyPX6YOE7l9NSLvBknuSfPhUC/KN2vRdM9BPFhx+QQkWWj6 X-Received: by 2002:aca:eb57:: with SMTP id j84mr3604959oih.22.1583365207479; Wed, 04 Mar 2020 15:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583365207; cv=none; d=google.com; s=arc-20160816; b=rhRY7JEzT5uw2SWMUNbTQ0kBE6POKwi+hxamFLqBI9Zw3R7zV4UB2C5EEdoTN5N03S MCKGm5p0VupXnNdv3lvu3s2s+Qdine1zXP+GlZrVGfTaZ8thwT9+sl9EFWxlb+sVNfU7 KQ1PTotKUlo2Sr/AqVNg3nkM4xx983xxM5QbkOEbsRfLxOgoy9hEEB+e4JYLq4LJwZ8/ x0Vki4TW8FdpVRlSH2gN5g6saBcBSj/9BSZohbqbStv8Zt0YoFmr59ju+PYvlm6YV6v9 MP+5kzlHy+umHThZtjd2BvlFBe2r+UpdxOK7jygZb45a+fvok6DgpULhJRBnSmhK0YTc gatQ== 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:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8Gx0yyMTCLy46CS6BxZMajly6C+iXhSLX+tb3jzaZH8=; b=I4+7RMnUXGKBk+7BVbFgC58YsXzMiOOrua4wrDMO8Atoviu2bjYqB7G4A8SSSeqa7W 7m4xmfI4JLUL9JCezPyEaJVpTvppO1yaLb8mmuxGwdc/E1XdwFvgmgmBDTxK92SQJDLX 4eQNxd94np0VHI/+NW4T4wGfMRdmom/6o6A/CPuVE68TbHAOZgX6hfauP5CC54QxjnDo I2u00aCSlrKYoRfOrOtuxZaH90sjrLl5cTadd3fs8N3juzbvrqCaWpGNI2HjQD5Es0x7 j1YzLFHlorEVfI7j39RS11wnd9+W0DCJwIt9UqUUx0vjBmC8N00J56aH8CV4AUCQhVQi jntQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 l21si2076508oic.126.2020.03.04.15.39.48; Wed, 04 Mar 2020 15:40:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388490AbgCDXjT (ORCPT + 99 others); Wed, 4 Mar 2020 18:39:19 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:42183 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388484AbgCDXjS (ORCPT ); Wed, 4 Mar 2020 18:39:18 -0500 Received: from callcc.thunk.org (guestnat-104-133-0-105.corp.google.com [104.133.0.105] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 024NdCWC016511 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 4 Mar 2020 18:39:13 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 0090A42045B; Wed, 4 Mar 2020 18:39:11 -0500 (EST) Date: Wed, 4 Mar 2020 18:39:11 -0500 From: "Theodore Y. Ts'o" To: Andreas Dilger Cc: linux-ext4@vger.kernel.org Subject: Re: [PATCH] e2fsck: avoid overflow with very large dirs Message-ID: <20200304233911.GI74069@mit.edu> References: <1581037786-62789-1-git-send-email-adilger@whamcloud.com> <1581469641-85696-1-git-send-email-adilger@whamcloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1581469641-85696-1-git-send-email-adilger@whamcloud.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Feb 11, 2020 at 06:07:21PM -0700, Andreas Dilger wrote: > In alloc_size_dir() it multiples signed ints when allocating the > buffer for rehashing an htree-indexed directory. This will overflow > when the directory size is above 4GB, which is possible with largedir > directories having about 100M entries, assuming an average 3/4 leaf > fullness and 24-byte filenames, or fewer with longer filenames. > The same problem exisgs in get_next_block(). > > Similarly, the out_dir struct used a signed int for the number of > blocks in the directory, which may result in a negative size if the > directory is over 2GB (about 50M entries or fewer). > > Use appropriate unsigned variables for block counts, and use larger > types for calculating the byte count for memory offsets/sizes. > > Such large directories not been seen yet, but are not too far away. > The ext2fs_get_array() function will properly calculate the needed > memory allocation, and detect overflow on 32-bit systems. > Add ext2fs_resize_array() to do the same for array resize. > > Signed-off-by: Andreas Dilger > Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197 Applied, thanks. I had to make a slight change to fix a "merge conflict" with the patch. - Ted