Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1507396rdb; Wed, 24 Jan 2024 19:05:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHT463++KHKwc5CJZlHabqPujXroY4znKdvZTJOjKomCjRstVYHQcD+QbKs0lSronZEKuRk X-Received: by 2002:ae9:e101:0:b0:783:70c7:3519 with SMTP id g1-20020ae9e101000000b0078370c73519mr424168qkm.100.1706151949598; Wed, 24 Jan 2024 19:05:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706151949; cv=pass; d=google.com; s=arc-20160816; b=SbmxOmGBnhxFCyPO3amJrKvhu/7SoZP4c3ENj6AMQjOijbC6JrvviBO04CAyKlRTi3 iQe9QWFzD8nQ0D/niWR/M6gFiC5BPZvDz3HzAj73jfpZVTQZ6E5tH+WBSbSyxCCsyYjR eX9baYem1hrMdLqiTWneu429o9yzI6PCW6GV5ykhKcm6qkp8AtlcyGJuqyGtHy/ElmWR X5PkuHnNiSYSTWoIEZ3an5h8+1F/XkPaHhVdPsGvGANWBs6xjQ58vPvQrb26xGHMS5Id WkIvCbxmma+dfkI6rrsmDHLJw1ODini66ulkKT+tffMws+C3Lc/VgIKy0brvnW4cgCuI vX5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=R7lVZpcxIo/fskWnBX7E++DalAuH+CS+W2ZfJ0YRyJs=; fh=iyy13j/hzfuQ7wUjKw2aoGVnHVkfJeRlTmijr91AKLc=; b=jx2pSO4Q5Nv4YbTRUhW+OiTAGoLrAulwXbymy5eSNKYz6O7ZFFT1ngEWIgPmgE891e j7lOy8HsK1c9uRSJy3ycAY0ourZRzPPdJQ+5YJ4wOjrSGkT8mVaFUZOlD9hFl+QUQhMV XNmKSzqETwXs0cPV12/iJagjOxOeFRh4H8491mLqroM8WHb6TndhqE7J/bW40YrxpxP7 9+/bnDvNxD44ZzODJO/1IhqPSmbaztJhkGUo/2pqlbvfYqP4TGN8krQfOHZvIqvUQbSy /Dz/gaCZtME57wfUxG5INK546mINKj9QG4Iye1xqLTfKzqYJdPqygzRN6Mk3d75BfqZk GHTA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C2MBZ2Ii; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-910-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t13-20020a05620a004d00b007811c7bf132si5426315qkt.380.2024.01.24.19.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 19:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-910-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C2MBZ2Ii; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-910-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 20FE51C24181 for ; Thu, 25 Jan 2024 03:05:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0F085C9A; Thu, 25 Jan 2024 03:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C2MBZ2Ii" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 337721866; Thu, 25 Jan 2024 03:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706151933; cv=none; b=bTOG1bKS2di8QiPTvi2y0neyqSAOmj+OQZLMwq5j/pue3Oi9Unn3kVYdCzC6a5/hfzzBBYX3wCwhtBf5hBL4wXt/BsQAmryGHDR2hYWlDMDcbLd8rdDce42550pBgGP34TighvVXQ6mwYBgpPO6GQViQvBbjKEYd8Ur3Nj9fi7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706151933; c=relaxed/simple; bh=k/lcg2zazVrlN5kWliEtrgP95ZsgX1rocgc1aIdg3L4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iNK5Iy7zKFOaceyOREpECHlEbCqWXkj9gPcb8MWJNN4NvjWzrySlxv05dYXEatYhdiBsMRV2RXJNedtO0NOfW8AgcOLjYRLk8gsJfy5i75WJg9ebks3zHOCDGnHmE5NOXZRfbiFXtaOqVGNNv8gioNosOsVsBoEwwVP26+Cbux8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C2MBZ2Ii; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F35DC433F1; Thu, 25 Jan 2024 03:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706151932; bh=k/lcg2zazVrlN5kWliEtrgP95ZsgX1rocgc1aIdg3L4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C2MBZ2Ii8noSNTJIR9GJXA/gpybC54e7/5EkfmuEekhstUGgZBwcYYV7cn5pvnmFj mnI91/Enut3AM5eLngfH35zaZXbp/aaoypZPhVJ1csin1MBrgy1J8zlfKF6RkWFC4H 1038qtJRm8ANP8twzH7GGrGr1boqXCBxtwCCkVX2qDaZgUvmE9Z8jwz9/ByhXw8OLI bCXBsupFXihzmYcAyHi5K8rxJiuj3XFotYLULPttjSAmSl9fQQP418LAvDWHBG04Yf xqvaNZ/pqPLly+hnluO8JNn141QNZl3ge17G7QrHsO/LGe6z9UlDV48Tf6fyK8j3je HFIW9zCxGXjDg== Date: Wed, 24 Jan 2024 19:05:30 -0800 From: Eric Biggers To: Gabriel Krisman Bertazi Cc: viro@zeniv.linux.org.uk, jaegeuk@kernel.org, tytso@mit.edu, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, amir73il@gmail.com Subject: Re: [PATCH v3 02/10] fscrypt: Share code between functions that prepare lookup Message-ID: <20240125030530.GB52073@sol.localdomain> References: <20240119184742.31088-1-krisman@suse.de> <20240119184742.31088-3-krisman@suse.de> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240119184742.31088-3-krisman@suse.de> On Fri, Jan 19, 2024 at 03:47:34PM -0300, Gabriel Krisman Bertazi wrote: > To make the patch simpler, we now call fscrypt_get_encryption_info twice > for fscrypt_prepare_lookup, once inside fscrypt_setup_filename and once > inside fscrypt_prepare_lookup_dentry. It seems safe to do, and > considering it will bail early in the second lookup and most lookups > should go to the dcache anyway, it doesn't seem problematic for > performance. In addition, we add a function call for the unencrypted > case, also during lookup. Unfortunately I don't think it's correct. This is basically undoing my fix b01531db6cec ("fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext") from several years ago. When a lookup is done, the filesystem needs to either treat the name being looked up as a no-key name *or* as a regular name, depending on whether the directory's key is present. We shouldn't enable race conditions where, due to the key being concurrently added, the name is treated as a no-key name for filename matching purposes but a regular name for dentry validation purposes. That can result in an anomaly where a file that exists ends up with a negative dentry that doesn't get invalidated. Basically, the boolean fscrypt_name::is_nokey_name that's produced by fscrypt_setup_filename() should continue to be propagated to DCACHE_NOKEY_NAME. - Eric