Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp193277rdb; Mon, 14 Aug 2023 13:52:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMiHdkLgQf6rIkDD6WfBtdnhwB7QHUQwl3S5IFV2G7XQ0PHJqvB5NPGx4i9ansVo2Z6pqW X-Received: by 2002:a05:6a20:8f28:b0:134:d8e6:2717 with SMTP id b40-20020a056a208f2800b00134d8e62717mr11644717pzk.47.1692046327925; Mon, 14 Aug 2023 13:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692046327; cv=none; d=google.com; s=arc-20160816; b=FWVhZgeZ0uwD9fBXztYTjYWvEkUQIIk8MM5vNNowdRROQ9C1zIPHZX5NBNvA6ZHs4s /Jl32CZ95YAq+UH5cSIMZmAOn7fsqixiOZUClckj1jeEg1c5QKz1zIc2KfVHt3zNO1TT rQXftBt92Mq65uDB/ET6I9bXXUvGw+M6H/E82v7Gk92QGA7GMjGBCR9nrNa7h1ZK1r/2 BNw4leGwiNTL6jQcZPEHhtBnbUtPcxXzk1l4QmHZXdNKlGx6LwESzc3WHKE7GE/09ubb x89BOaHQ2I/w/OgZNjmyDn5HWl9h+jC4kBm2Ba0uRuUjwAKffRgnl4fl8h8AxloucKIL 3HDQ== 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=Wr0jlOrbqQZ4Ja8r3hNSjj2Kw1StEQwdvxiB/7DzNag=; fh=nqHm+0UlN4oy33YLKsbIypUQQ/aBowIzqXgYU0xmALs=; b=F3oYu2reRXVLgNFP7YQ/PTXOt5ySz3QvDtoh3Fc3e2ilp0izVv33oxLYbYFUHA7gRR GpllHgk/d4+/LigWtifqNL/jWKLplaoLcblG+WZMaY8/yHHdQPUuFqijW6LvRHnC6gOn NKWVE9xD4/hYRkdpqmtK9/7MMVnQ1zRx/gGhbpM8z6lANkNd5HQ/2lKKtXje8oSyjIpm yJwsPsqEnNBfpNogD2P26cY0vqYFn8G9oeJQeQAC/H4xLQPPU12w8V/UfON+0xZOJ6YF N0lPiTpNxpcblPKoKJb6MX4g/HBTJbTLo2IDBbTL74DSVsiqDGnkIjB6O1OGebMIjAsc ujgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OesZRZ9P; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n184-20020a6327c1000000b005640642a1dfsi8391724pgn.102.2023.08.14.13.51.48; Mon, 14 Aug 2023 13:52:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OesZRZ9P; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231523AbjHNTYM (ORCPT + 99 others); Mon, 14 Aug 2023 15:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbjHNTYK (ORCPT ); Mon, 14 Aug 2023 15:24:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE659C; Mon, 14 Aug 2023 12:24:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 34AD9640B6; Mon, 14 Aug 2023 19:24:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BD7FC433C7; Mon, 14 Aug 2023 19:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692041048; bh=o3Hr6U8ctryPOyOYt2lVWBvOEWrDutJ89GR/VnTpMVY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OesZRZ9PiKG3L4wcz5xDW1Lc17kKT6aeN3dnVAkSQhARhNhfBUyE0oYpJ/gUTaoOq 7JilTzw3/wuSlhdNjZBUa7rI+S4+p9MlFG/CiqXRp+AdBfPoe39cdJgls4yIpHxclK /OusVTJntyl8hB6HdZ0ao55bHLfQxMDfEcpH3Uiur2RirmnspkqQCNB87xR7WEoGWd OiHNr/1tNgHnwuczie1P8jvYZbbOAD9Va9fEChQCNma4Ho7ZoPB77zg3eqekSRThuO LQQtnT2DedPomEAg2K8Ig14ntksk+q6IVdLYsdYu4tv8gu2+Ro9loD+cNtfH5QJz7f rgQ7sXM/R7TwQ== Date: Mon, 14 Aug 2023 12:24:06 -0700 From: Eric Biggers To: Gabriel Krisman Bertazi Cc: linux-ext4@vger.kernel.org, Theodore Ts'o , linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH 1/3] ext4: reject casefold inode flag without casefold feature Message-ID: <20230814192406.GD1171@sol.localdomain> References: <20230814182903.37267-1-ebiggers@kernel.org> <20230814182903.37267-2-ebiggers@kernel.org> <87jztx5tle.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87jztx5tle.fsf@suse.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Aug 14, 2023 at 03:09:33PM -0400, Gabriel Krisman Bertazi wrote: > Eric Biggers writes: > > > From: Eric Biggers > > > > It is invalid for the casefold inode flag to be set without the casefold > > superblock feature flag also being set. e2fsck already considers this > > case to be invalid and handles it by offering to clear the casefold flag > > on the inode. __ext4_iget() also already considered this to be invalid, > > sort of, but it only got so far as logging an error message; it didn't > > actually reject the inode. Make it reject the inode so that other code > > doesn't have to handle this case. This matches what f2fs does. > > > > Note: we could check 's_encoding != NULL' instead of > > ext4_has_feature_casefold(). This would make the check robust against > > the casefold feature being enabled by userspace writing to the page > > cache of the mounted block device. However, it's unsolvable in general > > for filesystems to be robust against concurrent writes to the page cache > > of the mounted block device. Though this very particular scenario > > involving the casefold feature is solvable, we should not pretend that > > we can support this model, so let's just check the casefold feature. > > tune2fs already forbids enabling casefold on a mounted filesystem. > > just because we can't fix the general issue for the entire filesystem > doesn't mean this case *must not* ever be addressed. What is the > advantage of making the code less robust against the syzbot code? Just > check sb->s_encoding and be safe later knowing the unicode map is > available. > Just to make sure, it sounds like you agree that the late checks of ->s_encoding are not needed and only __ext4_iget() should handle it, right? That simplifies the code so it is obviously beneficial if we can do it. As for whether __ext4_iget() should check the casefold feature or ->s_encoding, we should simply go with the one that makes the code clearer, as per what I've said. I think it's casefold, but it could be ->s_encoding if others prefer. - Eric