Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp462824rdb; Thu, 8 Feb 2024 10:43:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1cN4UohhXmErdVe6fY1jp1bWZpqaC0q2Z2iGIRSSiEIOxUTxP48RTAsLznzkSI76KDshNX1k7AINbpY6Rs41z6pGbhRDeQm+/7Sbrnw== X-Google-Smtp-Source: AGHT+IEcvC0pxQuF0ICv/MfvZpWOwdVYAH/uwFPntRRZ9RGr7ngAIPgQVJGWZYYKRNiivcZaherv X-Received: by 2002:a0c:df88:0:b0:68c:45d8:35d8 with SMTP id w8-20020a0cdf88000000b0068c45d835d8mr99802qvl.5.1707417805586; Thu, 08 Feb 2024 10:43:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707417805; cv=pass; d=google.com; s=arc-20160816; b=SZYjkj9vSrRykdDbdUYAB9XMGjXxQY0RYIBvs6RQOrYp59MFA1x2zwmMKgKAxaqgjx LM9LpcOVm98zKmLPS+AXTSsk3QeJp0lcqteJwsSWieWej5m4uEEcHwjCx1k4SL0wPedu rHAxNS1ROvGbKqz4c3WgZ4yjxrYtPdkXIMNnMJXRnHqdLTWTnKLmdGboTevZevChQ0hu wvKSd+jkTOTc5mFl8KVPEdOE/VYo7MrreffdOuBhlOF+sSqxX+tyoMol99HmIEjQLyFS 6QHNGAuz+syJz0r8F9pWNdfnyP0kx3C4ycfd/RTYk3aeBdX0rO0K2mAmbxGViWFfH1FG fLBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=rGFuTx22nZyt1Ef3qC80mJYAGVh7KhD1thhPxbHOGK4=; fh=K/YUayAG7ibH47uS933RDkeIdINn74LWf1x3Vg4mi7g=; b=GaeAz0Q/JlZvnVMzE8Un2NyA0bSxRW26MHw7lVPJhklfxLLF/QJcvhnK5FV9p7VfCk zLh8DvT+6qOjANKswv0eFQJu9lfVdwg2JXeGMncXgU+eQzUQWRkt/xJg2TWAfydPVHCs s2hDk0rq/Ehuf998013bt9IvsbozVwPlhaZjl7Mu4lXnsnFZUSJIoClIc0uS2/AWtzYK piC8GjHZP7oVvmqPTKNoGPV6oKNTGSJ/tGzGNJxTV2K5Omfs+9eUHIZuQ3JB3Hr0lrXc bNx/msLgy3qWANRP/9VA6wjwbQ5PQ5MpBXi0m2RQHEadGTxqz36aSdHdwdCKoAPh/4ij usWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=D8wF4yq8; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=D8wF4yq8; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-58543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=2; AJvYcCWZ7P3lFHLevqhLRBTSHio6eC59tjnEzlRUIuLEJJIcxUSq91png/5tGYBE1FhyZjfwlWHLA0Mm5CO9pRCTElYRDBtod7JZXfycWZ48SA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jo3-20020a056214500300b0068cb9707fcesi114041qvb.529.2024.02.08.10.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:43:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=D8wF4yq8; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=D8wF4yq8; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-58543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4999D1C2404A for ; Thu, 8 Feb 2024 18:43:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EE28250ED; Thu, 8 Feb 2024 18:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="D8wF4yq8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kIfh3JVw"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="D8wF4yq8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kIfh3JVw" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F2C720335; Thu, 8 Feb 2024 18:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417781; cv=none; b=OK5GhLpanclBLyrzmj2c3PD8dO8Sexyu/MX0MFVoCOqhEgxZws2wbluiVwLpRSipIRpOf3En9h1JGIKRdPktqVL//jL+oUY/sYJidOlGrXi0Te9FEzkTeiv2x1bN9TWcOGg10q3wyto4Dd8tlmVVq3cueeGp1uBuswJBiUAxGUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707417781; c=relaxed/simple; bh=ZW79UOB61sdCtxFs9rijrIwJ4eurUey1b1meP3mOTsM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=t2zPAl+Zi3HeC2YuG1SLD8A8jSY/O9aXktvoGqu0agOF4oVQlSXrwH0Jfe6D1HontfOUbXOaRQ0xrjGMCTuPWI6B4XqVWjDRdzGpjIiyiJ1xbLsteHR/EzApdnP9CrCmpm/NjBK6EJecEdDSlaZsuZ34SM+pLT0ssPZpqzuW2E4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=D8wF4yq8; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kIfh3JVw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=D8wF4yq8; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kIfh3JVw; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 67B781FCFF; Thu, 8 Feb 2024 18:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707417776; 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=rGFuTx22nZyt1Ef3qC80mJYAGVh7KhD1thhPxbHOGK4=; b=D8wF4yq8THXA1vsqQdCTE6uUX6rW7cNjgIgR8xhM/GZ16nCCoc+4e+x2fnssC1xsFlLgfF HHjFlL6QrUvFFXoYyDjoNcM3lhUUNhAVH3UHdm+OEdXovXxeP2KG1U4JLfbsQtmxZwgNPp 6YvhSlyhufFeVADqNyyVpDRCme3XFkU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707417776; 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=rGFuTx22nZyt1Ef3qC80mJYAGVh7KhD1thhPxbHOGK4=; b=kIfh3JVw0WDKSkwrxfijyXcmYm9rzJN0/q6AaQ+aGGaWL1ZonJma/1e/o4VEswAS70MnAa 9rIYaC0cxoo0rZAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707417776; 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=rGFuTx22nZyt1Ef3qC80mJYAGVh7KhD1thhPxbHOGK4=; b=D8wF4yq8THXA1vsqQdCTE6uUX6rW7cNjgIgR8xhM/GZ16nCCoc+4e+x2fnssC1xsFlLgfF HHjFlL6QrUvFFXoYyDjoNcM3lhUUNhAVH3UHdm+OEdXovXxeP2KG1U4JLfbsQtmxZwgNPp 6YvhSlyhufFeVADqNyyVpDRCme3XFkU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707417776; 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=rGFuTx22nZyt1Ef3qC80mJYAGVh7KhD1thhPxbHOGK4=; b=kIfh3JVw0WDKSkwrxfijyXcmYm9rzJN0/q6AaQ+aGGaWL1ZonJma/1e/o4VEswAS70MnAa 9rIYaC0cxoo0rZAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 24A1D1326D; Thu, 8 Feb 2024 18:42:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id bIXQArAgxWWqMgAAD6G6ig (envelope-from ); Thu, 08 Feb 2024 18:42:56 +0000 From: Gabriel Krisman Bertazi To: Eugen Hristev Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, chao@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel@collabora.com, Gabriel Krisman Bertazi Subject: Re: [RESEND PATCH v9 2/3] ext4: Reuse generic_ci_match for ci comparisons In-Reply-To: <20240208064334.268216-3-eugen.hristev@collabora.com> (Eugen Hristev's message of "Thu, 8 Feb 2024 08:43:33 +0200") References: <20240208064334.268216-1-eugen.hristev@collabora.com> <20240208064334.268216-3-eugen.hristev@collabora.com> Date: Thu, 08 Feb 2024 13:42:54 -0500 Message-ID: <87plx6vlu9.fsf@mailhost.krisman.be> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -1.31 X-Spamd-Result: default: False [-1.31 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.01)[46.77%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO Eugen Hristev writes: > int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, > struct ext4_filename *name) > { > @@ -1503,20 +1451,35 @@ static bool ext4_match(struct inode *parent, > #if IS_ENABLED(CONFIG_UNICODE) > if (IS_CASEFOLDED(parent) && > (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) { > - if (fname->cf_name.name) { > - if (IS_ENCRYPTED(parent)) { > - if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) || > - fname->hinfo.minor_hash != > - EXT4_DIRENT_MINOR_HASH(de)) { > + int ret; > > - return false; > - } > - } > - return !ext4_ci_compare(parent, &fname->cf_name, > - de->name, de->name_len, true); > + /* > + * Just checking IS_ENCRYPTED(parent) below is not > + * sufficient to decide whether one can use the hash for > + * skipping the string comparison, because the key might > + * have been added right after > + * ext4_fname_setup_ci_filename(). In this case, a hash > + * mismatch will be a false negative. Therefore, make > + * sure cf_name was properly initialized before > + * considering the calculated hash. > + */ > + if (IS_ENCRYPTED(parent) && fname->cf_name.name && > + (fname->hinfo.hash != EXT4_DIRENT_HASH(de) || > + fname->hinfo.minor_hash != EXT4_DIRENT_MINOR_HASH(de))) > + return false; > + > + ret = generic_ci_match(parent, fname->usr_fname, > + &fname->cf_name, de->name, > + de->name_len); > + if (ret < 0) { > + /* > + * Treat comparison errors as not a match. The > + * only case where it happens is on a disk > + * corruption or ENOMEM. > + */ > + return false; A minor problem with splitting the series as you did is that "ext4: Log error when lookup of encoded dentry fails" conflicts with this change and you get a merge conflict if it is applied in the wrong order. -- Gabriel Krisman Bertazi