Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1573883ybg; Wed, 29 Jul 2020 18:49:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6s2Vi8O+ZaxYiE3/Igpp1JVwG399ZIi0ew9VyvL4/EA8edBjwXrst8MHvqh4Ov3/Ffhjw X-Received: by 2002:a17:906:384a:: with SMTP id w10mr401579ejc.235.1596073794826; Wed, 29 Jul 2020 18:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596073794; cv=none; d=google.com; s=arc-20160816; b=dCFzZuPrC7Xm9NboZOUf5eL7zCoHRyYFBoX+ZI4sRWMopHwW0r3Gc8r/wIQr/NSySk dJ6H8DDYjyxsBgxQyDc0GGSmAqIJgUidonWyp/aMcFtDfluPtUx5hWbwatM+9lT4hoZu FePXOW9vYtEnRMwEY8XGEVqEq0qk++PBjZivh0yO/nwLSZjmUlyXUEdLIcMqBaL/JuH0 ywLtGg2TSMuRrXROMhx8eG2qiHZHE6V2/2e/wE5LULNw4jYQhHig5yeGxaLi3iys63Gj Yk1Rqt3UdmwmZ8jLwSKuWxbmKIuYCn3O3vApa38ER7gHkM7h8ZrI7LmKsaRHTwiOdVBY zNLg== 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=Zv84sJ2DKNRGnJtrwuj77YfqTT1bZovfAK/tiXpCPS8=; b=mtTNCxjenD9mB5wJfB6GTbqaaTITEyiaZgvN+82Cncu5FLBD4rW56QsjNk8sKovzF5 eFrbzV8xAyroqiARH2TK5VEj89oLzwBX2ep9ZUVyGebtIUuNJ8P5eMfunzAEqrRqG0GC J4IHw9p1tKLV/Hc47vQsJ8ZJ56cU5tclY9cNhkuUa0FehlqARExI/JCRTvhPJDLxrBuI QUJd/MjPZSEpYZvx0UeOfGTwXbRmjR39A6lIDxjVGU/yJLSCMyX13vRYFYMv1xmgKrHW xW8fdbI0wGgp/pYmrylDy8WK8KiIDdvUyuJS29aNa5T/c+3NsCQTlr//f2O2P3M6wLX3 VRHw== ARC-Authentication-Results: i=1; mx.google.com; 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 bl25si2509105ejb.731.2020.07.29.18.48.47; Wed, 29 Jul 2020 18:49:54 -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; 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 S1726341AbgG3Bsl (ORCPT + 99 others); Wed, 29 Jul 2020 21:48:41 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:35990 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726287AbgG3Bsl (ORCPT ); Wed, 29 Jul 2020 21:48:41 -0400 Received: from callcc.thunk.org (pool-96-230-252-158.bstnma.fios.verizon.net [96.230.252.158]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 06U1matc026303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 21:48:36 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 07683420304; Wed, 29 Jul 2020 21:48:36 -0400 (EDT) Date: Wed, 29 Jul 2020 21:48:35 -0400 From: tytso@mit.edu To: Eric Sandeen Cc: "linux-ext4@vger.kernel.org" Subject: Re: [PATCH 1/1] ext4: fix potential negative array index in do_split() Message-ID: <20200730014835.GC44720@mit.edu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Jun 17, 2020 at 02:19:04PM -0500, Eric Sandeen wrote: > If for any reason a directory passed to do_split() does not have enough > active entries to exceed half the size of the block, we can end up > iterating over all "count" entries without finding a split point. > > In this case, count == move, and split will be zero, and we will > attempt a negative index into map[]. > > Guard against this by detecting this case, and falling back to > split-to-half-of-count instead; in this case we will still have > plenty of space (> half blocksize) in each split block. > > Fixes: ef2b02d3e617 ("ext34: ensure do_split leaves enough free space in both blocks") > Signed-off-by: Eric Sandeen Thanks, applied. - Ted