Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp521795rdb; Sat, 19 Aug 2023 11:08:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH47UXZUlYc9XFN0fF4UbqjCe/Htt5WmpnC/TQaNUOxo0Ibmjn0dlNwd7F94SYzltS9XPW X-Received: by 2002:a05:6a21:3393:b0:13b:1482:261 with SMTP id yy19-20020a056a21339300b0013b14820261mr2474990pzb.44.1692468528593; Sat, 19 Aug 2023 11:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692468528; cv=none; d=google.com; s=arc-20160816; b=ExM3Vw0lrZ1PLuoLav6F5HxtEbsZyztZm2ccZou1vwUF50bYBi/AbExf3R15bKuwlX V1b/rsozz7pCTOGRva10zTFl1eMWeaXmkHJ7wipWit1ToHQsj/FHmSP6PJlNwe/18sd1 u/CkqfFX3uZS822koOTUa/lkbZx2ZDnul3MTspRx/xqLbuNu6+9XV955DfPiISq5uH36 eSmfsbPOUv/Gl8XvRKaBWmZRN7hdstYgEuPklbPXJw7Gy7eqoQv046W0nHGiItXEi1ui ZiyoulgBrzVb+MVVvnLS/k5jN5bkEhu0LlrMWej+n5/hQV/7qUs6vT7tgkBnhLy0WIMs oxgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:date :references:organization:in-reply-to:subject:cc:to:from :dkim-signature:dkim-signature; bh=onjKw2D7T28KbiV2fqNVPG/lTv3CeMZukA/2FuhuI3k=; fh=VwtM/hi5smecnGgUx1608w6VDCMzQnDNVj2o5jPfzd8=; b=hrHJLFCVvF9TTyCj6xZybVKwHDF2SL19Paxvm4hURB+L2kL7VVZ++fZbcgTyp32/m8 VbZBNIBRRKXGcvfib17iBZEHXPBbJ/q7sfXyCD/jcP5aS6n/Sw4RuOGXGAhZg8566U0R nUGuaIuEf1eomzHLP7r201OY7cyoQJCijELzRN2LSsl38T45ZNUNwjvhgwigGcUF/vIg aV84lvbqbBQ4xee4/ysno0jbKxjAl2AMHCbLNzo8dSB76iVQuq4roVOna6yIeVK9VKoc K0Db1w++GrjUqlNZDMDXb1MaIZYzJwP/zfBvl9WJN4MEt0xhXRtlSaqvblwuBIJ5d8eb Jt0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OaoCL+1H; dkim=neutral (no key) header.i=@suse.de header.b=kRIzSOep; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n1-20020a632701000000b00565eb0b2e66si4141361pgn.864.2023.08.19.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 11:08:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OaoCL+1H; dkim=neutral (no key) header.i=@suse.de header.b=kRIzSOep; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 856911B32E; Sat, 19 Aug 2023 01:26:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjHNTKR (ORCPT + 99 others); Mon, 14 Aug 2023 15:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbjHNTJm (ORCPT ); Mon, 14 Aug 2023 15:09:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D826310F2; Mon, 14 Aug 2023 12:09:41 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 68B8E21921; Mon, 14 Aug 2023 19:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692040180; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=onjKw2D7T28KbiV2fqNVPG/lTv3CeMZukA/2FuhuI3k=; b=OaoCL+1HGmRHBb/F9NAWbs1Yqpa6tVc9MIOMVhrIMHAqEdUNMLyHbG0FGdhY90iwfKuI5k j9TCcXQEfk026eQ3FqiDSRR1GGqdp8VHedICVMqlRHvR+fGIDPOr+TjttqKQVHBiShlhgY P3wILlVnPYGNSNAK425Epk4m9m4zUG8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692040180; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=onjKw2D7T28KbiV2fqNVPG/lTv3CeMZukA/2FuhuI3k=; b=kRIzSOepmu2YkLWh1KFqx2AkwdR4+jq7yPp/s/r6AK4a2fNs8aCyiw1PyGOKEFF9ftMRoe 5rjqLvHyahidoDCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1A2F8138EE; Mon, 14 Aug 2023 19:09:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zankOfN72mQLdwAAMHmgww (envelope-from ); Mon, 14 Aug 2023 19:09:39 +0000 From: Gabriel Krisman Bertazi To: Eric Biggers 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 In-Reply-To: <20230814182903.37267-2-ebiggers@kernel.org> (Eric Biggers's message of "Mon, 14 Aug 2023 11:29:01 -0700") Organization: SUSE References: <20230814182903.37267-1-ebiggers@kernel.org> <20230814182903.37267-2-ebiggers@kernel.org> Date: Mon, 14 Aug 2023 15:09:33 -0400 Message-ID: <87jztx5tle.fsf@suse.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,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 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. > > Signed-off-by: Eric Biggers > --- > fs/ext4/inode.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 43775a6ca505..390dedbb7e8a 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -4940,9 +4940,12 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, > "iget: bogus i_mode (%o)", inode->i_mode); > goto bad_inode; > } > - if (IS_CASEFOLDED(inode) && !ext4_has_feature_casefold(inode->i_sb)) > + if (IS_CASEFOLDED(inode) && !ext4_has_feature_casefold(inode->i_sb)) { > ext4_error_inode(inode, function, line, 0, > "casefold flag without casefold feature"); > + ret = -EFSCORRUPTED; > + goto bad_inode; > + } > if ((err_str = check_igot_inode(inode, flags)) != NULL) { > ext4_error_inode(inode, function, line, 0, err_str); > ret = -EFSCORRUPTED; -- Gabriel Krisman Bertazi